[ncl-talk] Significance plot or stippling not working

Adam Phillips asphilli at ucar.edu
Fri Jul 24 13:44:35 MDT 2015


Hi Ipshita,
I think you need to add some additional resources to your res2 resource
list to get stippling to be applied correctly. I took the graphics portion
of your script and read in some data I had here to test this. Try the
following:

  wks  = gsn_open_wks("png","June_sst_jjas_cor_prob")
  gsn_define_colormap(wks,"BlWhRe")              ; choose colormap

  res                      = True                ; make plot mods
  res at gsnDraw = False
  res at gsnFrame = False
  res at cnFillOn             = True                ; turn on color
  res at gsnSpreadColors      = True                ; use full colormap
  res at lbLabelAutoStride    = True         ; automatic lb label stride

  res at cnLinesOn            = False               ; turn off contour lines
  res at cnLevelSelectionMode = "ManualLevels" ; manually set cnlev
  res at cnMinLevelValF       = -1.                 ; min level
  res at cnMaxLevelValF       =  1.                 ; max level
  res at cnLevelSpacingF      = .1                  ; contour level spacing

  lag                      = 0
  res at tiMainString         = "June SST with JJAS rainfall"
  plotA = gsn_csm_contour_map_ce(wks,corr_june(:,:,0),res)

 ; Significance plot on top of correlation plot
 ;========================= PLOT 2 =========
  res2 = True                            ; res2 probability plots

  res2 at gsnDraw             = False       ; Do not draw plot
  res2 at gsnFrame            = False       ; Do not advance frome
  res2 at cnFillOn = True                   ; turn on color/pattern fill
  res2 at cnMonoFillPattern = False   ; allow different patterns
  res2 at cnMonoFillColor = True       ; only use one color (black)

  res2 at cnLevelSelectionMode = "ExplicitLevels" ; set explicit cnlev
  res2 at cnLevels   = (/.95/)    ; only have 1 contour level
  res2 at cnFillPatterns = (/-1,17/) ; don't fill <0.95, stipple >=0.95

  res2 at gsnAddCyclic = True   ; may or may not be needed

  res2 at cnInfoLabelOn       = False       ; turn off info label

  res2 at cnLinesOn           = False       ; do not draw contour lines
  res2 at cnLineLabelsOn      = False    ; do not draw contour labels

  res2 at cnFillScaleF        = 0.5         ; add extra density

  printMinMax(prob_june,0)   ; check to make sure values are
                                             ; between 0 and 1.

  plot2   = gsn_csm_contour(wks,prob_june, res2)
  overlay (plotA, plot2)

  draw (plotA)
  frame(wks)
;-----------------------------------------

A few notes about what I added:
1 - I added gsnDraw/gsnFrame = False to both resource lists as you are
overlaying the two plots, and added a frame(wks) call at the end.

2 - cnFillOn must = True when color or pattern filling.
3 - If you are using more than one fill pattern you must set
cnMonoFillPattern = False.

For more pattern fill examples see examples 10 and 11 here:
http://www.ncl.ucar.edu/Applications/coneff.shtml#ex10

Hopefully that all makes sense.. If you have any further questions please
respond to the ncl-talk email list.
Adam



On Tue, Jul 21, 2015 at 10:17 PM, Ipshita Majhi <ipmajhi at alaska.edu> wrote:

