begin ; specify file names (input&output, netCDF) pathin = "" ; directory fin1 = "File1.nc" ; input file name #1 fin2 = "File2.nc" ; input file name #2 ;fout = "signif_eraint_t2m_DJF" ; output file name ;foutnc = fout+".nc" ; open input files in1 = addfile(pathin+fin1,"r") in2 = addfile(pathin+fin2,"r") ; read data tmp1 = in1->rf tmp2 = in2->rf ; t-test xtmp = tmp1(lat|:,lon|:,time|:) ytmp = tmp2(lat|:,lon|:,time|:) ;xtmp = tmp1(latitude|:,longitude|:,time|:) ;ytmp = tmp2(latitude|:,longitude|:,time|:) Xave = dim_avg_Wrap(xtmp) Yave = dim_avg_Wrap(ytmp) Xvar = dim_variance(xtmp) Yvar = dim_variance(ytmp) Xs = dimsizes(tmp1(0,0,:)) Ys = dimsizes(tmp2(0,0,:)) iflag = False ; population variance similar tval_opt = False ; p-value only prob = ttest(Xave,Xvar,Xs,Yave,Yvar,Ys,iflag,tval_opt) pval = (/prob/) ; diff@long_name = "difference of the means" pval@long_name = "probability" ;----- ; plot ;----- printVarSummary(pval) ; judge significance siglvl = 0.05 ; sig = pval ndim = dimsizes(pval) nlat = ndim(0) nlon = ndim(1) ; do j=0,nlat-1 ; do i=0,nlon-1 ; if (.not.ismissing(pval(j,i))) then ; if (pval(j,i).lt.siglvl) then ; sig(j,i) = 1. ; else ; sig(j,i) = 0. ; end if ; end if ;; end do ; end do sig = pval ; preallocate array w/metadata sig = where(pval.lt.siglvl,1,0) ;********************************* wks = gsn_open_wks("x11","test") res = True ; significance res@gsnDraw = False ; draw plot res@gsnFrame = False ; advance frome res@cnInfoLabelOn = False ; turn off info label res@cnLinesOn = False ; draw contour lines res@cnLineLabelsOn = False ; draw contour labels ; res@cnFillScaleF = 0.6 ; add extra density res@cnFillDotSizeF = 0.003 ; activate if gray shading for B&W plot res@cnFillOn = True res@cnFillMode = "RasterFill" ; res@cnFillColors = (/"transparent","transparent"/) ; choose one color for our single cn level res@cnLevelSelectionMode = "ExplicitLevels" ; set explicit contour levels res@cnLevels = 0.5 ; only set one level res@lbLabelBarOn = False res@tiMainString = "" ; title res@gsnCenterString = "" ; subtitle res@gsnLeftString = "" ; upper-left subtitle res@gsnRightString = "" ; upper-right subtitle plot = gsn_csm_contour(wks,sig,res) draw(plot) frame(wks) end