本文整理汇总了Python中MA.masked_less方法的典型用法代码示例。如果您正苦于以下问题:Python MA.masked_less方法的具体用法?Python MA.masked_less怎么用?Python MA.masked_less使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MA
的用法示例。
在下文中一共展示了MA.masked_less方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: processRainfall
# 需要导入模块: import MA [as 别名]
# 或者: from MA import masked_less [as 别名]
def processRainfall(file, outdir, var, north, west, south, east):
"Subsets, averages, writes to binary files."
f=cdms.open(file)
v=f(var, lat=(south, north), lon=(west, east))
timevalues=v.getTime()[:]
t0=timevalues[0]
# I need to test if step 0 always has only missing values
# remove -50 values???
v=MA.masked_less(v,0)
# create average of all ensemble members
av=MA.average(v, axis=1)
# get stuff for name
datetime=os.path.split(file)[-1].split(".")[1]
outpaths=[]
# now step through time dimension (0)
count=0
for dslice in av:
ts=timevalues[count]-t0
outfile="rainfall.%s.%dh.dat" % (datetime, ts)
outpath=os.path.join(outdir, outfile)
count=count+1
numarray=Numeric.array(dslice._data)
sh=numarray.shape
length=sh[0]*sh[1]
flatarray=Numeric.resize(numarray, [length])
output=open(outpath, "wb")
arr=array.array('f', flatarray)
arr.tofile(output)
output.close()
print "Written:", outpath
outpaths.append(outpath)
return outpaths