[ncl-talk] draw a cross section
靳茜芃
1801111815 at pku.edu.cn
Tue Oct 22 02:12:27 MDT 2019
Hello Everyone I use ncl 6.6.2 when I deal with wrfout_* files generated by WRF, I have this problem: I want to draw a cross section of the potential temperature between any two points (longitude and latitude). I have drawn a figure based on the example of "http://www.ncl.ucar.edu/applications/scripts/wrf'interp'3.ncl"(wrf_user_vert_cross). But there is no value below 200m in the figure: Here is my code:;----------------------------------------------------------------------
; wrf_interp_3.ncl
;----------------------------------------------------------------------
; Concepts illustrated:
; - Interpolating a vertical cross-section from a 3D WRF-ARW field.
;----------------------------------------------------------------------
; wrf_user_vert_cross and wrf_user_interp_level replace the
; deprecated wrf_user_intrp3d function.
;
; NCL V6.6.0 or higher is required to run this example.
;----------------------------------------------------------------------
begin
filename = "/home/jxp/wrfout_d02_2017120215"
a = addfile(filename,"r")
z = wrf_user_getvar(a, "z",0)
dim = dimsizes(z)
all_n=dim(0) ;time
all_k=dim(1) ;south-north
all_j=dim(2) ;west-east
hgt0 = wrf_user_getvar(a,"ter",0)
zag0=new((/all_n,all_k,all_j/),"float") ;z above ground
hgt2=new((/all_n,all_k,all_j/),"float") do n=0,all_n-1 hgt2(n,:,:)=hgt0 end do zag0 = z-hgt2 printVarSummary(zag0)
th = wrf_user_getvar(a, "th",0) ; theta k
loc = wrf_user_ll_to_ij(a,116.21,39.28,True)
print(th(:,loc(1),loc(0)))
print(zag0(:,loc(1),loc(0)))
lats = wrf_user_getvar(a, "lat",0)
lons = wrf_user_getvar(a, "lon",0)
start_lat = 38.625
end_lat = 39.982
start_lon = 116.61
end_lon = 115.782
opt = True
opt at latlon = True
opt at linecoords = True
opt at file_handle = a
th_latlon = wrf_user_vert_cross(th,zag0,(/start_lon,start_lat,end_lon,end_lat/),opt)
; printVarSummary(th) ; [bottom_top | 31] x [south_north | 546] x [west_east | 480]
; printVarSummary(th_latlon) ; [vertical | 100] x [cross_line_idx | 171]
wks = gsn_open_wks("png","wrf_interp2017120215")
res = True
res at gsnMaximize = True ; maximize plot in frame
res at cnFillOn = True ; turn on contour fill
res at cnLinesOn = True ; turn off contour lines
res at cnLineLabelsOn = True ; turn off line labels
res at cnLevelSelectionMode = "ManualLevels"
res at cnMinLevelValF = 276
res at cnMaxLevelValF = 285
res at cnLevelSpacingF = 0.5
res at lbOrientation = "Vertical"
res at lbLabelFontHeightF = 0.01
res at tiMainString = "Cross section from ("+start_lat+","+start_lon+ \
") to ("+end_lat + ","+end_lon+")"
res at gsnStringFontHeightF = 0.015
res at tmXBLabelFontHeightF = 0.01
res at tmXBLabelAngleF = 45.
res at tmYLMode = "Explicit"
res at tmYLLabels = (/0, 200, 400, 600, 800, 1000/)
res at trYMinF = 0;ymin
res at trYMaxF = 1000;ymax
;--Explicitly set lat/lon labels for X axis
xvalues = ispan(0,dimsizes(th_latlon(0,:))-1,1)
ll_step = 15 ; step interval for tickmarks
res at tmXBMode = "Explicit"
res at tmXBValues = xvalues(::ll_step)
res at tmXBLabels = sprintf("%6.2f",th_latlon at lats(::ll_step)) + "~S~o~N~N~C~" + \
sprintf("%6.2f",th_latlon at lons(::ll_step)) + "~S~o~N~E"
plot = gsn_csm_contour(wks,th_latlon,res)
end
What's wrong with my code? Why there is no value below 200m in the figure?Thank you!Xipeng Jin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20191022/4be22ee3/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 1571731369260.png
Type: image/png
Size: 175382 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20191022/4be22ee3/attachment.png>
More information about the ncl-talk
mailing list