def test_metar(self): """ Tests end-to-end METAR translation """ units = structs.Units(**static.NA_UNITS) data = { "altimeter": _core.make_number("29.92", "2992"), "clouds": [_core.make_cloud("BKN015CB")], "dewpoint": _core.make_number("M01"), "other": ["+RA"], "temperature": _core.make_number("03"), "visibility": _core.make_number("3"), "wind_direction": _core.make_number("360"), "wind_gust": _core.make_number("20"), "wind_speed": _core.make_number("12"), "wind_variable_direction": [ _core.make_number("340"), _core.make_number("020"), ], } data.update({ k: "" for k in ( "raw", "remarks", "station", "time", "flight_rules", "remarks_info", "runway_visibility", "sanitized", ) }) data = structs.MetarData(**data) trans = structs.MetarTrans( altimeter="29.92 inHg (1013 hPa)", clouds="Broken layer at 1500ft (Cumulonimbus) - Reported AGL", dewpoint="-1°C (30°F)", other="Heavy Rain", remarks={}, temperature="3°C (37°F)", visibility="3sm (4.8km)", wind="N-360 (variable 340 to 020) at 12kt gusting to 20kt", ) translated = translate.metar(data, units) self.assertIsInstance(translated, structs.MetarTrans) self.assertEqual(translated, trans)
def update(self, report: str = None) -> bool: """Updates raw, data, and translations by fetching and parsing the METAR report Returns True is a new report is available, else False """ if report is not None: self.raw = report else: raw = self.service.fetch(self.station) if raw == self.raw: return False self.raw = raw self.data, self.units = metar.parse(self.station, self.raw) self.translations = translate.metar(self.data, self.units) self.last_updated = datetime.utcnow() return True
def test_metar(self): """ Tests end-to-end METAR translation """ units = structs.Units(**static.NA_UNITS) data = { 'altimeter': core.make_number('2992'), 'clouds': [core.make_cloud('BKN015CB')], 'dewpoint': core.make_number('M01'), 'other': ['+RA'], 'temperature': core.make_number('03'), 'visibility': core.make_number('3'), 'wind_direction': core.make_number('360'), 'wind_gust': core.make_number('20'), 'wind_speed': core.make_number('12'), 'wind_variable_direction': [core.make_number('340'), core.make_number('020')] } data.update({ k: '' for k in ('raw', 'remarks', 'station', 'time', 'flight_rules', 'remarks_info', 'runway_visibility', 'sanitized') }) data = structs.MetarData(**data) trans = structs.MetarTrans( altimeter='29.92 inHg (1013 hPa)', clouds='Broken layer at 1500ft (Cumulonimbus) - Reported AGL', dewpoint='-1°C (30°F)', other='Heavy Rain', remarks={}, temperature='3°C (37°F)', visibility='3sm (4.8km)', wind='N-360 (variable 340 to 020) at 12kt gusting to 20kt') translated = translate.metar(data, units) self.assertIsInstance(translated, structs.MetarTrans) self.assertEqual(translated, trans)
def test_metar(self): """ Tests end-to-end METAR translation """ units = structs.Units(**static.NA_UNITS) data = { 'altimeter': core.make_number('2992'), 'clouds': [core.make_cloud('BKN015CB')], 'dewpoint': core.make_number('M01'), 'other': ['+RA'], 'temperature': core.make_number('03'), 'visibility': core.make_number('3'), 'wind_direction': core.make_number('360'), 'wind_gust': core.make_number('20'), 'wind_speed': core.make_number('12'), 'wind_variable_direction': [ core.make_number('340'), core.make_number('020') ] } data.update({k: '' for k in ( 'raw', 'remarks', 'station', 'time', 'flight_rules', 'remarks_info', 'runway_visibility', 'sanitized' )}) data = structs.MetarData(**data) trans = structs.MetarTrans( altimeter='29.92 inHg (1013 hPa)', clouds='Broken layer at 1500ft (Cumulonimbus) - Reported AGL', dewpoint='-1°C (30°F)', other='Heavy Rain', remarks={}, temperature='3°C (37°F)', visibility='3sm (4.8km)', wind='N-360 (variable 340 to 020) at 12kt gusting to 20kt' ) translated = translate.metar(data, units) self.assertIsInstance(translated, structs.MetarTrans) self.assertEqual(translated, trans)
def _post_update(self): self.data, self.units = metar.parse(self.station, self.raw) self.translations = translate.metar(self.data, self.units) self.last_updated = datetime.utcnow()
def _post_update(self): self.data, self.units = metar.parse(self.station, self.raw) self.translations = translate.metar(self.data, self.units)