• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python util.utc函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pyiem.util.utc函数的典型用法代码示例。如果您正苦于以下问题:Python utc函数的具体用法?Python utc怎么用?Python utc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了utc函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_valid_nomnd

def test_valid_nomnd():
    """ check valid (no Mass News) Parsing """
    utcnow = utc(2012, 11, 27)
    tp = product.TextProduct(
        get_test_file('AFD_noMND.txt'), utcnow=utcnow)
    ts = utc(2012, 11, 27, 0, 1)
    assert tp.valid == ts
开发者ID:akrherz,项目名称:pyIEM,代码行数:7,代码来源:test_product.py


示例2: test_mcdparser

def test_mcdparser(dbcursor):
    ''' Test Parsing of MCD Product '''
    prod = parser(get_test_file('MCD_MPD/SWOMCD.txt'))
    assert abs(prod.geometry.area - 4.302) < 0.001
    assert prod.discussion_num == 1525
    assert prod.attn_wfo[2] == 'DLH'
    ans = "PORTIONS OF NRN WI AND THE UPPER PENINSULA OF MI"
    assert prod.areas_affected == ans

    # With probability this time
    prod = parser(get_test_file('MCD_MPD/SWOMCDprob.txt'))
    assert abs(prod.geometry.area - 2.444) < 0.001
    assert prod.watch_prob == 20

    jmsg = prod.get_jabbers('http://localhost')
    ans = (
        '<p>Storm Prediction Center issues '
        '<a href="http://www.spc.noaa.gov/'
        'products/md/2013/md1678.html">Mesoscale Discussion #1678</a> '
        '[watch probability: 20%] (<a href="http://localhost'
        '?pid=201308091725-KWNS-ACUS11-SWOMCD">View text</a>)</p>')
    assert jmsg[0][1] == ans
    ans = (
        'Storm Prediction Center issues Mesoscale Discussion #1678 '
        '[watch probability: 20%] '
        'http://www.spc.noaa.gov/products/md/2013/md1678.html')
    assert jmsg[0][0] == ans
    ans = utc(2013, 8, 9, 17, 25)
    assert prod.sts == ans
    ans = utc(2013, 8, 9, 19, 30)
    assert prod.ets == ans

    prod.database_save(dbcursor)
开发者ID:akrherz,项目名称:pyIEM,代码行数:33,代码来源:test_mcd.py


示例3: test_utc

def test_utc():
    """Does the utc() function work as expected."""
    answer = datetime.datetime(2017, 2, 1, 2, 20).replace(tzinfo=pytz.UTC)
    res = util.utc(2017, 2, 1, 2, 20)
    assert answer == res
    answer = datetime.datetime.utcnow().replace(tzinfo=pytz.UTC)
    assert answer.year == util.utc().year
开发者ID:akrherz,项目名称:pyIEM,代码行数:7,代码来源:test_util.py


示例4: test_01

def test_01():
    """LSR.txt process a valid LSR without blemish """
    utcnow = utc(2013, 7, 23, 23, 54)
    prod = parser(get_test_file("LSR.txt"), utcnow=utcnow)
    assert len(prod.lsrs) == 58

    assert abs(prod.lsrs[57].magnitude_f - 73) < 0.01
    assert prod.lsrs[57].county == "MARION"
    assert prod.lsrs[57].state == "IA"
    assert abs(prod.lsrs[57].get_lon() - -93.11) < 0.01
    assert abs(prod.lsrs[57].get_lat() - 41.3) < 0.01

    assert prod.is_summary()
    assert prod.lsrs[57].wfo == 'DMX'

    answer = utc(2013, 7, 23, 3, 55)
    assert prod.lsrs[57].valid == answer
    j = prod.get_jabbers('http://iem.local/')
    assert j[57][0], (
        "Knoxville Airport [Marion Co, IA] AWOS reports NON-TSTM WND "
        "GST of M73 MPH at 22 Jul, 10:55 PM CDT -- HEAT BURST. "
        "TEMPERATURE ROSE FROM 70 TO 84 IN 15 MINUTES AND DEW POINT "
        "DROPPED FROM 63 TO 48 IN 10 MINUTES. "
        "http://iem.local/#DMX/201307230355/201307230355")

    ans = (
        "At 4:45 PM CDT, Dows [Wright Co, IA] LAW ENFORCEMENT "
        "reports TSTM WND DMG. DELAYED REPORT. LARGE TREE "
        "BRANCH DOWN IN TOWN THAT TOOK OUT A POWER LINE "
        "AND BLOCKING PART OF A ROAD."
    )
    assert prod.lsrs[5].tweet() == ans
