Example #1
0
    def test_1(self):
        """ PIREP.txt, can we parse it! """
        utcnow = utc(2015, 1, 9, 0, 0)
        nwsli_provider = {
            'BIL': {
                'lat': 44,
                'lon': 99
            },
            'LBY': {
                'lat': 45,
                'lon': 100
            },
            'PUB': {
                'lat': 46,
                'lon': 101
            },
            'HPW': {
                'lat': 47,
                'lon': 102
            }
        }
        prod = pirepparser(get_file('PIREP.txt'),
                           utcnow=utcnow,
                           nwsli_provider=nwsli_provider)
        self.assertEquals(len(prod.warnings), 0, "\n".join(prod.warnings))

        j = prod.get_jabbers()
        self.assertEquals(j[0][2]['channels'], 'UA.None,UA.PIREP')
Example #2
0
def test_150202_groupdict():
    """groupdict.txt threw an error"""
    nwsli_provider = {"GCC": {"lat": 44.26, "lon": -88.52}}
    prod = pirepparser(
        get_test_file("PIREPS/groupdict.txt"), nwsli_provider=nwsli_provider
    )
    assert len(prod.reports) == 1
Example #3
0
    def test_150120_latlonloc(self):
        """ latlonloc.txt Turns out there is a LAT/LON option for OV """
        prod = pirepparser(get_file('PIREPS/latlonloc.txt'))
        self.assertEquals(len(prod.warnings), 0, "\n".join(prod.warnings))
        self.assertEquals(prod.reports[0].latitude, 25.00)
        self.assertEquals(prod.reports[0].longitude, -70.00)
        self.assertEquals(prod.reports[1].latitude, 39.00)
        self.assertEquals(prod.reports[1].longitude, -45.00)

        prod = pirepparser(get_file('PIREPS/latlonloc2.txt'))
        self.assertEquals(len(prod.warnings), 0, "\n".join(prod.warnings))

        nwsli_provider = {'PKTN': {'lat': 44, 'lon': -99}}
        prod = pirepparser(get_file('PIREPS/PKTN.txt'),
                           nwsli_provider=nwsli_provider)
        self.assertEquals(len(prod.warnings), 0, "\n".join(prod.warnings))
Example #4
0
def test_151210_badgeom():
    """prevent geom parse error"""
    nwsli_provider = {"GCC": {"lat": 44.26, "lon": -88.52}}
    prod = pirepparser(
        get_test_file("PIREPS/badgeom.txt"), nwsli_provider=nwsli_provider
    )
    assert not prod.reports
Example #5
0
def test_1():
    """ PIREP.txt, can we parse it! """
    utcnow = utc(2015, 1, 9, 0, 0)
    nwsli_provider = {
        'BIL': {
            'lat': 44,
            'lon': 99
        },
        'LBY': {
            'lat': 45,
            'lon': 100
        },
        'PUB': {
            'lat': 46,
            'lon': 101
        },
        'HPW': {
            'lat': 47,
            'lon': 102
        }
    }
    prod = pirepparser(get_test_file('PIREPS/PIREP.txt'),
                       utcnow=utcnow,
                       nwsli_provider=nwsli_provider)
    assert not prod.warnings

    j = prod.get_jabbers()
    assert j[0][2]['channels'] == 'UA.None,UA.PIREP'
Example #6
0
 def test_150126_space(self):
     """ space.txt has a space where it should not """
     nwsli_provider = {'CZBA': {'lat': 44.26, 'lon': -88.52}}
     prod = pirepparser(get_file('PIREPS/space.txt'),
                        nwsli_provider=nwsli_provider)
     self.assertEquals(len(prod.warnings), 0, "\n".join(prod.warnings))
     self.assertAlmostEquals(prod.reports[0].latitude, 44.15, 2)
Example #7
0
def test_150126_space():
    """ space.txt has a space where it should not """
    nwsli_provider = {'CZBA': {'lat': 44.26, 'lon': -88.52}}
    prod = pirepparser(
        get_test_file('PIREPS/space.txt'), nwsli_provider=nwsli_provider)
    assert not prod.warnings
    assert abs(prod.reports[0].latitude - 44.15) < 0.01
