[ncl-talk] Wrf Vertical Cross Section Help
Nicholas Thomas Luchetti
Nicholas.Luchetti at colorado.edu
Wed Mar 14 08:46:13 MDT 2018
Hi all,
I am trying to use the script: WRF_cn_4.ncl provided by NCAR to plot a
vertical cross section of wrfoutput from an idealized case...
I simply just changed the file to my wrfoutput.nc file, and changed the
lat/lon to the idealized (i,j) point of interest....
The script apparently runs fine with no errors, but nothing is plotted at
all...
The dimensions of variable W seems to be exactly the same as in the sample
script so I can't seem to figure out why it doesn't plot anything? Does
anyone have any idea as to why?
Is there something special I need to do use the (i,j) idealized coordinates
as opposed to lat/lon coordinates?
I've attached the script as a .txt file.
Thanks,
Nick Luchetti
--
Nicholas Luchetti
Graduate Student
Department of Atmospheric and Oceanic Sciences (ATOC)
CU Boulder
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180314/de446125/attachment.html>
-------------- next part --------------
;----------------------------------------------------------------------
; WRF_cn_4.ncl
;
; Concepts illustrated:
; - Plotting WRF data
; - Plotting a cross section
;----------------------------------------------------------------------
; WRF: time-z cross section.
;----------------------------------------------------------------------
; These files are loaded by default in NCL V6.2.0 and newer
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRF_contributed.ncl"
begin
;---Open file; substitute your own WRF output file here
f = addfile ("/Users/nicholasluchetti/Build_WRF/WRFV3/test/em_quarter_ss/wrfout_d01_control.nc","r")
;
; Read character variable Times
; Convert to units of "hours since" for plotting purposes
;
times = f->Times
Time = wrf_times_c(f->Times, 0) ; convert to "hours since"
print(Time)
;
; Read W(bottom_top_stag,west_east) at lat
; index 15, lon index nlon.
; Read associated levels and longitudes
;
nlat = 85
nlon = 120
w = f->W(:,:,nlat,nlon) ; W(Time,bottom_top_stag)
znw = f->ZNW(0,:) ; znw(bottom_top_stag)
printVarSummary(w)
w&Time := Time
printVarSummary(w)
print(w&Time)
exit
;---Use simple array syntax [like f90] to change units
w = w ; for demo change units
w at units = "m/s"
printVarSummary(w)
printMinMax(w,0)
;---Add/change meta data to conform to netCDF convention standards
w!0 = "Time"
w&Time = Time
w!1 = "lev" ; name dimensions
w&lev = znw ; assign values to named dimensions
;---For plot purposes only, read the specific lat/lon point
lat = f->XLAT(0,nlat,nlon)
lon = f->XLONG(0,nlat,nlon)
;
; create plots
; (1) A "BlWhRe" is often selected when plus/minus are of interest
; (2) The "symMinMaxPlt" procedure determines contour limits
; that are symmetric.
; (3) Use the "sprintf" function to format the title
; (4) Because the rightmost dimension will become the "x" axis
; use NCL's "dimension reordering" to reshape
;
wks = gsn_open_wks("pdf","plt_vv_vertical.pdf")
res = True ; plot mods desired
res at gsnMaximize = True ; maximize plot size
res at cnFillOn = True ; turn on color
res at cnFillPalette = "BlWhRe" ; set the color map
res at cnLinesOn = False ; turn off contour lines
res at lbOrientation = "vertical" ; vertical label bar
res at trYReverse = True ; reverse y axis
res at tiXAxisString = Time at units ; label bottom axis with units attribute
symMinMaxPlt(w, 14, False, res) ; contributed.ncl
res at tiMainString = sprintf("%4.2f", nlat)+"N " \
+ sprintf("%4.2f", fabs(nlon))+"W"
plot = gsn_csm_contour(wks,w(lev|:,Time|:),res)
end
More information about the ncl-talk
mailing list