本文整理汇总了Python中Avn.category方法的典型用法代码示例。如果您正苦于以下问题:Python Avn.category方法的具体用法?Python Avn.category怎么用?Python Avn.category使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Avn
的用法示例。
在下文中一共展示了Avn.category方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: fixTafTempo
# 需要导入模块: import Avn [as 别名]
# 或者: from Avn import category [as 别名]
def fixTafTempo(p, t):
# eliminates TAF TEMPO elements that match those in FM group
if not ('obv' in t or 'pcp' in t) and 'vsby' in t:
tcat = Avn.category(t['vsby']['val'], _VsbyCat)
pcat = Avn.category(p['vsby']['val'], _VsbyCat)
if tcat == pcat:
del t['vsby']
else:
t['obv'] = {'str': 'NSW'}
if 'wind' in t:
tdd, tff = t['wind']['dd'], t['wind']['ff']
pdd, pff = p['wind']['dd'], p['wind']['ff']
if Avn.VARIABLE in (tdd, pdd):
delta = 0
else:
delta = abs(pdd - tdd)
if delta > 180:
delta = 360 - delta
if abs(tff-pff) < 10 and (max(tff, pff) < 12 or delta < 30):
del t['wind']
if 'sky' in t:
tcat = Avn.category(t['sky']['cig'], _CigCat)
pcat = Avn.category(p['sky']['cig'], _CigCat)
if tcat == pcat:
del t['sky']
示例2: _getOffset
# 需要导入模块: import Avn [as 别名]
# 或者: from Avn import category [as 别名]
def _getOffset(cfg, period):
offObv = 0
if 'obv' in period:
obv = period['obv']['str']
if 'HZ' in obv:
offObv |= 1
if 'BR' in obv or 'FG' in obv:
offObv |= 2
if 'BL' in obv:
offObv |= 4
offInt, offPcp = 0, 0
if 'pcp' in period:
pcp = period['pcp']['str']
if '-' in pcp:
offInt = 1
elif '+' in pcp:
offInt = 3
else:
offInt = 2
if 'SN' in pcp:
offPcp = 1
elif 'DZ' in pcp:
offPcp = 2
else:
offPcp = 3
offDD, offFF = Avn.wind_category(period['wind']['dd'],
period['wind']['ff'], cfg['dd'], cfg['ff'])
offVsby = Avn.category(period['vsby']['value'], cfg['vsby'])
offCig = Avn.category(period['sky']['cig'], cfg['cig'])
return offDD, offFF, offObv, offInt, offPcp, offCig, offVsby
示例3: method
# 需要导入模块: import Avn [as 别名]
# 或者: from Avn import category [as 别名]
def method(self, taf, grids):
self.setmsg('Ceilings categories differs by %d', self.args['ncat'])
try:
thresholds = self.sitedata['thresholds']['cig']
tclo = Avn.category(taf['sky']['lo'], thresholds)
tchi = Avn.category(taf['sky']['hi'], thresholds)
gclo = Avn.category(grids['sky']['lo'], thresholds)
gchi = Avn.category(grids['sky']['hi'], thresholds)
if gchi < tclo:
return tclo-gchi >= self.args['ncat']
elif gclo > tchi:
return gclo-tchi >= self.args['ncat']
else:
return False
except KeyError:
raise Avn.AvnMissing
示例4: _checkVisibility
# 需要导入模块: import Avn [as 别名]
# 或者: from Avn import category [as 别名]
def _checkVisibility(self,taf,deltas,wet=False):
"""Adjust ceilings if necessary"""
#
if wet:
lamp=self.lampdata['cvsby']
lampBestCat=self.lampdata['cvis_bestCat']
probabilities=self.lampdata['cvprob']
thresholds=self.cvisthr
else:
lamp=self.lampdata['vsby']
lampBestCat=self.lampdata['vis_bestCat']
probabilities=self.lampdata['vprob']
thresholds=self.visthr
tcat = Avn.category(taf['vsby']['value'],_LAMPVisibilities)
if tcat == lampBestCat:
try:
if taf['obv']['str'] in ['BR','FG']:
if taf['vsby']['value'] <= 0.5:
taf['obv']['str'] = 'FG'
else:
taf['obv']['str'] = 'BR'
except KeyError:
pass
return
#
# Determine if we can hit taf's category by seeing how much its off
if tcat > lampBestCat and _inCategory(lampBestCat,thresholds,probabilities,deltas['up']):
return
if tcat < lampBestCat and _inCategory(tcat,thresholds,probabilities,deltas['down']):
return
#
# Check precip/obvis in the VFR/VLIFR cases, all other cases, TAF obvis will be accepted.
if lampBestCat < tcat:
taf['vsby'] = AvnLib.fixTafVsby(_LAMPNewVisibilities[lampBestCat][1])
#
# If LAMP forecasting VLIFR and TAF obvis is BR, change that
if lampBestCat == 1:
try:
if taf['obv'] and taf['obv']['str'] == 'BR':
taf['obv']['str'] = 'FG'
except KeyError:
pass
#
# Tedious for precipitation
try:
if lampBestCat == 1:
taf['pcp']['str'] = self._adjustSNDZIntensity(taf['pcp']['str'],'+')
else:
taf['pcp']['str'] = self._adjustSNDZIntensity(taf['pcp']['str'],'-')
except KeyError:
pass
if not taf.has_key('pcp') and not taf.has_key('obv'):
taf['obv'] = copy.copy(self.lampdata['obv'])
if taf['obv']['str'] == 'FG' and lampBestCat > 1:
taf['obv']['str'] = 'BR'
else:
#
# If there's obstruction to vision or precipitation, and LAMP indicates VFR
# better to accept forecaster's value in this case.
#
if lampBestCat > 5 and ('obv' in taf.keys() or self._isGroupWet(taf)):
return
#
# Otherwise, adjust according.
taf['vsby'] = AvnLib.fixTafVsby(_LAMPNewVisibilities[lampBestCat][0])
#
# Change occurrence of FG to BR
try:
if lampBestCat > 2 and taf['obv'] and taf['obv']['str'] == 'FG':
taf['obv']['str'] = 'BR'
except KeyError:
pass
#
# Tedious for precipitation
try:
if lampBestCat == 2:
taf['pcp']['str'] = self._adjustSNDZIntensity(taf['pcp']['str'],'+')
else:
taf['pcp']['str'] = self._adjustSNDZIntensity(taf['pcp']['str'],'-')
except KeyError:
pass
if lampBestCat < 7 and not taf.has_key('pcp') and not taf.has_key('obv'):
taf['obv'] = copy.copy(self.lampdata['obv'])
if taf['obv']['str'] == 'FG' and lampBestCat > 1:
taf['obv']['str'] = 'BR'
示例5: _checkCeiling
# 需要导入模块: import Avn [as 别名]
# 或者: from Avn import category [as 别名]
def _checkCeiling(self,taf,deltas,maxcbhgt,wet=False):
"""Adjust ceilings if necessary"""
#
if wet:
lamp=self.lampdata['csky']
lampBestCat=self.lampdata['ccig_bestCat']
probabilities=self.lampdata['ccprob']
thresholds=self.ccigthr
else:
lamp=self.lampdata['sky']
lampBestCat=self.lampdata['cig_bestCat']
probabilities=self.lampdata['cprob']
thresholds=self.cigthr
tcat = Avn.category(taf['cig'],_LAMPCeilings)
if tcat == lampBestCat:
return
#
# If LAMP and TAF both do not have a ceiling, return early
if lamp['cig'] == taf['cig'] == 99999:
return
#
# Adjust thresholds, determine if we can hit taf's category.
if tcat > lampBestCat and _inCategory(lampBestCat,thresholds,probabilities,deltas['up']):
return
if tcat < lampBestCat and _inCategory(tcat,thresholds,probabilities,deltas['down']):
return
#
# Otherwise, the guidance 'strongly' disagrees with TAF
self.cig_changed = self.changed = True
newsky = []
newceiling = []
#
# Preserve CB in sky condition, cb_skyamt serves as a flag as well
cb_skyamt = None
for lyr in taf['str'].split():
if lyr.endswith('CB'):
cb_skyamt = lyr[:3]
#
# Find layers at or below LAMP ceiling category
if lampBestCat < tcat:
# They have to be FEW or SCT layers
for layer in [x for x in taf['str'].split() if Avn.category(_getCldHt(x),_LAMPCeilings) <= lampBestCat]:
# SCT layers that match LAMP category, change to BKN
if layer[:3] == 'SCT' and Avn.category(_getCldHt(layer),_LAMPCeilings) == lampBestCat:
newceiling.append('BKN%03d' % int(_getCldHt(layer)*0.01))
else:
newsky.append(layer)
#
# If no ceiling found in LAMP category add one
if not newceiling:
maxCeiling = _LAMPNewCeilings[lampBestCat][1]
if lamp['str'] != 'SKC':
newceiling.append(lamp['str'][:3]+'%03d'%maxCeiling)
else:
newceiling.append(lamp['str'])
cb_skyamt = None
newsky = []
#
newsky.extend(newceiling)
else:
# Remove ceilings below lamp category, leave FEW and SCT alone
newsky = [x for x in taf['str'].split()
if x[:3] in ['FEW','SCT'] and \
Avn.category(_getCldHt(x),_LAMPCeilings) < lampBestCat]
newceiling = [x for x in taf['str'].split()
if Avn.category(_getCldHt(x),_LAMPCeilings) == lampBestCat]
#
if not newceiling:
if lamp['str']=='SKC':
newsky=['SKC']
else:
newsky.extend([lamp['str'][:3]+'%03d'%(_LAMPNewCeilings[lampBestCat][0])])
else:
newsky.extend(newceiling)
if cb_skyamt:
#
# If there's already a CB present, break
for i, lyr in enumerate(newsky):
if lyr.endswith('CB'):
break
else:
#
# If there's a cloud amount that matches the original TAF CB amount and its
# below a configurable max CB height
#
for i, lyr in enumerate(newsky):
try:
if cb_skyamt == lyr[:3] and int(lyr[3:6]) <= maxcbhgt:
newsky[i]+='CB'
break
except (ValueError,IndexError):
pass
else:
#
# Otherwise, use the first acceptable layer found below a configurable
# max CB height
#
for i, lyr in enumerate(newsky):
#.........这里部分代码省略.........