PROBLEM WITH NCL-PRECIPITATION PLOT

The NCL graphics package.

PROBLEM WITH NCL-PRECIPITATION PLOT

Postby enzo » Wed Sep 29, 2010 7:50 am

Dear NCL-WRF experts,
I am trying to produce precipitation plot...but it doesn't...

This my problem:

Variable: times
Type: string
Total Size: 4 bytes
1 values
Number of Dimensions: 1
Dimensions and sizes: [1]
Coordinates:
Number Of Attributes: 2
description : times in file
_FillValue : missing
(0) 2000-01-24_00:00:00
(0) Working on time: 2000-01-24_00:00:00


...so I have no precipitation plot!!!

Any error in the script I am using?


; Example script to produce plots for a WRF real-data run,
; with the ARW coordinate dynamics option.

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"

begin
;
; The WRF ARW input file.
; This needs to have a ".nc" appended, so just do it.
a = addfile("./wrfout_d01_2000-01-24_00:00:00.nc","r")


; We generate plots, but what kind do we prefer?
type = "x11"
; type = "pdf"
; type = "ps"
; type = "ncgm"
wks = gsn_open_wks(type,"plt_Precip")


; Set some basic resources
res = True
res@MainTitle = "REAL-TIME WRF"

pltres = True
mpres = True
mpres@mpGeophysicalLineColor = "Black"
mpres@mpNationalLineColor = "Black"
mpres@mpUSStateLineColor = "Black"
mpres@mpGridLineColor = "Black"
mpres@mpLimbLineColor = "Black"
mpres@mpPerimLineColor = "Black"

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

; What times and how many time steps are in the data set?
FirstTime = True
times = wrf_user_list_times(a) ; get times in the file
ntimes = dimsizes(times) ; number of times in the file

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

do it = 0,ntimes-1,2 ; TIME LOOP

print("Working on time: " + times(it) )
if (FirstTime) then ; Save some times for tracking tendencies
times_sav = times(it)
end if
res@TimeLabel = times(it) ; Set Valid time to use on plots

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; First get the variables we will need

slp = wrf_user_getvar(a,"slp",it) ; slp
wrf_smooth_2d( slp, 3 ) ; smooth slp

; Get non-convective, convective and total precipitation
; Calculate tendency values
rain_exp = wrf_user_getvar(a,"RAINNC",it)
rain_con = wrf_user_getvar(a,"RAINC",it)
rain_tot = rain_exp + rain_con
rain_tot@description = "Total Precipitation"

if( FirstTime ) then
if ( it .eq. 0 ) then
rain_exp_save = rain_exp
rain_con_save = rain_con
rain_tot_save = rain_tot
else
rain_exp_save = wrf_user_getvar(a,"RAINNC",it-1)
rain_con_save = wrf_user_getvar(a,"RAINC",it-1)
rain_tot_save = rain_exp_save + rain_con_save
FirstTime = False
times_sav = times(it-1)
end if
end if

rain_exp_tend = rain_exp - rain_exp_save
rain_con_tend = rain_con - rain_con_save
rain_tot_tend = rain_tot - rain_tot_save
rain_exp_tend@description = "Explicit Precipitation Tendency"
rain_con_tend@description = "Param Precipitation Tendency"
rain_tot_tend@description = "Precipitation Tendency"

; Bookkeeping, just to allow the tendency at the next time step
rain_exp_save = rain_exp
rain_con_save = rain_con
rain_tot_save = rain_tot

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

if( .not. FirstTime ) then ; We will skip the first time

; Plotting options for Sea Level Pressure
opts_psl = res
opts_psl@ContourParameters = (/ 900., 1100., 2. /)
opts_psl@cnLineColor = "Blue"
opts_psl@cnInfoLabelOn = False
opts_psl@cnLineLabelFontHeightF = 0.01
opts_psl@cnLineLabelPerimOn = False
opts_psl@gsnContourLineThicknessesScale = 1.5
contour_psl = wrf_contour(a,wks,slp,opts_psl)
delete(opts_psl)