开发者ID:akrherz,项目名称:pyIEM,代码行数:32,代码来源:test_products.py


示例5: find_time

    def find_time(self):
        """Find the start and end valid time of this watch

        Returns:
          (datetime, datetime): representing the time of this watch
        """
        if self.action == self.CANCELS:
            return (None, None)
        sts = self.utcnow
        ets = self.utcnow
        tokens = re.findall(("([0-3][0-9])([0-2][0-9])([0-6][0-9])Z - "
                             "([0-3][0-9])([0-2][0-9])([0-6][0-9])Z"),
                            self.unixtext)

        day1 = int(tokens[0][0])
        hour1 = int(tokens[0][1])
        minute1 = int(tokens[0][2])
        day2 = int(tokens[0][3])
        hour2 = int(tokens[0][4])
        minute2 = int(tokens[0][5])

        sts = utc(self.utcnow.year, self.utcnow.month, day1, hour1, minute1)
        ets = utc(self.utcnow.year, self.utcnow.month, day2, hour2, minute2)

        # If we are near the end of the month and the day1 is 1, add 1 month
        if self.utcnow.day > 27 and day1 == 1:
            sts += datetime.timedelta(days=+35)
            sts = sts.replace(day=1)
        if self.utcnow.day > 27 and day2 == 1:
            ets += datetime.timedelta(days=+35)
            ets = ets.replace(day=1)
        return (sts, ets)
开发者ID:akrherz,项目名称:pyIEM,代码行数:32,代码来源:saw.py


示例6: test_sigpat

def test_sigpat():
    """ Make sure we don't have another failure with geom parsing """
    utcnow = utc(2014, 8, 11, 12, 34)
    tp = parser(get_test_file('SIGMETS/SIGPAT.txt'), utcnow)
    j = tp.get_jabbers('http://localhost', 'http://localhost')
    assert abs(tp.sigmets[0].geom.area - 33.71) < 0.01
    assert tp.sigmets[0].sts == utc(2014, 8, 11, 12, 35)
    assert tp.sigmets[0].ets == utc(2014, 8, 11, 16, 35)
    assert j[0][0] == 'PHFO issues SIGMET TANGO 1 till 1635 UTC'
开发者ID:akrherz,项目名称:pyIEM,代码行数:9,代码来源:test_sigmet.py


示例7: test_171121_issue45

def test_171121_issue45(dbcursor):
    """Do we alert on duplicated ETNs?"""
    utcnow = utc(2017, 4, 20, 21, 33)
    prod = vtecparser(get_test_file('vtec/NPWDMX_0.txt'), utcnow=utcnow)
    prod.sql(dbcursor)
    utcnow = utc(2017, 11, 20, 21, 33)
    prod = vtecparser(get_test_file('vtec/NPWDMX_1.txt'), utcnow=utcnow)
    prod.sql(dbcursor)
    warnings = filter_warnings(prod.warnings)
    assert len(warnings) == 1
开发者ID:akrherz,项目名称:pyIEM,代码行数:10,代码来源:test_products_vtec.py


示例8: test_170406_day48

def test_170406_day48(dbcursor):
    """Can we parse a present day days 4-8"""
    spc = parser(get_test_file('SPCPTS/PTSD48.txt'))
    # spc.draw_outlooks()
    outlook = spc.get_outlook('ANY SEVERE', '0.15', 4)
    assert abs(outlook.geometry.area - 40.05) < 0.01
    spc.sql(dbcursor)
    collect = spc.get_outlookcollection(4)
    assert collect.issue == utc(2017, 4, 9, 12)
    assert collect.expire == utc(2017, 4, 10, 12)
开发者ID:akrherz,项目名称:pyIEM,代码行数:10,代码来源:test_spcpts.py