> Dear NCL,
>
> I don't get any errors when I run this code, but the stippling does not
> show up. Could you guide me on this.
> Best Regards
> Ipshita
>
>
> ;This is for correlating JJAS monthly precp with JJAS temperature
>
> ;******************************************************
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
> ;*******************************************************
>
> ;=============================================
> ; Reading data
> ;=============================================
>
> a=addfile("~/Documents/SST/Monthly/sst.mnmean.v4.nc","r")
> JJAS
> =asciiread("~/Documents/SST/Monthly/jjas_1871_2012.txt",(/142,1/),"float")
>
>
> ;=============================================
> ;The dataset goes from 1854-2015
> sst=a->sst
> ; copy meta data and coordinate variables using contributed functions
>  copy_VarAtts(a,sst)
>  copy_VarCoords_1(a,sst)
> ;============================================
>
> ;Extracting 1871-2012 for SST
>  sst_1871_2012=sst(216:1908,:,:)
>
> copy_VarAtts(sst,sst_1891_2012)
> copy_VarCoords_1(a,sst_1891_2012)
>
> ;============================================
> ;Extracting 1871 to 2012 in JJAS rainfall
>
>
> June = new((/142,89,180/),float)
> June at _FillValue = -9.9621e+36
>
> Feb = new((/142,89,180/),float)
> Feb at _FillValue = -9.9621e+36
> ;==========================================
>
> ;Extracting SST for month of June
>
> do nyr=0,1692,12
>
> June(nyr/12,:,:)=sst_1871_2012(nyr+5,:,:)
> Feb(nyr/12,:,:)=sst_1871_2012(nyr+1,:,:)
> end do
>
> copy_VarAtts(sst_1871_2012,June)
> copy_VarCoords_1(sst_1871_2012,June)
>
> copy_VarAtts(sst_1871_2012,Feb)
> copy_VarCoords_1(sst_1871_2012,Feb)
>
> ;==========================================
> ;Calculating correlation
>
>
> e=transpose(JJAS)
>
> print(dimsizes(JJAS))
> June_reorder=June(lat|:,lon|:,time|:)
>
> copy_VarAtts(June,June_reorder)
> copy_VarCoords_1(June,June_reorder)
>
> corr_june=escorc(June_reorder,e)
>
> copy_VarAtts(June_reorder,corr_june)
> copy_VarCoords_1(June_reorder,corr_june)
>
>
> prob_june  = rtest(corr_june(:,:,0), 142,0)
> copy_VarAtts(June_reorder,prob_june)
> copy_VarCoords_1(June_reorder,prob_june)
> ;===========================================
>
> ; Now plotting the correlation
>
>
>   wks  = gsn_open_wks("pdf","June_sst_jjas_cor_prob")              ; open
> a ps plot
>   gsn_define_colormap(wks,"BlWhRe")              ; choose colormap
>
>   res                      = True                ; make plot mods
>
>   res at cnFillOn             = True                ; turn on color
>
> ;---These two resources not needed in NCL V6.1.0
>   res at gsnSpreadColors      = True                ; use full colormap
>
> ;---This resource defaults to True in NCL V6.1.0
>   res at lbLabelAutoStride    = True                ; automatic lb label
> stride
>
>   res at cnLinesOn            = False               ; turn off contour lines
>   res at cnLevelSelectionMode = "ManualLevels"      ; manually set cn levels
>   res at cnMinLevelValF       = -1.                 ; min level
>   res at cnMaxLevelValF       =  1.                 ; max level
>   res at cnLevelSpacingF      = .1                  ; contour level spacing
>
>   lag                      = 0
>   res at tiMainString         = "June SST with JJAS rainfall"
>   plotA = gsn_csm_contour_map_ce(wks,corr_june(:,:,lag),res)
>
>  ; Significance plot on top of correlation plot
>  ;
>
>  ; Significance plot on top of correlation plot
>  ;========================= PLOT 2 ==============================
>   res2 = True                            ; res2 probability plots
>
>   res2 at gsnDraw             = False       ; Do not draw plot
>   res2 at gsnFrame            = False       ; Do not advance frome
>
>   res2 at cnLevelSelectionMode = "ManualLevels" ; set manual contour levels
>   res2 at cnMinLevelValF      = 0.00        ; set min contour level
>   res2 at cnMaxLevelValF      = 1.05        ; set max contour level
>   res2 at cnLevelSpacingF     = 0.05        ; set contour spacing
>
>   res2 at cnInfoLabelOn       = False       ; turn off info label
>
>   res2 at cnLinesOn           = False       ; do not draw contour lines
>   res2 at cnLineLabelsOn      = False       ; do not draw contour labels
>
>   res2 at cnFillScaleF        = 0.6         ; add extra density
>
>
>   plot2   = gsn_csm_contour(wks,prob_june, res2)
>   ;plot2   = ShadeLtContour(plot2, 0.07, 17)  ; shade all areas less than
> the
>                                              ; 0.05 contour level
>   overlay (plotA, plot2)
>
>   draw (plotA)
> ;***************************************************************
>
> --
> Ipshita Majhi
> PhD Candidate
> University of Alaska , Fairbanks
> Atmospheric Science Department
> (907)978-4220 ipmajhi at alaska.edu
>
> _______________________________________________
> 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/20150724/0eba5764/attachment.html 


More information about the ncl-talk mailing list