- 积分
- 105
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2013-3-8
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
NCL画图出现问题,向各位大神求助,跪谢!
以下是我的NCL脚本,资料是OLR以及气温的月均值数据,想把OLR以及气温随时间的距平变化图画到一张XY图上,想画1989-2013年每年1月的资料,运行总是报错。之前用这个程序画2013年1-12月OLR及气温随时间的距平变化图是可以画成功,但是想把每年9月份的数据挑出来然后画图就不行了,我在想是不是cd_inv_calendar这个函数是不是不能画间断时间的呀?请各位大神指教
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"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/skewt_func.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/wind_rose.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/time_axis_labels.ncl"
begin
minlat = 32
maxlat = 42
minlon = 110
maxlon = 120
minyr = 1980
maxyr = 2013
timerange = cd_inv_calendar((/minyr, maxyr/), (/1, 1/),(/1, 31/),(/0, 0/),(/0, 0/),(/0, 0/),"hours since 1-1-1 00:00:0.0", 0)
print(timerange)
yr = ispan(minyr,maxyr,1)
nyrs = dimsizes(yr)
print(nyrs)
one = new(nyrs, "integer") ;; create arrays of required size
one = 1 ; array syntax
zero = one ; create arrays of required size
zero = 0 ; array syntax
tt = cd_inv_calendar(yr,one,one,zero,zero,zero,"hours since 1-1-1 00:00:0.0", 0)
; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
f=addfile("/cygdrive/e/wangcd/air.mon.mean.nc","r")
print(f)
lat = f->lat
lon = f->lon
time = f->time({timerange(0) : timerange(1)})
air = dim_avg_n(short2flt(f->air({timerange(0) : timerange(1)}, {minlat : maxlat}, {minlon : maxlon})), (/1, 2/))
air_juping = dim_rmvmean(air)
printVarSummary(air_juping)
; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
f1=addfile("/cygdrive/e/wangcd/olr.mon.mean.nc","r")
print(f1)
timerange1 = cd_inv_calendar((/minyr, maxyr/), (/1, 1/),(/1, 31/),(/0, 0/),(/0, 0/),(/0, 0/),"hours since 1800-1-1 00:00:0.0", 0)
olr = dim_avg_n(short2flt(f1->olr({timerange1(0) : timerange1(1)}, {minlat : maxlat}, {minlon : maxlon})), (/1, 2/))
olr_juping = dim_rmvmean(olr)
printVarSummary(olr_juping)
; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
juping =new((/2,34/),float)
juping(0,:) =air_juping
juping(1,:) =olr_juping
; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
siglvl = 0.05
mxlag=0
ccr =esccr(air_juping,olr_juping,mxlag)
Nr = 34
prob =rtest(ccr,Nr,0)
yes_no = where(prob.lt.siglvl, True, False)
print(ccr+" "+prob+" "+yes_no)
;print(ccr)
;print(prob)
wtype = "png"
wks = gsn_open_wks(wtype,"huabeiTO1")
gsn_define_colormap(wks,"rainbow")
res = True
res@gsnFrame = False
restick = True
restick@ttmFormat = "%Y/%c"
time_axis_labels(time,res,restick)
res@trXMinF= timerange(0)
res@trXMaxF= timerange(1)
res@vpWidthF= 1.0
res@vpHeightF= 0.7
res@tmXBMode="Explicit"
res@xyLineColors = (/"blue","red"/)
res@gsnMaximize = True
res@tiMainString= "Variation of the air temperature and OLR in Huabei area "
;res@tiYAxisString= "T(degC)"
plot = gsn_csm_xy(wks,time,juping,res)
rc = regline(time, air_juping)
x = (/time(0), time(dimsizes(time) - 1)/)
yreg = rc * x + rc@yintercept
rc1 = regline(time, olr_juping)
x1 = (/time(0), time(dimsizes(time) - 1)/)
yreg1 = rc1 * x1 + rc1@yintercept
air_zero =new((/34/),"float")
do n =0,33
air_zero(n)=0
end do
lnres = True
lnres@gsLineThicknessF = 2.0
lnres@gsLineColor = "yellow"
gsn_polyline(wks,plot,x,yreg,lnres)
lnres1 = True
lnres1@gsLineThicknessF = 3.0
lnres1@gsLineColor = "green"
gsn_polyline(wks,plot,x,yreg1,lnres1)
gsn_polyline(wks,plot,time,air_zero,True)
legend = create "Legend" legendClass wks
"vpXF" : 0.26 ; orientation on page
"vpYF" : 0.17
"vpWidthF" : 0.5 ; width
"vpHeightF" : 0.1 ; height
"lgPerimOn" : False ; no perimeter
"lgItemCount" : 4 ; how many
"lgLineLabelStrings" : (/"Temperature","OLR","Tem trend","OLR trend"/) ; labels
"lgLabelsOn" : False ; no default lables
"lgLineLabelFontHeightF" : 0.015 ; font height
"lgDashIndexes" : (/0,1,0,1/) ; line paters
"lgLineColors" : (/"blue","red","yellow","green"/)
"lgMonoLineLabelFontColor" : True ; one label color
end create
draw(legend)
frame(wks)
end
|
|