Example #8
0
def test_150126_space():
    """ space.txt has a space where it should not """
    nwsli_provider = {'CZBA': {'lat': 44.26, 'lon': -88.52}}
    prod = pirepparser(get_test_file('PIREPS/space.txt'),
                       nwsli_provider=nwsli_provider)
    assert not prod.warnings
    assert abs(prod.reports[0].latitude - 44.15) < 0.01
Example #9
0
    def test_150120_latlonloc(self):
        """ latlonloc.txt Turns out there is a LAT/LON option for OV """
        prod = pirepparser(get_file('PIREPS/latlonloc.txt'))
        self.assertEquals(len(prod.warnings), 0, "\n".join(prod.warnings))
        self.assertEquals(prod.reports[0].latitude, 25.00)
        self.assertEquals(prod.reports[0].longitude, -70.00)
        self.assertEquals(prod.reports[1].latitude, 39.00)
        self.assertEquals(prod.reports[1].longitude, -45.00)

        prod = pirepparser(get_file('PIREPS/latlonloc2.txt'))
        self.assertEquals(len(prod.warnings), 0, "\n".join(prod.warnings))

        nwsli_provider = {'PKTN': {'lat': 44, 'lon': -99}}
        prod = pirepparser(get_file('PIREPS/PKTN.txt'),
                           nwsli_provider=nwsli_provider)
        self.assertEquals(len(prod.warnings), 0, "\n".join(prod.warnings))
Example #10
0
 def test_150126_space(self):
     """ space.txt has a space where it should not """
     nwsli_provider = {'CZBA': {'lat': 44.26, 'lon': -88.52}}
     prod = pirepparser(get_file('PIREPS/space.txt'),
                        nwsli_provider=nwsli_provider)
     self.assertEquals(len(prod.warnings), 0, "\n".join(prod.warnings))
     self.assertAlmostEquals(prod.reports[0].latitude, 44.15, 2)
Example #11
0
 def test_161010_missingtime(self):
     """prevent geom parse error"""
     nwsli_provider = {'GTF': {'lat': 44.26, 'lon': -88.52},
                       'ALB': {'lat': 44.26, 'lon': -88.52}}
     prod = pirepparser(get_file("PIREPS/PRCUS.txt"),
                        nwsli_provider=nwsli_provider)
     j = prod.get_jabbers()
     self.assertEquals(j[0][2]['channels'], 'UA.None,UA.PIREP')
Example #12
0
def test_180307_aviation_controlchar(dbcursor):
    """Darn Aviation control character showing up in WMO products"""
    nwsli_provider = {"BWI": {"lat": 44.26, "lon": -88.52}}
    prod = pirepparser(
        get_test_file("PIREPS/ubmd90.txt"), nwsli_provider=nwsli_provider
    )
    assert len(prod.reports) == 1
    prod.sql(dbcursor)
Example #13
0
def test_150126_space():
    """ space.txt has a space where it should not """
    nwsli_provider = {"CZBA": {"lat": 44.26, "lon": -88.52}}
    prod = pirepparser(
        get_test_file("PIREPS/space.txt"), nwsli_provider=nwsli_provider
    )
    assert not prod.warnings
    assert abs(prod.reports[0].latitude - 44.15) < 0.01
Example #14
0
def test_150120_latlonloc():
    """ latlonloc.txt Turns out there is a LAT/LON option for OV """
    prod = pirepparser(get_test_file('PIREPS/latlonloc.txt'))
    assert not prod.warnings
    assert prod.reports[0].latitude == 25.00
    assert prod.reports[0].longitude == -70.00
    assert prod.reports[1].latitude == 39.00
    assert prod.reports[1].longitude == -45.00

    prod = pirepparser(get_test_file('PIREPS/latlonloc2.txt'))
    assert not prod.warnings
    assert abs(prod.reports[0].latitude - 38.51) < 0.01
    assert abs(prod.reports[0].longitude - -144.3) < 0.01

    nwsli_provider = {'PKTN': {'lat': 44, 'lon': -99}}
    prod = pirepparser(
        get_test_file('PIREPS/PKTN.txt'), nwsli_provider=nwsli_provider)
    assert not prod.warnings
