<div dir="ltr">Hi Sri,<div>I think the issue is that you are letting NCL create the contour levels (for plot2), as you are setting <span style="font-size:12.8px">res2@cnLevelSelectionMode = "ExplicitLevels" but you are </span>not setting res2@cnLevels. </div><div><div>gsn_contour_shade uses the existing contour levels to modify the plot, it does not add them itself. I would suggest doing this:</div></div><div><br></div><div>  stat_dispersion(probt,True)   ; Make sure your data has values less than  or equal to .05 that can be plotted</div><div>                                            ; <a href="https://www.ncl.ucar.edu/Document/Functions/Contributed/stat_dispersion.shtml">https://www.ncl.ucar.edu/Document/Functions/Contributed/stat_dispersion.shtml</a></div><div><br></div><div><span style="font-size:12.8px">  res2 = True                          </span><wbr style="font-size:12.8px"><span style="font-size:12.8px">  ; res2 probability plots</span><br style="font-size:12.8px"><span style="font-size:12.8px">  res2@gsnDraw             = False       ; Do not draw plot</span><br style="font-size:12.8px"><span style="font-size:12.8px">  res2@gsnFrame            = False       ; Do not advance frome</span><br style="font-size:12.8px"><span style="font-size:12.8px">  res2@cnLevelSelectionMode = "ExplicitLevels" ; set explicit cnlev</span><br style="font-size:12.8px"><span style="font-size:12.8px">  res2@cnLevels   = (/.05/)    ; only have 1 contour level</span><br style="font-size:12.8px"><span style="font-size:12.8px">  ;res2@cnFillPatterns = (/-1,17/) ; don't fill <0.95, stipple >=0.95</span><br style="font-size:12.8px"><span style="font-size:12.8px">  res@cnFillOn = True</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px">  res2@cnInfoLabelOn       = False</span><br style="font-size:12.8px"><span style="font-size:12.8px">  res2@cnLinesOn           = False       ; do not draw contour lines</span><br style="font-size:12.8px"><span style="font-size:12.8px">  res2@cnLineLabelsOn      = False       ; do not draw contour labels</span><br style="font-size:12.8px"><span style="font-size:12.8px">  res2@cnFillScaleF        = 0.6         ; add extra density</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px">  plot2 = gsn_csm_contour(wks,probt,</span><wbr style="font-size:12.8px"><span style="font-size:12.8px">res2)                         </span><wbr style="font-size:12.8px"><span style="font-size:12.8px">            ; add cyclic point</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px">  opt = True                    ; set up parameters for pattern fill</span><br style="font-size:12.8px"><span style="font-size:12.8px">  opt@gsnShadeFillType = "pattern"  ; specify pattern fill</span><br style="font-size:12.8px"><span style="font-size:12.8px">  opt@gsnShadeLow      = 17         ; stipple pattern</span><br style="font-size:12.8px"><span style="font-size:12.8px">  plot2   = gsn_contour_shade(plot2, 0.05, 3., opt) ; stipple all areas <= 0.05 contour</span><br style="font-size:12.8px"><span style="font-size:12.8px">  overlay (plot, plot2)</span><br style="font-size:12.8px"></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">or, more simply, do not even use gsn_contour_shade:</span></div><div><div>stat_dispersion(probt,True)   ; Make sure your data has values less than  or equal to .05 that can be plotted</div><div>                                            ; <a href="https://www.ncl.ucar.edu/Document/Functions/Contributed/stat_dispersion.shtml">https://www.ncl.ucar.edu/Document/Functions/Contributed/stat_dispersion.shtml</a></div></div><div><span style="font-size:12.8px">  res2 = True                          </span><wbr style="font-size:12.8px"><span style="font-size:12.8px">  ; res2 probability plots</span><br style="font-size:12.8px"><span style="font-size:12.8px">  res2@gsnDraw             = False       ; Do not draw plot</span><br style="font-size:12.8px"><span style="font-size:12.8px">  res2@gsnFrame            = False       ; Do not advance frome</span><br style="font-size:12.8px"><span style="font-size:12.8px">  res2@cnLevelSelectionMode = "ExplicitLevels" ; set explicit cnlev</span><br style="font-size:12.8px"><span style="font-size:12.8px">  res2@cnLevels   = (/.05/)    ; only have 1 contour level</span><br style="font-size:12.8px"><span style="font-size:12.8px">  res2@cnFillPatterns = (/17,-1/) ; don't fill <0.95, stipple >=0.95</span><br style="font-size:12.8px"><span style="font-size:12.8px">  res@cnFillOn = True</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px">  res2@cnInfoLabelOn       = False</span><br style="font-size:12.8px"><span style="font-size:12.8px">  res2@cnLinesOn           = False       ; do not draw contour lines</span><br style="font-size:12.8px"><span style="font-size:12.8px">  res2@cnLineLabelsOn      = False       ; do not draw contour labels</span><br style="font-size:12.8px"><span style="font-size:12.8px">  res2@cnFillScaleF        = 0.6         ; add extra density</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px">  plot2 = gsn_csm_contour(wks,probt,</span><wbr style="font-size:12.8px"><span style="font-size:12.8px">res2)                         </span><wbr style="font-size:12.8px"><span style="font-size:12.8px">            ; add cyclic point</span><br style="font-size:12.8px"></div><div><span style="font-size:12.8px">  </span><span style="font-size:12.8px">overlay (plot, plot2)</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Hope that helps. If you have any further questions please respond to the ncl-talk email list.</span></div><div><span style="font-size:12.8px">Adam</span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jan 17, 2018 at 1:18 PM, Sri Nandini via ncl-talk <span dir="ltr"><<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>Hello<br><br>I am trying to plot ttest values overlay onto the T2m differences, but it is not being plotted nor shaded region according to 95%confidence limits with ttest.<br>Below is the script, i would be grateful if someone could let me know of my omission or deletion in the resources plotting attributes.<br><br>;Use NCL's named dimensions to reorder in time.<br>;Calculate the temporal means and variances using the dim_avg and dim_variance functions.<br>;Specify a critical significance level to test the lag-one auto-correlation coefficient and determine the (temporal) number of equivalent sample sizes in each grid point using equiv_sample_size.<br>;Specify a critical significance level for the ttest and test if the means are different at each grid point. <br>; This file still has to be loaded manually<br>load "$NCARG_ROOT/lib/ncarg/<wbr>nclscripts/csm/shea_util.ncl"<br><br> yrStrt = 0000<br> yrLast = 0100<br>; ==============================<wbr>==============================<wbr>==<br>; Open the file: Read only the user specified period <br>; ==============================<wbr>==============================<wbr>==<br>f= addfile("T2M_C.nc", "r") ;Model Control<br>TIME   = f->time<br>  YYYY   = cd_calendar(TIME,-1)/100      <wbr>           ; entire file<br>  iYYYY  = ind(YYYY.ge.yrStrt .and. YYYY.le.yrLast)<br>T41    = f->TREFHT(iYYYY,:,:)<br>printVarSummary(T41)          <wbr>                      ; (time, lat,lon)<br>T4    = lonFlip(T41)<br>printVarSummary(T4)           <wbr>                     ; (time, lat,lon)<br>T4@_FillValue = -9.96921e+36  <br>aveX = dim_avg_n_Wrap(T4, 0)                   ;; average over the 0th dim<br>printVarSummary(aveX)         <wbr>                       ; (lat,lon) <br>varX = dim_variance_n_Wrap(T4,0)     <wbr>          ; compute variance<br>printVarSummary(varX)         <wbr>                       ; (lat,lon) <br>;=============================<wbr>==============================<wbr>===================<br><br>f2= addfile("T2M_CC.nc", "r") ;Current Caspian<br>TIME2  = f2->time<br>  YYYY2   = cd_calendar(TIME2,-1)/100     <wbr>            ; entire file<br>  iYYYY2  = ind(YYYY2.ge.yrStrt .and. YYYY2.le.yrLast)<br>air22   = f2->TREFHT(iYYYY2,:,:)<br>air2    = lonFlip(air22)<br>printVarSummary(air2)         <wbr>                       ; (time, lat,lon)<br>air2@_FillValue = -9.96921e+36                  <wbr>            <br>aveY = dim_avg_n_Wrap(air2,0)  ; average over the 0th dim<br>printVarSummary(aveY)         <wbr>                       ; (lat,lon) <br>varY = dim_variance_n_Wrap(air2,0) ; compute variance<br>printVarSummary(varY)         <wbr>                       ; (lat,lon) <br>;=============================<wbr>==============================<wbr>=====================<br>;Use "ttest" to compute the probabilities<br>;=============================<wbr>==============================<wbr>======================<br><br>  sigr = 0.05                        ; critical sig lvl for r<br><br> xEqv = new(dimsizes(varY),typeof(<wbr>varY),varY@_FillValue)<br>printVarSummary(xEqv)         <wbr>                      ; (lat,lon) <br>  xEqv = equiv_sample_size (T4(lat|:,lon|:,time|:), sigr,0)   <br> copy_VarMeta(varY,xEqv)<br>printVarSummary(xEqv)         <wbr>                      ; (lat,lon) <br><br> yEqv = new(dimsizes(varY),typeof(<wbr>varY),varY@_FillValue)<br>printVarSummary(yEqv)         <wbr>                       ; (lat,lon) <br>  yEqv = equiv_sample_size (air2(lat|:,lon|:,time|:), sigr,0)<br>copy_VarMeta(varY,yEqv)<br>printVarSummary(yEqv)         <wbr>                       ; (lat,lon) <br>                   <br>;=============================<wbr>==============================<wbr>=======================<br> probt = new(dimsizes(varY),typeof(<wbr>varY),varY@_FillValue)<br><br> probt = ttest(aveY,varY,xEqv,aveX,<wbr>varX,yEqv,True,False) ; values are between 0 and 1<br><br>;probt = 100.*(1. -ttest(aveY,varY,xEqv,aveX,<wbr>varX,yEqv,True,False)) ; all areas whose value > 95 are significant<br>printVarSummary(probt)        <wbr>        ; (lat,lon) <br>copy_VarMeta(varY,probt)<br>printVarSummary(probt)        <wbr>        ; (lat,lon) <br>print(probt)                   ;check to make sure values are between 0 and 1.<br>;=============================<wbr>==============================<wbr>=<br>;calculate the T2M difference <br>;=============================<wbr>==============================<wbr>= <br> T2diff = new(dimsizes(aveY),typeof(<wbr>aveY),aveY@_FillValue)<br>printVarSummary(T2diff)       <wbr>                          <br>copy_VarMeta(aveY,T2diff)<br>printVarSummary(T2diff)       <wbr>                          <br>T2diff=aveY-aveX<br>   printVarSummary(T2diff)       <wbr>                         ; (lat,lon) <br>;=============================<wbr>==============================<wbr>=========<br>;Here is a section of my code that draws a color fill plot, and then<br>;overlays contours of statistical significance.<br>;=============================<wbr>==============================<wbr>=========<br>   wks = gsn_open_wks("pdf","T2M_ttest"<wbr>)<br>   gsn_define_colormap(wks,"<wbr>BlWhRe")<br><br>  res = True<br>  res@cnFillOn             = True                ; turn on color<br>  res@gsnSpreadColors      = True                ; use full colormap<br><br>  res@cnLinesOn            = False               ; turn off contour lines<br>  res@cnLevelSelectionMode = "ManualLevels"  ; set manual contour levels<br>  res@cnMinLevelValF       = -2.             ; set min contour level<br>  res@cnMaxLevelValF       =  2.             ; set max contour level<br>  res@cnLevelSpacingF      =  0.2            ; set contour spacing<br><br>  res@gsnDraw              = False           ; Do not draw plot<br>  res@gsnFrame             = False           ; Do not advance frome<br><br>  res@tiMainString         = "T2M Difference: 50yrs overlay with ttest"<br>  res@gsnCenterString      = "5% stippled"<br>  res@gsnLeftString        = "K"<br><br>   res@cnRasterModeOn            <wbr>  = True              ; Raster mode shows grid cells<br>   plot = gsn_csm_contour_map_ce(wks,<wbr>T2diff,res)  <br>   plot = ZeroNegDashLineContour (plot)<br><br>  res2 = True                          <wbr>  ; res2 probability plots<br>  res2@gsnDraw             = False       ; Do not draw plot<br>  res2@gsnFrame            = False       ; Do not advance frome<br>  res2@cnLevelSelectionMode = "ExplicitLevels" ; set explicit cnlev<br>  ;res2@cnLevels   = (/.95/)    ; only have 1 contour level<br>  ;res2@cnFillPatterns = (/-1,17/) ; don't fill <0.95, stipple >=0.95<br>  res@cnFillOn = False<br><br>  res2@cnInfoLabelOn       = False<br>  res2@cnLinesOn           = False       ; do not draw contour lines<br>  res2@cnLineLabelsOn      = False       ; do not draw contour labels<br>  res2@cnFillScaleF        = 0.6         ; add extra density<br><br>  plot2 = gsn_csm_contour(wks,probt,<wbr>res2)                         <wbr>            ; add cyclic point<br><br>  opt = True                    ; set up parameters for pattern fill<br>  opt@gsnShadeFillType = "pattern"  ; specify pattern fill<br>  opt@gsnShadeLow      = 17         ; stipple pattern<br>  plot2   = gsn_contour_shade(plot2, 0.091, 3., opt) ; stipple all areas < 0.09 contour<br>  overlay (plot, plot2)<br><br>  draw (plot)<br>  frame(wks)<br></div>
<br>______________________________<wbr>_________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/<wbr>mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div><div><span><font color="#888888">Adam Phillips <br></font></span></div><span><font color="#888888">Associate Scientist,  </font></span><span><font color="#888888">Climate and Global Dynamics Laboratory, NCAR<br></font></span></div></div><div><span><font color="#888888"><a href="http://www.cgd.ucar.edu/staff/asphilli/" target="_blank">www.cgd.ucar.edu/staff/asphilli/</a>   </font></span><span><font color="#888888">303-497-1726 </font></span></div><span><font color="#888888"></font></span><div><div><span><font color="#888888"><br></font></span><div><span><font color="#888888"><a href="http://www.cgd.ucar.edu/staff/asphilli" target="_blank"></a></font></span></div></div></div></div></div></div></div></div></div></div></div>
</div>