本文整理汇总了Python中Avn.pairs方法的典型用法代码示例。如果您正苦于以下问题:Python Avn.pairs方法的具体用法?Python Avn.pairs怎么用?Python Avn.pairs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Avn
的用法示例。
在下文中一共展示了Avn.pairs方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _decodeCCFP
# 需要导入模块: import Avn [as 别名]
# 或者: from Avn import pairs [as 别名]
def _decodeCCFP(data):
def _gettime(s):
y, m, d, h = int(s[:4]), int(s[4:6]), int(s[6:8]), int(s[9:11])
return time.mktime((y, m, d, h, 0, 0, 0, 0, 0))
dcd = {}
for line in data:
if line.startswith('CCFP'):
tok = line.split()
dcd['itime'] = _gettime(tok[1])
dcd['vtime'] = _gettime(tok[2])
elif line.startswith('AREA'):
tok = [int(x) for x in line.split()[1:]]
d = {'coverage': tok[0], 'conf': tok[1], 'growth': tok[2], \
'tops': tok[3], 'speed': tok[4], 'direction': tok[5]}
d['latlon'] = Avn.pairs(tok[7:-2])
dcd.setdefault('area', []).append(d)
tmp = [(d['coverage'], d) for d in dcd.get('area', [])]
tmp.sort()
tmp.reverse()
dcd['area'] = [x[1] for x in tmp] # sorted w.r. coverage, highest first
return dcd
示例2: __makeData
# 需要导入模块: import Avn [as 别名]
# 或者: from Avn import pairs [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