Example #15
0
 def test_150121_runway(self):
     """ runway.txt has KATW on the runway, this was not good """
     nwsli_provider = {'ATW': {'lat': 44.26, 'lon': -88.52},
                       'IPT': {'lat': 44.26, 'lon': -88.52}}
     prod = pirepparser(get_file('PIREPS/runway.txt'),
                        nwsli_provider=nwsli_provider)
     self.assertEquals(len(prod.warnings), 0, "\n".join(prod.warnings))
     self.assertAlmostEquals(prod.reports[0].latitude, 44.26, 2)
     self.assertAlmostEquals(prod.reports[1].longitude, -88.52, 2)
Example #16
0
def test_150120_latlonloc():
    """ latlonloc.txt Turns out there is a LAT/LON option for OV """
    prod = pirepparser(get_test_file('PIREPS/latlonloc.txt'))
    assert not prod.warnings
    assert prod.reports[0].latitude == 25.00
    assert prod.reports[0].longitude == -70.00
    assert prod.reports[1].latitude == 39.00
    assert prod.reports[1].longitude == -45.00

    prod = pirepparser(get_test_file('PIREPS/latlonloc2.txt'))
    assert not prod.warnings
    assert abs(prod.reports[0].latitude - 38.51) < 0.01
    assert abs(prod.reports[0].longitude - -144.3) < 0.01

    nwsli_provider = {'PKTN': {'lat': 44, 'lon': -99}}
    prod = pirepparser(get_test_file('PIREPS/PKTN.txt'),
                       nwsli_provider=nwsli_provider)
    assert not prod.warnings
Example #17
0
def test_170324_ampersand():
    """Do we properly escape the ampersand"""
    nwsli_provider = {'DUG': {'lat': 44.26, 'lon': -88.52}}
    prod = pirepparser(get_test_file("PIREPS/ampersand.txt"),
                       nwsli_provider=nwsli_provider)
    j = prod.get_jabbers()
    ans = ("Routine pilot report at 1259Z: DUG UA /OV SSO/"
           "TM 1259/FL340/TP CRJ9/TB LT TURB &amp; CHOP/RM ZAB FDCS")
    assert j[0][0] == ans
Example #18
0
 def test_150121_fourchar(self):
     """ Another coding edition with four char identifiers """
     nwsli_provider = {'FAR': {'lat': 44, 'lon': -99},
                       'SMF': {'lat': 42, 'lon': -99},
                       'RDD': {'lat': 43, 'lon': -100}}
     prod = pirepparser(get_file('PIREPS/fourchar.txt'),
                        nwsli_provider=nwsli_provider)
     self.assertEquals(len(prod.warnings), 0, "\n".join(prod.warnings))
     self.assertAlmostEquals(prod.reports[0].latitude, 44.10, 2)
     self.assertAlmostEquals(prod.reports[1].latitude, 42.50, 2)
Example #19
0
def test_150121_runway():
    """ runway.txt has KATW on the runway, this was not good """
    nwsli_provider = {
        'ATW': {'lat': 44.26, 'lon': -88.52},
        'IPT': {'lat': 44.26, 'lon': -88.52}}
    prod = pirepparser(
        get_test_file('PIREPS/runway.txt'), nwsli_provider=nwsli_provider)
    assert not prod.warnings
    assert abs(prod.reports[0].latitude - 44.26) < 0.01
    assert abs(prod.reports[1].longitude - -88.52) < 0.01
Example #20
0
def test_161010_missingtime():
    """prevent geom parse error"""
    nwsli_provider = {
        "GTF": {"lat": 44.26, "lon": -88.52},
        "ALB": {"lat": 44.26, "lon": -88.52},
    }
    prod = pirepparser(
        get_test_file("PIREPS/PRCUS.txt"), nwsli_provider=nwsli_provider
    )
    j = prod.get_jabbers("unused")
    assert j[0][2]["channels"] == "UA.None,UA.PIREP"
