Scheduled Downtime
On Friday 21 April 2023 @ 5pm MT, this website will be down for maintenance and expected to return online the morning of 24 April 2023 at the latest

wrf_user_vert_cross

This post was from a previous version of the WRF&MPAS-A Support Forum. New replies have been disabled and if you have follow up questions related to this post, then please start a new thread from the forum home page.

melpomene23

New member
Hi all,

I am trying to plot a vertical cross-section of two staggered variables (W and TKE) from WRF using wrf_user_vert_cross and gsn_csm_contour. However, in both cases, even though I unstagger the variables with wrf_user_unstagger, the first layer does not appear in the contour plot. I am attaching a plot that shows how the function skips the first layer when plotting these variables. I was wondering if there's a way to make that gap go away.

Thanks,
 

Attachments

  • CROSS_72_2018re_W.pdf
    55.6 KB · Views: 95
Hi,

Here's the relevant parts of the code:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
times = wrf_user_list_times(a)
time = (/72,78,102/)
t = 0
it = time(t)

QB = wrf_user_getvar(a,"QBUOY",it)
Cld = wrf_user_getvar(a,"CLDFRA",it)
Z = wrf_user_getvar(a,"z",it)
lats = wrf_user_getvar(a, "lat",it)
lons = wrf_user_getvar(a, "lon",it)

Slat = new((/3/),"float")
Slon = new((/3/),"float")
Elat = new((/3/),"float")
Elon = new((/3/),"float")

do j = 0, 2
Slat(j) = lat_T(129 - time(j) + 6)
Elat(j) = lat_T(129 - time(j) - 6)
Slon(j) = lon_T(129 - time(j) + 6)
Elon(j) = lon_T(129 - time(j) - 6)
end do

;---------------------------------------- General Resources--------------------------------------------
res = True
res@gsnStringFont = 25
res@tiMainOn = False
; res@tiMainFont = 25
; res@tiMainFontHeightF = 0.03
res@tmBorderLineColor = "grey43"
res@tmBorderThicknessF = 1.0

res@gsnFrame = False
res@gsnDraw = False
res@vpWidthF = 0.7
res@vpHeightF = .16

res@tiYAxisFont = 25
res@tiYAxisFontHeightF = 0.03
res@tmYLMinorOn = False

res@tmYLLabelFontHeightF = 0.02
res@tmYMajorGrid = True
res@tmYMajorGridLineColor = "grey70"
res@tmYMajorGridLineDashPattern = 2
res@tmYMajorGridThicknessF = 0.5
res@tmYLLabelFont = 25
res@tmYROn = False
res@tmYLMajorLineColor = "grey43"
res@tmYLMajorThicknessF = 1.0
res@tmYLLabelDeltaF = -0.6
res@trXMinF = 0
res@trXMaxF = 120
res@tmXMajorGrid = True
res@tmXBMajorLengthF = 0.005
res@tmXMajorGridLineColor = "grey70"
res@tmXMajorGridLineDashPattern = 2
res@tmXMajorGridThicknessF = 0.5
res@tmXBMinorOn = True
res@tmXTOn = False
res@tmXBMajorLineColor = "grey43"
res@tmXBMajorThicknessF = 1.0

res@gsnStringFontHeightF = 0.022
res@gsnCenterStringOrthogonalPosF = -0.05

res@cnLineLabelsOn = False
res@cnInfoLabelOn = False

res@gsnMaximize = True

res@trYMinF = 0
res@trYMaxF = 1500
res@tiYAxisString = ""
res@tmYLMode = "Explicit"
res@tmYLDataBottomF = 0
res@tmYLDataTopF = 1500
res@tmYLValues = fspan(0,1500,4)
res@tmYLMinorOn = False
res@tmYLLabels = sprintf("%4.0f",fspan(0,1500,4))

;----------------------------------------------------------------------------------
opt = True
start_lat = Slat(0)
end_lat = Elat(0)
start_lon = Slon(0)
end_lon = Elon(0)
opt@latlon = True
opt@linecoords = True
opt@file_handle = a

QBa = wrf_user_unstagger(QB, QB@stagger)

