weather_stations

weather_stations - Imports weather station data files.

class upoints.weather_stations.Station(alt_id, name, state, country, wmo, latitude, longitude, ua_latitude, ua_longitude, altitude, ua_altitude, rbsn)[source]

Bases: upoints.trigpoints.Trigpoint

Class for representing a weather station from a NOAA data file.

New in version 0.2.0.

Initialise a new Station object.

Parameters:
  • alt_id (str) – Alternate location identifier
  • name (str) – Station’s name
  • state (str) – State name, if station is in the US
  • country (str) – Country name
  • wmo (int) – WMO region code
  • latitude (float) – Station’s latitude
  • longitude (float) – Station’s longitude
  • ua_latitude (float) – Station’s upper air latitude
  • ua_longitude (float) – Station’s upper air longitude
  • altitude (int) – Station’s elevation
  • ua_altitude (int) – Station’s upper air elevation
  • rbsn (bool) – True if station belongs to RSBN
class upoints.weather_stations.Stations(data=None, index='WMO')[source]

Bases: upoints.point.KeyedPoints

Class for representing a group of Station objects.

New in version 0.5.1.

Initialise a new Stations object.

import_locations(data, index='WMO')[source]

Parse NOAA weather station data files.

import_locations() returns a dictionary with keys containing either the WMO or ICAO identifier, and values that are Station objects that describes the large variety of data exported by NOAA.

It expects data files in one of the following formats:

00;000;PABL;Buckland, Buckland Airport;AK;United States;4;65-58-56N;161-09-07W;;;7;;
01;001;ENJA;Jan Mayen;;Norway;6;70-56N;008-40W;70-56N;008-40W;10;9;P
01;002;----;Grahuken;;Norway;6;79-47N;014-28E;;;;15;

or:

AYMD;94;014;Madang;;Papua New Guinea;5;05-13S;145-47E;05-13S;145-47E;3;5;P
AYMO;--;---;Manus Island/Momote;;Papua New Guinea;5;02-03-43S;147-25-27E;;;4;;
AYPY;94;035;Moresby;;Papua New Guinea;5;09-26S;147-13E;09-26S;147-13E;38;49;P

Files containing the data in this format can be downloaded from the NOAA‘s site in their station location page.

WMO indexed files downloaded from the NOAA site when processed by import_locations() will return dict object of the following style:

{'00000': Station('PABL', 'Buckland, Buckland Airport', 'AK',
                  'United States', 4, 65.982222. -160.848055, None,
                  None, 7, False),
 '01001'; Station('ENJA', Jan Mayen, None, 'Norway', 6, 70.933333,
                  -7.333333, 70.933333, -7.333333, 10, 9, True),
 '01002': Station(None, 'Grahuken', None, 'Norway', 6, 79.783333,
                  13.533333, None, None, 15, False)}

And dict objects such as the following will be created when ICAO indexed data files are processed:

{'AYMD': Station("94", "014", "Madang", None, "Papua New Guinea",
                 5, -5.216666, 145.783333, -5.216666,
                 145.78333333333333, 3, 5, True,
 'AYMO': Station(None, None, "Manus Island/Momote", None,
                 "Papua New Guinea", 5, -2.061944, 147.424166,
                 None, None, 4, False,
 'AYPY': Station("94", "035", "Moresby", None, "Papua New Guinea",
                 5, -9.433333, 147.216667, -9.433333, 147.216667,
                 38, 49, True}
Parameters:
  • data (iter) – NOAA station data to read
  • index (str) – The identifier type used in the file
Returns:

WMO locations with Station objects

Return type:

dict

Raises:

FileFormatError – Unknown file format