当前位置: 首页>>代码示例>>Python>>正文


Python Avn.string2time方法代码示例

本文整理汇总了Python中Avn.string2time方法的典型用法代码示例。如果您正苦于以下问题:Python Avn.string2time方法的具体用法?Python Avn.string2time怎么用?Python Avn.string2time使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Avn的用法示例。


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

示例1: getCCFP

# 需要导入模块: import Avn [as 别名]
# 或者: from Avn import string2time [as 别名]
 def getCCFP(self, id_, ftime=0):
     # Retrieves recent CCFP newer than ftime
     path = os.path.join('data', 'ccfp')
     ccfps = []
     try:
         # get up to 3 most recent forecasts
         # if valid times equal, select one with newer issue time
         flist = _getFiles(path, 13, ftime, 3)
         vtimes = [Avn.string2time(x)+3600.0*int(x[-2:]) for x in flist]
         tmp = [(vtimes[0], flist[0])]
         for n, t in enumerate(vtimes[1:]):
             if t not in vtimes[:n+1]:
                 tmp.append((vtimes[n+1], flist[n+1]))
         tmp.sort()
         for t, f in tmp:
             try:
                 data = file(os.path.join(path, f)).read()
                 lines = data.split('\n')
                 for line in lines[1:]:
                     if line.startswith(id_):
                         ccfps.append(Avn.Bunch(file=f, header=lines[0], 
                             text=line))
                         break
                 else:
                     ccfps.append(Avn.Bunch(file=f, header=lines[0], 
                         text=''))
             except OSError:
                 pass
         return ccfps
     except (OSError, IndexError):
         return ccfps
开发者ID:KeithLatteri,项目名称:awips2,代码行数:33,代码来源:DataRequestServ.py

示例2: getXmitTime

# 需要导入模块: import Avn [as 别名]
# 或者: from Avn import string2time [as 别名]
def getXmitTime(kind, headertime):
    t = Avn.string2time('%s%s' % (Avn.time2string()[:6], headertime[2:])) \
        + 3600.0 - _Xmit_Windows[0]
    now = time.time()
    if t < now - 43200.0:
        t += 86400.0
    return max(t, now)
开发者ID:KeithLatteri,项目名称:awips2,代码行数:9,代码来源:AvnLib.py

示例3: getIssueTime

# 需要导入模块: import Avn [as 别名]
# 或者: from Avn import string2time [as 别名]
def getIssueTime(kind, bbb, t=None):
    if t is None:
        t = time.time()
    if not bbb or bbb[0] == ' ':    # regular issue forecast
        itime = Avn.string2time('%s00' % getFmtValidTime(kind, bbb, t)[:8])
        itime -= _Xmit_Windows[0]
        if itime > t:
            return itime
    return t
开发者ID:KeithLatteri,项目名称:awips2,代码行数:11,代码来源:AvnLib.py

示例4: _cleanup

# 需要导入模块: import Avn [as 别名]
# 或者: from Avn import string2time [as 别名]
def _cleanup(direct, nhours):
    # removes files older than "nhours"
    cutoff = time.time() - nhours * 3600.0
    for f in os.listdir(direct):
        try:
            path = os.path.join(direct, f)
            if Avn.string2time(f) < cutoff:
                os.unlink(path)
                _Logger.info('Removed %s', path)
        except (ValueError, OSError):
            _Logger.exception('Cannot remove %s', path)
开发者ID:KeithLatteri,项目名称:awips2,代码行数:13,代码来源:TextThreadP.py

示例5: _getFiles

# 需要导入模块: import Avn [as 别名]
# 或者: from Avn import string2time [as 别名]
def _getFiles(path, length, ftime=0, num=99):
    """Returns sorted list of file names of length "length", newer than
ftime, up to "num" long"""
    cutoff = time.time() + 3600.0
    filelist = [f for f in os.listdir(path) if len(f) == length \
        and cutoff > Avn.string2time(f) > ftime]
    if not filelist:
        raise OSError, 'Empty list'
    filelist.sort()
    filelist.reverse()
    return filelist[:num]
