爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 6899|回复: 4

[作图] 回归分析作图出错

[复制链接]
发表于 2015-6-15 15:22:20 | 显示全部楼层 |阅读模式

登录后查看更多精彩内容~

您需要 登录 才可以下载或查看,没有帐号?立即注册

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

regression.png
密码修改失败请联系微信:mofangbao
发表于 2015-12-10 11:26:24 | 显示全部楼层
同问,我做这种overlay也出现同样的问题??
密码修改失败请联系微信:mofangbao
发表于 2016-3-22 21:35:23 | 显示全部楼层
请问 LZ 解决问题没?
密码修改失败请联系微信:mofangbao
发表于 2016-4-6 21:07:59 | 显示全部楼层
楼主可以说一下是做的什么和什么的回归分析吗?你那个regCoef是具体怎么用的?
密码修改失败请联系微信:mofangbao
发表于 2016-4-22 12:52:56 | 显示全部楼层
是不是tval没有敬畏读的属性
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Copyright ©2011-2014 bbs.06climate.com All Rights Reserved.  Powered by Discuz! (京ICP-10201084)

本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论

快速回复 返回顶部 返回列表