Package elisa :: Package extern :: Package metar :: Module Metar
[hide private]
[frames] | no frames]

Module Metar

source code

This module defines the Metar class. A Metar object represents the weather report encoded by a single METAR code.


Version: 1.2

Classes [hide private]
  ParserError
Exception raised when an unparseable group is found in body of the report.
  Metar
METAR (aviation meteorology report)
Functions [hide private]
 
xlate_loc(loc)
Substitute English terms for the location codes in the given string.
source code
 
_report_match(handler, match)
Report success or failure of the given handler function.
source code
 
_unparsedGroup(self, d)
Handle otherwise unparseable main-body groups.
source code
Variables [hide private]
  __email__ = 'pollard@alum.mit.edu'
  __LICENSE__ = '\nCopyright (c) 2004,\nAll rights reserved.\n\n...
  MISSING_RE = re.compile(r'^[M/]+$')
  TYPE_RE = re.compile(r'^(?P<type>METAR|SPECI)\s+')
  STATION_RE = re.compile(r'^(?P<station>[A-Z][A-Z0-9]{3})\s+')
  TIME_RE = re.compile(r'(?x)^(?P<day>\d\d)(?P<hour>\d\d)(?P<min...
  MODIFIER_RE = re.compile(r'^(?P<mod>AUTO|FINO|NIL|TEST|CORR?|R...
  WIND_RE = re.compile(r'(?x)^(?P<dir>[\dO]{3}|[0O]|///|MMM|VRB)...
  VISIBILITY_RE = re.compile(r'(?x)^(?P<vis>(?P<dist>M?(\d\s*)?\...
  RUNWAY_RE = re.compile(r'(?x)^(RVRNO|(?P<name>\d\d(RR?|LL?|C)?...
  WEATHER_RE = re.compile(r'(?x)^(?P<int>(-|\+|VC)*)(?P<desc>(MI...
  SKY_RE = re.compile(r'(?x)^(?P<cover>VV|CLR|SKC|SCK|NSC|NCD|BK...
  TEMP_RE = re.compile(r'(?x)^(?P<temp>([M-])?\d+|//|XX|MM)/(?P<...
  PRESS_RE = re.compile(r'(?x)^(?P<unit>A|Q|QNH|SLP)?(?P<press>[...
  RECENT_RE = re.compile(r'(?x)^RE(?P<desc>MI|PR|BC|DR|BL|SH|TS|...
  WINDSHEAR_RE = re.compile(r'^(WS\s+)?(ALL\s+RWY|RWY(?P<name>\d...
  COLOR_RE = re.compile(r'(?x)^(BLACK)?(BLU|GRN|WHT|RED)\+?(/?(B...
  TREND_RE = re.compile(r'^(?P<trend>TEMPO|BECMG|FCST|NOSIG)\s+')
  REMARK_RE = re.compile(r'^(RMKS?|NOSPECI|NOSIG)\s+')
  AUTO_RE = re.compile(r'^AO(?P<type>\d)\s+')
  SEALVL_PRESS_RE = re.compile(r'^SLP(?P<press>\d\d\d)\s+')
  PEAK_WIND_RE = re.compile(r'(?x)^P[A-Z]\s+WND\s+(?P<dir>\d\d\d...
  WIND_SHIFT_RE = re.compile(r'(?x)^WSHFT\s+(?P<hour>\d\d)?(?P<m...
  PRECIP_1HR_RE = re.compile(r'^P(?P<precip>\d\d\d\d)\s+')
  PRECIP_24HR_RE = re.compile(r'(?x)^(?P<type>[67])(?P<precip>\d...
  PRESS_3HR_RE = re.compile(r'(?x)^5(?P<tend>[0-8])(?P<press>\d\...
  TEMP_1HR_RE = re.compile(r'(?x)^T(?P<tsign>[01])(?P<temp>\d\d\...
  TEMP_6HR_RE = re.compile(r'(?x)^(?P<type>[12])(?P<sign>[01])(?...
  TEMP_24HR_RE = re.compile(r'(?x)^4(?P<smaxt>[01])(?P<maxt>\d\d...
  UNPARSED_RE = re.compile(r'(?P<group>\S+)\s+')
  LIGHTNING_RE = re.compile(r'(?x)^((?P<freq>OCNL|FRQ|CONS)\s+)?...
  TS_LOC_RE = re.compile(r'(?x)TS(\s+(?P<loc>(OHD|VC|DSNT\s+|\s+...
  loc_terms = [('OHD', 'overhead'), ('DSNT', 'distant'), ('AND',...
  SKY_COVER = {'///': '', 'BKN': 'broken ', 'CLR': 'clear', 'FEW...
  CLOUD_TYPE = {'ACC': 'altocumulus castellanus', 'ACSL': 'stand...
  WEATHER_INT = {'+': 'heavy', '+VC': 'nearby heavy', '-': 'ligh...
  WEATHER_DESC = {'BC': 'patches of', 'BL': 'blowing', 'DR': 'lo...
  WEATHER_PREC = {'//': '', 'DZ': 'drizzle', 'GR': 'hail', 'GS':...
  WEATHER_OBSC = {'BR': 'mist', 'DU': 'dust', 'FG': 'fog', 'FU':...
  WEATHER_OTHER = {'DS': 'dust storm', 'FC': 'funnel cloud', 'PO...
  WEATHER_SPECIAL = {'+FC': 'tornado'}
  COLOR = {'BLU': 'blue', 'GRN': 'green', 'WHT': 'white'}
  PRESSURE_TENDENCY = {'0': 'increasing, then decreasing', '1': ...
  LIGHTNING_FREQUENCY = {'CONS': 'constant', 'FRQ': 'frequent', ...
  LIGHTNING_TYPE = {'CA': 'cloud-to-air', 'CC': 'cloud-to-cloud'...
  REPORT_TYPE = {'AUTO': 'automatic report', 'COR': 'manually co...
  debug = True
Function Details [hide private]

_report_match(handler, match)

source code 
Report success or failure of the given handler function. (DEBUG)

Variables Details [hide private]

__LICENSE__

Value:
'''
Copyright (c) 2004,
All rights reserved.

Redistribution and use in source and binary forms, with or without mod\
ification, are permitted provided that the following conditions are me\
t:

...

TIME_RE

Value:
re.compile(r'(?x)^(?P<day>\d\d)(?P<hour>\d\d)(?P<min>\d\d)Z?\s+')

MODIFIER_RE

Value:
re.compile(r'^(?P<mod>AUTO|FINO|NIL|TEST|CORR?|RTD|CC[A-G])\s+')

WIND_RE

Value:
re.compile(r'(?x)^(?P<dir>[\dO]{3}|[0O]|///|MMM|VRB)(?P<speed>P?[\dO]{\
2,3}|[0O]+|[/M]{2,3})(G(?P<gust>P?(\d{1,3}|[/M]{1,3})))?(?P<units>KTS?\
|LT|K|T|KMH|MPS)?(\s+(?P<varfrom>\d\d\d)V(?P<varto>\d\d\d))?\s+')

VISIBILITY_RE

Value:
re.compile(r'(?x)^(?P<vis>(?P<dist>M?(\d\s*)?\d/\d\d?|M?\d+)(\s*(?P<un\
its>SM|KM|M|U)|(?P<dir>[NSEW][EW]?))?|CAVOK)\s+')

RUNWAY_RE

Value:
re.compile(r'(?x)^(RVRNO|(?P<name>\d\d(RR?|LL?|C)?)/(?P<low>([MP])?\d\\
d\d\d)(V(?P<high>([MP])?\d\d\d\d))?(?P<unit>FT)?[/NDU]*)\s+')

WEATHER_RE

Value:
re.compile(r'(?x)^(?P<int>(-|\+|VC)*)(?P<desc>(MI|PR|BC|DR|BL|SH|TS|FZ\
)+)?(?P<prec>(DZ|RA|SN|SG|IC|PL|GR|GS|UP|/)*)(?P<obsc>BR|FG|FU|VA|DU|S\
A|HZ|PY)?(?P<other>PO|SQ|FC|SS|DS|NSW|/+)?(?P<int2>[-\+])?\s+')

SKY_RE

Value:
re.compile(r'(?x)^(?P<cover>VV|CLR|SKC|SCK|NSC|NCD|BKN|SCT|FEW|[O0]VC|\
///)(?P<height>[\dO]{2,4}|///)?(?P<cloud>([A-Z][A-Z]+|///))?\s+')

TEMP_RE

Value:
re.compile(r'(?x)^(?P<temp>([M-])?\d+|//|XX|MM)/(?P<dewpt>([M-])?\d+|/\
/|XX|MM)?\s+')

PRESS_RE

Value:
re.compile(r'(?x)^(?P<unit>A|Q|QNH|SLP)?(?P<press>[\dO]{3,4}|////)(?P<\
unit2>INS)?\s+')

RECENT_RE

Value:
re.compile(r'(?x)^RE(?P<desc>MI|PR|BC|DR|BL|SH|TS|FZ)?(?P<prec>(DZ|RA|\
SN|SG|IC|PL|GR|GS|UP)*)?(?P<obsc>BR|FG|FU|VA|DU|SA|HZ|PY)?(?P<other>PO\
|SQ|FC|SS|DS)?\s+')

WINDSHEAR_RE

Value:
re.compile(r'^(WS\s+)?(ALL\s+RWY|RWY(?P<name>\d\d(RR?|L?|C)?))\s+')

COLOR_RE

Value:
re.compile(r'(?x)^(BLACK)?(BLU|GRN|WHT|RED)\+?(/?(BLACK)?(BLU|GRN|WHT|\
RED)\+?)*\s*')

PEAK_WIND_RE

Value:
re.compile(r'(?x)^P[A-Z]\s+WND\s+(?P<dir>\d\d\d)(?P<speed>P?\d\d\d?)/(\
?P<hour>\d\d)?(?P<min>\d\d)\s+')

WIND_SHIFT_RE

Value:
re.compile(r'(?x)^WSHFT\s+(?P<hour>\d\d)?(?P<min>\d\d)(\s+(?P<front>FR\
OPA))?\s+')

PRECIP_24HR_RE

Value:
re.compile(r'(?x)^(?P<type>[67])(?P<precip>\d\d\d\d)\s+')

PRESS_3HR_RE

Value:
re.compile(r'(?x)^5(?P<tend>[0-8])(?P<press>\d\d\d)\s+')

TEMP_1HR_RE

Value:
re.compile(r'(?x)^T(?P<tsign>[01])(?P<temp>\d\d\d)((?P<dsign>[01])(?P<\
dewpt>\d\d\d))?\s+')

TEMP_6HR_RE

Value:
re.compile(r'(?x)^(?P<type>[12])(?P<sign>[01])(?P<temp>\d\d\d)\s+')

TEMP_24HR_RE

Value:
re.compile(r'(?x)^4(?P<smaxt>[01])(?P<maxt>\d\d\d)(?P<smint>[01])(?P<m\
int>\d\d\d)\s+')

LIGHTNING_RE

Value:
re.compile(r'(?x)^((?P<freq>OCNL|FRQ|CONS)\s+)?LTG(?P<type>(IC|CC|CG|C\
A)*)(\s+(?P<loc>(OHD|VC|DSNT\s+|\s+AND\s+|[NSEW][EW]?(-[NSEW][EW]?)*)+\
))?\s+')

TS_LOC_RE

Value:
re.compile(r'(?x)TS(\s+(?P<loc>(OHD|VC|DSNT\s+|\s+AND\s+|[NSEW][EW]?(-\
[NSEW][EW]?)*)+))?(\s+MOV\s+(?P<dir>[NSEW][EW]?))?\s+')

loc_terms

Value:
[('OHD', 'overhead'),
 ('DSNT', 'distant'),
 ('AND', 'and'),
 ('VC', 'nearby')]

SKY_COVER

Value:
{'///': '',
 'BKN': 'broken ',
 'CLR': 'clear',
 'FEW': 'a few ',
 'NCD': 'clear',
 'NSC': 'clear',
 'OVC': 'overcast',
 'SCT': 'scattered ',
...

CLOUD_TYPE

Value:
{'ACC': 'altocumulus castellanus',
 'ACSL': 'standing lenticular altocumulus',
 'CB': 'cumulonimbus',
 'CBMAM': 'cumulonimbus mammatus',
 'CCSL': 'standing lenticular cirrocumulus',
 'CU': 'cumulus',
 'SC': 'stratocumulus',
 'SCSL': 'standing lenticular stratocumulus',
...

WEATHER_INT

Value:
{'+': 'heavy',
 '+VC': 'nearby heavy',
 '-': 'light',
 '-VC': 'nearby light',
 'VC': 'nearby'}

WEATHER_DESC

Value:
{'BC': 'patches of',
 'BL': 'blowing',
 'DR': 'low drifting',
 'FZ': 'freezing',
 'MI': 'shallow',
 'PR': 'partial',
 'SH': 'showers',
 'TS': 'thunderstorm'}

WEATHER_PREC

Value:
{'//': '',
 'DZ': 'drizzle',
 'GR': 'hail',
 'GS': 'snow pellets',
 'IC': 'ice crystals',
 'PL': 'ice pellets',
 'RA': 'rain',
 'SG': 'snow grains',
...

WEATHER_OBSC

Value:
{'BR': 'mist',
 'DU': 'dust',
 'FG': 'fog',
 'FU': 'smoke',
 'HZ': 'haze',
 'PY': 'spray',
 'SA': 'sand',
 'VA': 'volcanic ash'}

WEATHER_OTHER

Value:
{'DS': 'dust storm',
 'FC': 'funnel cloud',
 'PO': 'sand whirls',
 'SQ': 'squalls',
 'SS': 'sandstorm'}

PRESSURE_TENDENCY

Value:
{'0': 'increasing, then decreasing',
 '1': 'increasing more slowly',
 '2': 'increasing',
 '3': 'increasing more quickly',
 '4': 'steady',
 '5': 'decreasing, then increasing',
 '6': 'decreasing more slowly',
 '7': 'decreasing',
...

LIGHTNING_FREQUENCY

Value:
{'CONS': 'constant', 'FRQ': 'frequent', 'OCNL': 'occasional'}

LIGHTNING_TYPE

Value:
{'CA': 'cloud-to-air',
 'CC': 'cloud-to-cloud',
 'CG': 'cloud-to-ground',
 'IC': 'intracloud'}

REPORT_TYPE

Value:
{'AUTO': 'automatic report',
 'COR': 'manually corrected report',
 'METAR': 'routine report',
 'SPECI': 'special report'}