美文网首页
相关分析

相关分析

作者: Rex_Diego | 来源:发表于2016-12-05 19:23 被阅读0次

用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<psig significant
        if ((.not.ismissing(p)).and.(p.le.psig)) then 
            coe_ttest(i,j)=1
        else
            coe_ttest(i,j)=0
        end if
    end do 
end do 
copy_VarCoords(coe,coe_ttest)
printMinMax(coe_ttest,False)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;resourse
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
res                      = True
res@cnFillOn             = True
res@cnLinesOn            = False
res@mpCenterLonF         = 180
res@gsnDraw              = False
res@gsnFrame             = False
res@mpMinLatF            = -20
res@mpMaxLatF            = 30
res@mpMinLonF            = 30
res@mpMaxLonF            = 130
res@cnLevelSelectionMode = "ExplicitLevels"
res@cnLevels             = fspan(-0.5,0.5,11)

;resShade
resShade=True
resShade@gsnFrame=False
resShade@gsnDraw=False
resShade@gsnSpreadColors      = True
resShade@mpCenterLonF = 180
resShade@cnFillOn=False
resShade@cnLinesOn=False
resShade@cnLineLabelsOn=False
resShade@cnInfoLabelOn=False
resShade@cnLevelSelectionMode="ExplicitLevels"
resShade@cnLevels=(/0,0.90,0.95/)

opt = True
opt@gsnShadeFillType = "pattern"      ; pattern fill
opt@gsnShadeHigh = 17                   ; use pattern #2 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;plot
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
wks=gsn_open_wks("eps","./"+get_script_prefix_name)
plot=gsn_csm_contour_map(wks,coe,res)
plot_shade=gsn_csm_contour(wks,coe_ttest,resShade)
plot_ttest=gsn_contour_shade(plot_shade,0,0.95,opt)
overlay(plot,plot_ttest)
draw(plot)
frame(wks)

Figure:

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:

coe_sst_uvwnd.png

相关文章

  • 白话统计学——相关分析

    白话统计学——相关分析R语言当中相关分析的结果分类资料的相关分析基于秩次的相关系数指标一致性评价相关分析当中P值的...

  • R相关性分析和相关性热图

    相关性分析 相关性分析是指对两个或多个具备相关性的变量元素进行分析,从而衡量两个变量因素的相关密切程度。相关性分析...

  • R语言进行相关性分析

    相关性分析 相关性分析是指对两个或多个具备相关性的变量元素进行分析,从而衡量两个变量因素的相关密切程度。相关性分析...

  • 使用R语言进行相关性分析热图的绘制

    相关性分析 相关性分析是指对两个或多个具备相关性的变量元素进行分析,从而衡量两个变量因素的相关密切程度。相关性分析...

  • 相关

    相关分析与回归分析是密不可分。 简单相关、偏相关、部分相关。 简单相关:皮尔逊相关。 工具:Excel、SPSS。...

  • 相关分析

    用NCL很多年,确实方便,但是若让我信手写来一段程序漂亮地做个相关分析附带检验,还是要扒拉官网调教半天(方便个鬼啊...

  • 相关分析

    相关分析,是表明因素之间相关程度的绝佳方法,比如被人津津乐道的 超市里啤酒和尿不湿的相关分析。 超市工作人员发现:...

  • 相关分析

    1 相关关系 相关关系指变量之间存在着非确定性依存关系。即当一个或一组变量每取一个值时,相应的另一个变量可能有多个...

  • 数据预处理_数据相关性分析

    相关性分析 1、相关性分析是指对多个具备相关关系的变量进行分析,从而衡量变量间的相关程度或密切程度 2、相关性可以...

  • 数据分析知识图谱- part2

    6.相关分析汇总 相关分析用于研究X和Y的关系情况,X、Y都为定量数据。 (1)简单相关分析是分析对两个变量之间的...

网友评论

      本文标题:相关分析

      本文链接:https://www.haomeiwen.com/subject/ufklmttx.html