Python gsod library* 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).
First, one requires to load the header:
Minimum user input is (what I call) weather station id which actually combines USAF (6-digit) and WBAN (5-digit) separated by a dash sign, eg 801100-99999 for the OLAYA HERRERA weather station in Colombia. Getting weather data for it is as simple as:
o_herrera = GSOD('801100-99999').get_data()
A pandas.DataFrame() object is returned. By default, it contains weather data for the current year.
Other .get_data() function arguments
User can get data for several consecutive years, with one call to the function***:
o_herrera = GSOD(station=‘801100-99999’, 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. One then passes an extra argument unit with a string as value if only one conversion is desired or a Python list instead for more than one conversions, eg:
o_herrera = GSOD(station='801100-99999', units=['celsius', 'km', 'kph', 'cm']).get_data()
One can check whether station IDs are valid. Function call is trivial:
GSOD(station='801100-99999').valid_station() ''' ** 801100-99999 ** STATION NAME : OLAYA HERRERA Country : CO State : nan Icao : SKMD Latitude : 6.22 Longitude : -75.59100000000001 Elevation (m) : 1505.7 Begin : 05/01/1949 End : 30/01/2015 '''
In case, the station ID doesn’t exist, a message like the following will be returned:
GSOD(station='911100-99999').valid_station() ''' ** 911100-99999 ** Station does not exist! '''