示例9: test_daily_offset

def test_daily_offset():
    """ Compute the offsets """
    ts = utc(2013, 1, 1, 0, 0)
    offset = iemre.daily_offset(ts)
    assert offset == 0

    ts = datetime.date(2013, 2, 1)
    offset = iemre.daily_offset(ts)
    assert offset == 31

    ts = utc(2013, 1, 5, 12, 0)
    offset = iemre.daily_offset(ts)
    assert offset == 4
开发者ID:akrherz,项目名称:pyIEM,代码行数:13,代码来源:test_iemre.py


示例10: test_vtec_series

def test_vtec_series(dbcursor):
    """Test a lifecycle of WSW products """
    prod = vtecparser(get_test_file('WSWDMX/WSW_00.txt'))
    assert prod.afos == 'WSWDMX'
    prod.sql(dbcursor)

    # Did Marshall County IAZ049 get a ZR.Y
    dbcursor.execute("""
        SELECT issue from warnings_2013 WHERE
        wfo = 'DMX' and eventid = 1 and phenomena = 'ZR' and
        significance = 'Y' and status = 'EXB'
        and ugc = 'IAZ049'
    """)
    assert dbcursor.rowcount == 1

    prod = vtecparser(get_test_file('WSWDMX/WSW_01.txt'))
    assert prod.afos == 'WSWDMX'
    prod.sql(dbcursor)

    # Is IAZ006 in CON status with proper end time
    answer = utc(2013, 1, 28, 6)
    dbcursor.execute("""SELECT expire from warnings_2013 WHERE
    wfo = 'DMX' and eventid = 1 and phenomena = 'WS' and
    significance = 'W' and status = 'CON'
    and ugc = 'IAZ006' """)

    assert dbcursor.rowcount == 1
    row = dbcursor.fetchone()
    assert row[0] == answer

    # No change
    for i in range(2, 9):
        prod = vtecparser(get_test_file('WSWDMX/WSW_%02i.txt' % (i,)))
        assert prod.afos == 'WSWDMX'
        prod.sql(dbcursor)

    prod = vtecparser(get_test_file('WSWDMX/WSW_09.txt'))
    assert prod.afos == 'WSWDMX'
    prod.sql(dbcursor)

    # IAZ006 should be cancelled
    answer = utc(2013, 1, 28, 5, 38)
    dbcursor.execute("""SELECT expire from warnings_2013 WHERE
    wfo = 'DMX' and eventid = 1 and phenomena = 'WS' and
    significance = 'W' and status = 'CAN'
    and ugc = 'IAZ006' """)

    assert dbcursor.rowcount == 1
    row = dbcursor.fetchone()
    assert row[0] == answer
开发者ID:akrherz,项目名称:pyIEM,代码行数:50,代码来源:test_products_vtec.py


示例11: test_str1

def test_str1(dbcursor):
    """ check spcpts parsing """
    spc = parser(get_test_file('SPCPTS/SPCPTS.txt'))
    # spc.draw_outlooks()
    assert spc.valid == utc(2013, 7, 19, 19, 52)
    assert spc.issue == utc(2013, 7, 19, 20, 0)
    assert spc.expire == utc(2013, 7, 20, 12, 0)

    spc.sql(dbcursor)
    spc.compute_wfos(dbcursor)
    # It is difficult to get a deterministic result here as in Travis, we
    # don't have UGCS, so the WFO lookup yields no results
    j = spc.get_jabbers("")
    assert len(j) >= 1
开发者ID:akrherz,项目名称:pyIEM,代码行数:14,代码来源:test_spcpts.py


示例12: test_hourly_offset

def test_hourly_offset():
    """ Compute the offsets """
    ts = utc(2013, 1, 1, 0, 0)
    offset = iemre.hourly_offset(ts)
    assert offset == 0

    ts = utc(2013, 1, 1, 6, 0)
    ts = ts.astimezone(pytz.timezone("America/Chicago"))
    offset = iemre.hourly_offset(ts)
    assert offset == 6

    ts = utc(2013, 1, 5, 12, 0)
    offset = iemre.hourly_offset(ts)
    assert offset == 4*24 + 12
