Archivo de la categoría: Uncategorized

GSOD data with Python

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).

Basic usage

First, one requires to load the header:

import gsod

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()

.valid_station() function**

One can check whether station IDs are valid. Function call is trivial:

** 801100-99999 **
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:

** 911100-99999 **
Station does not exist!
* Early version, not publicly released for the time being (jajaja)
** More to come…
*** NOAA server must be called for earch single year of data, anyway