Re: Help : gsn_contour_shade is not working for "ExplicitLevels" cnLevelSelectionMode

From: Adam Phillips <asphilli_at_nyahnyahspammersnyahnyah>
Date: Fri Sep 07 2012 - 20:35:46 MDT

Hi Li,
Our apologies for taking so long to get back to you on this issue. There
were a few things that had to be sorted out on our end, but after
investigating we believe that you found a graphical bug. This bug was
introduced post-version5.2.1, which is similar to what you reported in
your last email. The good news is that there is a work around available.
Set the following:
res@mpLimitMode = "latlon"
res@mpMinLatF = 0.01 ; normally for the NH polar stereo projection
this = 0.0. For bug work-around set = 0.1

alternatively you can set:
res@cnFillMode = "RasterFill"
res@cnRasterSmoothingOn = True

Always remember that when using gsn_contour_shade that the function only
color fills from existing contours. From the documentation:
Note: The shading will always begin at a contour, and not necessarily at
the specified/lowval/or/highval/. Check your plot to make sure that the
results are what you expected.

In your case I think you have things set up fine; you have contours set
at -.99 and .99, and you are specifying -.99 and .99 as the gsnShadeHigh
and gsnShadeLow inputs into gsn_contour_shade.

Finally for everyone's information, the graphical bug actually has
nothing to do with gsn_contour_shade.. It is a general NCL graphical bug.

If you still have problems with your script, please let ncl-talk know.
Good luck,
Adam

