How to use the metar.metar.ParserError function in metar

To help you get started, we’ve selected a few metar examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github UrbanCCD-UChicago / plenario / scripts / test_metar.py View on Github external
allw = getAllCurrentWeather()

# here's a list of Illinois-area wban_codes (from python scripts/get_weather_station_bboxes.py where whitelist_urls=['ce29323c565cbd4a97eb61c73426fb01'] (idol_public_works_prohibited_contractors)
illinois_wbans = [u'14855', u'54808', u'14834', u'04838', u'04876', u'03887', u'04871', u'04873', u'04831', u'04879', u'04996', u'14880', u'04899', u'94892', u'94891', u'04890', u'54831', u'94870', u'04894', u'94854', u'14842', u'93822', u'04807', u'04808', u'54811', u'94822', u'94846', u'04868', u'04845', u'04896', u'04867', u'04866', u'04889', u'14816', u'04862', u'94866', u'04880', u'14819']

#illinois_w = getCurrentWeather(wban_codes=illinois_wbans)

metars = []
om = None
rain_metar = None
all_metars = []
for w in allw:
#for w in illinois_w:
    try:
        metar = Metar(w)
    except ParserError, e:
        print "parser error! on error" , e

    all_metars.append(metar)
    wban = getWban(metar)
    if (wban in illinois_wbans):
        print w
        if (wban =='94846'):
            om = metar # ohare metar
        if metar.precip_1hr:
            rain_metar = metar
        print "got Wban from metar: ", wban
        
        metars.append(metar)
    #print "metar is", metar
    dumpMetar(metar)
github UrbanCCD-UChicago / plenario / plenario / utils / weather.py View on Github external
def _parse_row_metar(self, row, header):
        try:
            m = getMetar(row)
        except ParserError:
            return []

        vals = getMetarVals(m)
        #print "_parse_row_metar(): header=", header
        #print "_parse_row_metar(): vals=",vals
        assert(len(header) == len(vals))
        return vals