开发者ID:akrherz,项目名称:pyIEM,代码行数:14,代码来源:test_iemre.py


示例13: test_simple

def test_simple(month):
    """Can we walk before we run."""
    text = (
        "KCVG DS 24/%02i 590353/ 312359// 53/ 48/"
        "/9470621/T/T/00/00/00/00/00/00/"
        "00/00/00/00/00/00/00/00/00/00/00/00/00/00/00/00/00/225/26381759/"
        "26500949="
    ) % (month, )
    tzprovider = {'KCVG': pytz.timezone("America/New_York")}
    dsm = process(text)
    dsm.compute_times(utc(2019, month, 25))
    dsm.tzlocalize(tzprovider['KCVG'])
    assert dsm.date == datetime.date(2019, month, 24)
    assert dsm.station == 'KCVG'
    assert dsm.time_sped_max == utc(2019, month, 24, 22, 59)
开发者ID:akrherz,项目名称:pyIEM,代码行数:15,代码来源:test_dsm.py


示例14: test_140610_no_vtec_time

def test_140610_no_vtec_time(dbcursor):
    """ A VTEC Product with both 0000 for start and end time, sigh """
    utcnow = utc(2014, 6, 10, 0, 56)
    prod = vtecparser(get_test_file('FLSLZK_notime.txt'), utcnow=utcnow)
    prod.sql(dbcursor)
    assert prod.segments[0].vtec[0].begints is None
    assert prod.segments[0].vtec[0].endts is None
开发者ID:akrherz,项目名称:pyIEM,代码行数:7,代码来源:test_products_vtec.py


示例15: test_150102_multiyear

def test_150102_multiyear(dbcursor):
    """ WSWOUN See how well we span multiple years """
    for i in range(13):
        print(datetime.datetime.utcnow())
        print('Parsing Product: %s.txt' % (i,))
        prod = vtecparser(get_test_file('WSWOUN/%i.txt' % (i,)))
        prod.sql(dbcursor)
        # Make sure there are no null issue times
        dbcursor.execute("""
            SELECT count(*) from warnings_2014
            where wfo = 'OUN' and eventid = 16
            and phenomena = 'WW' and significance = 'Y'
            and issue is null
        """)
        assert dbcursor.fetchone()[0] == 0
        if i == 5:
            dbcursor.execute("""
                SELECT issue from warnings_2014
                WHERE ugc = 'OKZ036' and wfo = 'OUN' and eventid = 16
                and phenomena = 'WW' and significance = 'Y'
            """)
            row = dbcursor.fetchone()
            assert row[0] == utc(2015, 1, 1, 6, 0)
        warnings = filter_warnings(prod.warnings)
        warnings = filter_warnings(warnings, "Segment has duplicated")
        warnings = filter_warnings(warnings, "VTEC Product appears to c")
        assert not warnings
开发者ID:akrherz,项目名称:pyIEM,代码行数:27,代码来源:test_products_vtec.py


示例16: test_wcn_updates

def test_wcn_updates():
    """ Make sure our Tags and svs_special works for combined message """
    utcnow = utc(2014, 6, 6, 20, 37)
    ugc_provider = {}
    for u in range(1, 201, 2):
        n = 'a' * int(min((u+1/2), 40))
        for st in ['AR', 'MS', 'TN', 'MO']:
            ugc_provider["%sC%03i" % (st, u)] = UGC(st, 'C', "%03i" % (u,),
                                                    name=n, wfos=['DMX'])
    prod = vtecparser(get_test_file('WCNMEG.txt'), utcnow=utcnow,
                      ugc_provider=ugc_provider)
    j = prod.get_jabbers('http://localhost', 'http://localhost')
    ans = (
        'MEG updates Severe Thunderstorm Watch (expands area to include '
        'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa [MO] and 11 counties in '
        '[TN], continues 12 counties in [AR] and '
        'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa [MO] and 22 counties in '
        '[MS] and aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, '
        'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, '
        'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, '
        'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, '
        'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, '
        'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa [TN]) till Jun 6, 7:00 PM '
        'CDT. http://localhost2014-O-EXA-KMEG-SV-A-0240'
    )
    assert j[0][0] == ans