plane_plot = wrf_user_vert_cross(Cld:)40,:,:),Z:)40,:,:),(/start_lon, start_lat, end_lon, end_lat/),opt)
plane_plotII = wrf_user_vert_cross(QBa:)40,:,:),Z:)40,:,:),(/start_lon, start_lat, end_lon, end_lat/),opt)


;--------------------------------------------------- QB Plot ------------------------------------------------------------
resDw = res
cmapI = read_colormap_file("NCV_blue_red")
resDw@cnFillOn = True
resDw@cnFillMode = "RasterFill"
resDw@cnRasterSmoothingOn = True
resDw@cnFillPalette = cmapI(CMP_min:CMP_max,:)
resDw@cnLinesOn = False
resDw@cnLabelBarEndStyle = "IncludeMinMaxLabels"

resDw@lbOrientation = "vertical"
resDw@pmLabelBarWidthF = 0.06
resDw@pmLabelBarHeightF = 0.16
resDw@pmLabelBarOrthogonalPosF = 0
resDw@pmLabelBarParallelPosF = 0.5
resDw@lbLabelFontHeightF = 0.02
resDw@lbLabelFont = 25
resDw@lbAutoManage = False
resDw@cnExplicitLabelBarLabelsOn = True
resDw@lbLabelAutoStride = False
resDw@lbBoxLinesOn = False

resDw@lbLabelStrings = sprintf("%5.2f",fspan(MIN_val,MAX_val,tot_cm))
resDw@lbLabelStride = STR ;3*decimalPlaces(tot_cm/10,0,False)

resDw@cnLevelSelectionMode = "ExplicitLevels"
resDw@cnLevels = fspan(MIN_val,MAX_val,tot_cm)

;--------------------------------------- CLD plot ---------------------------------------------------
resFc = True
resFc@gsnDraw = False
resFc@gsnFrame = False
cmap2 = read_colormap_file("precip2_17lev")
resFc@cnFillOn = False
resFc@cnLinePalette = cmap2
resFc@cnMonoLineColor = False
resFc@cnLinesOn = True ; Line contours
; resFc@cnLineColor = "black"
resFc@cnLineLabelsOn = False
resFc@cnLineThicknessF = 1.5
resFc@cnInfoLabelOn = False
resFc@cnLevelSelectionMode = "ExplicitLevels"
resFc@cnLevels = fspan(min(Cld:)40,:,:)),max(Cld:)40,:,:)),11)


xvalues = ispan(0,dimsizes(plane_plotII(0,:))-1,1)
ll_step = 40
resDw@tmXBMode = "Explicit"
resDw@tmXBValues = xvalues:):ll_step)
resDw@tmXBLabels = sprintf("%6.2f",plane_plotII@lats:):ll_step)) + "~S~o~N~N~C~" + \
sprintf("%6.2f",plane_plotII@lons:):ll_step)) + "~S~o~N~E"


resDw@tmXBLabelFontHeightF = 0.01
resDw@tmXBLabelAngleF = 45.

plotII = gsn_csm_contour(wks,plane_plotII,resDw)

plotI = gsn_csm_contour(wks,plane_plot,resFc)
overlay(plotII, plotI)
draw(plotII)
frame(wks)

end

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Please disregard CMP_min, CMP_max, MIN_val, MAX_val, and tot_cm. They are calculated from plane_plot and plane_plotII and only determine the range of colors used in the contour plots. The relevant parts of the code are in bold.

I should also note that the plot I previously attached is created using the exact same code for W (vertical velocity) instead of QB but has the same gap in the first layer.

Thank you so much for your help,
 
Hi,

Your issue is that because this is interpolating between levels it cannot go lower than the lowest level, which is always above ground level. You are interpolating to Z, which by definition here is height above mean sea level. However, you will want to make a new Z which will be height above ground level (old Z - terrain height (HGT)). You will want your code to look something like this:

z_AGL = z
dims = dimsizes(z)
do k=0,dims(0)-1
z_AGL(k,:,:) = z_AGL(k,:,:) - terrain:),:)
end do

Does this make sense?
 
Hi,

I need to try and run your code on one of my files to test it and I can't do it without your entire script. Can you please send the whole thing?
 
Top