Archivo de la categoría: pandas

GSOD data with Python

This one-file project fetches  Global Surface Summary of the Day (GSOD) from the National Oceanic and Atmospheric Administration (NOAA)’s HTTP server (data are also available on their FTP).

See the code on github.


Whether a given weather station is part of the GSOD project can be checked using the station_search() function. For instance, the station Stanton (UK) can be retrieved as follows:

gsod = GSOD()
stanton = gsod.station_search({'station_name' : 'STANTON'})

This function also allows to retrieve all weather stations in a given country or US State, e.g. all stations in Iowa can be listed as folllows:

iowa = gsod.station_search({'state' : 'IA'})



Basic usage requires only requires (what I call) weather station id which actually combines USAF (6-digit) and WBAN (5-digit) identification numbers linked by a dash sign. For instance, 699604-03145 is  the station id for YUMA MCAS (US) weather station. Getting YUMA MCAS weather data for the current year is as simple as:

yuma = GSOD('699604-03145').get_data()

The object returned is a pandas.DataFrame().

User can also be willing to download YUMA MCAS weather data for several consecutive years, with a single call to the function*:

yuma_13_15 = GSOD(station='699604-03145', start=2013, end=2015).get_data()

Original data are reported in Fahrenheit, miles, knots, and inches. It is possible to convert them to Celsius, km, kph, and cm, respectively. To do so, one passes an extra argument unit with a string as value if only one conversion is desired or a list of strings instead if 2+ unit conversions are required, e.g.:

yuma_converted = GSOD(station='699604-03145', units=['celsius', 'km', 'kph', 'cm']).get_data()
* Still, behind the scene, NOAA servers are called once for each single year of required data