Example #21
0
def test_150121_fourchar():
    """ Another coding edition with four char identifiers """
    nwsli_provider = {
        'FAR': {'lat': 44, 'lon': -99},
        'SMF': {'lat': 42, 'lon': -99},
        'RDD': {'lat': 43, 'lon': -100}}
    prod = pirepparser(get_test_file('PIREPS/fourchar.txt'),
                       nwsli_provider=nwsli_provider)
    assert not prod.warnings
    assert abs(prod.reports[0].latitude - 44.10) < 0.01
    assert abs(prod.reports[1].latitude - 42.50) < 0.01
Example #22
0
 def test_150121_offset(self):
     """ offset.txt and yet another /OV iteration """
     nwsli_provider = {'MRF': {'lat': 44.26, 'lon': -88.52},
                       'PDT': {'lat': 44.26, 'lon': -88.52},
                       'HQZ': {'lat': 44.26, 'lon': -88.52}}
     prod = pirepparser(get_file('PIREPS/offset.txt'),
                        nwsli_provider=nwsli_provider)
     self.assertEquals(len(prod.warnings), 0, "\n".join(prod.warnings))
     self.assertAlmostEquals(prod.reports[0].latitude, 44.48, 2)
     self.assertAlmostEquals(prod.reports[1].latitude, 44.26, 2)
     self.assertAlmostEquals(prod.reports[2].latitude, 44.22, 2)
Example #23
0
def test_170324_ampersand():
    """Do we properly escape the ampersand"""
    nwsli_provider = {'DUG': {'lat': 44.26, 'lon': -88.52}}
    prod = pirepparser(
        get_test_file("PIREPS/ampersand.txt"), nwsli_provider=nwsli_provider)
    j = prod.get_jabbers()
    ans = (
        "Routine pilot report at 1259Z: DUG UA /OV SSO/"
        "TM 1259/FL340/TP CRJ9/TB LT TURB &amp; CHOP/RM ZAB FDCS"
    )
    assert j[0][0] == ans
Example #24
0
def test_150121_runway():
    """ runway.txt has KATW on the runway, this was not good """
    nwsli_provider = {
        "ATW": {"lat": 44.26, "lon": -88.52},
        "IPT": {"lat": 44.26, "lon": -88.52},
    }
    prod = pirepparser(
        get_test_file("PIREPS/runway.txt"), nwsli_provider=nwsli_provider
    )
    assert not prod.warnings
    assert abs(prod.reports[0].latitude - 44.26) < 0.01
    assert abs(prod.reports[1].longitude - -88.52) < 0.01
Example #25
0
def test_150120_OVO():
    """ PIREPS/OVO.txt has a location of OV 0 """
    nwsli_provider = {
        "AVK": {"lat": 44, "lon": 99},
        "TED": {"lat": 61.17, "lon": -149.99},
    }
    prod = pirepparser(
        get_test_file("PIREPS/OVO.txt"), nwsli_provider=nwsli_provider
    )
    assert not prod.warnings
    assert abs(prod.reports[1].latitude - 61.17) > 0.009
    assert abs(prod.reports[1].longitude - -149.99) > 0.009
Example #26
0
def test_150121_offset():
    """ offset.txt and yet another /OV iteration """
    nwsli_provider = {
        'MRF': {'lat': 44.26, 'lon': -88.52},
        'PDT': {'lat': 44.26, 'lon': -88.52},
        'HQZ': {'lat': 44.26, 'lon': -88.52}}
    prod = pirepparser(
        get_test_file('PIREPS/offset.txt'), nwsli_provider=nwsli_provider)
    assert not prod.warnings
    assert abs(prod.reports[0].latitude - 44.48) < 0.01
    assert abs(prod.reports[1].latitude - 44.26) < 0.01
    assert abs(prod.reports[2].latitude - 44.22) < 0.01
Example #27
0
def test_150121_fourchar():
    """ Another coding edition with four char identifiers """
    nwsli_provider = {
        "FAR": {"lat": 44, "lon": -99},
        "SMF": {"lat": 42, "lon": -99},
        "RDD": {"lat": 43, "lon": -100},
    }
    prod = pirepparser(
        get_test_file("PIREPS/fourchar.txt"), nwsli_provider=nwsli_provider
    )
    assert not prod.warnings
    assert abs(prod.reports[0].latitude - 44.10) < 0.01
    assert abs(prod.reports[1].latitude - 42.50) < 0.01