On 8/27/12 8:32 PM, heaven_bird334 wrote:
> Dear Mary,
> Thank you very much, you are right! Through adding add a draw
> and frame pair it works.
> res@gsnDraw <mailto:res@gsnDraw> = False
> res@gsnFrame <mailto:res@gsnFrame> = False
> .......
> draw(plot2)
> frame(wks)
> However, the output pic just shaded the high value part and NOT
> shaded the low value part(please see the attched t.png).
> I'm so sorry that I did not express my problems clear in
> previous letter.The other key problem of my scripts lies in that the
> NCL just shaded the lower value part of my pics. But, What I need is
> both the low part shaded in cold color (light blue) and low part
> shaded in warm color (light yellow).
> Actually, this is script is used to shaded the significant
> confidence in a correlation map. I seperate the significant area into
> 3 parts:
> 1) if below significant level (prob .gt. 0.05), then sig=0 (sig
> is the new varible for shaded).
> 2) if above significant level (prob .le. 0.05) .and. ccr .le. 0
> (ccr is correlation coefficient), then sig= -1.0 (sig is the new
> varible for shaded);
> 3) if above significant level (prob .le. 0.05) .and. ccr .ge. 0
> (ccr is correlation coefficient), then sig= 1.0 (sig is the new
> varible for shaded).
> I want to shade the correlation map into three parts:
> 1) sig=0,no shadeing;
> 2) sig=-1, light blue;
> 3) sig=1, light yellow.
> Into ncl codes, it like this:
> opt = True
> .......
> opt@cnInfoLabelOn <mailto:opt@cnInfoLabelOn> = True;False
> opt@gsnDraw <mailto:opt@gsnDraw> = False
> opt@gsnFrame <mailto:opt@gsnFrame> = False
> opt@gsnShadeHigh <mailto:opt@gsnShadeHigh> =
> 12 ; Use fill color #150 (yellow)
> opt@gsnShadeLow <mailto:opt@gsnShadeLow> =
> 7 ; You can use color indices or named
> colors.
> plot2 = gsn_contour_shade(plot2, -0.99,0.99, opt)
> draw(plot2)
> frame(wks)
> These script work well in early versions lower then 6.0.0. Now
> I'm using 6.0.0 (not 6.1.0-beta, because 6.1.0-beta seems not
> installed well in my computer Mac OS X Lion 10.7.4 x86_64) and these
> codes are not working well. So, I'm really a little puzzle about this
> problem.
> Best Regards,
> Li
>
> At 2012-08-28 01:26:47,"Mary Haley" <haley@ucar.edu> wrote:
>
> I think you just need to add a draw and frame call after
> gsn_contour_shade:
>
> draw(plot2)
> frame(wks)
>
> --Mary
>
> On Aug 25, 2012, at 7:59 PM, heaven_bird334 wrote:
>
>> Hi,
>> I met a strange problem that the "gsn_contour_shade" seems
>> not working for "ExplicitLevels" cnLevelSelectionMode. It seems
>> can not add the shaded area for coutours. I have attached the
>> script(t.nc), input data(t.nc) and ouput pic(t.png) behind this
>> email. And the following is the detailing infos:
>> @> ncl
>> <mailto:lxf@MacBook-4:/Users/lxf/work/back-iarc-pc/lxf/work/for2-dof-correlation[79]ncl>
>> -x t.ncl
>> Copyright (C) 1995-2011 - All Rights Reserved
>> University Corporation for Atmospheric Research
>> NCAR Command Language Version 6.0.0
>> The use of this software is governed by a License Agreement.
>> See http://www.ncl.ucar.edu/ for more details.
>> Loading file "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
>> +
>> Loading file "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
>> +
>> Loading file "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
>> +
>> Loading file "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
>> +
>> + begin
>> + f=addfile("t.nc","r")
>> + sig=f->sig ; Three values in this var, -1,0,1
>> + printVarSummary(sig)
>> +
>> + ;wks = gsn_open_wks("x11","t")
>> + & amp; nbsp; wks = gsn_open_wks("png","t")
>> + gsn_define_colormap(wks,"amwg_blueyellowred")
>> + res = True
>> + res@cnLineLabelBackgroundColor
>> <mailto:res@cnLineLabelBackgroundColor> = "white" ; white
>> bckgrnd around label
>> + res@gsnAddCyclic <mailto:res@gsnAddCyclic> = True
>> + res@gsnPolar <mailto:res@gsnPolar> = "NH" ; select
>> northern hemisphere
>> + res@mpCenterLonF <mailto:res@mpCenterLonF> = 0
>> +
>> + res@cnLineLabelsOn <mailto:res@cnLineLabelsOn> = True;
>> False ; turn on line labels
>> + res@cnFillOn <mailto:res@cnFillOn> ; = False
>> + res@cnLinesOn <mailto:res@cnLinesOn> = True; False
>> + res@cnLevelSelectionMode <mailto:res@cnLevelSelectionMode> =
>> "ExplicitLevels" ; set manual contour levels
>> + res@cnLevels <mailto:res@cnLevels> = (/-0.99,0.,0.99/)
>> + plot2 = gsn_csm_contour_map_polar(wks,sig(:,:),res)
>> + opt = True
>> + opt@cnInfoLabelOn <mailto:opt@cnInfoLabelOn> = True;False
>> + opt@gsnDraw <mailto:opt@gsnDraw> = False
>> + opt@gsnFrame <mailto:opt@gsnFrame> = False
>> + opt@gsnShadeHigh <mailto:opt@gsnS%0A%20hadeHig%20h> =
>> 12 ; Use fill color #150 (yellow)
>> + opt@gsnShadeLow <mailto:opt@gsnShadeLow> =
>> 7 ; You can use color indices or named
>> colors.
>> + plot2 = gsn_contour_shade(plot2, -0.99,0.99, opt) ; Shade
>> contours > -4 yellow, and shade contour
>> +
>> +
>> + end
>> Variable: sig
>> Type: float
>> Total Size: 21312 bytes
>> 5328 values
>> Number of Dimensions: 2
>> Dimensions and sizes: [lat | 37] x [lon | 144]
>> Coordinates:
>> lat: [ 0..90]
>> lon: [ 0..357.5]
>> Number Of Attributes: 4
>> units :
>> long_name : correlation
>> _FillValue : -99.99
>> missing_value : -99.99
>> Any suggestion or commont is thankworthy!
>> Best Regards,
>> Li
>>
>>
>> <t.nc><t.ncl><t.png>_______________________________________________
>> 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

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Sep 7 20:35:54 2012

This archive was generated by hypermail 2.1.8 : Tue Sep 11 2012 - 15:30:42 MDT