开发者ID:KeithLatteri,项目名称:awips2,代码行数:13,代码来源:DataRequestServ.py

示例6: plot

# 需要导入模块: import Avn [as 别名]
# 或者: from Avn import string2time [as 别名]
 def plot(self, tafid, sites, tref, tticks, vticks, cticks, header):
     itime = Avn.string2time(header)
     for mosid in sites.get(self.model, []):
         data = Globals.DRC.getMosData(mosid, self.model, itime)
         if data:
             break
     else:
         data = None
     if data is None:
         raise Avn.AvnError('Cannot get %s MOS data' % self.model.upper())
     # simulate decoded TAF, without ocnl weather
     groups = [{'prev': g} for g in data.data['group']]
     self.data = AvnLib.TafData(groups)
     return TafPlotP.plot(self.data, tticks, vticks, cticks, self.color)
开发者ID:KeithLatteri,项目名称:awips2,代码行数:16,代码来源:MosPlot.py

示例7: _makeTimeStamp

# 需要导入模块: import Avn [as 别名]
# 或者: from Avn import string2time [as 别名]
def _makeTimeStamp(tstamp):
    # Returns time stamp used in output file name
    now = time.time()
    tmptstamp = '%s%s' % (Avn.time2string(now)[:4], tstamp)
    # possible correction for next month/year
    t = Avn.string2time(tmptstamp)
    if t > now + 86400:
        mm = int(tmptstamp[2:4]) - 1
        yy = int(tmptstamp[:2])
        if mm < 1:
            mm = 12
            yy -= 1
        return '%02d%02d%s' % (yy, mm, tmptstamp[4:])
    else:
        return tmptstamp
开发者ID:KeithLatteri,项目名称:awips2,代码行数:17,代码来源:DataRequestServ.py

示例8: __makeData

# 需要导入模块: import Avn [as 别名]
# 或者: from Avn import string2time [as 别名]
 def __makeData(self, data):
     # 6 hour forecast
     tstart = (time.time()//3600.0 + 1) * 3600.0
     tend = tstart + 7*3600.0 - 10.0
     seq = [{'time': t} for t in Avn.frange(tstart, tend, 3600.0)]
     fcst, text = {}, []
     try:
         for line in [d.text for d in data]:
             tok = line.split()
             if tok:
                 vtime = Avn.string2time(tok[1]) # tok[0] is site id
                 tmp = [(x.lower(), int(y)) for (x, y) in Avn.pairs(tok[2:])]
                 fcst[vtime] = d = dict(tmp)
                 ttok = ['%s: %s' % (x.upper(), _Code[x].get(int(d[x]), ''))\
                         for x in d]
                 text.append('%sZ %s' % (tok[1][4:-2], ' '.join(ttok)))
         if not text:
             text.append('NIL CONVECTION')
         for s in seq:
             s.update(fcst.get(s['time'], {}))
         return {'hourly': seq, 'text': text}
     except Exception:
         _Logger.exception('Failure parsing %s', data)
         return None
开发者ID:KeithLatteri,项目名称:awips2,代码行数:26,代码来源:CCFPMonitor.py

示例9: _filter

# 需要导入模块: import Avn [as 别名]
# 或者: from Avn import string2time [as 别名]
 def _filter(f):
     if not self.regStat.match(f):
         return False
     tok = f.split('-')
     header_time = Avn.string2time(tok[4])
     return header_time > cutoff
开发者ID:KeithLatteri,项目名称:awips2,代码行数:8,代码来源:XmitServ.py

示例10: __get_timestamp

# 需要导入模块: import Avn [as 别名]
# 或者: from Avn import string2time [as 别名]
 def __get_timestamp(self):
     try:
         return Avn.string2time(file(self.TimeStamp).read())
     except:
         _Logger.error('Cannot access %s', self.TimeStamp)
         return 0.0
开发者ID:KeithLatteri,项目名称:awips2,代码行数:8,代码来源:XmitServ.py


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