- 积分
- 76
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2019-4-29
- 最后登录
- 1970-1-1
|
发表于 2020-6-5 09:43:18
|
显示全部楼层
求助:按照老师的脚本,只改了数据,但是出现错误,请帮忙看看是怎么回事,谢谢
>>> run script...
Open data files...
Read data array...
Calculate...
Traceback (most recent call last):
File "<iostream>", line 17, in <module>
File "D:\MeteoInfo\pylib\mipylib\numeric\core\numeric.py", line 2184, in cdiff
r = ArrayMath.cdiff(a.asarray(), dimidx)
TypeError: cdiff(): 2nd arg can't be coerced to int
脚本如下:
print 'Open data files...'
f_air = addfile('D:/nc/air.2015.nc')
f_uwnd = addfile('D:/nc/uwnd.2015.nc')
f_vwnd = addfile('D:/nc/vwnd.2015.nc')
print 'Read data array...'
tidx = 173
t = f_air.gettime(tidx)
lidx = 0
air = f_air['air'][tidx,lidx,::-1,:]
uwnd = f_uwnd['uwnd'][tidx,lidx,::-1,:]
vwnd = f_vwnd['vwnd'][tidx,lidx,::-1,:]
lon = f_air['lon'][:]
lat = f_air['lat'][::-1]
lon, lat = meshgrid(lon, lat)
# Calculate
print 'Calculate...'
dtx = cdiff(air, 'x')
dty = cdiff(air, 'y')
dx = cdiff(lon, 'x') * pi / 180
dy = cdiff(lat, 'y') * pi / 180
tadv = -1*((uwnd*dtx)/(cos(lat*pi/180)*dx)+vwnd*dty/dy)/6.37e6
#Plot
print 'Plot...'
axesm()
mlayer = shaperead('D:/Temp/map/country1.shp')
geoshow(mlayer, edgecolor='black')
layer = contourfm(tadv, cmap='grads_rainbow')
title('Temporature advection (' + t.strftime('%Y-%m-%d') + ')')
colorbar(layer)
xlim(0, 360)
ylim(-90, 90)
|
|