[ncl-talk] Panel Label Bar

Adam Phillips asphilli at ucar.edu
Thu Aug 2 10:07:38 MDT 2018


Hi Melissa,
Please remember to always copy ncl-talk on any responses so that the group
can see them. In your offline reply you state that you want white to be
designated to the value of 0. Within your script you have this:
res at ContourParameters = (/0.0, max(qc_plane), 0.01 /) indicating a contour
spacing of 0.01, but the labelbar shows the contour spacing being 0.1. Are
you receiving any error messages? There is a limit to the number of
contours you can have (256 I believe), and I am wondering if you are
hitting it, and NCL is ignoring your input settings.

Getting back to your question, if you want values near 0.0 to be colored
white, and with ContourParameters not allowing you to explicitly select
levels that aren't separated by a constant value, there's limited options
here. The easiest suggestion I would make would be to not start your
contour levels at 0.;  start them at 0.01 (as you seem to want a contour
interval of 0.01). This would result in all values less than 0.01 being
shaded white. Thus:
res at ContourParameters = (/0.01,2.55, 0.01 /)

Alternatively, if you want only values exactly = 0.0 to be white, then the
best method might be to set all values = 0 to _FillValue (as cells set to
_FillValue will be shaded white by default). You can accomplish this using
a where statement:
qc_plane = where(qc_plane.eq.0, qc_plane at _FillValue,qc_plane)
and then you can set your contour levels to whatever you want, and
eliminate white from your colormap as I referenced in my last email (and
Barry sent a coding example about).

If the above does not help, let ncl-talk know.
Adam

On Thu, Aug 2, 2018 at 4:26 AM Barry Lynn <barry.h.lynn at gmail.com> wrote:

> Here's an example.
>
>   cmap := read_colormap_file("NCV_rainbow2")
>
>   cmap := cmap(50:, :)
>
>   cmap(0,:) = 1.   ; Make first color white
>
>   opts_Prec at cnFillPalette     = cmap         ; set color map
>
>
> On Thu, Aug 2, 2018 at 7:52 AM Adam Phillips <asphilli at ucar.edu> wrote:
>
>> Hi Melissa,
>> If all you want is white to not be the first color in your labelbar, you
>> can read in your colormap using read_colormap_file, and then specify a
>> subset of the colormap (eliminating white) in cnFillPalette. See example #8
>> here:
>> http://www.ncl.ucar.edu/Applications/rgbacolor.shtml#ex8
>>
>> Hope that helps. If not or if you have further questions please respond
>> to the ncl-talk email list.
>> Adam
>>
>> On Tue, Jul 31, 2018 at 4:06 PM MELISSA KAZEMI RAD <
>> mk1369 at scarletmail.rutgers.edu> wrote:
>>
>>> Hi,
>>>
>>> I'm trying to create a panel contour plot of cloud liquid water, and I
>>> particularly want to have as many contour levels as possible, i.e. I need
>>> to be able to show the smallest amount of cloud water. In order to do so,
>>> I've set:
>>> res at ContourParameters = (/0.0, max(qc_plane), 0.01 /)
>>>
>>> However, the plots that I get don't have any designated color for 0
>>> value.
>>> I use a similar code to produce one such plot (instead of a panel plot),
>>> and it works fine, in the sense that I can divide the panel bar to the
>>> number of contour levels.
>>>
>>> Here is my NCL code and the plot that I get: (NCL.6.4.0)
>>>
>>>     type = "png"
>>>
>>>    wks = gsn_open_wks(type,"Cloud_panel")
>>>
>>>    times  = wrf_user_list_times(a)
>>>    time = 166
>>>
>>>     p    = wrf_user_getvar(a, "pressure", time)    ; Total Pressure
>>>     z    = wrf_user_getvar(a,"z",time)
>>>     qc   = wrf_user_getvar(a,"QCLOUD", time)
>>>
>>>     qc       = qc*1000.
>>>     qc at units = "g/kg"
>>>
>>>     res                          = True
>>>     res at NoHeaderFooter           = True
>>>
>>>     pltres                  = True
>>>     pltres at PanelPlot        = True
>>>     mpres                   = True
>>>
>>>   ; Generate Contours
>>>
>>>     height_levels = (/750., 1000., 1200, 1400./)   ; heigth levels to
>>> plot
>>>     nlevels         = dimsizes(height_levels)     ; number of height
>>> levels
>>>     nplots     = 4
>>>     plots      = new(nplots,"graphic")
>>>     iplot      = 0
>>>
>>>     do level  = 0,nlevels-1
>>>        res at cnFillOn            = True
>>>        res at cnFillPalette       = "WhViBlGrYeOrRe"
>>>        res at lbLabelBarOn        = False
>>>        res at cnLinesOn           = False
>>>        res at cnLevelSpacingF     = 0.1
>>>
>>>        height = height_levels(level)
>>>        qc_plane = wrf_user_intrp3d(qc,z,"h",height,0.,False)
>>>
>>>        res at ContourParameters = (/0.0, max(qc_plane), 0.01 /)
>>>
>>>        contour = wrf_contour(a,wks,qc_plane,res)
>>>        pltres at CommonTitle      = True
>>>        pltres at PlotTitle        = height+"m"
>>>        plots(iplot) = wrf_map_overlays(a, wks, (/contour/), pltres,
>>> mpres)
>>>        delete(contour)
>>>        iplot = iplot + 1
>>>     end do
>>>
>>>   ; Panel the WRF Plots
>>>     pnlres                            = True
>>>     pnlres at txString                   = qc at description + "  (" +
>>> qc at units + ")"+ "at" + " at "+  times(time)
>>>     pnlres at gsnPanelYWhiteSpacePercent = 10       ; Add white space b/w
>>> plots.
>>>     pnlres at gsnPanelLabelBar           = True    ; Turn on common
>>> labelbar
>>>
>>>     pnlres at lbLabelAlignment           = "BoxCenters"
>>>     pnlres at lbLabelsOn           = True
>>>     pnlres at lbPerimOn            = False
>>>     pnlres at lbTitleOn            = False
>>>
>>>     pnlres at pmLabelBarWidthF           = 0.6
>>>
>>>     gsn_panel(wks,(/plots/),(/2,2/),pnlres)
>>>
>>> end
>>>
>>> --
>>> *Melissa Kazemi Rad*
>>> *Atmospheric Sciences Department*
>>> *Rutgers University*
>>> _______________________________________________
>>> ncl-talk mailing list
>>> ncl-talk at ucar.edu
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>
>>
>>
>> --
>> Adam Phillips
>> Associate Scientist,  Climate and Global Dynamics Laboratory, NCAR
>> www.cgd.ucar.edu/staff/asphilli/   303-497-1726
>>
>> <http://www.cgd.ucar.edu/staff/asphilli>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>
>
> --
> Barry H. Lynn, Ph.D
> Senior Associate Scientist, Lecturer,
> The Institute of the Earth Science,
> The Hebrew University of Jerusalem,
> Givat Ram, Jerusalem 91904, Israel
> Tel: 972 547 231 170
> Fax: (972)-25662581
>
> C.E.O, Weather It Is, LTD
> Weather and Climate Focus
> http://weather-it-is.com
> Jerusalem, Israel
> Local: 02 930 9525
> Cell: 054 7 231 170
> Int-IS: x972 2 930 9525
>
>

-- 
Adam Phillips
Associate Scientist,  Climate and Global Dynamics Laboratory, NCAR
www.cgd.ucar.edu/staff/asphilli/   303-497-1726

<http://www.cgd.ucar.edu/staff/asphilli>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180802/75ebe935/attachment.html>


More information about the ncl-talk mailing list