开发者ID:akrherz,项目名称:pyIEM,代码行数:26,代码来源:test_products_vtec.py


示例17: test_170815_pywwa_issue3

def test_170815_pywwa_issue3():
    """This example was in pyWWA issues list, so lets test here"""
    utcnow = utc(2015, 9, 30, 16, 56)

    tp = parser(get_test_file('SIGMETS/SIGE.txt'), utcnow,
                nwsli_provider=NWSLI_PROVIDER)
    assert len(tp.sigmets) == 4
开发者ID:akrherz,项目名称:pyIEM,代码行数:7,代码来源:test_sigmet.py


示例18: test_nbm

def test_nbm(cursor):
    """Can we parse the NBM data."""
    utcnow = utc(2018, 11, 7, 15)
    prod = mosparser(get_test_file("MOS/NBSUSA.txt"), utcnow=utcnow)
    assert len(prod.data) == 2

    inserts = prod.sql(cursor)
    assert inserts == (2 * 21)

    cursor.execute("""
        SELECT count(*), max(ftime) from t2018
        where model = 'NBS' and station = 'KALM' and runtime = %s
    """, (utcnow, ))
    row = cursor.fetchone()
    assert row[0] == 21
    assert row[1] == utc(2018, 11, 10, 9)
开发者ID:akrherz,项目名称:pyIEM,代码行数:16,代码来源:test_mos.py


示例19: iemob

def iemob():
    """Database."""
    res = blah()
    ts = utc(2015, 9, 1, 1, 0)
    sid = ''.join(random.choice(
                string.ascii_uppercase + string.digits) for _ in range(7))
    res.iemid = 0 - random.randint(0, 1000)
    res.ob = observation.Observation(sid, 'FAKE', ts)
    res.conn = get_dbconn('iem')
    res.cursor = res.conn.cursor(
        cursor_factory=psycopg2.extras.DictCursor)
    # Create fake station, so we can create fake entry in summary
    # and current tables
    res.cursor.execute("""
        INSERT into stations(id, network, iemid, tzname)
        VALUES (%s, 'FAKE', %s, 'UTC')
    """, (sid, res.iemid))
    res.cursor.execute("""
        INSERT into current(iemid, valid) VALUES
        (%s, '2015-09-01 00:00+00')
    """, (res.iemid, ))
    res.cursor.execute("""
        INSERT into summary_2015(iemid, day) VALUES
        (%s, '2015-09-01')
    """, (res.iemid, ))
    return res
开发者ID:akrherz,项目名称:pyIEM,代码行数:26,代码来源:test_observation.py


示例20: test_140604_sbwupdate

def test_140604_sbwupdate(dbcursor):
    """Make sure we are updating the right info in the sbw table """
    utcnow = utc(2014, 6, 4)

    dbcursor.execute("""DELETE from sbw_2014 where
    wfo = 'LMK' and eventid = 95 and phenomena = 'SV' and
    significance = 'W' """)
    dbcursor.execute("""DELETE from warnings_2014 where
    wfo = 'LMK' and eventid = 95 and phenomena = 'SV' and
    significance = 'W' """)

    prod = vtecparser(get_test_file('SVRLMK_1.txt'), utcnow=utcnow)
    prod.sql(dbcursor)

    dbcursor.execute("""SELECT expire from sbw_2014 WHERE
    wfo = 'LMK' and eventid = 95 and phenomena = 'SV' and
    significance = 'W' """)
    assert dbcursor.rowcount == 1

    prod = vtecparser(get_test_file('SVRLMK_2.txt'), utcnow=utcnow)
    prod.sql(dbcursor)

    dbcursor.execute("""SELECT expire from sbw_2014 WHERE
    wfo = 'LMK' and eventid = 95 and phenomena = 'SV' and
    significance = 'W' """)
    assert dbcursor.rowcount == 3
    warnings = filter_warnings(prod.warnings)
    assert not warnings
开发者ID:akrherz,项目名称:pyIEM,代码行数:28,代码来源:test_products_vtec.py



注:本文中的pyiem.util.utc函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python pyigl.readOFF函数代码示例发布时间:2022-05-25
下一篇:
Python util.get_test_file函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap