<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title></title><style type="text/css">.felamimail-body-blockquote {margin: 5px 10px 0 3px;padding-left: 10px;border-left: 2px solid #000088;} </style></head><body>Hello and thank you<br><br>It still fails to overlay the ttest values plot onto the temperature difference plot.<br>I am using NCL 6.4.0 and the output from <br>aa=stat_dispersion(probt,True) ; Make sure your data has values less than or equal to .05 that can be plotted<br>print(aa) ; https://www.ncl.ucar.edu/Document/Functions/Contributed<br><br>Variable: aa<br>Type: float<br>Total Size: 120 bytes<br> 30 values<br>Number of Dimensions: 1<br>Dimensions and sizes: [30]<br>Coordinates: <br>Number Of Attributes: 3<br> _FillValue : -9.96921e+36<br> long_name : Robust Dispersion Statistics: Reference height temperature<br> units : K<br>(0) 0.858591<br>(1) 0.1372048<br>(2) 0.02715817<br>(3) 0.6629735<br>(4) 0.6921139<br>(5) 0.7334394<br>(6) 0.7922389<br>(7) 0.8389528<br>(8) 0.9062879<br>(9) 0.945545<br>(10) 0.9611294<br>(11) 0.9747813<br>(12) 0.9816338<br>(13) 0.9856359<br>(14) 1<br>(15) 0.9728418<br>(16) 7.090436<br>(17) 0.1372029<br>(18) 55296<br>(19) 55296<br>(20) 0<br>(21) 0<br>(22) 0.1603864<br>(23) 0.4063157<br>(24) 0.577707<br>(25) 0.9930354<br>(26) 0.9986112<br>(27) 0.9998707<br>(28) -1.52195<br>(29) 2.54508<br><br><br><br><br>On Jan 17, 2018 9:36:03 PM, Adam Phillips wrote:
<br><blockquote class="felamimail-body-blockquote"><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" target="_blank">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><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><span style="font-size:12.8px;">res2) </span><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" target="_blank">https://www.ncl.ucar.edu/Document/Functions/Contributed/stat_dispersion.shtml</a></div></div><div><span style="font-size:12.8px;"> res2 = True </span><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><span style="font-size:12.8px;">res2) </span><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="felamimail-body-blockquote" 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/nclscripts/csm/shea_util.ncl"<br><br> yrStrt = 0000<br> yrLast = 0100<br>; ==============================================================<br>; Open the file: Read only the user specified period <br>; ==============================================================<br>f= addfile("T2M_C.nc", "r") ;Model Control<br>TIME = f->time<br> YYYY = cd_calendar(TIME,-1)/100 ; entire file<br> iYYYY = ind(YYYY.ge.yrStrt .and. YYYY.le.yrLast)<br>T41 = f->TREFHT(iYYYY,:,:)<br>printVarSummary(T41) ; (time, lat,lon)<br>T4 = lonFlip(T41)<br>printVarSummary(T4) ; (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) ; (lat,lon) <br>varX = dim_variance_n_Wrap(T4,0) ; compute variance<br>printVarSummary(varX) ; (lat,lon) <br>;==============================================================================<br><br>f2= addfile("T2M_CC.nc", "r") ;Current Caspian<br>TIME2 = f2->time<br> YYYY2 = cd_calendar(TIME2,-1)/100 ; entire file<br> iYYYY2 = ind(YYYY2.ge.yrStrt .and. YYYY2.le.yrLast)<br>air22 = f2->TREFHT(iYYYY2,:,:)<br>air2 = lonFlip(air22)<br>printVarSummary(air2) ; (time, lat,lon)<br>air2@_FillValue = -9.96921e+36 <br>aveY = dim_avg_n_Wrap(air2,0) ; average over the 0th dim<br>printVarSummary(aveY) ; (lat,lon) <br>varY = dim_variance_n_Wrap(air2,0) ; compute variance<br>printVarSummary(varY) ; (lat,lon) <br>;================================================================================<br>;Use "ttest" to compute the probabilities<br>;=================================================================================<br><br> sigr = 0.05 ; critical sig lvl for r<br><br> xEqv = new(dimsizes(varY),typeof(varY),varY@_FillValue)<br>printVarSummary(xEqv) ; (lat,lon) <br> xEqv = equiv_sample_size (T4(lat|:,lon|:,time|:), sigr,0) <br> copy_VarMeta(varY,xEqv)<br>printVarSummary(xEqv) ; (lat,lon) <br><br> yEqv = new(dimsizes(varY),typeof(varY),varY@_FillValue)<br>printVarSummary(yEqv) ; (lat,lon) <br> yEqv = equiv_sample_size (air2(lat|:,lon|:,time|:), sigr,0)<br>copy_VarMeta(varY,yEqv)<br>printVarSummary(yEqv) ; (lat,lon) <br> <br>;==================================================================================<br> probt = new(dimsizes(varY),typeof(varY),varY@_FillValue)<br><br> probt = ttest(aveY,varY,xEqv,aveX,varX,yEqv,True,False) ; values are between 0 and 1<br><br>;probt = 100.*(1. -ttest(aveY,varY,xEqv,aveX,varX,yEqv,True,False)) ; all areas whose value > 95 are significant<br>printVarSummary(probt) ; (lat,lon) <br>copy_VarMeta(varY,probt)<br>printVarSummary(probt) ; (lat,lon) <br>print(probt) ;check to make sure values are between 0 and 1.<br>;============================================================<br>;calculate the T2M difference <br>;============================================================ <br> T2diff = new(dimsizes(aveY),typeof(aveY),aveY@_FillValue)<br>printVarSummary(T2diff) <br>copy_VarMeta(aveY,T2diff)<br>printVarSummary(T2diff) <br>T2diff=aveY-aveX<br> printVarSummary(T2diff) ; (lat,lon) <br>;====================================================================<br>;Here is a section of my code that draws a color fill plot, and then<br>;overlays contours of statistical significance.<br>;====================================================================<br> wks = gsn_open_wks("pdf","T2M_ttest")<br> gsn_define_colormap(wks,"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 = True ; Raster mode shows grid cells<br> plot = gsn_csm_contour_map_ce(wks,T2diff,res) <br> plot = ZeroNegDashLineContour (plot)<br><br> res2 = True ; 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,res2) ; 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>_______________________________________________<br>
ncl-talk mailing list<br><a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br><a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br><br></blockquote></div><br><br style="clear:both;"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div><div><span><span style="color:#888888;">Adam Phillips <br></span></span></div><span><span style="color:#888888;">Associate Scientist, </span></span><span><span style="color:#888888;">Climate and Global Dynamics Laboratory, NCAR<br></span></span></div></div><div><span><span style="color:#888888;"><a href="http://www.cgd.ucar.edu/staff/asphilli/" target="_blank">www.cgd.ucar.edu/staff/asphilli/</a> </span></span><span><span style="color:#888888;">303-497-1726 </span></span></div><span><span style="color:#888888;"></span></span><div><div><span><span style="color:#888888;"><br></span></span><div><span><span style="color:#888888;"><a href="http://www.cgd.ucar.edu/staff/asphilli" target="_blank"></a></span></span></div></div></div></div></div></div></div></div></div></div></div>
</div>
</blockquote><br></body></html>