Ejemplo n.º 1
0
def parse_in_line(line: str, units: Units) -> {str: str}:
    """
    Parser for the International TAF forcast variant
    """
    wxdata = _core.dedupe(line.split())
    wxdata = _core.sanitize_report_list(wxdata)
    retwx = {"sanitized": " ".join(wxdata)}
    (
        wxdata,
        retwx["type"],
        retwx["start_time"],
        retwx["end_time"],
    ) = _core.get_type_and_times(wxdata)
    wxdata, retwx["wind_shear"] = _core.get_wind_shear(wxdata)
    (
        wxdata,
        retwx["wind_direction"],
        retwx["wind_speed"],
        retwx["wind_gust"],
        _,
    ) = _core.get_wind(wxdata, units)
    if "CAVOK" in wxdata:
        retwx["visibility"] = _core.make_number("CAVOK")
        retwx["clouds"] = []
        wxdata.pop(wxdata.index("CAVOK"))
    else:
        wxdata, retwx["visibility"] = _core.get_visibility(wxdata, units)
        wxdata, retwx["clouds"] = _core.get_clouds(wxdata)
    (
        retwx["other"],
        retwx["altimeter"],
        retwx["icing"],
        retwx["turbulence"],
    ) = _core.get_taf_alt_ice_turb(wxdata)
    return retwx
Ejemplo n.º 2
0
def parse_na_line(line: str, units: Units) -> {str: str}:
    """
    Parser for the North American TAF forcast variant
    """
    wxdata = _core.dedupe(line.split())
    wxdata = _core.sanitize_report_list(wxdata)
    retwx = {"sanitized": " ".join(wxdata)}
    (
        wxdata,
        retwx["type"],
        retwx["start_time"],
        retwx["end_time"],
    ) = _core.get_type_and_times(wxdata)
    wxdata, retwx["wind_shear"] = _core.get_wind_shear(wxdata)
    (
        wxdata,
        retwx["wind_direction"],
        retwx["wind_speed"],
        retwx["wind_gust"],
        _,
    ) = _core.get_wind(wxdata, units)
    wxdata, retwx["visibility"] = _core.get_visibility(wxdata, units)
    wxdata, retwx["clouds"] = _core.get_clouds(wxdata)
    (
        retwx["other"],
        retwx["altimeter"],
        retwx["icing"],
        retwx["turbulence"],
    ) = _core.get_taf_alt_ice_turb(wxdata)
    return retwx
Ejemplo n.º 3
0
 def test_get_wind_shear(self):
     """
     Tests extracting wind shear
     """
     for wx, shear in (
         (["1", "2"], None),
         (["1", "2", "WS020/07040"], "WS020/07040"),
     ):
         self.assertEqual(_core.get_wind_shear(wx), (["1", "2"], shear))
Ejemplo n.º 4
0
 def test_get_wind_shear(self):
     """
     Tests extracting wind shear
     """
     for wx, shear in (
         (['1', '2'], None),
         (['1', '2', 'WS020/07040'], 'WS020/07040'),
     ):
         self.assertEqual(_core.get_wind_shear(wx), (['1', '2'], shear))