Example #28
0
    def test_1(self):
        """ PIREP.txt, can we parse it! """
        utcnow = utc(2015, 1, 9, 0, 0)
        nwsli_provider = {'BIL': {'lat': 44, 'lon': 99},
                          'LBY': {'lat': 45, 'lon': 100},
                          'PUB': {'lat': 46, 'lon': 101},
                          'HPW': {'lat': 47, 'lon': 102}}
        prod = pirepparser(get_file('PIREP.txt'), utcnow=utcnow,
                           nwsli_provider=nwsli_provider)
        self.assertEquals(len(prod.warnings), 0, "\n".join(prod.warnings))

        j = prod.get_jabbers()
        self.assertEquals(j[0][2]['channels'], 'UA.None,UA.PIREP')
Example #29
0
def test_170324_ampersand():
    """Do we properly escape the ampersand"""
    nwsli_provider = {"DUG": {"lat": 44.26, "lon": -88.52}}
    prod = pirepparser(
        get_test_file("PIREPS/ampersand.txt"), nwsli_provider=nwsli_provider
    )
    j = prod.get_jabbers("unused")
    ans = (
        "Routine pilot report at 1259Z: DUG UA /OV SSO/"
        "TM 1259/FL340/TP CRJ9/TB LT TURB &amp; CHOP/RM ZAB FDCS"
    )
    assert j[0][0] == ans
    prod.reports[0].is_duplicate = True
    assert not prod.get_jabbers("")
Example #30
0
def test_150121_offset():
    """ offset.txt and yet another /OV iteration """
    nwsli_provider = {
        "MRF": {"lat": 44.26, "lon": -88.52},
        "PDT": {"lat": 44.26, "lon": -88.52},
        "HQZ": {"lat": 44.26, "lon": -88.52},
    }
    prod = pirepparser(
        get_test_file("PIREPS/offset.txt"), nwsli_provider=nwsli_provider
    )
    assert not prod.warnings
    assert abs(prod.reports[0].latitude - 44.48) < 0.01
    assert abs(prod.reports[1].latitude - 44.26) < 0.01
    assert abs(prod.reports[2].latitude - 44.22) < 0.01
Example #31
0
def test_1():
    """ PIREP.txt, can we parse it! """
    utcnow = utc(2015, 1, 9, 0, 0)
    nwsli_provider = {
        'BIL': {'lat': 44, 'lon': 99},
        'LBY': {'lat': 45, 'lon': 100},
        'PUB': {'lat': 46, 'lon': 101},
        'HPW': {'lat': 47, 'lon': 102}}
    prod = pirepparser(
        get_test_file('PIREPS/PIREP.txt'), utcnow=utcnow,
        nwsli_provider=nwsli_provider)
    assert not prod.warnings

    j = prod.get_jabbers()
    assert j[0][2]['channels'] == 'UA.None,UA.PIREP'
Example #32
0
 def test_161010_missingtime(self):
     """prevent geom parse error"""
     nwsli_provider = {
         'GTF': {
             'lat': 44.26,
             'lon': -88.52
         },
         'ALB': {
             'lat': 44.26,
             'lon': -88.52
         }
     }
     prod = pirepparser(get_file("PIREPS/PRCUS.txt"),
                        nwsli_provider=nwsli_provider)
     j = prod.get_jabbers()
     self.assertEquals(j[0][2]['channels'], 'UA.None,UA.PIREP')
Example #33
0
def test_150121_runway():
    """ runway.txt has KATW on the runway, this was not good """
    nwsli_provider = {
        'ATW': {
            'lat': 44.26,
            'lon': -88.52
        },
        'IPT': {
            'lat': 44.26,
            'lon': -88.52
        }
    }
    prod = pirepparser(get_test_file('PIREPS/runway.txt'),
                       nwsli_provider=nwsli_provider)
    assert not prod.warnings
    assert abs(prod.reports[0].latitude - 44.26) < 0.01
    assert abs(prod.reports[1].longitude - -88.52) < 0.01
