|
WRF Model GRAPHIC TOOLS : NCL Scripts
Detailed Sample Script
We will create a plot with
Surface Temperature in F,
Sea Level Pressure, and
Winds in kts
; basic NCL functions
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
; basic options, maps and interface to inline functions
load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
begin
; The WRF ARW input file. Append ".nc" here, to show it is an
; netCDF file. Input file do not actually need to have ".nc"
;
appended.
a = addfile("../wrfout_d01_2000-01-24_12:00:00.nc","r")
; We want output on screen. Output will be called "plt_Surface1"
type = "x11"
wks = gsn_open_wks(type,"plt_Surface1")
; Set basic plot options and Give our plot a main title
; Set Footers off
ARWres = True
ARWres@MainTitle = "REAL-TIME WRF"
ARWres@Footer = False
;---------------------------------------------------------------------------------
; Lets find out how many times are in the datasets.
times = wrf_user_list_times(a) ; get times in the file
ntimes = dimsizes(times) ; number of times in the file
it = ntimes-1 ; for this plot we are only interested in the last time
ARWres@TimeLabel = times(it) ; keep some time information
; Create a MAP background.
mpres = True
map = wrf_map(wks,a,mpres)
;---------------------------------------------------------------------------------
; Get the variables we will need
; wrf_user_getvar function is located in the
;
"$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
; script.
;
This function either extract the requested WRF variables
;
(like in the case of U10 and V10), or call in-line function
;
to calculate diagnostic (like slp).
slp = wrf_user_getvar(a,"slp",it) ; Calculate diagnostics slp
wrf_smooth_2d( slp, 3 ) ; smooth slp
tc2 = wrf_user_getvar(a,"T2",it) ; Get T2 (deg K)
tc2 = tc2-273.16 ; Convert to deg C
tf2 = 1.8*tc2+32. ; Turn temperature into Fahrenheit
tf2@description = "Surface Temperature"
tf2@units = "F" td_f = 1.8*td2+32.
u10 = wrf_user_getvar(a,"U10",it) ; Get U10
v10 = wrf_user_getvar(a,"V10",it) ; get V10
u10 = u10*1.94386 ; Turn wind into knots
v10 = v10*1.94386
u10@units = "kts"
v10@units = "kts"
;--------------------------------------------------------------------------
; Plotting options for T
opts = ARWres
opts@cnFillOn = True ; Shaded plot
opts@ContourParameters = (/ -20., 90., 5./) ; Contour intervals
opts@gsnSpreadColorEnd = -3 ; End 3rd from last color
contour_tc = wrf_contour(a,wks,tf2,opts) ; Create plot
delete(opts)
; Plotting options for SLP
opts = ARWres
opts@cnLineColor = "NavyBlue" ; Set line color
opts@cnHighLabelsOn = True ; Add high/low labels
opts@cnLowLabelsOn = True
opts@ContourParameters = (/ 900., 1100., 4. /) ; Contour intervals
opts@cnLineLabelBackgroundColor = -1 ; Label background transparent
opts@gsnContourLineThicknessesScale = 2.0 ; Set line thickness
contour_psl = wrf_contour(a,wks,slp,opts) ; Create plot
delete(opts)
; Plotting options for Wind Vectors
opts = ARWres
opts@FieldTitle = "Winds" ; Overwrite the field title
opts@NumVectors = 47 ; Density of wind barbs - high is denser
vector = wrf_vector(a,wks,u10,v10,opts); Create plot
delete(opts)
; MAKE PLOTS
; wrf_map_overlay function is located in the
"$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
; script.
;
This function overlays the desired plots (created above),
; with the map background.
; The last option (True in this case), indicates that frame
: should be advanced once the overlay is complete.
wrf_map_overlay(wks,map,(/contour_tc,contour_psl,vector/),True)
;--------------------------------------------------------------------------
end
|