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


Python Avn.flatten方法代码示例

本文整理汇总了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)
开发者ID:KeithLatteri,项目名称:awips2,代码行数:76,代码来源:TAMPGenerator.py


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