- 积分
- 55946
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2011-6-21
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
本帖最后由 MeteoInfo 于 2020-4-11 19:09 编辑
气象分析中经常会用到某个变量在某个矩形范围内沿经度或纬度方向平均场的垂直分布。这里有两个例子,第一个例子是“正矩形”,第二个例子是“斜矩形”(用到格点场的旋转,参考此例:http://bbs.06climate.com/forum.p ... 1110&extra=page%3D1)。
脚本1:
- f = addfile('D:/Temp/nc/uwnd.2011.nc')
- data = f['uwnd'][0,:,'10:40','70:130']
- data = mean(data, axis=1)
- lev1 = data.dimvalue(0)
- #lev2 = 1000 - lev1
- lev2 = meteo.pressure_to_height_std(lev1)
- levels = []
- for j in range(0, len(lev1)):
- levels.append('%i' % lev1[j])
- data.setdimvalue(0, lev2)
- #Plot
- layer = contourf(data, 20)
- colorbar(layer)
- yticks(lev2, levels)
- xlabel('Longitude')
- ylabel('Pressure (hPa)')
- title('Latitude average uwnd profile')
脚本2:
- #Read data array
- f = addfile('D:/Temp/nc/uwnd.2011.nc')
- data = f['uwnd'][0,:,'0:70','50:150']
- #Get rotated grid
- lat = arange(10, 41, 5)
- lon = arange(70, 131, 5)
- xn = len(lon)
- yn = len(lat)
- lon, lat = meshgrid(lon, lat)
- angle = 20 * pi / 180
- rotate = array([[cos(angle),sin(angle)], [-sin(angle),cos(angle)]])
- n = lon.size
- xy = zeros([n, 2])
- xy[:,0] = lon - 70
- xy[:,1] = lat - 10
- xy = dot(xy, rotate) #Matrix multiplication
- xy[:,0] = xy[:,0] + 70
- xy[:,1] = xy[:,1] + 10
- lon[:,:] = xy[:,0]
- lat[:,:] = xy[:,1]
- #Project data to the grid
- ndata = data.project(lon, lat)
- #Average data along tilt latitude
- londata = mean(ndata, axis=1)
- latdata = mean(ndata, axis=2)
- lev1 = data.dimvalue(0)
- lev2 = meteo.pressure_to_height_std(lev1)
- levels = []
- for j in range(0, len(lev1)):
- levels.append('%i' % lev1[j])
- #Plot
- subplot(2,1,1)
- layer = contourf(lon[0,:], lev2, londata, 20)
- colorbar(layer)
- yticks(lev2, levels)
- xlabel('Longitude')
- ylabel('Pressure (hPa)')
- title('Tilt latitude average uwnd profile')
- subplot(2,1,2)
- layer = contourf(lat[0,:], lev2, latdata, 20)
- colorbar(layer)
- yticks(lev2, levels)
- xlabel('Latitude')
- ylabel('Pressure (hPa)')
- title('Tilt longitude average uwnd profile')
|
|