本文整理汇总了Python中Avn.flatten方法的典型用法代码示例。如果您正苦于以下问题:Python Avn.flatten方法的具体用法?Python Avn.flatten怎么用?Python Avn.flatten使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Avn
的用法示例。
在下文中一共展示了Avn.flatten方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _avgSky
# 需要导入模块: import Avn [as 别名]
# 或者: from Avn import flatten [as 别名]
def _avgSky(clouds):
"""Returns most frequently occurring layers"""
#
cldlayers=[]
newstring=[]
#
allrpts=Avn.flatten([y.split() for y in [x['str'] for x in clouds]])
toofew = len(allrpts)/4
cldlayers=[rpt for num, rpt in [(len(list(g)),k) for k, g in groupby(sorted(allrpts))] if num > toofew]
if len(cldlayers) == 0:
mostfreqlyrs=_freqList(allrpts)
else:
mostfreqlyrs=_freqList(cldlayers)
if mostfreqlyrs[-1] == 'SKC':
return 'SKC'
#
# Remove all occurrences of SKC
while True:
try:
ignored = mostfreqlyrs.pop(mostfreqlyrs.index('SKC'))
except:
break
#
# Remove layers at the same height
uniqclddict=dict([(_getCldHt(x),x) for x in mostfreqlyrs])
#
# Prepare to order the most frequent layers
lyrs = dict([(x,0) for x in ['OVC','BKN','SCT','FEW','VV']])
sortedlayers=sorted([_getCldHt(x) for x in mostfreqlyrs[-4:]])
lastheight = 0
for height in sortedlayers:
try:
strng = uniqclddict[height]
except KeyError:
continue
if height <= lastheight:
continue
lastheight = height
coverage=strng[:3]
if strng.startswith('V'):
coverage='VV'
#
# Don't allow VV, SCT or FEW if a BKN is present
if lyrs['BKN']:
if coverage in ['FEW','SCT','VV']:
continue
#
# Don't allow FEW or VV above a SCT layer
if lyrs['SCT']:
if coverage in ['FEW','VV']:
continue
try:
lyrs[coverage] += 1
newstring.append(strng)
except KeyError:
continue
#
# First overcast or VV stops the loop.
if lyrs['OVC'] or lyrs['VV']:
break
#
# Or two BKN layers
if lyrs['BKN'] == 2:
break
#
# Three cloud layers results in breakout
if lyrs['FEW'] + lyrs['SCT'] + lyrs['BKN'] > 2:
break
return ' '.join(newstring)