- 积分
- 978
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2012-11-21
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
在论坛参考了其他的脚本,想画回归分析和显著性检验的图,但是图形总是出错,
脚本如下:
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
;************************************************
begin
;time=27
;nx=144
;ny=72
;missing_value=-1.0E+30
lat = fspan(-88.75,88.75,72)
lon = fspan(1.25,358.75,144)
lat@units = "degrees_north"
lon@units = "degrees_east"
tf=addfile("hgt.fldmean.nc","r")
printVarSummary(tf)
x = tf->hgt(0:26,0,0,0)
x!0="time"
printVarSummary(x)
tf2=addfile("pre.lowpass.mean.nc","r")
printVarSummary(tf2)
y = tf2->precip(:,::-1,:)
y!0="time"
y!1="lat"
y!2="lon"
y&lat=lat
y&lon=lon
printVarSummary(y)
rc = regCoef(x,y(lat|:,lon|:,time|:))
;copyatt(rc,ts)
rc!0 = "lat" ; name dimensions
rc!1 = "lon"
rc&lat = y&lat ; assign coordinate values to named dimensions
rc&lon = y&lon
printVarSummary(rc) ; variable overview
tval = onedtond(rc@tval , dimsizes(rc)) ;t-statistic
df = onedtond(rc@nptxy, dimsizes(rc)) - 2 ;自由度
b = tval ; b must be same size as tval (and df)
b = 0.5
prob = betainc(df/(df+tval^2),df/2.0,b) ; prob(nlat,nlon)
;print(prob)
prob!0 = "lat" ; name dimensions
prob!1 = "lon"
prob&lat = y&lat ; assign coordinate values to named dimensions
prob&lon = y&lon
rc@long_name = "regression coefficient"
prob@long_name = "probability"
wks = gsn_open_wks("png","regression")
gsn_define_colormap(wks,"BlWhRe")
res = True
res@gsnDraw = False
res@gsnFrame = False
res@cnInfoLabelOn = False
res@cnFillOn = True
res@cnLineLabelsOn = False
res@gsnSpreadColors = True
res@lbLabelBarOn = False
res@tiMainString = ""
res@gsnRightString = ""
res@cnLevelSelectionMode = "ExplicitLevels"
res@cnMinLevelValF = -1.
res@cnMaxLevelValF = 1.
res@cnLevelSpacingF = 0.2
;res@mpCenterLonF = 180
;plot1 = gsn_csm_contour_map_ce(wks,rc,res)
plot1 = gsn_csm_contour_map(wks,rc,res)
res2 = res
res2@gsnDraw = False ; do not draw
res2@gsnFrame = False ; do not advance frame
res2@gsnMaximize = True
res2@cnMonoFillPattern = False
res2@cnLevelSelectionMode = "ExplicitLevels"
res2@cnLevels = (/b/) ;; set to significance level
res2@cnFillPatterns = (/3/)
;res2@gsnLeftString = ""
plot2 = gsn_csm_contour(wks,tval,res2)
opt = True
opt@gsnShadeFillType = "pattern" ; pattern fill
opt@gsnShadeLow = 17
opt@gsnShadeHigh = 17 ; use pattern #17
opt@gsnLeftString = " "
opt@gsnRightString = " "
opt@cnLinesOn = False ; turn off contour lines
opt@cnLineLabelsOn = False ; turn off contour line labels
plot2 = gsn_contour_shade(plot2,-2.0,2.0,opt)
overlay(plot1,plot2)
draw(plot1)
frame(wks)
end
|
-
|