Example #34
0
 def test_150121_runway(self):
     """ runway.txt has KATW on the runway, this was not good """
     nwsli_provider = {
         'ATW': {
             'lat': 44.26,
             'lon': -88.52
         },
         'IPT': {
             'lat': 44.26,
             'lon': -88.52
         }
     }
     prod = pirepparser(get_file('PIREPS/runway.txt'),
                        nwsli_provider=nwsli_provider)
     self.assertEquals(len(prod.warnings), 0, "\n".join(prod.warnings))
     self.assertAlmostEquals(prod.reports[0].latitude, 44.26, 2)
     self.assertAlmostEquals(prod.reports[1].longitude, -88.52, 2)
Example #35
0
    def test_offset(self):
        """ Test out our displacement logic """
        lat = 42.5
        lon = -92.5
        nwsli_provider = {'BIL': {'lat': lat, 'lon': lon}}
        p = pirepparser("\001\r\r\n000 \r\r\nUBUS01 KMSC 090000\r\r\n",
                        nwsli_provider=nwsli_provider)
        lon2, lat2 = p.compute_loc("BIL", 0, 0)
        self.assertEquals(lon2, lon)
        self.assertEquals(lat2, lat)

        lon2, lat2 = p.compute_loc("BIL", 100, 90)
        self.assertAlmostEquals(lon2, -90.54, 2)
        self.assertEquals(lat2, lat)

        lon2, lat2 = p.compute_loc("BIL", 100, 0)
        self.assertEquals(lon2, lon)
        self.assertAlmostEquals(lat2, 43.95, 2)
Example #36
0
def test_offset():
    """ Test out our displacement logic """
    lat = 42.5
    lon = -92.5
    nwsli_provider = {'BIL': {'lat': lat, 'lon': lon}}
    p = pirepparser("\001\r\r\n000 \r\r\nUBUS01 KMSC 090000\r\r\n",
                    nwsli_provider=nwsli_provider)
    lon2, lat2 = p.compute_loc("BIL", 0, 0)
    assert lon2 == lon
    assert lat2 == lat

    lon2, lat2 = p.compute_loc("BIL", 100, 90)
    assert abs(lon2 - -90.54) < 0.01
    assert lat2 == lat

    lon2, lat2 = p.compute_loc("BIL", 100, 0)
    assert lon2 == lon
    assert abs(lat2 - 43.95) < 0.01
Example #37
0
def real_parser(txn, buf):
    """
    I'm gonna do the heavy lifting here
    """
    prod = pirepparser(buf, nwsli_provider=LOCS)
    prod.assign_cwsu(txn)
    for report in prod.reports:
        if report.text in PIREPS:
            report.is_duplicate = True
        PIREPS[report.text] = datetime.datetime.utcnow()

    j = prod.get_jabbers()
    if prod.warnings:
        common.email_error("\n".join(prod.warnings), buf)
    for msg in j:
        JABBER.send_message(msg[0], msg[1], msg[2])

    prod.sql(txn)
Example #38
0
def test_1():
    """ PIREP.txt, can we parse it! """
    utcnow = utc(2015, 1, 9, 0, 0)
    nwsli_provider = {
        "BIL": {"lat": 44, "lon": 99},
        "LBY": {"lat": 45, "lon": 100},
        "PUB": {"lat": 46, "lon": 101},
        "HPW": {"lat": 47, "lon": 102},
    }
    prod = pirepparser(
        get_test_file("PIREPS/PIREP.txt"),
        utcnow=utcnow,
        nwsli_provider=nwsli_provider,
    )
    assert not prod.warnings

    j = prod.get_jabbers("unused")
    assert j[0][2]["channels"] == "UA.None,UA.PIREP"
