Dear NCL users,
I am currently new user of ncl. I manage to plot my wind and slp results from one of the output files, but I would like to plot them for each of the outputs. I understood that I have to use the addfiles but I am getting confused on how to loop through all the output files. Please see bellow what I am trying to do:
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
begin
;---Open the WRF data file
dir = "/home/c1735271/Dec2013TestRun/d01/"
files = systemfunc("cd "+ dir+" ; ls wrfout*")
a = addfiles(dir + files,"r")
times = wrf_user_list_times(a) ; get times in the file
it = 0 ; only one time step on this file
print("Working on time: " + times(it) )
;---Get the variables we need
slp = wrf_user_getvar(a,"slp",it) ; sea level pressure
wrf_smooth_2d( slp, 3 ) ; smooth slp
u = wrf_user_getvar(a,"ua",it) ; 3D U at mass points
v = wrf_user_getvar(a,"va",it) ; 3D V at mass points
u10 = u(0,:, ; Use lowest level at time 0
v10 = v(0,:,
utotal=sqrt(u10^2+v10^2)
delete([/u,v,u10,v10/]) ; Don't need these anymore
;---Attach some descriptive attributes
utotal@units = "m/s"
utotal@description = "Wind at 10m"
;---Open x11 window or png file
wks = gsn_open_wks("png","wrf_slp_uv")
;---Set some options common across all plots
cres = True
cres@MainTitle = "SLP_Wind"
cres@TimeLabel = times(it) ; Set Valid time to use on plots
;---Plot options for sea level pressure
res = cres
res@cnLineColor = "NavyBlue"
res@cnLineLabelBackgroundColor = -1 ; transparent
res@cnLineThicknessF = 2.0 ; default is 1.0
contour_slp = wrf_contour(a[0],wks,slp,res)
delete(res)
;---Plot options for wind countourf
res = cres
res@cnFillOn = True
contour_utot = wrf_contour(a[0],wks,utotal,res)
;res@FieldTitle = "Wind" ; overwrite Field Title
delete(res)
;---Overlay plots on map and draw
mpres = True
mpres@mpGeophysicalLineColor = "Black"
mpres@mpNationalLineColor = "Black"
mpres@mpUSStateLineColor = "Black"
mpres@mpGridLineColor = "Black"
mpres@mpLimbLineColor = "Black"
mpres@mpPerimLineColor = "Black"
mpres@mpGeophysicalLineThicknessF = 1.0
mpres@mpGridLineThicknessF = 1.0
mpres@mpLimbLineThicknessF = 1.0
mpres@mpNationalLineThicknessF = 0.6
mpres@mpUSStateLineThicknessF = 0.6
mpres@mpDataResolution = "FinestResolution"
pltres = True
ov = wrf_map_overlays(a[0],wks,(/contour_slp,contour_utot/),pltres,mpres)
end
Any help on the loop would be highly appreciated!
Thank you in advance,
Nefeli
I am currently new user of ncl. I manage to plot my wind and slp results from one of the output files, but I would like to plot them for each of the outputs. I understood that I have to use the addfiles but I am getting confused on how to loop through all the output files. Please see bellow what I am trying to do:
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
begin
;---Open the WRF data file
dir = "/home/c1735271/Dec2013TestRun/d01/"
files = systemfunc("cd "+ dir+" ; ls wrfout*")
a = addfiles(dir + files,"r")
times = wrf_user_list_times(a) ; get times in the file
it = 0 ; only one time step on this file
print("Working on time: " + times(it) )
;---Get the variables we need
slp = wrf_user_getvar(a,"slp",it) ; sea level pressure
wrf_smooth_2d( slp, 3 ) ; smooth slp
u = wrf_user_getvar(a,"ua",it) ; 3D U at mass points
v = wrf_user_getvar(a,"va",it) ; 3D V at mass points
u10 = u(0,:, ; Use lowest level at time 0
v10 = v(0,:,
utotal=sqrt(u10^2+v10^2)
delete([/u,v,u10,v10/]) ; Don't need these anymore
;---Attach some descriptive attributes
utotal@units = "m/s"
utotal@description = "Wind at 10m"
;---Open x11 window or png file
wks = gsn_open_wks("png","wrf_slp_uv")
;---Set some options common across all plots
cres = True
cres@MainTitle = "SLP_Wind"
cres@TimeLabel = times(it) ; Set Valid time to use on plots
;---Plot options for sea level pressure
res = cres
res@cnLineColor = "NavyBlue"
res@cnLineLabelBackgroundColor = -1 ; transparent
res@cnLineThicknessF = 2.0 ; default is 1.0
contour_slp = wrf_contour(a[0],wks,slp,res)
delete(res)
;---Plot options for wind countourf
res = cres
res@cnFillOn = True
contour_utot = wrf_contour(a[0],wks,utotal,res)
;res@FieldTitle = "Wind" ; overwrite Field Title
delete(res)
;---Overlay plots on map and draw
mpres = True
mpres@mpGeophysicalLineColor = "Black"
mpres@mpNationalLineColor = "Black"
mpres@mpUSStateLineColor = "Black"
mpres@mpGridLineColor = "Black"
mpres@mpLimbLineColor = "Black"
mpres@mpPerimLineColor = "Black"
mpres@mpGeophysicalLineThicknessF = 1.0
mpres@mpGridLineThicknessF = 1.0
mpres@mpLimbLineThicknessF = 1.0
mpres@mpNationalLineThicknessF = 0.6
mpres@mpUSStateLineThicknessF = 0.6
mpres@mpDataResolution = "FinestResolution"
pltres = True
ov = wrf_map_overlays(a[0],wks,(/contour_slp,contour_utot/),pltres,mpres)
end
Any help on the loop would be highly appreciated!
Thank you in advance,
Nefeli