; Plotting options for Precipitation
opts_r = res
opts_r@UnitLabel = "mm"
opts_r@cnLevelSelectionMode = "ExplicitLevels"
opts_r@cnLevels = (/ .1, .2, .4, .8, 1.6, 3.2, 6.4, \
12.8, 25.6, 51.2, 102.4/)
opts_r@cnFillColors = (/"White","White","DarkOliveGreen1", \
"DarkOliveGreen3","Chartreuse", \
"Chartreuse3","Green","ForestGreen", \
"Yellow","Orange","Red","Violet"/)
opts_r@cnInfoLabelOn = False
opts_r@cnConstFLabelOn = False
opts_r@cnFillOn = True


; Total Precipitation (color fill)
contour_tot = wrf_contour(a,wks, rain_tot, opts_r)

; Precipitation Tendencies
opts_r@SubFieldTitle = "from " + times_sav + " to " + times(it)

contour_tend = wrf_contour(a,wks, rain_tot_tend,opts_r) ; total (color)
contour_res = wrf_contour(a,wks,rain_exp_tend,opts_r) ; exp (color)
opts_r@cnFillOn = False
opts_r@cnLineColor = "Red4"
contour_prm = wrf_contour(a,wks,rain_con_tend,opts_r) ; con (red lines)
delete(opts_r)



; MAKE PLOTS

; Total Precipitation
plot = wrf_map_overlays(a,wks,contour_tot,pltres,mpres)

; Total Precipitation Tendency + SLP
plot = wrf_map_overlays(a,wks,(/contour_tend,contour_psl/),pltres,mpres)

; Non-Convective and Convective Precipiation Tendencies
plot = wrf_map_overlays(a,wks,(/contour_res,contour_prm/),pltres,mpres)

end if ; END IF FOR SKIPPING FIRST TIME

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

times_sav = times(it)
FirstTime = False
end do ; END OF TIME LOOP

end



Kindly help me.
Thanking you,
ENZO
enzo
 
Posts: 16
Joined: Mon Jun 08, 2009 9:51 am

Re: PROBLEM WITH NCL-PRECIPITATION PLOT

Postby jimmyc » Tue Oct 05, 2010 12:53 pm

It doesn't do what?

Looks like you have type set to X11, so if you have x11 set up, the plot should appear on your computer screen.
You can try setting type to "ps" so that ncl will generate an image in postscript format that you can then view.
The views expressed in this message do not necessarily reflect those of NOAA or the National Weather Service or the University of Oklahoma.
James Correia, Jr
jimmyc
 
Posts: 518
Joined: Tue Apr 15, 2008 1:10 am

Re: PROBLEM WITH NCL-PRECIPITATION PLOT

Postby enzo » Thu Oct 07, 2010 4:10 am

Yes jimmyc,

I have set to X11 in the script...but I have no X11 window with precipitation plot image.

As you say, I have also tried setting to "ps"...but NCL doesn't generate any image in postscript format yet...only a white sheet!

This is the terminal response :

Variable: times
Type: string
Total Size: 4 bytes
1 values
Number of Dimensions: 1
Dimensions and sizes: [1]
Coordinates:
Number Of Attributes: 2
description : times in file
_FillValue : missing
(0) 2010-09-09_07:00:00
(0) Working on time: 2010-09-09_07:00:00

I think the problem is in reading times...what do you think?

Thank you in advance for your help,
ENZO
enzo
 
Posts: 16
Joined: Mon Jun 08, 2009 9:51 am

Re: PROBLEM WITH NCL-PRECIPITATION PLOT

Postby jimmyc » Thu Oct 07, 2010 12:19 pm

You will need to put in some print statements to see if the loop is just running and not doing what you are asking it to do.

add some of these:
print(it)

and be especially aware of the double if statement you have. You might just combine that into one IF statement.

clearly it not the times issue since time was printed correctly. The script might be in an infinite loop.
The views expressed in this message do not necessarily reflect those of NOAA or the National Weather Service or the University of Oklahoma.
James Correia, Jr
jimmyc
 
Posts: 518
Joined: Tue Apr 15, 2008 1:10 am

Re: PROBLEM WITH NCL-PRECIPITATION PLOT

Postby enzo » Tue Oct 26, 2010 5:46 am

Thank you jimmyc,

I've solved the problem by modifying some lines in the script:

; Example script to produce plots for a WRF real-data run,
; with the ARW coordinate dynamics option.

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"

begin
;
; The WRF ARW input file.
; This needs to have a ".nc" appended, so just do it.
a = addfile("./wrfout_d01_2010-09-09_17:00:00.nc","r")

; We generate plots, but what kind do we prefer?
type = "x11"
; type = "pdf"
; type = "ps"
; type = "ncgm"
wks = gsn_open_wks(type,"plt_Precip")

; Set some basic resources
res = True
res@MainTitle = "REAL-TIME WRF"

pltres = True
mpres = True
mpres@mpGeophysicalLineColor = "Black"
mpres@mpNationalLineColor = "Black"
mpres@mpUSStateLineColor = "Black"
mpres@mpGridLineColor = "Black"
mpres@mpLimbLineColor = "Black"
mpres@mpPerimLineColor = "Black"

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

; What times and how many time steps are in the data set?
FirstTime = True
times = wrf_user_list_times(a) ; get times in the file
ntimes = dimsizes(times) ; number of times in the file

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

do it = 0,ntimes-1,2 ; TIME LOOP

print("Working on time: " + times(it) )
if (FirstTime) then ; Save some times for tracking tendencies
times_sav = times(it)
end if
res@TimeLabel = times(it) ; Set Valid time to use on plots

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

; First get the variables we will need

slp = wrf_user_getvar(a,"slp",it) ; slp
wrf_smooth_2d( slp, 3 ) ; smooth slp

; Get non-convective, convective and total precipitation
; Calculate tendency values
rainnc = wrf_user_getvar(a,"RAINNC",it)
rainc = wrf_user_getvar(a,"RAINC",it)
rain_tot = rainnc + rainc
rain_tot@description = "Total Precipitation"

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

; Plotting options for Sea Level Pressure
opts_psl = res
opts_psl@ContourParameters = (/ 900., 1100., 2. /)
opts_psl@cnLineColor = "Blue"
opts_psl@cnInfoLabelOn = False
opts_psl@cnLineLabelFontHeightF = 0.01
opts_psl@cnLineLabelPerimOn = False
opts_psl@gsnContourLineThicknessesScale = 1.5
contour_psl = wrf_contour(a,wks,slp,opts_psl)
delete(opts_psl)

; Plotting options for Precipitation
opts_r = res
opts_r@UnitLabel = "mm"
opts_r@cnLevelSelectionMode = "ExplicitLevels"
opts_r@cnLevels = (/ .1, .2, .4, .8, 1.6, 3.2, 6.4, \
12.8, 25.6, 51.2, 102.4/)
opts_r@cnFillColors = (/"0","107","108", \
"2","8", \
"10","20","24", \
"16","17","18","28"/)
opts_r@cnInfoLabelOn = False
opts_r@cnConstFLabelOn = False
opts_r@cnFillOn = True

; Total Precipitation (color fill)
contour_tot = wrf_contour(a,wks, rain_tot, opts_r)

; Precipitation Tendencies
opts_r@SubFieldTitle = "from " + times_sav + " to " + times(it)

contour_tend = wrf_contour(a,wks, rain_tot,opts_r) ; total (color)
contour_res = wrf_contour(a,wks,rainnc,opts_r) ; non con (color)
opts_r@cnFillOn = False
opts_r@cnLineColor = "Blue"
contour_prm = wrf_contour(a,wks,rainc,opts_r) ; con (red lines)
delete(opts_r)

; MAKE PLOTS

; Total Precipitation
plot = wrf_map_overlays(a,wks,contour_tot,pltres,mpres)

; Total Precipitation + SLP
plot = wrf_map_overlays(a,wks,(/contour_tot,contour_psl/),pltres,mpres)

; Non-Convective and Convective Precipiation
plot = wrf_map_overlays(a,wks,(/contour_res,contour_prm/),pltres,mpres)

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

end do ; END OF TIME LOOP

end


Best regards,
Enzo :)
enzo
 
Posts: 16
Joined: Mon Jun 08, 2009 9:51 am


Return to NCL

Who is online

Users browsing this forum: No registered users and 2 guests