Example #39
0
def test_offset():
    """ Test out our displacement logic """
    lat = 42.5
    lon = -92.5
    nwsli_provider = {'BIL': {'lat': lat, 'lon': lon}}
    p = pirepparser("\001\r\r\n000 \r\r\nUBUS01 KMSC 090000\r\r\n",
                    nwsli_provider=nwsli_provider)
    lon2, lat2 = p.compute_loc("BIL", 0, 0)
    assert lon2 == lon
    assert lat2 == lat

    lon2, lat2 = p.compute_loc("BIL", 100, 90)
    assert abs(lon2 - -90.54) < 0.01
    assert lat2 == lat

    lon2, lat2 = p.compute_loc("BIL", 100, 0)
    assert lon2 == lon
    assert abs(lat2 - 43.95) < 0.01
Example #40
0
def real_parser(txn, buf):
    """
    I'm gonna do the heavy lifting here
    """
    prod = pirepparser(buf, nwsli_provider=LOCS)
    prod.assign_cwsu(txn)
    for report in prod.reports:
        if report.text in PIREPS:
            report.is_duplicate = True
        PIREPS[report.text] = datetime.datetime.utcnow()

    j = prod.get_jabbers("unused")
    if prod.warnings:
        common.email_error("\n".join(prod.warnings), buf)
    for msg in j:
        JABBER.send_message(msg[0], msg[1], msg[2])

    prod.sql(txn)
Example #41
0
    def test_offset(self):
        """ Test out our displacement logic """
        lat = 42.5
        lon = -92.5
        nwsli_provider = {'BIL': {'lat': lat, 'lon': lon}}
        p = pirepparser("\001\r\r\n000 \r\r\nUBUS01 KMSC 090000\r\r\n",
                        nwsli_provider=nwsli_provider)
        lon2, lat2 = p.compute_loc("BIL", 0, 0)
        self.assertEquals(lon2, lon)
        self.assertEquals(lat2, lat)

        lon2, lat2 = p.compute_loc("BIL", 100, 90)
        self.assertAlmostEquals(lon2, -90.54, 2)
        self.assertEquals(lat2, lat)

        lon2, lat2 = p.compute_loc("BIL", 100, 0)
        self.assertEquals(lon2, lon)
        self.assertAlmostEquals(lat2, 43.95, 2)
Example #42
0
 def test_150121_fourchar(self):
     """ Another coding edition with four char identifiers """
     nwsli_provider = {
         'FAR': {
             'lat': 44,
             'lon': -99
         },
         'SMF': {
             'lat': 42,
             'lon': -99
         },
         'RDD': {
             'lat': 43,
             'lon': -100
         }
     }
     prod = pirepparser(get_file('PIREPS/fourchar.txt'),
                        nwsli_provider=nwsli_provider)
     self.assertEquals(len(prod.warnings), 0, "\n".join(prod.warnings))
     self.assertAlmostEquals(prod.reports[0].latitude, 44.10, 2)
     self.assertAlmostEquals(prod.reports[1].latitude, 42.50, 2)
Example #43
0
def test_150121_fourchar():
    """ Another coding edition with four char identifiers """
    nwsli_provider = {
        'FAR': {
            'lat': 44,
            'lon': -99
        },
        'SMF': {
            'lat': 42,
            'lon': -99
        },
        'RDD': {
            'lat': 43,
            'lon': -100
        }
    }
    prod = pirepparser(get_test_file('PIREPS/fourchar.txt'),
                       nwsli_provider=nwsli_provider)
    assert not prod.warnings
    assert abs(prod.reports[0].latitude - 44.10) < 0.01
    assert abs(prod.reports[1].latitude - 42.50) < 0.01
Example #44
0
 def test_150121_offset(self):
     """ offset.txt and yet another /OV iteration """
     nwsli_provider = {
         'MRF': {
             'lat': 44.26,
             'lon': -88.52
         },
         'PDT': {
             'lat': 44.26,
             'lon': -88.52
         },
         'HQZ': {
             'lat': 44.26,
             'lon': -88.52
         }
     }
     prod = pirepparser(get_file('PIREPS/offset.txt'),
                        nwsli_provider=nwsli_provider)
     self.assertEquals(len(prod.warnings), 0, "\n".join(prod.warnings))
     self.assertAlmostEquals(prod.reports[0].latitude, 44.48, 2)
     self.assertAlmostEquals(prod.reports[1].latitude, 44.26, 2)
     self.assertAlmostEquals(prod.reports[2].latitude, 44.22, 2)
