Skip to content

Instantly share code, notes, and snippets.

@marcusrussi
Created September 18, 2019 19:50
Show Gist options
  • Select an option

  • Save marcusrussi/a68aac0353a89b942c1864783f341fe3 to your computer and use it in GitHub Desktop.

Select an option

Save marcusrussi/a68aac0353a89b942c1864783f341fe3 to your computer and use it in GitHub Desktop.
TOKEN='ATreGoqkKeGhBrqAHVbNNTychduhSkdg'
TWEED='USW00014758'
# Print header, then pull daily weather summary from Tweed's station
echo 'date,daily_hi' &&
curl -sGH "token:$TOKEN" \
-d "stationid=GHCND:$TWEED" \
-d 'datasetid=GHCND' \
-d 'startdate=2019-09-10' \
-d 'enddate=2020-01-15' \
-d 'limit=1000' \
'https://www.ncdc.noaa.gov/cdo-web/api/v2/data' | \
# Select the daily maximum temperature for each date, convert to ˚F, output as CSV
jq -r '.results | map(select(.datatype == "TMAX")) | map([.date,(32+.18*.value)]) | map(join(",")) | join("\n")'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment