Re: gsnRightString is not a valid resource

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Wed Jan 08 2014 - 14:01:59 MST

Xiaoming,

The "gsn" resources are special ones that are specific to the gsn_xxxx plotting scripts. They cannot be treated as "regular" NCL resources that you can retrieve or set via setvalues/getvalues.

You need to set these resources when calling gsn_xxxx, and not afterwards.

--Mary

On Jan 7, 2014, at 8:33 AM, xiaoming Hu <yuanfangcan@hotmail.com> wrote:

> Dear Mary
>
> Thank you so much! You suggestion worked so well!!!!!
>
> I now have another issue for the same code.
> I failed to add "gsnRightString"
>
> See what I got
> "
> warning:gsnRightString is not a valid resource in wrfout_d01_W_cross_1_contour at this time
> warning:gsnRightString is not a valid resource in wrfout_d01_W_cross_1_contour at this time
> "
> and the string did not show up on the right-up corner.
>
> I tried both
> opts_W@gsnRightString = res@TimeLabel
> and
>
> setvalues contour_W
> "vpHeightF" : 0.4
> "vpWidthF" : 0.4
> "vpYF" : 0.95-ifile_loop*0.41
> "tiMainString" : "Cross section"
> "gsnRightString" : res@TimeLabel
> end setvalues
> draw(contour_W)
>
> Neither of them worked. The whole code is pasted below.
>
> Thanks again
>
> Xiaoming
>
> ; Example script to produce plots for a WRF real-data run,
> ; with the ARW coordinate dynamics option.
> ; Plot data on a cross section
> ; This script will plot data at a set angle through a specified point
> ; Add some label info to the Y-axis
>
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
>
> begin
> gsres = True
> gsres@gsMarkerIndex = 16 ; circle at first
> gsres@gsMarkerThicknessF = 1
> gsres@gsMarkerSizeF = 0.01
> gsres@gsMarkerColor = "black"
> Meteo_Lat = 39.02 ; from ZhiQiang QQ
> Meteo_Lon = 115.65 ; height above sea 16.1
> idomain = 1
> files = systemfunc("ls wrfout_d0"+idomain+"_2013-08-1?_*:00:00")
> ; We generate plots, but what kind do we prefer?
> type = "eps"
> figurename = "wrfout_d0"+idomain+"_W_cross_1"
> wks = gsn_open_wks(type,figurename)
> gsn_define_colormap(wks,"GreenMagenta16") ; select color map
>
> plot = new(2,graphic)
> ifile_pick = (/7,8/)
>
> do ifile_loop = 0, dimsizes(ifile_pick)-1
> ifile = ifile_pick(ifile_loop)
>
> a = addfile(files(ifile)+".nc","r")
> opt = True
> ij = wrf_user_ll_to_ij(a,Meteo_Lon, Meteo_Lat,opt)
> print(ij)
> ij(1) = ij(1)- 3
>
>
> ; Set some basic resources
> res = True
> res@Footer = False
>
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
> times = wrf_user_getvar(a,"times",-1) ; get times in the file
> ntimes = dimsizes(times) ; number of times in the file
> FirstTime = True
>
> mdims = getfilevardimsizes(a,"P") ; get some dimension sizes for the file
> nd = dimsizes(mdims)
>
> ;---------------------------------------------------------------
>
> do it = 0,ntimes-1,2 ; TIME LOOP
>
> print("Working on time: " + times(it) )
> res@TimeLabel = times(it) ; Set Valid time to use on plots
>
> tc = wrf_user_getvar(a,"tc",it) ; T in C
> theta = wrf_user_getvar(a,"theta",it) ; relative humidity
> z = wrf_user_getvar(a, "z",it) ; grid point height
> ua = wrf_user_getvar(a,"ua",it) ; u on mass points
> wa = wrf_user_getvar(a,"wa",it) ; v on mass points
>
>
> if ( FirstTime ) then ; get height info for labels
> zmin = 0.
> zmax = max(z)/1000.
> nz = floattoint(zmax/2 + 1)
> FirstTime = False
> end if
>
> ;---------------------------------------------------------------
>
> angle = 90
> plane = new(2,float)
> plane = (/ ij(0), ij(1) /) ; pivot point is center of domain (x,y)
> opts = False ; start and end points not specified
>
> theta_plane = wrf_user_intrp3d(theta,z,"v",plane,angle,opts)
> tc_plane = wrf_user_intrp3d(tc,z,"v",plane,angle,opts)
> ua_plane = wrf_user_intrp3d(ua,z,"v",plane,angle,opts)
> wa_plane = wrf_user_intrp3d(wa,z,"v",plane,angle,opts)
>
> dim = dimsizes(theta_plane) ; Find the data span - for use in labels
> zspan = dim(0)
> print(zspan)
>
> ; Options for XY Plots
> opts_xy = res
> opts_xy@tiYAxisString = "Height, km"
> opts_xy@cnMissingValPerimOn = True
> opts_xy@cnMissingValFillColor = 0
> opts_xy@cnMissingValFillPattern = 11
> opts_xy@tmYLMode = "Explicit"
> opts_xy@tmYLValues = fspan(0,zspan,nz*2) ; Create tick marks
> opts_xy@tmYLLabels = sprintf("%.1f",fspan(zmin,zmax,nz*2)) ; Create labels
> opts_xy@tiXAxisString = "Distance, km"
> opts_xy@tmXBMode = "Explicit"
> opts_xy@tmXBValues = ispan(-400,400,100)/40.5+75.
> opts_xy@tmXBMinorValues = ispan(-400,400,50)/40.5+75.
> opts_xy@tmXBLabels = ispan(-400,400,100)
> opts_xy@tiXAxisFontHeightF = 0.020
> opts_xy@tiYAxisFontHeightF = 0.020
> opts_xy@tmXBMajorLengthF = 0.02
> opts_xy@tmYLMajorLengthF = 0.02
> opts_xy@tmYLLabelFontHeightF = 0.015
> opts_xy@PlotOrientation = tc_plane@Orientation
>
> ; Plotting options for W
> opts_W = opts_xy
> ; opts_W@ContourParameters = (/ 300., 328., 1. /)
> opts_W@ContourParameters = (/ -5., 5., 1 /)
> opts_W@trYMaxF = 30.
> opts_W@trXMinF = 65
> opts_W@trXMaxF = 83
> opts_W@tmXBFormat = "f"
> opts_W@pmLabelBarOrthogonalPosF = -0.07
> opts_W@cnFillOn = True
> opts_W@gsnSpreadColors = True ; use full range of colormap
> opts_W@gsnRightString = res@TimeLabel
> opts_W@gsnDraw = False
> opts_W@gsnFrame = False
>
> printVarSummary(tc_plane)
> print(opts_W)
> contour_W = wrf_contour(a,wks,wa_plane*100,opts_W)
>
> resvector = True
> resvector@gsnDraw = False
> resvector@gsnFrame = False
> resvector@vcGlyphStyle = "CurlyVector"
> resvector@tmXBFormat = "f"
> resvector@trYMaxF = 30.
> resvector@trXMinF = 65.
> resvector@trXMaxF = 83
> resvector@vcRefAnnoOn = True
> resvector@vcRefMagnitudeF = 8. ; define vector ref mag
> resvector@vcRefLengthF = 0.025 ; define length of vec ref
> resvector@vcRefAnnoOrthogonalPosF = -1. ; move ref vector
> resvector@vcRefAnnoParallelPosF = 0.95 ; move ref vector
> resvector@vcMinDistanceF = 0.025 ; larger means sparser
> resvector@vcLineArrowHeadMaxSizeF = 0.0075 ; default: 0.05 (LineArrow), 0.012 (CurlyVector)
>
> vector = wrf_vector(a,wks,ua_plane,wa_plane*100,resvector)
> dummy = gsn_add_polymarker(wks,vector,ij(0),0.08,gsres)
>
> ; MAKE PLOTS
> pltres = True
> pltres@NoTitles = True
> pltres@FramePlot = False
> pltres@PanelPlot = True
> ; pltres@vpXF =0.15+ispecies*0.405
>
> plot(ifile_loop) = wrf_overlays(a,wks,(/contour_W,vector/),pltres)
> setvalues contour_W
> "vpHeightF" : 0.4
> "vpWidthF" : 0.4
> "vpYF" : 0.95-ifile_loop*0.41
> "tiMainString" : "Cross section"
> "gsnRightString" : res@TimeLabel
> end setvalues
> draw(contour_W)
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> end do ; END OF TIME LOOP
> ; draw(plot(ifile_loop))
>
> end do ; ifiles
>
> frame(wks)
>
> end
>
>
>
>
>
> Subject: Re: cannot use vpXF, vpYF, vpWidthF, and vpHeightF to make panel plots
> From: haley@ucar.edu
> Date: Mon, 6 Jan 2014 09:10:46 -0700
> CC: ncl-talk@ucar.edu
> To: yuanfangcan@hotmail.com
>
> Xiaoming,
>
> The wrf_xxxx plotting functions are generally meant to be “black box” routines for drawing plots on an 8.5” x 11” piece of paper. The plots are resized as necessary to fit this size, and hence the vpXXX resources are ignored.
>
> To force the vp resources to take effect, you can apply them *after* the plots are created. You can do this via a “setvalues” block.
>
> Instead of this:
>
> pltres@vpHeightF =0.4
> pltres@vpWidthF = 0.4
> pltres@vpYF = 0.95-ifile_loop*0.41
> ; pltres@vpXF =0.15+ispecies*0.405
>
> plot(ifile_loop) = wrf_overlays(a,wks,(/contour_W,vector/),pltres)
> end do ; END OF TIME LOOP
> draw(plot(ifile_loop))
> end do ; ifiles
>
> On Jan 3, 2014, at 10:06 P
>
> Try this:
>
> plot(ifile_loop) = wrf_overlays(a,wks,(/contour_W,vector/),pltres)
> setvalues contour_W
> "vpHeightF" : 0.4
> "vpWidthF" : 0.4
> "vpYF" : 0.95-ifile_loop*0.41
> end setvalues
> draw(contour_W)
>
> Dear all
>
> I can use gsn_panel to generate a panel plot, but cannot use vpXF, vpYF, vpWidthF, and vpHeightF to make the panel plot.
>
> I attached my script, which only generate a plot with only one panel.
>
> If I comment out draw(plot(ifile_loop)) and frame(wks)
> and un-comment out
> ; resP = True ; modify the panel plot
> ; resP@txString = "Vetical velocity"
> ; gsn_panel(wks,plot,(/2,1/),resP)
>
> Then the script would generate a plot with two panels.
>
> I prefer to use vpXF, vpYF, vpWidthF, and vpHeightF to generate the panel plot since I can exactly put the panels wherever I want.
>
> Any suggestions?
>
> Thanks
> Xiaoming
>
>
> <wrf_CrossSection_WplusVecters_combine.ncl>_______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Jan 8 14:02:12 2014

This archive was generated by hypermail 2.1.8 : Sun Jan 19 2014 - 21:56:35 MST