本文整理汇总了Python中Avn.frange方法的典型用法代码示例。如果您正苦于以下问题:Python Avn.frange方法的具体用法?Python Avn.frange怎么用?Python Avn.frange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Avn
的用法示例。
在下文中一共展示了Avn.frange方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: draw
# 需要导入模块: import Avn [as 别名]
# 或者: from Avn import frange [as 别名]
def draw(self, arg=None):
self.messagebar().resetmessages('systemerror')
width = self.Width * int(self.counter.get())
graphics = {'cig': [], 'vsby': [], 'wind': []}
for key in graphics:
self.graph[key].clear()
event = Avn.Bunch(width=width, height=self.Height[key])
self.graph[key]._reconfigure(event)
items = self.chkbtns.getvalue()
if not items:
return
ident = self.siteids.get()
if ident != self.ident:
if not self._getSiteConfig(ident):
return
now = time.time()
ftime = now - 3600.0*self.cfg['hours']['back']
ttime = now + (3600.0*max(self.cfg['hours']['forward'],self.tafduration))
tticks = [t for t in Avn.frange((ftime//3600.0)*3600.0, ttime, 3600.0)]
self.xaxis = ((tticks[0]-1800.0, ''),) + \
tuple([(t, time.strftime('%H', time.gmtime(t))) for t in tticks]) +\
((tticks[-1]+1800.0, ''),)
times = self.timeselector.getTimes()
for item in items:
header = times.get(item)
if not header:
continue
try:
g = self._viewer[item].plot(ident, self.sites, now, tticks,
self.vsby, self.cig, header)
for key in graphics:
graphics[key].extend(g[key])
except Avn.AvnError, e:
msg = str(e)
_Logger.error(msg)
self.messagebar().message('usererror', msg)
except Exception:
msg = 'Unexpected error, check log file'
_Logger.exception(msg)
self.messagebar().message('systemerror', msg)
示例2: __makeData
# 需要导入模块: import Avn [as 别名]
# 或者: from Avn import frange [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