登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
本帖最后由 HDdd 于 2018-12-20 19:50 编辑
分享一下气候统计作业
begin neof = 3 latS = 0 latN = -60 lonL = 150 lonR = 260 ;******************************************* ; Read data ;******************************************* path = "/cygdrive/F/ncl/qhtj/" fi = "sst.mon.mean.nc" f = addfile(path+fi,"r") YYYYMM = cd_calendar( f->time, -1) ymStrt = 198701 ymLast = 201612 iStrt = ind(YYYYMM .eq. ymStrt) iLast = ind(YYYYMM .eq. ymLast) xx =f->sst(iStrt:iLast,{latS:latN},{lonL:lonR}) ;x = month_to_season(xx, "JJA") ;year = ispan(1987,2016,1) xx_avg = clmMonTLL(xx);计算逐月平均值 x = calcMonAnomTLL(xx, xx_avg);计算距平 ;******************************************* ; EOF ;******************************************* eof = eofunc_n_Wrap( x, neof, False, 0) eof_ts = eofunc_ts_n_Wrap( x, eof, False, 0) ;yyyymm = cd_calendar(eof_ts&time, -1) yyyymm = ispan(1,360,1)
printVarSummary(eof) printVarSummary(eof_ts) ;******************************************* ; plots ;******************************************* output = "/cygdrive/F/ncl/eof_hd1" wks =gsn_open_wks("png",output) ; send graphics to PNG file
plot = new(neof,graphic) ; create graphic array ;only needed if paneling res = True res@gsnDraw = False ; don't draw yet res@gsnFrame = False ; don't advance frame yet res@gsnAddCyclic = False ; data not cyclic res@cnFillPalette = "BlWhRe" ; choose colormap res@mpCenterLonF = 180. res@mpMinLatF = min(x&lat) res@mpMaxLatF = max(x&lat) res@mpMinLonF = min(x&lon) res@mpMaxLonF = max(x&lon) res@mpFillDrawOrder = "PostDraw" res@mpGeophysicalLineColor ="white" res@cnFillOn = True ; turn on color fill res@cnLinesOn = True ; True is default res@lbLabelBarOn = False ; turn off individual lb's symMinMaxPlt(eof, 16, False, res);contributed.ncl
; panel plot onlyresources resP = True ; modify the panel plot resP@gsnMaximize = True ; large format resP@gsnPanelLabelBar = True ; add common colorbar
resP@gsnPanelMainString = "EOF" do n=0,neof-1 res@gsnLeftString = "EOF "+(n+1) res@gsnRightString =sprintf("%5.1f", eof@pcvar(n)) +"%" plot(n) =gsn_csm_contour_map(wks,eof(n,:,:),res) end do gsn_panel(wks,plot,(/neof,1/),resP) ; draw all 'neof' as one plot
;******************************************* ; time series (principalcomponent) plot ;******************************************* eof_ts@long_name = "Amplitude"
rts = True rts@gsnDraw = False ; don't draw yet rts@gsnFrame = False ; don't advanceframe yet ;rts@gsnScale = True ; force textscaling
; these four resourcesallow the user to stretch the plot size, and ; decide exactly where onthe page to draw it.
rts@vpHeightF = 0.40 ; Changes the aspect ratio rts@vpWidthF = 0.85 rts@vpXF = 0.10 ; change startlocations rts@vpYF = 0.75 ; the plot
rts@gsnYRefLine = 0. ; reference line rts@gsnXYBarChart = True rts@gsnAboveYRefLineColor ="red" ; above refline fill red rts@gsnBelowYRefLineColor ="blue" ; below refline fill blue
; panel plot onlyresources rtsP = True ; modify the panel plot rtsP@gsnMaximize = True ; large format ;resP@gsnPanelMainString = "SCRIPPS: Pierce" rts@tmXBMode = "Explicit" rts@tmXBValues = (/37,97,157,217,277,337/) ;rts@tmXBValues =(/199001,199501,200001,200501,201001,201501/) rts@tmXBLabels =(/199001,199501,200001,200501,201001,201501/)
do n=0,neof-1 rts@gsnLeftString = "EOF "+(n+1) rts@gsnRightString =sprintf("%5.1f", eof@pcvar(n)) +"%" plot(n) = gsn_csm_xy(wks,yyyymm,eof_ts(n,:),rts) end do gsn_panel(wks,plot,(/neof,1/),rtsP) ; draw all 'neof' as one plot end
|