API:
https://www.ncdc.noaa.gov/cdo-web/webservices/v2
Parameters:
CITY:US270013
specifies Minneapolis, MN
datatypeid=TOBS
specifies that I want the observed temperature
Python Code
url = 'https://www.ncdc.noaa.gov/cdo-web/api/v2/data?datasetid=GHCND&locationid=CITY:US270013&startdate=2016-05-01&enddate=2016-05-31&limit=1000&datatypeid=TOBS'
response = requests.get(url, headers = headers)
response = response.json()
stationData = pd.DataFrame(response['results'])
print(stationData.sort_values(by='station').to_string(index=False))
Results:
attributes datatype date station value
,,7,2400 TOBS 2016-05-01T00:00:00 GHCND:USC00211448 89
,,7,2400 TOBS 2016-05-14T00:00:00 GHCND:USC00211448 6
,,7,2400 TOBS 2016-05-07T00:00:00 GHCND:USC00211448 61
,,7,2400 TOBS 2016-05-16T00:00:00 GHCND:USC00211448 106
,,7,2400 TOBS 2016-05-26T00:00:00 GHCND:USC00211448 172
,,7,2400 TOBS 2016-05-28T00:00:00 GHCND:USC00211448 161
,,7,2400 TOBS 2016-05-17T00:00:00 GHCND:USC00211448 50
,,7,2400 TOBS 2016-05-06T00:00:00 GHCND:USC00211448 178
According to that table, May 6th 2015 had an observed temperature of 178 degrees in Minneapolis. This is clearly wrong but there is little documentation on their website. Does their TOBS
follow a different scale for temperatures, or is there a different variable I should be using?
From the documentation:
ftp://ftp.ncdc.noaa.gov/pub/data/ghcn/daily/readme.txt
TOBS = Temperature at the time of observation (tenths of degrees C)
Divide your results by 10, multiply by 9/5 + 32 to convert to F (or whatever you need to do).
Minneapolis can be freezing in May!