<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Glad to hear it.<div>&nbsp;-dave</div><div><br><div><div>On Oct 21, 2012, at 2:56 PM, Enrico Benso wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><meta http-equiv="content-type" content="text/html; charset=utf-8"><div dir="auto"><div>Perfect, it works!</div><div><br></div><div>Thanks!</div><div><br></div><div>Bye!</div><div><br></div><div>Enrico<br>
<br><div><br></div></div><div><br>Il giorno 18/ott/2012, alle ore 01:24, David Brown &lt;<a href="mailto:dbrown@ucar.edu">dbrown@ucar.edu</a>&gt; ha scritto:<br><br></div><blockquote type="cite"><div><div><br></div><div>You need to set lbLabelAutoStride to False. There are a couple of other resources that would be good to set as well:</div>
<div><br></div><div><div>&nbsp; lbres@lbLabelAutoStride = False</div><div>&nbsp;&nbsp;lbres@lbLabelAngleF = -45.0 &nbsp; ; when you use all the labels they will overlap unless you make the font very small or you rotate the labels</div><div>&nbsp; lbres@lbLabelAlignment = "interioredges" &nbsp;; I am not sure why, but if you don't set this you will get an extra default label called "Label_17" -- interior edges should be the default</div>
</div><div>&nbsp; Also you probably want to unset this (I just commented it out), but that is up to you.&nbsp;</div><div><br></div><div>; &nbsp;lbres@lbLabelJust &nbsp; &nbsp; &nbsp; &nbsp;= "CenterLeft" &nbsp;; left justify labels</div><div><br></div>
<div>Hope this helps.</div><div>&nbsp;-dave</div><div><br></div><div><br></div><br><div><div>On Oct 17, 2012, at 11:54 AM, Enrico Benso wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Ok, it seems to work!<br>
I also added a title an the label bar.<br>I wonder if is it possible to display a label every bar.<br>Right now it display a label every 2 bars.<br>I tried to set lbres@lbLabelStride = 1 but it doesn't work.<br>
<br>Thanks a lot!!<br><br>Enrico<br><br><div class="gmail_quote">2012/10/17 David Brown <span dir="ltr">&lt;<a href="mailto:dbrown@ucar.edu" target="_blank">dbrown@ucar.edu</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Hi Enrico,<br>
Although I was able to get the "ForceAlways" option to work using a setvalues call on contour_tend right after this line:<br>
<div class="im"><br>
&nbsp; contour_tend = wrf_contour(a[it],wks, rain_tot_tend(it,:,:),opts_r) ; total (color)<br>
</div>&nbsp; setvalues contour_tend<br>
&nbsp; &nbsp; &nbsp; &nbsp; "pmLabelBarDisplayMode" : "ForceAlways"<br>
&nbsp; end setvalues<br>
<br>
it probably does not do what you want, because when the data are constant, it does not honor the explicit labels or colors.<br>
Hopefully this can be corrected soon, but until then your only option is to manually create your own labelbar using gsn_create_labelbar.<br>
It actually is not too hard. I have modified your original script to demonstrate a basic version. I am attaching it here. I also generated some<br>
random data for the first frame just to see what the plot should look like when it has valid data.<br>
&nbsp;-dave<br>
<br>
<br><br>
<br>
<br>
On Oct 16, 2012, at 12:40 PM, Enrico Benso wrote:<br>
<br>
&gt; Hi Dave,<br>
&gt;<br>
&gt; I tried pmLabelBarDisplayMode = "ForceAlways"<br>
&gt; but I get a lot of warnings and the label bar is not plotted even if precipitations are present:<br>
&gt;<br>
&gt; (0) &nbsp; &nbsp;Working on time: 2012-10-19_00:00:00<br>
&gt; warning:ContourPlotInitialize: scalar field is constant; ContourPlot not possible:[errno=1102]<br>
&gt; warning:ContourPlotSetValues: Data values out of range of levels set by EXPLICITLEVELS mode<br>
&gt; warning:lbPerimOn is not a valid resource in /prec3h_contour.PlotManager at this time<br>
&gt; warning:lbLabelFontHeightF is not a valid resource in /prec3h_contour.PlotManager at this time<br>
&gt; warning:lbAutoManage is not a valid resource in /prec3h_contour.PlotManager at this time<br>
&gt; warning:lbLabelJust is not a valid resource in /prec3h_contour.PlotManager at this time<br>
&gt; warning:lbLabelAutoStride is not a valid resource in /prec3h_contour.PlotManager at this time<br>
&gt; warning:lbBoxMinorExtentF is not a valid resource in /prec3h_contour.PlotManager at this time<br>
&gt; warning:lbTitleFontHeightF is not a valid resource in /prec3h_contour.PlotManager at this time<br>
&gt; warning:lbTitleOn is not a valid resource in /prec3h_contour.PlotManager at this time<br>
&gt; warning:lbTitleString is not a valid resource in /prec3h_contour.PlotManager at this time<br>
&gt; warning:lbTitleJust is not a valid resource in /prec3h_contour.PlotManager at this time<br>
&gt; warning:lbTitleOffsetF is not a valid resource in /prec3h_contour.PlotManager at this time<br>
&gt;<br>
&gt;<br>
&gt; If this can help you, I attach here my script.<br>
&gt;<br>
&gt;<br>
&gt; ; &nbsp; Example script to produce plots for a WRF real-data run,<br>
&gt; ; &nbsp; with the ARW coordinate dynamics option.<br>
&gt;<br>
&gt; load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"<br>
&gt; load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"<br>
&gt; ;load "./WRFUserARW.ncl"<br>
&gt;<br>
&gt; begin<br>
&gt; ;<br>
&gt; ; Make a list of all files we are interested in<br>
&gt; &nbsp; DATADir = "/home/vonjack/wrfems/runs/veneto/wrfprd/"<br>
&gt; &nbsp; FILES = systemfunc (" ls -1 " + DATADir + "*d02* ")<br>
&gt; &nbsp; numFILES = dimsizes(FILES)<br>
&gt; &nbsp; print("numFILES = " + numFILES)<br>
&gt; &nbsp; print(FILES)<br>
&gt; &nbsp; print (" ")<br>
&gt;<br>
&gt; ; We generate plots, but what kind do we prefer?<br>
&gt; &nbsp;; type = "x11"<br>
&gt; ; type = "pdf"<br>
&gt; &nbsp;type = "png"<br>
&gt; ; type = "ncgm"<br>
&gt; ;type = "ps"<br>
&gt;<br>
&gt; &nbsp;type@wkWidth = 1024 ; default is 1024 by 1024<br>
&gt; &nbsp;type@wkHeight = 1024<br>
&gt; wks = gsn_open_wks(type,"img/prec3h")<br>
&gt;<br>
&gt;<br>
&gt; ; Set some basic resources<br>
&gt; &nbsp; res = True<br>
&gt; &nbsp; res@MainTitle = "<a href="http://www.avmeteo.it/" target="_blank">www.avmeteo.it</a> &nbsp; WRF 1.8Km"<br>
&gt; &nbsp; res@Footer = False<br>
&gt;<br>
&gt;<br>
&gt; &nbsp; pltres = True<br>
&gt; &nbsp; mpres = True<br>
&gt; &nbsp; mpres@mpOutlineOn = False<br>
&gt; &nbsp; mpres@mpGeophysicalLineColor = "Black"<br>
&gt; &nbsp; mpres@mpNationalLineColor &nbsp; &nbsp;= "Black"<br>
&gt; &nbsp; mpres@mpUSStateLineColor &nbsp; &nbsp; = "Black"<br>
&gt; &nbsp; mpres@mpGridLineColor &nbsp; &nbsp; &nbsp; &nbsp;= "Black"<br>
&gt; &nbsp; mpres@mpLimbLineColor &nbsp; &nbsp; &nbsp; &nbsp;= "Black"<br>
&gt; &nbsp; mpres@mpPerimLineColor &nbsp; &nbsp; &nbsp; = "Black"<br>
&gt; &nbsp; mpres@mpDataBaseVersion = "HighRes"<br>
&gt; &nbsp; mpres@mpGeophysicalLineThicknessF &nbsp;= 2<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<br>
&gt; &nbsp; a = addfiles(FILES+".nc","r")<br>
&gt;<br>
&gt; &nbsp; times = wrf_user_getvar(a,"times",-1) &nbsp;; get all times in the file<br>
&gt; &nbsp; ntimes = dimsizes(times) &nbsp; &nbsp; &nbsp; &nbsp; ; number of times in the file<br>
&gt;<br>
&gt;<br>
&gt; &nbsp; ; Get non-convective, convective and total precipitation<br>
&gt; &nbsp; rain_exp = wrf_user_getvar(a,"RAINNC",-1)<br>
&gt; &nbsp; rain_con = wrf_user_getvar(a,"RAINC",-1)<br>
&gt; &nbsp; rain_tot = rain_exp + rain_con<br>
&gt; &nbsp; rain_tot@description = "Precipitazioni accumulate (3h)"<br>
&gt;<br>
&gt; &nbsp; ; just creating new arrays here<br>
&gt; &nbsp; rain_exp_tend = rain_exp<br>
&gt; &nbsp; rain_con_tend = rain_con<br>
&gt; &nbsp; rain_tot_tend = rain_tot<br>
&gt; &nbsp; rain_exp_tend = 0.0<br>
&gt; &nbsp; rain_con_tend = 0.0<br>
&gt; &nbsp; rain_tot_tend = 0.0<br>
&gt; &nbsp; rain_exp_tend@description = "Explicit Precipitation Tendency"<br>
&gt; &nbsp; rain_con_tend@description = "Param &nbsp;Precipitation Tendency"<br>
&gt; &nbsp; rain_tot_tend@description = "Precipitazioni accumulate (3h)"<br>
&gt;<br>
&gt; &nbsp; ; Calculate tendency values<br>
&gt; &nbsp; ; We know our data is available every 3 hours, so setting tend_int to 1 gives<br>
&gt; &nbsp; ; tendencies for 3 hours, setting it to 2, gives 6hourly tendencies<br>
&gt; &nbsp; tend_int = 1<br>
&gt; &nbsp; rain_exp_tend(tend_int:ntimes-1:tend_int,:,:) = rain_exp(tend_int:ntimes-1:tend_int,:,:) - rain_exp(0:ntimes-2:tend_int,:,:)<br>
&gt; &nbsp; rain_con_tend(tend_int:ntimes-1:tend_int,:,:) = rain_con(tend_int:ntimes-1:tend_int,:,:) - rain_con(0:ntimes-2:tend_int,:,:)<br>
&gt; &nbsp; rain_tot_tend(tend_int:ntimes-1:tend_int,:,:) = rain_tot(tend_int:ntimes-1:tend_int,:,:) - rain_tot(0:ntimes-2:tend_int,:,:)<br>
&gt;<br>
&gt; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<br>
&gt;<br>
&gt; &nbsp; do it = tend_int,ntimes-1,tend_int &nbsp; &nbsp;; Let's skip the first time as rain is 0 here<br>
&gt;<br>
&gt; &nbsp; &nbsp; print("Working on time: " + times(it) )<br>
&gt; &nbsp; &nbsp; res@TimeLabel = times(it) &nbsp; ; Set Valid time to use on plots<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; &nbsp; ; Plotting options for Precipitation<br>
&gt; &nbsp; &nbsp; opts_r = res<br>
&gt; &nbsp; &nbsp; opts_r@UnitLabel &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;= "mm"<br>
&gt; &nbsp; &nbsp; opts_r@cnLevelSelectionMode = "ExplicitLevels"<br>
&gt; &nbsp; &nbsp; opts_r@cnLevels &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = (/ .5, 1, 2, 5, 10, 15, 20, \<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 30, 40, 50, 60, 80, 100, 120, 150, 200, 250/)<br>
&gt; &nbsp; &nbsp; opts_r@cnFillColors = (/"0", "116","103", \<br>
&gt; "93","83", \<br>
&gt; "75","58","38", \<br>
&gt; "28","08","02","ForestGreen","Green","Chartreuse","Yellow","208","224","235"/)<br>
&gt; &nbsp; &nbsp; opts_r@cnInfoLabelOn &nbsp; &nbsp; &nbsp; &nbsp;= False<br>
&gt; &nbsp; &nbsp; opts_r@cnConstFLabelOn &nbsp; &nbsp; &nbsp;= False<br>
&gt; &nbsp; &nbsp; opts_r@cnFillOn &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = True<br>
&gt; &nbsp; &nbsp; opts_r@pmLabelBarDisplayMode = "ForceAlways"<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; &nbsp; ; Precipitation Tendencies<br>
&gt; &nbsp; &nbsp; opts_r@SubFieldTitle = "da " + times(it-tend_int) + " a " + times(it)<br>
&gt;<br>
&gt; &nbsp; &nbsp; contour_tend = wrf_contour(a[it],wks, rain_tot_tend(it,:,:),opts_r) ; total (color)<br>
&gt; &nbsp; &nbsp; opts_r@cnFillOn = False<br>
&gt;<br>
&gt;<br>
&gt; &nbsp; &nbsp; delete(opts_r)<br>
&gt;<br>
&gt; &nbsp; &nbsp; pltres@PanelPlot = True<br>
&gt;<br>
&gt; &nbsp; ; MAKE PLOTS<br>
&gt;<br>
&gt;<br>
&gt; &nbsp; &nbsp; ; Total Precipitation Tendency + SLP<br>
&gt; &nbsp; &nbsp; &nbsp; plot = wrf_map_overlays(a[it],wks,contour_tend,pltres,mpres)<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; &nbsp; shp_filename = "ITA_adm2.shp"<br>
&gt; &nbsp; f = addfile(shp_filename, "r") ; Open shapefile<br>
&gt; ;---Read data off shapefile<br>
&gt; &nbsp; segments = f-&gt;segments<br>
&gt; &nbsp; geometry = f-&gt;geometry<br>
&gt; &nbsp; segsDims = dimsizes(segments)<br>
&gt; &nbsp; geomDims = dimsizes(geometry)<br>
&gt; ;---Read global attributes<br>
&gt; &nbsp; geom_segIndex = f@geom_segIndex<br>
&gt; &nbsp; geom_numSegs = f@geom_numSegs<br>
&gt; &nbsp; segs_xyzIndex = f@segs_xyzIndex<br>
&gt; &nbsp; segs_numPnts = f@segs_numPnts<br>
&gt; &nbsp; numFeatures = geomDims(0)<br>
&gt; &nbsp; lines = new(segsDims(0),graphic) ; array to hold polylines<br>
&gt; &nbsp; plres = True ; resources for polylines<br>
&gt; &nbsp; plres@gsLineColor = "black" ; Default is foreground color<br>
&gt; &nbsp; plres@gsLineThicknessF = 2.0 ; Default is 1<br>
&gt; ;---Add polylines to plot<br>
&gt; &nbsp; lon = f-&gt;x<br>
&gt; &nbsp; lat = f-&gt;y<br>
&gt; &nbsp; segNum = 0 ; Counter for adding polylines<br>
&gt; &nbsp; do i=0, numFeatures-1<br>
&gt; &nbsp; &nbsp; &nbsp;startSegment = geometry(i, geom_segIndex)<br>
&gt; &nbsp; &nbsp; &nbsp;numSegments = geometry(i, geom_numSegs)<br>
&gt; &nbsp; &nbsp; &nbsp;do seg=startSegment, startSegment+numSegments-1<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; startPT = segments(seg, segs_xyzIndex)<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; endPT = startPT + segments(seg, segs_numPnts) - 1<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; lines(segNum) = gsn_add_polyline(wks, plot, lon(startPT:endPT), \<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; lat(startPT:endPT), plres)<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; segNum = segNum + 1<br>
&gt; &nbsp; &nbsp; &nbsp;end do<br>
&gt; &nbsp; end do<br>
&gt; ;---Drawing the plot will draw the newly attached polylines.<br>
&gt; &nbsp;resP &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = True &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ; panel options<br>
&gt; &nbsp; &nbsp; resP@gsnMaximize &nbsp; &nbsp; &nbsp; &nbsp; = True &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ; maximize image<br>
&gt; draw(plot)<br>
&gt; &nbsp; frame(wks) ; Advanced frame.<br>
&gt;<br>
&gt; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<br>
&gt;<br>
&gt; &nbsp; end do &nbsp; &nbsp; &nbsp; &nbsp;; END OF TIME LOOP<br>
&gt;<br>
&gt; end<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; 2012/10/16 David Brown &lt;<a href="mailto:dbrown@ucar.edu">dbrown@ucar.edu</a>&gt;<br>
&gt; Hi Enrico,<br>
&gt; There is a not-yet-documented setting for pmLabelBarDisplayMode called "ForceAlways" that will cause the LabelBar to appear even if the contour field is constant. Let us know if this does not work.<br>
&gt; &nbsp;-dave<br>
&gt;<br>
&gt;<br>
&gt; On Oct 15, 2012, at 1:57 PM, Enrico Benso wrote:<br>
&gt;<br>
&gt; &gt;&gt; Hello,<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; I have a question about label bars.<br>
&gt; &gt;&gt; I use NCL to view my Wrf model output.<br>
&gt; &gt;&gt; When i try to display precipitations, and there si no rain in my small<br>
&gt; &gt;&gt; domain, I get a warning (constant scalar field).<br>
&gt; &gt;&gt; The problem is that in this case the label bar disappears, even if I<br>
&gt; &gt;&gt; set levels with Explicit Mode.<br>
&gt; &gt;&gt; Is there a way to avoid this?<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; Thank You!<br>
&gt; &gt; _______________________________________________<br>
&gt; &gt; ncl-talk mailing list<br>
&gt; &gt; List instructions, subscriber options, unsubscribe:<br>
&gt; &gt; <a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
&gt;<br>
&gt;<br>
<br>
<br></blockquote></div><br>
</blockquote></div><br></div></blockquote></div>
</blockquote></div><br></div></body></html>