相关分析

用NCL很多年,确实方便,但是若让我信手写来一段程序漂亮地做个相关分析附带检验,还是要扒拉官网调教半天(方便个鬼啊)。所以决定以后常用的代码模板在此分享。满满干货,欢迎打赏!

Contour、Shaded、Lat-Lon、Scalar:

Code:

coe=escorc(index,sst_summer_dtrend(lat|:,lon|:,time|:))
coe!0="lat"
coe!1="lon"
coe&lat=sst_summer_dtrend&lat
coe&lon=sst_summer_dtrend&lon

coe_ttest=coe
coe_ttest=coe@_FillValue
dim_coe_ttest=dimsizes(coe_ttest)
do i=0,dim_coe_ttest(0)-1
    do j=0,dim_coe_ttest(1)-1
        n    = dimsizes(index) 
        df   = n-2         ; degree of freedom
        t    = coe(i,j)*sqrt((n-2)/(1-coe(i,j)^2))
        p    = student_t(t, df)
        psig = 0.05        ; test significance level: p>psig not significant; p

Figure:

相关分析_第1张图片
coe_sst.png

Contour、Shaded、Lat-Lon、Scalar+Vector:

Code:


uvwnd_coe_ttest=where(uwnd_coe_ttest.gt.vwnd_coe_ttest,uwnd_coe_ttest,vwnd_coe_ttest)
copy_VarCoords(vwnd_coe,uvwnd_coe_ttest)

;resWind
resWind=True
resWind@gsnFrame=False
resWind@gsnDraw=False
resWind@gsnAddCyclic=True
resWind@gsnSpreadColors      = True
resWind@lbLabelBarOn=False
resWind@vcRefMagnitudeF=0.8
resWind@vcRefLengthF=0.045
resWind@vcGlyphStyle="CurlyVector"
resWind@vcRefAnnoOrthogonalPosF=-1.0
resWind@vcMonoLineArrowColor    = False
resWind@vcLevelSelectionMode= "ExplicitLevels"
resWind@vcLevels= (/0.95/)
resWind@vcLevelColors= (/ "black","green"/)
resWind@vcMinDistanceF=0.02


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;plot
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
wks=gsn_open_wks("eps","./"+get_script_prefix_name)
plot=gsn_csm_contour_map(wks,sst_coe,res)
plot_shade=gsn_csm_contour(wks,sst_coe_ttest,resShade)
plot_ttest=gsn_contour_shade(plot_shade,0,0.95,opt)
plot_wind_ttest=gsn_csm_vector_scalar(wks,uwnd_coe(lat|:,lon|:),vwnd_coe(lat|:,lon|:),uvwnd_coe_ttest(lat|:,lon|:),resWind)
overlay(plot,plot_ttest)
overlay(plot,plot_wind_ttest)
draw(plot)
frame(wks)

Figure:

相关分析_第2张图片
coe_sst_uvwnd.png

你可能感兴趣的:(相关分析)