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