コード例 #1
0
ファイル: hvtec.py プロジェクト: yyqyu/pyIEM
 def __init__(self, tokens, nwsli_provider=None):
     ''' Constructor '''
     if nwsli_provider is None:
         nwsli_provider = dict()
     self.line = tokens[0]
     self.nwsli = nwsli_provider.get(tokens[1], NWSLI(tokens[1]))
     self.severity = tokens[2]
     self.cause = tokens[3]
     self.beginTS = contime(tokens[4])
     self.crestTS = contime(tokens[5])
     self.endTS = contime(tokens[6])
     self.record = tokens[7]
コード例 #2
0
def test_vtec(dbcursor):
    """Simple test of VTEC parser"""
    # Remove cruft first
    dbcursor.execute("""
        DELETE from warnings_2005 WHERE
        wfo = 'JAN' and eventid = 130 and phenomena = 'TO' and
        significance = 'W'
    """)
    dbcursor.execute("""
        DELETE from sbw_2005 WHERE
        wfo = 'JAN' and eventid = 130 and phenomena = 'TO' and
        significance = 'W' and status = 'NEW'
    """)

    ugc_provider = {"MSC091": UGC("MS", "C", "091", "DARYL", ["XXX"])}
    nwsli_provider = {"AMWI4": NWSLI("AMWI4", "Ames", ["XXX"], -99, 44)}
    prod = vtecparser(
        get_test_file("TOR.txt"),
        ugc_provider=ugc_provider,
        nwsli_provider=nwsli_provider,
    )
    assert not prod.skip_con
    assert abs(prod.segments[0].sbw.area - 0.3053) < 0.0001

    prod.sql(dbcursor)

    # See if we got it in the database!
    dbcursor.execute("""
        SELECT issue from warnings_2005 WHERE
        wfo = 'JAN' and eventid = 130 and phenomena = 'TO' and
        significance = 'W' and status = 'NEW'
    """)
    assert dbcursor.rowcount == 3

    dbcursor.execute("""
        SELECT issue from sbw_2005 WHERE
        wfo = 'JAN' and eventid = 130 and phenomena = 'TO' and
        significance = 'W' and status = 'NEW'
    """)
    assert dbcursor.rowcount == 1

    msgs = prod.get_jabbers("http://localhost", "http://localhost/")
    ans = ("JAN issues Tornado Warning for "
           "((MSC035)), ((MSC073)), DARYL [MS] till Aug 29, 1:15 PM CDT * AT "
           "1150 AM CDT...THE NATIONAL WEATHER SERVICE HAS ISSUED A "
           "TORNADO WARNING FOR DESTRUCTIVE WINDS OVER 110 MPH IN THE EYE "
           "WALL AND INNER RAIN BANDS OF HURRICANE KATRINA. THESE WINDS "
           "WILL OVERSPREAD MARION...FORREST AND LAMAR COUNTIES DURING "
           "THE WARNING PERIOD. "
           "http://localhost2005-O-NEW-KJAN-TO-W-0130_2005-08-29T16:51Z")
    assert msgs[0][0] == ans
