本文整理匯總了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