[ncl-talk] Color filled contour disappears with contour_shade pattern

S Br sbr.climate at gmail.com
Fri May 3 08:11:59 MDT 2019


Hi Adam and Rick,
I have followed your suggestions and changed slightly here and there. I
could solve the issue.

Thank you.
SB

On Fri, May 3, 2019 at 7:15 AM S Br <sbr.climate at gmail.com> wrote:

> Hi Adam,
> It still doesn't work because I am using a regional domain. It shows the
> following error.
>
> warning:mpMinLonF is not a valid resource in correlation_NCL_contour at
> this time
> warning:mpMaxLonF is not a valid resource in correlation_NCL_contour at
> this time
> warning:mpMinLatF is not a valid resource in correlation_NCL_contour at
> this time
> warning:mpMaxLatF is not a valid resource in correlation_NCL_contour at
> this time
> warning:mpFillOn is not a valid resource in correlation_NCL_contour at
> this time
>
> Is there any other way, I can overlay the 2nd value with the patterns.
>
> Thank you.
> SB
>
> On Thu, May 2, 2019 at 7:43 PM Adam Phillips <asphilli at ucar.edu> wrote:
>
>> Hi SB,
>> The plot that is going to be overlaid cannot be created by calling
>> gsn_csn_contour_map. You should use gsn_csm_contour instead. So switch this:
>>   plot2 =  gsn_csm_contour_map(wks,rain,res)
>> with this:
>>   plot2 =  gsn_csm_contour(wks,rain,res)
>> Adam
>>
>>
>> On Thu, May 2, 2019 at 11:59 AM S Br <sbr.climate at gmail.com> wrote:
>>
>>> Hi Rick,
>>> You have correctly guessed my query. Now, I have checked that the new
>>> variable 'rain' is correctly defined with the value gt/lt .39/-.39 but I am
>>> still struggling to overlay this value with patterns with
>>> another gsn_csm_contour_map. I am copying here the last part of my program.
>>> Am I doing somewhere wrong? Else, do I need to send a second resources
>>> (res2) for the 2nd plot?
>>>
>>>    plot1 =  gsn_csm_contour_map(wks,rain,res)
>>>
>>>   res at cnMonoFillPattern = True
>>>   res at cnFillPattern = 12
>>>   rain = where(rain.lt. .39 .and. rain.gt. -.39, rain at _FillValue, rain)
>>>   plot2 =  gsn_csm_contour_map(wks,rain,res)
>>>   overlay(plot1,plot2)
>>>
>>>   draw(plot1)
>>>   frame(wks)
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> On Thu, May 2, 2019 at 6:03 PM Rick Brownrigg <brownrig at ucar.edu> wrote:
>>>
>>>>
>>>> So my (very limited) understanding from the code you sent, you drew a
>>>> color-filled contour plot of the variable "rain", which was a time slice of
>>>> the variable precip from the file. Then you intended to use gsn_csm_shade
>>>> to hachure regions where rain was gt/lt .39/-.39 ?
>>>>
>>>> This is speculation:
>>>>
>>>> i) draw your color-filled plot as before
>>>>
>>>> ii) mask out the rain variable for only the values you want:
>>>>
>>>>    rain = where(rain.lt. .39 .and. rain.gt. -.39, rain at _FillValue,
>>>> rain)
>>>>
>>>> iii) redraw the rain variable with gsn_csm_contour_map as before, but
>>>> using cnFillPatterns instead of color
>>>>
>>>> iv) overlay the two plots as in the coneff_14 example (this requires
>>>> you set res at gsnFrame = False and res at gsnDraw = False)
>>>>
>>>> HTH...
>>>> Rick
>>>>
>>>>
>>>>
>>>> On Thu, May 2, 2019 at 10:30 AM S Br <sbr.climate at gmail.com> wrote:
>>>>
>>>>> Hi Rick,
>>>>> Thanks for your reply but my region of interest cover a regional
>>>>> lat/lon domain, so I can't use gsn_csm_contour(). Instead, I am using
>>>>> gsn_csm_contour_map().
>>>>> Actually, my main objective is to draw a correlation plot with contour
>>>>> filled with color and then mark pattern to the region having significant
>>>>> correlation value (see the map attached).
>>>>> For example, I have calculated the threshold value of correlation to
>>>>> be significant is 0.39. So, I want to draw patterns over the filled contour
>>>>> for the region having the correlation value below -0.39 and above 0.39.
>>>>> 'gsn_contour_shade' is working fine for this but unfortunately, I
>>>>> can't use this with gsn_csm_contour_map()
>>>>>
>>>>> Is there any otherway to achieve this?
>>>>>
>>>>> Thanks.
>>>>> SB
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> On Thu, May 2, 2019 at 4:45 PM Rick Brownrigg <brownrig at ucar.edu>
>>>>> wrote:
>>>>>
>>>>>> The docs for gsn_contour_shade() state:
>>>>>>
>>>>>> You cannot mix and match color and shading with this routine. For an
>>>>>> example of drawing shaded and filled contours, see example
>>>>>> coneff_14.ncl <http://ncl.ucar.edu/Applications/coneff.shtml#ex14>.
>>>>>>
>>>>>> However, that example coneff_14 shows how to achieve the result via
>>>>>> two calls to gsn_csm_contour():
>>>>>>
>>>>>> http://ncl.ucar.edu/Applications/coneff.shtml#ex14
>>>>>>
>>>>>> Hope that helps...
>>>>>> Rick
>>>>>>
>>>>>> On Thu, May 2, 2019 at 5:39 AM S Br <sbr.climate at gmail.com> wrote:
>>>>>>
>>>>>>> Hi Users,
>>>>>>> I am trying to plot a contour map filled with color and then apply
>>>>>>> patterns to the values greater and smaller than the specified values using
>>>>>>> the function gsn_contour_shade(plot,0.5,3.0,opt)
>>>>>>>
>>>>>>> However, when I use the gsn_contour_shade and overlay, the contour
>>>>>>> filled with color disappears. I can only see the patterns without the
>>>>>>> filled contour. Please have a look at the attached image.
>>>>>>>  I am using NCL6.4.0 and my script is given below.
>>>>>>>
>>>>>>> Thank you, SB
>>>>>>>
>>>>>>> begin
>>>>>>>
>>>>>>>  in1 = addfile("precip.gpcp.mon.mean.nc","r")
>>>>>>>   rain=in1->precip(0,:,:)
>>>>>>>   printVarSummary(rain)
>>>>>>> ;************************************
>>>>>>> ;create plot
>>>>>>> ;************************************
>>>>>>>   wks = gsn_open_wks("pdf","overlay")             ; send graphics to
>>>>>>> PNG file
>>>>>>>   res                     = True
>>>>>>>   res at gsnDraw           = False         ; Don't draw plots
>>>>>>>   res at gsnFrame          = False         ; Don't advance frame
>>>>>>>   res at cnFillOn          = True          ; Turn on contour fill
>>>>>>>   res at cnLinesOn         = False         ; Turn off contour lines
>>>>>>>   res at cnFillPalette       = "MPL_YlOrRd"   ; set color map
>>>>>>>   res at tiMainString        = "Overlaying shaded contours on filled
>>>>>>> contours"
>>>>>>> ;  res at cnFillMode = "RasterFill"
>>>>>>>   res at cnLevelSelectionMode =  "ManualLevels"
>>>>>>>   res at cnMinLevelValF       = 0.0
>>>>>>>   res at cnMaxLevelValF       = 5.0
>>>>>>>   res at cnLevelSpacingF      = 0.5
>>>>>>>
>>>>>>> ;   res at gsnAddCyclic     = False
>>>>>>>    res at mpMinLatF    =   -10.0               ; only plot 30S to 30N
>>>>>>>    res at mpMaxLatF    =  54.0
>>>>>>>    res at mpMinLonF    = 30.0              ; only plot 30S to 30N
>>>>>>>    res at mpMaxLonF    = 100.0
>>>>>>>
>>>>>>>   plot = gsn_csm_contour_map(wks,rain,res)
>>>>>>>
>>>>>>>   opt = True
>>>>>>>   opt at gsnShadeFillType = "pattern"      ; pattern fill
>>>>>>>   opt at gsnShadeHigh = 2                  ; use pattern #2
>>>>>>>   opt at gsnShadeLow = 17                  ; use pattern #17
>>>>>>>   plot2 = gsn_contour_shade(plot,0.5,3.0,opt)
>>>>>>>   overlay(plot,plot2)
>>>>>>>
>>>>>>>   draw(plot)
>>>>>>>   frame(wks)
>>>>>>> end
>>>>>>> _______________________________________________
>>>>>>> ncl-talk mailing list
>>>>>>> ncl-talk at ucar.edu
>>>>>>> List instructions, subscriber options, unsubscribe:
>>>>>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>>>>>
>>>>>> _______________________________________________
>>> 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>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190503/30e27459/attachment.html>


More information about the ncl-talk mailing list