コード例 #3
0
ファイル: test_products_vtec.py プロジェクト: Freeze/pyIEM
def test_vtec(dbcursor):
    """Simple test of VTEC parser"""
    # Remove cruft first
    dbcursor.execute("""
        DELETE from warnings_2005 WHERE
        wfo = 'JAN' and eventid = 130 and phenomena = 'TO' and
        significance = 'W'
    """)
    dbcursor.execute("""
        DELETE from sbw_2005 WHERE
        wfo = 'JAN' and eventid = 130 and phenomena = 'TO' and
        significance = 'W' and status = 'NEW'
    """)

    ugc_provider = {'MSC091': UGC('MS', 'C', '091', 'DARYL', ['XXX'])}
    nwsli_provider = {'AMWI4': NWSLI('AMWI4', 'Ames', ['XXX'], -99, 44)}
    prod = vtecparser(get_test_file('TOR.txt'),
                      ugc_provider=ugc_provider,
                      nwsli_provider=nwsli_provider)
    assert not prod.skip_con
    assert abs(prod.segments[0].sbw.area - 0.3053) < 0.0001

    prod.sql(dbcursor)

    # See if we got it in the database!
    dbcursor.execute("""
        SELECT issue from warnings_2005 WHERE
        wfo = 'JAN' and eventid = 130 and phenomena = 'TO' and
        significance = 'W' and status = 'NEW'
    """)
    assert dbcursor.rowcount == 3

    dbcursor.execute("""
        SELECT issue from sbw_2005 WHERE
        wfo = 'JAN' and eventid = 130 and phenomena = 'TO' and
        significance = 'W' and status = 'NEW'
    """)
    assert dbcursor.rowcount == 1

    msgs = prod.get_jabbers('http://localhost', 'http://localhost/')
    ans = ('JAN issues Tornado Warning for '
           '((MSC035)), ((MSC073)), DARYL [MS] till Aug 29, 1:15 PM CDT * AT '
           '1150 AM CDT...THE NATIONAL WEATHER SERVICE HAS ISSUED A '
           'TORNADO WARNING FOR DESTRUCTIVE WINDS OVER 110 MPH IN THE EYE '
           'WALL AND INNER RAIN BANDS OF HURRICANE KATRINA. THESE WINDS '
           'WILL OVERSPREAD MARION...FORREST AND LAMAR COUNTIES DURING '
           'THE WARNING PERIOD. http://localhost2005-O-NEW-KJAN-TO-W-0130')
    assert msgs[0][0] == ans
コード例 #4
0
ファイル: gen_channels_html_table.py プロジェクト: xlia/pyWWA
def load_dicts():
    """Load up the directionaries"""
    pgconn = get_dbconn("postgis")
    cursor = pgconn.cursor(cursor_factory=psycopg2.extras.DictCursor)
    sql = """
        SELECT name, ugc, wfo from ugcs WHERE
        name IS NOT Null and end_ts is null
    """
    cursor.execute(sql)
    for row in cursor:
        nm = (row["name"]).replace("\x92", " ").replace("\xc2", " ")
        wfos = re.findall(r"([A-Z][A-Z][A-Z])", row["wfo"])
        ugc_dict[row["ugc"]] = UGC(
            row["ugc"][:2], row["ugc"][2], row["ugc"][3:], name=nm, wfos=wfos
        )

    sql = """SELECT nwsli,
     river_name || ' ' || proximity || ' ' || name || ' ['||state||']' as rname
     from hvtec_nwsli"""
    cursor.execute(sql)
    for row in cursor:
        nm = row["rname"].replace("&", " and ")
        nwsli_dict[row["nwsli"]] = NWSLI(row["nwsli"], name=nm)
コード例 #5
0
ファイル: test_nwsli.py プロジェクト: xoxo143/pyIEM
def test_simple():
    """ See if we can generate a proper string from a UGCS """
    nwsli = NWSLI("AMWI4", "Iowa All", ["DMX"], -99, 44)
    assert nwsli.id == "AMWI4"

    assert nwsli.get_name() == "Iowa All"
コード例 #6
0
ファイル: test_nwsli.py プロジェクト: akrherz/pyIEM
def test_simple():
    """ See if we can generate a proper string from a UGCS """
    nwsli = NWSLI('AMWI4', 'Iowa All', ['DMX'], -99, 44)
    assert nwsli.id == "AMWI4"

    assert nwsli.get_name() == "Iowa All"
コード例 #7
0
    def test_simple(self):
        """ See if we can generate a proper string from a UGCS """
        nwsli = NWSLI('AMWI4', 'Iowa All', ['DMX'], -99, 44)
        self.assertEqual(nwsli.id, "AMWI4")

        self.assertEqual(nwsli.get_name(), "Iowa All")
コード例 #8
0
ファイル: test_nwsli.py プロジェクト: sportsbitenews/pyIEM
    def test_simple(self):
        """ See if we can generate a proper string from a UGCS """
        nwsli = NWSLI('AMWI4', 'Iowa All', ['DMX'], -99, 44)
        self.assertEqual(nwsli.id, "AMWI4")

        self.assertEqual(nwsli.get_name(), "Iowa All")