- 积分
- 38
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2017-6-8
- 最后登录
- 1970-1-1
|
2金钱
我现在,正在计算画二氧化碳的3年的增长率的图,但是和官网的数据改了好多,结果还是报错,想请大神帮忙起个点睛之笔,能让我画出来增长率的图,包括年增长和四季增长率的图.,谢谢
begin
latS = -90
latN = 89
lonL = -180
lonR = 177.5
ymStrt = 0
ymLast = 14
;pltTitle = "Globe: "+(ymStrt/100)+"-"+(ymLast/100)
;=====addfiles=======
;------------------------------------------------------------
datadir ="/cmb/g6/zhangh/zhangshaohui/eryanghuatanzengzhanglv/nianfen/" ;加上明确路径
dataA = new((/3,180,360/),float)
B = new((/3,180,360/),float)
C =new((/3,180,360/),float)
D =new((/3,180,360/),float)
E =new((/3,180,360/),float)
YEARR=(/"2003","2004",“2005”/)
do i=0,2
f=addfile(datadir+"AIRS_Surface_CH4-"+YEARR(i)+".nc","r")
dataA(i,:,:)=f->Year
B(i,:,:)=f->DJF
C(i,:,:)=f->MAM
D(i,:,:)=f->JJA
E(i,:,:)=f->SON
;delete(f)
end do
printVarSummary(C)
;m = cd_calendar( m, -1) ;The values returned will be in the format YYYYMM and will be type double for option = 1, and type integer for option = -1.
;iStrt = ind(dataA.eq.ymStrt)
;iLast = ind(dataA.eq.ymLast)
;x = short2flt( sf(iStrt:iLast,{latS:latN},{lonL:lonR}) )
;printVarSummary(x) ; [time| 14]x[lat| 91]x[lon| 144]
;yyyymm = cd_calendar(x&time, -1)
;yyyy = yyyymm/100
;dimx = dimsizes(x)
;ntim = dimx(0) ; all years and months
;nlat = dimx(1)
;mlon = dimx(2)
year = ispan(0, 2, 1)
nyrs = dimsizes(year)
;Calculate the seansonal means
xDJF = B ; [year| 14]x[lat| 91]x[lon| 144]
printVarSummary(xDJF)
xMAM = C
xJJA = D
xSON = E
xDJF!0 = "year"
xMAM!0 = "year"
xJJA!0 = "year"
xSON!0 = "year"
xDJF&year = year
xMAM&year = year
;printVarSummary(xMAM)
xJJA&year = year
;printVarSummary(xJJA)
xSON&year = year
;printVarSummary(xSON)
;Calculate the regression coefficients (slopes)
rc1 = regCoef(year,xDJF(lat|:,lon|:,year|:))
rc1@long_name = "Trend"
rc1@units = xDJF@units+"/year"
copy_VarCoords(xDJF(0,:,:), rc1) ; copy lat,lon coords
printVarSummary(rc1)
rc2 = regCoef(year,xMAM(lat|:,lon|:,year|:))
rc2@long_name = "Trend"
rc2@units = xMAM@units+"/year"
copy_VarCoords(xMAM(0,:,:), rc2) ; copy lat,lon coords
;printVarSummary(rc2)
rc3 = regCoef(year,xJJA(lat|:,lon|:,year|:))
rc3@long_name = "Trend"
rc3@units = xJJA@units+"/year"
copy_VarCoords(xJJA(0,:,:), rc3) ; copy lat,lon coords
;printVarSummary(rc3)
rc4 = regCoef(year,xSON(lat|:,lon|:,year|:))
rc4@long_name = "Trend"
rc4@units = xSON@units+"/year"
copy_VarCoords(xSON(0,:,:), rc4) ; copy lat,lon coords
;printVarSummary(rc4)
; for illustration: change units to unit/period-used
;************************************************
;rc1 = rc1*nyrs ; (C/year)*(nyrs)
;rc1@units = "W m~S~-2/"+nyrs+"_year"
;rc2 = rc2*nyrs ; (C/year)*(nyrs)
;rc2@units = "W m~S~-2/"+nyrs+"_year"
;rc3 = rc3*nyrs ; (C/year)*(nyrs)
;rc3@units = "W m~S~-2/"+nyrs+"_year"
;rc4 = rc4*nyrs ; (C/year)*(nyrs)
;rc4@units = "W m~S~-2/"+nyrs+"_year"
; plotting parameters
;************************************************
wks = gsn_open_wks("eps","regress") ; send graphics to EPS file
gsn_define_colormap(wks,"BlueDarkRed18") ;"gui_default") ; choose colormap
plot = new(4,graphic)
res = True
;res@gsnMaximize = True ; make large
;=====gsn resources====
res@gsnDraw =False ;the individual plots are not drawn as they are created
res@gsnFrame =False ;suppress the automatic frame/page advance
res@lbLabelBarOn = False ;turn off single labelbar
res@cnInfoLabelOn = False ;important ;show or hide contour information
res@mpMaxLatF = 52.5
res@mpMinLatF = 4.5
res@mpMaxLonF = 134.5
res@mpMinLonF = 73.5
res@cnFillOn = True ; turn on color
res@cnLinesOn = False ; turn off contour lines
res@cnLineLabelsOn = False ; turn off contour line labels
;res@cnLevels=(/-32,-28,-24,-20,-16,-12,-8,-4,0,4,8,12,16,20,24/) ;WhViBlGrYeOrRe
;res@cnFillColors=(/2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17/)
;res@cnLevelSelectionMode = "ManualLevels" ; set manual contour levels
;res@cnMinLevelValF = -2.0 ; set min contour level
;res@cnMaxLevelValF = 2.0 ; set max contour level
;res@cnLevelSpacingF = 0.2 ; set contour interval
res@mpFillOn = False ; turn off default background gray
;res@mpCenterLonF = 180
;res@gsnCenterString = year(0)+"-"+year(nyrs-1)
;res@tiMainString = "20th Century Reanalysis: sig995" ; fili
;=====tm resources====
res@tmYLLabelFont = 25 ;Y left
res@tmYLLabelFontHeightF = 0.02
res@tmYLLabelFontThicknessF = 1.0
res@tmXBLabelFont = 25 ;X bottom
res@tmXBLabelFontHeightF = 0.02
res@tmXBLabelFontThicknessF = 1.0
;==========plot figure a===========
res@gsnStringFont = 25 ;0 represents pwritx_database ;1 default ;25 times-roman
res@gsnRightString= "W m~S~-2~N~/year"
res@gsnLeftString = "(a) sfc_net_sw_trend"
res@gsnLeftStringFontHeightF = 0.02
res@gsnRightStringFontHeightF = 0.02
res@tiMainString = "spring"
res@tiMainFont =25 ;0 writx ;1 default ;4 simplex_roman ;7 complex_roman ;125 o_times-roman ;0 is sanme to 7
res@tiMainFontHeightF = 0.025 ;different from gsnLeftStringFontHeightF
res@tiMainFontThicknessF = 1.25 ;Default = 1.0
res@tiMainOffsetYF = -0.015 ;move downward
res@gsnAddCyclic=False
plot(0) = gsn_csm_contour_map(wks,rc2,res)
;==========plot figure b===========
res@gsnStringFont = 25 ;0 represents pwritx_database ;1 default ;25 times-roman
res@gsnRightString= "W m~S~-2~N~/year"
res@gsnLeftString = "(b) sfc_net_sw_trend"
res@gsnLeftStringFontHeightF = 0.02
res@gsnRightStringFontHeightF = 0.02
res@tiMainString = "summer"
res@tiMainFont =25 ;0 writx ;1 default ;4 simplex_roman ;7 complex_roman ;125 o_times-roman ;0 is sanme to 7
res@tiMainFontHeightF = 0.025 ;different from gsnLeftStringFontHeightF
res@tiMainFontThicknessF = 1.25 ;Default = 1.0
res@tiMainOffsetYF = -0.015 ;move downward
res@gsnAddCyclic=False
plot(1) = gsn_csm_contour_map(wks,rc3,res)
;==========plot figure c===========
res@gsnStringFont = 25 ;0 represents pwritx_database ;1 default ;25 times-roman
res@gsnRightString= "W m~S~-2~N~/year"
res@gsnLeftString = "(c) sfc_net_sw_trend"
res@gsnLeftStringFontHeightF = 0.02
res@gsnRightStringFontHeightF = 0.02
res@tiMainString = "autumn"
res@tiMainFont =25 ;0 writx ;1 default ;4 simplex_roman ;7 complex_roman ;125 o_times-roman ;0 is sanme to 7
res@tiMainFontHeightF = 0.025 ;different from gsnLeftStringFontHeightF
res@tiMainFontThicknessF = 1.25 ;Default = 1.0
res@tiMainOffsetYF = -0.015 ;move downward
res@gsnAddCyclic=False
plot(2) = gsn_csm_contour_map(wks,rc4,res)
;==========plot figure d===========
res@gsnStringFont = 25 ;0 represents pwritx_database ;1 default ;25 times-roman
res@gsnRightString= "W m~S~-2~N~/year" ; unit
res@gsnLeftString = "(d) sfc_net_sw_trend"
res@gsnLeftStringFontHeightF = 0.02
res@gsnRightStringFontHeightF = 0.02
res@tiMainString = "winter"
res@tiMainFont =25 ;0 writx ;1 default ;4 simplex_roman ;7 complex_roman ;125 o_times-roman ;0 is sanme to 7
res@tiMainFontHeightF = 0.025 ;different from gsnLeftStringFontHeightF
res@tiMainFontThicknessF = 1.25 ;Default = 1.0
res@tiMainOffsetYF = -0.015 ;move downward
res@gsnAddCyclic=False
plot(3) = gsn_csm_contour_map(wks,rc1,res)
;===== creat pannel plot=====
resP = True
resP@gsnPanelLabelBar = True ; add common colorbar
resP@lbLabelStride = 2
resP@lbLabelAutoStride = False
resP@lbLabelFont = 25 ;"pwritx"
resP@lbAutoManage = False
resP@lbLabelFontHeightF = 0.015 ;labelbar test height
resP@lbLabelFontThicknessF = 1.0
resP@pmLabelBarOrthogonalPosF = 0.005 ;upward of labelkbar
resP@pmLabelBarWidthF = 0.5
gsn_panel(wks,plot,(/2,2/),resP)
;===== draw plot=====
draw(plot)
frame(wks)
end
|
|