- 积分
- 1626
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2016-1-5
- 最后登录
- 1970-1-1
|
发表于 2018-10-3 20:21:19
|
显示全部楼层
利用此方法,计算某一区域内,最大值,最小值,平均值,脚本仅供参考:
f = addfile('F:/DataSet/ncep/hgt.mon.mean.nc')
var = f['hgt'][0,'500','10:60','60:140']
temp = var
#print var.dimvalue(1)
#x = arange(60, 140, 1.0)
#y = arange(10, 60, 1.0)
x = var.dimvalue(1)
y = var.dimvalue(0)
mx, my = meshgrid(x,y)
#Read shape file
m_china = shaperead('F:/MeteoInfo/MeteoInfo/Map/china.shp')
#inpolygon function
b = inpolygon(mx, my, m_china)
#Convert boolean array to int
b = b.astype('int')
#print b.shape
#Save grid data
#b.savegrid(x, y, 'D:/Temp/test.dat')
#Plot
axesm()
geoshow(m_china)
ss = makesymbolspec('point', {'value':0, 'color':'lightgray', 'size':2, 'edge':False}, {'value':1, 'color':'red', 'size':2, 'edge':False})
#ss = makesymbolspec('point', {'value':(-10000,0), 'color':'b', 'marker':'m', 'size':6}, \
# {'value':(0,10000), 'color':'r', 'marker':'+', 'size':6})
layer = scatterm(mx, my,b,symbolspec=ss)
layer = contourm(var)
#layer = contourfm(x, y, b, 20)
colorbar(layer)
nx = var.dimlen(1)
ny = var.dimlen(0)
for j in arange(ny):
for i in arange(nx):
if(b[j,i]==0):
temp[j,i] = nan
#print temp[16,:]
xid = argmax(temp)%33
yid = argmax(temp)/33
#print xid,yid
print 'maxvalue: ',max(temp),'[x,y]',x[xid],y[yid]
xid = argmin(temp)%33
yid = argmin(temp)/33
print 'minvalue: ',min(temp),'[x,y]',x[xid],y[yid]
print 'meanvalue: ',mean(temp) |
|