Re: label bar labels and WRF contour

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Mon Nov 21 2011 - 12:59:24 MST

Dave,

I'm not sure what "lbUserLabels" is, but this isn't an official NCL resource. Did you mean lbLabelStrings?

I couldn't gunzip your file, so I was unable to run it.

When you use the default settings for filled contour plots, you will end up with a labelbar that has one more box than it has labels. This is because the contour levels represent the areas *between* two colors, and not exactly equal to the colors.

If you want to have your labels associated with a color in a box, then you have to set the lbLabelAlignment resource to "Box Centers" *and* you have to set lbLabelStrings to contain labels for every box.

You can see an example of this if you look at the second frame of example 14 at:

http://www.ncl.ucar.edu/Applications/labelbar.shtml#ex14

The problem, though, is the WRFUserARW.ncl script doesn't appear to recognize the "lbLabelStrings" resource, and hence it doesn't use it for labeling.

To fix this, I had to take the "wrf_contour" call, and replace it with a "gsn_csm_contour" call.

In a test script that I tried, here's what my original WRF code looked like:

      opts = ARWres
      opts@cnFillOn = True
      opts@lbLabelAlignment = "BoxCenters"
      opts@lbLabelStrings = "" + sprintf("%6.2f",(ispan(-20,95,5)-2.5))
      opts@ContourParameters = (/ -20., 90., 5./)
      opts@gsnSpreadColorEnd = -3 ; End third from the last color in color map

      contour_tc = wrf_contour(a,wks,tf2,opts)

Here's what I changed the code to:

      opts = ARWres
      opts@cnFillOn = True
      opts@lbLabelAlignment = "BoxCenters"
      opts@lbLabelStrings = "" + sprintf("%6.2f",(ispan(-20,95,5)-2.5))
      opts@gsnSpreadColorEnd = -3 ; End third from the last color in color map
      opts@lbOrientation = "Vertical"

;---These resources are set by wrf_contour
      opts@cnLevelSelectionMode = "ManualLevels"
      opts@cnMinLevelValF = -20.
      opts@cnMaxLevelValF = 90.
      opts@cnLevelSpacingF = 5.
      opts@gsnSpreadColors = True
      opts@gsnLeftString = ""
      opts@gsnRightString = ""
      opts@gsnDraw = False
      opts@gsnFrame = False

            contour_tc = gsn_csm_contour(wks,tf2,opts)

Note the extra resources I had to add. wrf_contour sets these for you automatically.

You have to be careful when you set lbLabelAlignment to BoxCenters. The contour levels *still* represent the values between box colors. So, you have to adjust the labels accordingly, which I did with:

      opts@lbLabelStrings = "" + sprintf("%6.2f",(ispan(-20,95,5)-2.5))

The labels are now -22.5, -17.5, etc, instead of -20, -15, etc.

I also made the labelbar vertical, so you could see the labels on every box without them running into each other.

I've attached the resultant plot.

--Mary

On Nov 17, 2011, at 11:22 AM, David B. Reusch wrote:

> Not sure if this is NCL or the WRF NCL scripts so you're both getting this email. I've been trying to create a soil category plot from geogrid data starting from the vegland_1 example on the NCL site. The problem I can't seem to resolve is that in my label bar I can either get (a) 16 number labels and 17 label boxes or (b) 15 number labels + "Label 15" and 16 label boxes (for my 16 category soil data). I've tried to follow this through the WRFUserARW.ncl code but have given up (after trying lots of variations...). Although I am providing a lbUserLabels all the way through (as far as I can tell), this seems to be being ignored at some level I haven't nailed down.
>
> I have put the file dbr_wrf_plot_lb.tgz at the ftp incoming site. It has my script, my input file and an output file.
>
> Thanks,
> Dave Reusch
> --
> Associate Research Professor of Climatology
> Dept of Earth and Environmental Science
> MSEC 304; 801 Leroy Place
> New Mexico Tech
> Socorro, NM 87801
> _______________________________________________
> 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 Mon Nov 21 12:59:41 2011

This archive was generated by hypermail 2.1.8 : Tue Nov 22 2011 - 14:17:52 MST