GetAuWeather

GetAuWeather is a Python module for downloading recent Australian weather station data from the Australian Bureau of Meteorology's website and parsing it nicely into a dictionary of dictionaries so you can use it in other programs.

Requirements

GetAuWeather depends only upon Python. It is known to work with Python 2.4 and should work with any version that provides the urllib module. It should work on any operating system that Python runs on.

License

GetAuWeather is distributed under a standard 3-clause BSD license. It's as free as software gets.

Download

Download the latest version of GetAuWeather, GetAuWeather 1.0 (released June 24 2007).

Detailed description

If you dig around the Australian Bureau of Meteorology's website long enough, you may stumble upon a very cool page, generated by a Perl CGI script, which displays a veritable bounty of weather data in a simple row-based plain text format which is ideal for parsing by a program.

GetAuWeather is a Python program to do just that. It downloads the page mentioned above using the urllib module and then busts the data up into a dictionary of dictionaries, which is a convenient format to use in other tasks - dumping this data into a database, .csv file, your screen, whatever.

The file contains data for 747 weather stations around Australia. The data you can get for each observation are:

Obviously, if the file format of the Bureau's webpage ever changes, this script will break. The folks at the Bureau are smart enough to include the date of the last format change in the page's output, so GetAuWeather makes sure this has not changed since the time it was written and will fail loudly if it has.

Complete Instructions

GetAuWeather is very simple. The module contains exactly one function, getauweather. This function accepts no arguments and returns a single dictionary. The keys of this dictionary are strings representing the names of Australian weather stations. Some 747 stations are included. The value for each of these keys is a second dictionary. The key/value pairs of this second dictionary are weather observations from the relevant station.

The following example of using the module from Python's interactive interpreter should make everything clear:

>>> # Import the function
>>> from getauweather import getauweather
>>> # Get the weather data
>>> data=getauweather()
>>> # Get the data for the Adelaide airport station
>>> adelaide=data["Adelaide"]                
>>> # Look at the available Adelaide data
>>> adelaide.keys()
['Bar', 'Temp', 'Tx', 'Cld', 'Rain', 'Day', 'Tn', 'Vis', 'Weather', 'Long', 'Lat',
'RH', 'Hour', 'Wind']
>>> # Examine some values
>>> adelaide["Temp"]
'9'
>>> adelaide["Wind"]                 
'NE/007'
>>> adelaide["Lat"], adelaide["Long"]
('3492','13862')