Example #45
0
def test_150121_offset():
    """ offset.txt and yet another /OV iteration """
    nwsli_provider = {
        'MRF': {
            'lat': 44.26,
            'lon': -88.52
        },
        'PDT': {
            'lat': 44.26,
            'lon': -88.52
        },
        'HQZ': {
            'lat': 44.26,
            'lon': -88.52
        }
    }
    prod = pirepparser(get_test_file('PIREPS/offset.txt'),
                       nwsli_provider=nwsli_provider)
    assert not prod.warnings
    assert abs(prod.reports[0].latitude - 44.48) < 0.01
    assert abs(prod.reports[1].latitude - 44.26) < 0.01
    assert abs(prod.reports[2].latitude - 44.22) < 0.01
Example #46
0
def test_180307_aviation_controlchar():
    """Darn Aviation control character showing up in WMO products"""
    nwsli_provider = {'BWI': {'lat': 44.26, 'lon': -88.52}}
    prod = pirepparser(
        get_test_file("PIREPS/ubmd90.txt"), nwsli_provider=nwsli_provider)
    assert len(prod.reports) == 1
Example #47
0
def test_150202_airmet():
    """airmet.txt has no valid data, so don't error out """
    prod = pirepparser(get_test_file('PIREPS/airmet.txt'))
    assert not prod.reports
Example #48
0
def test_150202_groupdict():
    """groupdict.txt threw an error"""
    nwsli_provider = {'GCC': {'lat': 44.26, 'lon': -88.52}}
    prod = pirepparser(
        get_test_file("PIREPS/groupdict.txt"), nwsli_provider=nwsli_provider)
    assert len(prod.reports) == 1
Example #49
0
def test_151210_badgeom():
    """prevent geom parse error"""
    nwsli_provider = {'GCC': {'lat': 44.26, 'lon': -88.52}}
    prod = pirepparser(
        get_test_file("PIREPS/badgeom.txt"), nwsli_provider=nwsli_provider)
    assert not prod.reports
Example #50
0
 def test_151210_badgeom(self):
     """prevent geom parse error"""
     nwsli_provider = {'GCC': {'lat': 44.26, 'lon': -88.52}}
     prod = pirepparser(get_file("PIREPS/badgeom.txt"),
                        nwsli_provider=nwsli_provider)
     self.assertEquals(len(prod.reports), 0)
Example #51
0
 def test_150202_airmet(self):
     """airmet.txt has no valid data, so don't error out """
     prod = pirepparser(get_file('PIREPS/airmet.txt'))
     self.assertEquals(len(prod.reports), 0)
Example #52
0
def test_150120_OVO():
    """ PIREPS/OVO.txt has a location of OV 0 """
    nwsli_provider = {'AVK': {'lat': 44, 'lon': 99}}
    prod = pirepparser(
        get_test_file('PIREPS/OVO.txt'), nwsli_provider=nwsli_provider)
    assert not prod.warnings
Example #53
0
 def test_150202_airmet(self):
     """airmet.txt has no valid data, so don't error out """
     prod = pirepparser(get_file('PIREPS/airmet.txt'))
     self.assertEquals(len(prod.reports), 0)
Example #54
0
 def test_150202_groupdict(self):
     """groupdict.txt threw an error"""
     nwsli_provider = {'GCC': {'lat': 44.26, 'lon': -88.52}}
     prod = pirepparser(get_file("PIREPS/groupdict.txt"),
                        nwsli_provider=nwsli_provider)
     self.assertEquals(len(prod.reports), 1)
Example #55
0
 def test_150120_OVO(self):
     """ PIREPS/OVO.txt has a location of OV 0 """
     nwsli_provider = {'AVK': {'lat': 44, 'lon': 99}}
     prod = pirepparser(get_file('PIREPS/OVO.txt'),
                        nwsli_provider=nwsli_provider)
     self.assertEquals(len(prod.warnings), 0, "\n".join(prod.warnings))