本文整理汇总了Python中ucar.unidata.data.grid.GridUtil.isTimeSequence方法的典型用法代码示例。如果您正苦于以下问题:Python GridUtil.isTimeSequence方法的具体用法?Python GridUtil.isTimeSequence怎么用?Python GridUtil.isTimeSequence使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ucar.unidata.data.grid.GridUtil
的用法示例。
在下文中一共展示了GridUtil.isTimeSequence方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: wrapper
# 需要导入模块: from ucar.unidata.data.grid import GridUtil [as 别名]
# 或者: from ucar.unidata.data.grid.GridUtil import isTimeSequence [as 别名]
def wrapper(*args, **kwargs):
wrappedArgs = []
returnFlatField = False
for i, arg in enumerate(args):
# print '%s: %s' % (i, arg)
if isinstance(arg, FlatField):
returnFlatField = True
arg = makeFlatFieldSequence([arg])
wrappedArgs.append(arg)
# print [type(a) for a in wrappedArgs]
wrappedKwargs = {}
for keyword in kwargs:
keywordValue = kwargs[keyword]
if isinstance(keywordValue, FlatField):
returnFlatField = True # ??? not sure about kwarg case
keywordValue = makeFlatFieldSequence([keywordValue])
wrappedKwargs[keyword] = keywordValue
# print [type(wrappedKwargs[a]) for a in wrappedKwargs]
result = func(*wrappedArgs, **wrappedKwargs)
# print 'result type=%s' % (type(result))
if GridUtil.isTimeSequence(result) and len(result) == 1 and returnFlatField:
# print 'attempting conversion...'
result = result.getSample(0)
# else:
# print 'not a time sequence! isseq=%s seqtype=%s' % (GridUtil.isSequence(result), GridUtil.getSequenceType(result))
# print 'returning type=%s' % (type(result))
return result
示例2: applyToRange
# 需要导入模块: from ucar.unidata.data.grid import GridUtil [as 别名]
# 或者: from ucar.unidata.data.grid.GridUtil import isTimeSequence [as 别名]
def applyToRange(function,data):
""" Apply the function name to each timestep of the data """
newData = data.clone()
f = function +'(rangeValue)'
if (GridUtil.isTimeSequence(newData)):
for t in range(newData.getDomainSet().getLength()):
rangeValue = newData.getSample(t)
result = eval(f)
newData.setSample(t,result,0)
else:
rangeValue = newData
newData = eval(f)
return newData
示例3: wrapper
# 需要导入模块: from ucar.unidata.data.grid import GridUtil [as 别名]
# 或者: from ucar.unidata.data.grid.GridUtil import isTimeSequence [as 别名]
def wrapper(*args):
wrappedArgs = []
for i, arg in enumerate(args):
# print '%s: %s' % (i, arg)
if isinstance(arg, SingleBandedImage):
arg = ImageSequenceImpl([arg])
wrappedArgs.append(arg)
# print [type(a) for a in wrappedArgs]
result = func(*wrappedArgs)
# print 'result type=%s' % (type(result))
if GridUtil.isTimeSequence(result) and len(result) == 1:
# print 'attempting conversion...'
result = result.getImage(0)
# else:
# print 'not a time sequence! isseq=%s seqtype=%s' % (GridUtil.isSequence(result), GridUtil.getSequenceType(result))
# print 'returning type=%s' % (type(result))
return result
示例4: applyToRangeValues
# 需要导入模块: from ucar.unidata.data.grid import GridUtil [as 别名]
# 或者: from ucar.unidata.data.grid.GridUtil import isTimeSequence [as 别名]
def applyToRangeValues(function,data):
""" Apply the function name to each value in each timestep of the data """
newData = data.clone()
f = function +'(values,step=step,rangeObject=rangeObject,field=field)'
step=0
if (GridUtil.isTimeSequence(newData)):
for t in range(newData.getDomainSet().getLength()):
rangeObject = newData.getSample(t)
values = rangeObject.getFloats(0)
values = eval(f)
rangeObject.setSamples(values,1)
step= step+1
else:
rangeObject = newData
values = rangeObject.getFloats(0)
values = eval(f)
rangeObject.setSamples(values,1)
return newData
示例5: substitute
# 需要导入模块: from ucar.unidata.data.grid import GridUtil [as 别名]
# 或者: from ucar.unidata.data.grid.GridUtil import isTimeSequence [as 别名]
def substitute(data, low, high, newValue):
"""change values in data between low/high to newvalue """
newData = data.clone();
if (GridUtil.isTimeSequence(newData)):
for t in range(newData.getDomainSet().getLength()):
rangeObject = newData.getSample(t)
values = rangeObject.getFloats(0);
for i in range(len(values)):
for j in range(len(values[0])):
if values[i][j]>=low:
if values[i][j]<=high: values[i][j] = newValue;
rangeObject.setSamples(values,1);
else:
rangeObject = newData;
values = rangeObject.getFloats(0);
for i in range(len(values)):
for j in range(len(values[0])):
if values[i][j]>=low:
if values[i][j]<=high: values[0][i] = newValue;
rangeObject.setSamples(values,1);
return newData;
示例6: oldaverageOverTime
# 需要导入模块: from ucar.unidata.data.grid import GridUtil [as 别名]
# 或者: from ucar.unidata.data.grid.GridUtil import isTimeSequence [as 别名]
def oldaverageOverTime(field,makeTimes = 0):
"""@deprecated Average the values in each time step
If makeTimes is true (1) then we return a field mapping all of the times
to the average. Else we just return the average """
if (GridUtil.isTimeSequence(field)==0):
return field;
cnt = 0;
domainSet = field.getDomainSet()
current = None;
for t in range(domainSet.getLength()):
cnt=cnt+1
rangeValue = field.getSample(t)
if(current is None):
current = rangeValue.clone();
else:
current = current+rangeValue;
if(cnt == 0):
return None;
current = current/cnt;
if(makeTimes):
return Util.makeTimeField(current, GridUtil.getDateTimeList(field))
return current