Last active
December 9, 2025 15:02
-
-
Save cmj/aa5687133b81a1375287a485d4cc682b to your computer and use it in GitHub Desktop.
Latest 24 hour precip for station
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # grab total -24hour precip for a station | |
| # ex: start=202512081428 end=202512091428 | |
| # ./wx-precip.sh KPDX | |
| # Total precip at KPDX (24Hr): 2.271 inches | |
| # Total precip at KSEA (24Hr): 1.163 inches | |
| if [ -z "$1" ]; then | |
| station=KSEA # KSEA KPDX C5053 | |
| else | |
| station=$1 | |
| fi | |
| hours=24 # 24 48 72 or custom | |
| start=$(date -u '+%Y%m%d%H%M' -d "-$hours hour") | |
| end=$(date -u '+%Y%m%d%H%M') | |
| curl -s "https://api.synopticlabs.org/v2/stations/precipitation?token=04f9ba4a7550477a9533d12a10b544ae&units=english&start=${start}&end=${end}&STID=${station}&_=$EPOCHSECONDS" \ | |
| -H 'Origin: https://www.weather.gov' | | |
| jq -r --arg id "${station}" --arg hr "${hours}" '.STATION[0].OBSERVATIONS | "Total precip at \($id) (\($hr)Hr): \(.total_precip_value_1) inches"' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment