在分析一些垂直环流形势的时候经常会需要分析剖面的环流情况,一般有两种资料,一是wrfout这种曲面网格,二是标准网格的再分析资料。两种用到的差值函数不太一样,脚本过长,这里只记录一些重要的步骤。
1. wrfout等曲面网格
原理是给定中心点及剖面的旋转角度,然后将变量往这个面上插值。
DATADir_ctrl=(/"/student/sunxiaoyun/wrfout_case/201901-ctrl/"/)
a = addfile(DATADir_ctrl + "wrfout_d02_2019-01-08_02:00:00.nc", "r")
; 设置中心点和旋转角度
mdims = getfilevardimsizes(a,"P") ; get some dimension sizes for the file
nd = dimsizes(mdims)
plane = new(2,float)
plane = (/ mdims(nd-1)/2, mdims(nd-2)/2/) ; pivot point is center of domain (x,y)
angle = 25.
;读取需要分析的变量画图
pm_ctrl = wrf_user_getvar(a,"PM2_5_DRY",0) ;三维的
pm_ctrl_plane = wrf_user_intrp3d(pm_ctrl,z,"v",plane,angle,False)
pblh_ctrl = wrf_user_getvar(a, "PBLH",0) ;二维的
pblh_plane_ctrl = wrf_user_intrp2d(pblh_ctrl,plane,angle,False)
;画图函数
contour_pm= wrf_contour(a,wks,pm_plane(0:zmax_pos,lat_min:lat_max),opts_cn)
contour_vc= wrf_vector(a, wks, v_plane(0:zmax_pos,lat_min:lat_max), w_plane(0:zmax_pos,lat_min:lat_max)*30, opts_vc)
plot = wrf_overlays(a,wks,(/contour_pm,contour_vc/),altres)
2. 标准网格的再分析资料
原理是给出起始点经纬度,线性插值出这条线上的经纬度,然后再将再分析网格资料插值到这条线上的点里。
datadir = "/public/home/sunxiaoyun/datadir/ERA5/vars4CEC/"
f_t = addfile(datadir+"T-type1.nc","r")
t = short2flt(f_t->t(:,:,::-1,:)) ;注意后面插值函数需要经纬度是线性增加的,我这儿原始资料的纬度是递减的,进行了倒置
level = f_t->level
xlat = f_t->latitude(::-1)
xlon = f_t->longitude
; calculate great circle along transect
leftlat = 27;45
rightlat = 34;30
leftlon = 112;76
rightlon = 116;95
npts = 30 ; number of points in resulting transect
dist = gc_latlon(leftlat,leftlon,rightlat,rightlon,npts,2)
lat_new = dist@gclat
lon_new = dist@gclon
points = ispan(0,npts-1,1)*1.0
; interpolate data to great circle
t_cross = linint2_points_Wrap(xlon,xlat,t_a,True,dist@gclon,dist@gclat,0)
t_cross!0 = "level"
t_cross&level = level
;画图就是正常用gsn_csm系列函数画图
plot = gsn_csm_pres_hgt_vector(wks,t_cross,v_cross,w_cross,res)