[ncl-talk] gsn_contour_shade

Adam Phillips asphilli at ucar.edu
Fri Jul 20 12:48:46 MDT 2018


Hi Laura,
A few things to unpack and note here:
- Everything that gsn_contour_shade does behind the scenes can be done
within the individual resource list (in your case, your ores list). Just
something to keep in mind if gsn_contour_shade becomes too unwieldy.

- gsn_contour_shade expects the second input to be lower than the third. If
you want to shade between those two values, you should set gsnShadeMid as a
resource that's passed to gsn_contour_shade, and not
gsnShadeLow/gsnShadeHigh. For example:
opt = True
opt at gsnShadeFillType = "pattern" ; pattern fill
opt at gsnShadeMid = 2     ; use pattern #2
plot2 = gsn_contour_shade(plot2,248,268,opt)

I would think that doing this:
opt at gsnShadeHigh = 2     ; use pattern #2
opt at gsnShadeLow = 17             ; use pattern #17
plot2 = gsn_contour_shade(plot2,268,248,opt)
would result in all areas less that 268 (including below 248) being shaded
pattern #2, and all areas greater than 248 (including above 268) shaded
pattern #17. There's an obvious conflict there so I'm not sure what happens
between 248 and 268 without examining the code.

- To answer your question about line thickness: You are not setting the
contours in your ores resource list (although you are in your res resource
list), and therefore NCL is choosing the contours for your cloud top
temperatures. I would highly recommend setting the contours, and then
setting the line colors/thicknesses within your ores resource list (and
outside of gsn_contour_shade) like this:

ores at cnLevelSelectionMode = "ExplicitLevels"
ores at cnLevels = ispan(248,268,4)
ores at cnLineThicknessF = 1.8

if need be, you can set individual line colors that match up to the
cnLevels array set above:
ores at cnMonoLineColor = False
ores at cnLineColors =
(/"transparent","black","black","black","black","transparent"/) ; Set
248/268 contours to transparent; all others to black.

Hope that helps!
Adam

On Thu, Jul 19, 2018 at 7:33 PM Laura Fowler <laura at ucar.edu> wrote:

