def taf(wxdata: TafData, units: Units) -> TafTrans: """ Translate the results of taf.parse Keys: Forecast, Min-Temp, Max-Temp Forecast keys: Wind, Visibility, Clouds, Altimeter, Wind-Shear, Turbulance, Icing, Other """ translations = {'forecast': []} for line in wxdata.forecast: trans = shared(line, units) trans['wind'] = wind(line.wind_direction, line.wind_speed, line.wind_gust, unit=units.wind_speed) trans['wind_shear'] = wind_shear(line.wind_shear, units.altitude, units.wind_speed) trans['turbulance'] = turb_ice(line.turbulance, units.altitude) trans['icing'] = turb_ice(line.icing, units.altitude) # Remove false 'Sky Clear' if line type is 'BECMG' if line.type == 'BECMG' and trans['clouds'] == 'Sky clear': trans['clouds'] = None translations['forecast'].append(TafLineTrans(**trans)) translations['min_temp'] = min_max_temp(wxdata.min_temp, units.temperature) translations['max_temp'] = min_max_temp(wxdata.max_temp, units.temperature) translations['remarks'] = remarks.translate(wxdata.remarks) return TafTrans(**translations)
def taf(wxdata: {str: object}) -> {str: str}: """ Translate the results of taf.parse Keys: Forecast, Min-Temp, Max-Temp Forecast keys: Wind, Visibility, Clouds, Altimeter, Wind-Shear, Turbulance, Icing, Other """ translations = {'Forecast': []} units = wxdata['Units'] for line in wxdata['Forecast']: trans = shared(line, units) trans['Wind'] = wind(line['Wind-Direction'], line['Wind-Speed'], line['Wind-Gust'], unit=units['Wind-Speed']) trans['Wind-Shear'] = wind_shear(line['Wind-Shear'], wxdata['Units']['Altitude'], units['Wind-Speed']) trans['Turbulance'] = turb_ice(line['Turb-List'], units['Altitude']) trans['Icing'] = turb_ice(line['Icing-List'], units['Altitude']) # Remove false 'Sky Clear' if line type is 'BECMG' if line['Type'] == 'BECMG' and trans['Clouds'] == 'Sky clear': trans['Clouds'] = '' translations['Forecast'].append(trans) translations['Min-Temp'] = min_max_temp(wxdata['Min-Temp'], units['Temperature']) translations['Max-Temp'] = min_max_temp(wxdata['Max-Temp'], units['Temperature']) translations['Remarks'] = remarks.translate(wxdata['Remarks']) return translations
def test_translate(self): """ Tests extracting translations from the remarks string """ for rmk, out in ( ('RMK AO1 ACFT MSHP SLP137 T02720183 BINOVC', { 'ACFT MSHP': 'Aircraft mishap', 'AO1': 'Automated with no precipitation sensor', 'BINOVC': 'Breaks in Overcast', 'SLP137': 'Sea level pressure: 1013.7 hPa', 'T02720183': 'Temperature 27.2°C and dewpoint 18.3°C' }), ('RMK AO2 51014 21045 60720 70016', { '21045': '6-hour minimum temperature -4.5°C', '51014': '3-hour pressure difference: +/- 1.4 mb - Increasing, then steady', '60720': 'Precipitation in the last 3 hours: 7 in. - 6 hours: 20 in.', '70016': 'Precipitation in the last 24 hours: 16 in.', 'AO2': 'Automated with precipitation sensor' }), ('RMK 91234 TSB20 P0123 NOSPECI $', { '$': 'ASOS requires maintenance', '91234': 'Duration of sunlight: 1234 minutes', 'NOSPECI': 'No SPECI reports taken', 'P0123': 'Hourly precipitation: 1.23 in.', 'TSB20': 'Thunderstorm began at :20' }), ): self.assertEqual(remarks.translate(rmk), out)
def metar(wxdata: MetarData, units: Units) -> MetarTrans: """ Translate the results of metar.parse Keys: Wind, Visibility, Clouds, Temperature, Dewpoint, Altimeter, Other """ translations = shared(wxdata, units) translations['wind'] = wind(wxdata.wind_direction, wxdata.wind_speed, wxdata.wind_gust, wxdata.wind_variable_direction, units.wind_speed) translations['temperature'] = temperature(wxdata.temperature, units.temperature) translations['dewpoint'] = temperature(wxdata.dewpoint, units.temperature) translations['remarks'] = remarks.translate(wxdata.remarks) return MetarTrans(**translations)
def metar(wxdata: {str: object}) -> {str: str}: """ Translate the results of metar.parse Keys: Wind, Visibility, Clouds, Temperature, Dewpoint, Altimeter, Other """ units = wxdata['Units'] translations = shared(wxdata, units) translations['Wind'] = wind(wxdata['Wind-Direction'], wxdata['Wind-Speed'], wxdata['Wind-Gust'], wxdata['Wind-Variable-Dir'], units['Wind-Speed']) translations['Temperature'] = temperature(wxdata['Temperature'], units['Temperature']) translations['Dewpoint'] = temperature(wxdata['Dewpoint'], units['Temperature']) translations['Remarks'] = remarks.translate(wxdata['Remarks']) return translations
def test_translate(self): """ Tests extracting translations from the remarks string """ for rmk, out in ( ( "RMK AO1 ACFT MSHP SLP137 T02720183 BINOVC", { "ACFT MSHP": "Aircraft mishap", "AO1": "Automated with no precipitation sensor", "BINOVC": "Breaks in Overcast", "SLP137": "Sea level pressure: 1013.7 hPa", "T02720183": "Temperature 27.2°C and dewpoint 18.3°C", }, ), ( "RMK AO2 51014 21045 60720 70016", { "21045": "6-hour minimum temperature -4.5°C", "51014": "3-hour pressure difference: +/- 1.4 mb - Increasing, then steady", "60720": "Precipitation in the last 3 hours: 7 in. - 6 hours: 20 in.", "70016": "Precipitation in the last 24 hours: 16 in.", "AO2": "Automated with precipitation sensor", }, ), ( "RMK 91234 TSB20 P0123 NOSPECI $", { "$": "ASOS requires maintenance", "91234": "Duration of sunlight: 1234 minutes", "NOSPECI": "No SPECI reports taken", "P0123": "Hourly precipitation: 1.23 in.", "TSB20": "Thunderstorm began at :20", }, ), ): self.assertEqual(remarks.translate(rmk), out)