> Hi Adam:
>
> I really appreciate you looking at my script. Let me reply first to your
> last question regarding my call to gsn_csm_shade. The picture I attached to
> my last e-mail shows the cloud liquid water path on the top of which I want
> to overlay cloud-top temperatures.
>
> For the cloud liquid water path, I use:
>
> res at cnFillMode               = "RasterFill"
>
> res at cnFillOn                 = True
>
> res at cnLinesOn                = False
>
> I only want to overlay cloud-top temperatures in the range between 248K
> and 268K. To do this, and prior to my call the gsn_csm_shade, I set:
>
>
> ores at cnFillOn       = False
>
> ores at cnLinesOn      = False
>
> ores at cnLineLabelsOn = False
>
> to not have contour lines on the top of the shading. If I set cnLines to
> True, then I have contour lines on the top of the shading.
>
>
> About your question regarding my values of lowval and highval, I set
> lowval to 268 "so that  all areas less than that first contour will be
> shaded" as explained in the definition of lowval. Same for highval so that "all
> areas greater than that first contour will be shaded" as also explained in
> the definition.
>
> In other words, I was trying to replicate the function
> ColorShadeLeGeContour which is now deprecated. This is the reason I used
>
> plot2 = gsn_contour_shade(plot2,268,248,opt)
>
>
> instead of
>
>
> plot2 = gsn_contour_shade(plot2,248,268,opt)
>
> Hope this makes more sense although that did not solve the issue about the line thickness.
>
>
> Cheers,
>
> Laura
>
>
>
>
>
>
>
>
>
> On Thu, Jul 19, 2018 at 4:02 PM, Adam Phillips <asphilli at ucar.edu> wrote:
>
>> Hi Laura,
>> Looking at your script, you are turning the lines off in your res and
>> ores resource list. gsn_contour_shade simply fills areas between existing
>> contour lines, it does not turn on certain lines nor alter their thickness.
>> If you could elaborate a bit on what you're trying to do that would be
>> helpful.
>>
>> Note: You are setting this in gsn_contour_shade:
>> plot2 = gsn_contour_shade(plot2,268,248,opt)
>> The 2nd input in this function represents the low value, beneath which
>> the first contour and all contours less than this value should be shaded.
>> The 3rd option represents the high value, above or equal to which the first
>> contour and all contours greater than this value will be shaded. (This
>> function does not necessarily shade between exact values .) I think you
>> want to reverse those two inputs here.
>> Adam
>>
>> On Thu, Jul 19, 2018 at 2:09 PM Laura Fowler <laura at ucar.edu> wrote:
>>
>>> Adam and Rick:
>>>
>>> I had tried Adam's suggestion earlier
>>>
>>> ores at cnMonoLineThickness = True
>>>
>>> ores at cnLineThicknessF    = 3.0
>>>
>>> but that did not work. Rick's suggestion did not work either:
>>>
>>> ores at gsnContourLineThicknessesScale = 2.0
>>>
>>>
>>> May be we just can't do this with gsn_csm_shade after all. I also tried
>>> to include them in the opt option used in the call to gsn_csm_shade, but
>>> that did not work either.
>>>
>>>
>>> Many thanks,
>>> Laura
>>>
>>>
>>> On Thu, Jul 19, 2018 at 1:55 PM, Adam Phillips <asphilli at ucar.edu>
>>> wrote:
>>>
>>>> Hi Laura,
>>>> Rick's suggestion should work. Alternatively you can set
>>>> cnLineThicknessF (to say, 2.0) within your ores resource list. Even though
>>>> it won't be used in the initial plot call, it will still be used when
>>>> gsn_contour_shade is called..
>>>> Adam
>>>>
>>>> On Thu, Jul 19, 2018 at 1:51 PM Rick Brownrigg <brownrig at ucar.edu>
>>>> wrote:
>>>>
>>>>> Hi Laura,
>>>>>
>>>>> I don't know with certainty that this works, but you might try:
>>>>>
>>>>> *gsnContourLineThicknessesScale* This resource, recognized by any gsn
>>>>> contour <http://ncl.ucar.edu/Document/Graphics/Interfaces/#Contours>
>>>>> drawing routine, allows you to set line thickness scale factors for all
>>>>> contour lines. For example, aq value of 2.0 will make the lines twice as
>>>>> thick. If this is set to an array that is not large enough to handle all
>>>>> contour lines, then the default value of 1.0 will be used for the remaining
>>>>> contour lines.
>>>>>
>>>>> On Thu, Jul 19, 2018 at 12:47 PM, Laura Fowler <laura at ucar.edu> wrote:
>>>>>
>>>>>> Hi Adam:
>>>>>> Thanks for your help. Now it did work (see attached plot). Is there a
>>>>>> way by chance to increase the thickness of the individual lines? Looking at
>>>>>> the documentation on gsm_csm_shade, it does not seem to be an option,
>>>>>> except that of increasing the density of lines?
>>>>>>
>>>>>> Thanks,
>>>>>> Laura
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Thu, Jul 19, 2018 at 12:12 PM, Adam Phillips <asphilli at ucar.edu>
>>>>>> wrote:
>>>>>>
>>>>>>> Hi Laura,
>>>>>>> Try adding:
>>>>>>> ores at cnLineLabelsOn = False
>>>>>>> Adam
>>>>>>>
>>>>>>> On Thu, Jul 19, 2018 at 12:09 PM Laura Fowler <laura at ucar.edu>
>>>>>>> wrote:
>>>>>>>
>>>>>>>> Hi Adam:
>>>>>>>>
>>>>>>>> Thanks for your help. It did work after switching to
>>>>>>>> gsn_csm_contour. I followed your suggestion and added separate resources
>>>>>>>> for plot2 to remove the "mp" warning messages.
>>>>>>>>
>>>>>>>> Despite adding the following lines:
>>>>>>>>
>>>>>>>> ores at cnFillOn      = False
>>>>>>>>
>>>>>>>> ores at cnLinesOn     = False
>>>>>>>>
>>>>>>>> ores at cnLevelFlags  = "NoLine"
>>>>>>>>
>>>>>>>> ores at cnInfoLabelOn = False
>>>>>>>>
>>>>>>>> to my second (ores) set of ressources, I still get labels attached
>>>>>>>> to the shading. Which additional option do I need to add to remove those
>>>>>>>> extra labels so that the output looks like the one in overlay.ncl?
>>>>>>>>
>>>>>>>> Many thanks,
>>>>>>>> Laura
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> On Thu, Jul 19, 2018 at 11:39 AM, Adam Phillips <asphilli at ucar.edu>
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>>> Hi Laura,
>>>>>>>>> One can't overlay a plotting type with a map over another plotting
>>>>>>>>> class with a map. This should work:
>>>>>>>>> plot  = gsn_csm_contour_map(wks,lwpath_a(:,:,n),res)
>>>>>>>>> plot2 = gsn_csm_contour(wks,cldtopt_a(:,:,n),res)
>>>>>>>>> overlay(plot,plot2)
>>>>>>>>>
>>>>>>>>> You are getting the various mp* errors as you can't pass mp
>>>>>>>>> resources to a non-map plotting function, in this case gsn_csm_contour. You
>>>>>>>>> should be able to safely ignore those messages as everything will still
>>>>>>>>> work; NCL is just telling you it is ignoring some of your resources. If you
>>>>>>>>> would like to get rid of the messages though, I would recommend you create
>>>>>>>>> a new resource list, res2, for your cldtopt_a array that excludes mp
>>>>>>>>> resources.
>>>>>>>>> Hope that helps!
>>>>>>>>> Adam
>>>>>>>>>
>>>>>>>>> On Thu, Jul 19, 2018 at 11:33 AM Laura Fowler <laura at ucar.edu>
>>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>>> Hello:
>>>>>>>>>>
>>>>>>>>>> I am following the ncl script overlay_5.ncl to overlay shading
>>>>>>>>>> over a contour plot. see the script test3.ncl in
>>>>>>>>>>
>>>>>>>>>> /glade2/scratch2/laura/forNCL
>>>>>>>>>>
>>>>>>>>>> first, I plot the cloud liquid water path:
>>>>>>>>>>
>>>>>>>>>> plot  = gsn_csm_contour_map(wks,lwpath_a(:,:,n),res)
>>>>>>>>>>
>>>>>>>>>> then I would like to overlay shading of the cloud-top temperature
>>>>>>>>>> with shading for cloud-top temperatures less than 248 or greater than 268.
>>>>>>>>>>
>>>>>>>>>> When I use:
>>>>>>>>>>
>>>>>>>>>> plot2 = gsn_csm_contour_map(wks,cldtopt_a(:,:,n),res)
>>>>>>>>>>
>>>>>>>>>> I get the error message:
>>>>>>>>>>
>>>>>>>>>> fatal:NhlAddOverlay: plot class mapPlotClass cannot be overlay
>>>>>>>>>> plot member
>>>>>>>>>>
>>>>>>>>>> When I use gsn_csm_contour(wks,cldtopt_a(:,:,n),res)
>>>>>>>>>> then I get the messages:
>>>>>>>>>>
>>>>>>>>>> warning:mpProjection is not a valid resource in
>>>>>>>>>> test3.ceres_aqua.PO.dec2015_contour at this time
>>>>>>>>>>
>>>>>>>>>> warning:mpMinLonF is not a valid resource in
>>>>>>>>>> test3.ceres_aqua.PO.dec2015_contour at this time
>>>>>>>>>>
>>>>>>>>>> warning:mpMaxLonF is not a valid resource in
>>>>>>>>>> test3.ceres_aqua.PO.dec2015_contour at this time
>>>>>>>>>>
>>>>>>>>>> warning:mpMinLatF is not a valid resource in
>>>>>>>>>> test3.ceres_aqua.PO.dec2015_contour at this time
>>>>>>>>>>
>>>>>>>>>> warning:mpMaxLatF is not a valid resource in
>>>>>>>>>> test3.ceres_aqua.PO.dec2015_contour at this time
>>>>>>>>>>
>>>>>>>>>> warning:mpCenterLonF is not a valid resource in
>>>>>>>>>> test3.ceres_aqua.PO.dec2015_contour at this time
>>>>>>>>>>
>>>>>>>>>> warning:mpShapeMode is not a valid resource in
>>>>>>>>>> test3.ceres_aqua.PO.dec2015_contour at this time
>>>>>>>>>>
>>>>>>>>>> warning:mpDataBaseVersion is not a valid resource in
>>>>>>>>>> test3.ceres_aqua.PO.dec2015_contour at this time
>>>>>>>>>>
>>>>>>>>>> I am not sure what is going wrong, and would really like a
>>>>>>>>>> suggestion on how to fix this.
>>>>>>>>>>
>>>>>>>>>> Many thanks,
>>>>>>>>>> Laura
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>>>
>>>>>>>>>> !-------------------------------------------------------------------------------------------------------------
>>>>>>>>>> Laura D. Fowler
>>>>>>>>>>
>>>>>>>>>> Mesoscale and Microscale Meteorology Division (MMM)
>>>>>>>>>> National Center for Atmospheric Research
>>>>>>>>>> P.O. Box 3000, Boulder CO 80307-3000
>>>>>>>>>>
>>>>>>>>>> e-mail: laura at ucar.edu
>>>>>>>>>> phone: 303-497-1628
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> !-------------------------------------------------------------------------------------------------------------
>>>>>>>>>> _______________________________________________
>>>>>>>>>> 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>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>>
>>>>>>>> !-------------------------------------------------------------------------------------------------------------
>>>>>>>> Laura D. Fowler
>>>>>>>>
>>>>>>>> Mesoscale and Microscale Meteorology Division (MMM)
>>>>>>>> National Center for Atmospheric Research
>>>>>>>> P.O. Box 3000, Boulder CO 80307-3000
>>>>>>>>
>>>>>>>> e-mail: laura at ucar.edu
>>>>>>>> phone: 303-497-1628
>>>>>>>>
>>>>>>>>
>>>>>>>> !-------------------------------------------------------------------------------------------------------------
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> 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>
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>>
>>>>>> !-------------------------------------------------------------------------------------------------------------
>>>>>> Laura D. Fowler
>>>>>>
>>>>>> Mesoscale and Microscale Meteorology Division (MMM)
>>>>>> National Center for Atmospheric Research
>>>>>> P.O. Box 3000, Boulder CO 80307-3000
>>>>>>
>>>>>> e-mail: laura at ucar.edu
>>>>>> phone: 303-497-1628
>>>>>>
>>>>>>
>>>>>> !-------------------------------------------------------------------------------------------------------------
>>>>>>
>>>>>> _______________________________________________
>>>>>> 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>
>>>>
>>>
>>>
>>>
>>> --
>>>
>>> !-------------------------------------------------------------------------------------------------------------
>>> Laura D. Fowler
>>>
>>> Mesoscale and Microscale Meteorology Division (MMM)
>>> National Center for Atmospheric Research
>>> P.O. Box 3000, Boulder CO 80307-3000
>>>
>>> e-mail: laura at ucar.edu
>>> phone: 303-497-1628
>>>
>>>
>>> !-------------------------------------------------------------------------------------------------------------
>>>
>>
>>
>> --
>> 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>
>>
>
>
>
> --
>
> !-------------------------------------------------------------------------------------------------------------
> Laura D. Fowler
>
> Mesoscale and Microscale Meteorology Division (MMM)
> National Center for Atmospheric Research
> P.O. Box 3000, Boulder CO 80307-3000
>
> e-mail: laura at ucar.edu
> phone: 303-497-1628
>
>
> !-------------------------------------------------------------------------------------------------------------
>


-- 
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/20180720/314e192d/attachment.html>


More information about the ncl-talk mailing list