- 积分
- 1235
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2019-9-1
- 最后登录
- 1970-1-1
|
GrADS
系统平台: |
ncl,cdo |
问题截图: |
|
问题概况: |
1.利用ERA的月平均数据求91年到2018年的全球范围夏季平均EOF,采用ncl官网中第一个例子进行绘图,发现出来的图很奇怪,为什么南北极变化这么明显.烦请各位老师不吝赐教。附上自己的ncl脚本
2.自己利用CDO 处理所得的季平均数据与ncl里的month_to_season函数结果不同,为什么呢,附上自己的cdo处理夏季平均的语句:cdo -yearmean -selmon,6,7,8 /public/homel/ERA5/ERA5-10/500hpa/hebing500hpa_low1*1.nc 678mean.nc |
我看过提问的智慧: |
看过 |
自己思考时长(天): |
4 |
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
; ==============================================================
; eof_1.ncl
;
; Concepts illustrated:
; - Calculating EOFs
; - Drawing a time series plot
; - Using coordinate subscripting to read a specified geographical region
; - Rearranging longitude data to span -180 to 180
; - Calculating symmetric contour intervals
; - Drawing filled bars above and below a given reference line
; - Drawing subtitles at the top of a plot
; - Reordering an array
; ==============================================================
; NCL V6.4.0 has new functions eofunc_n_Wrap and
; eofunc_ts_n_Wrap that allow you to calculate the EOFs without
; first having to first reorder the data. See eof_1_640.ncl.
; ==============================================================
; Calculate EOFs of the Sea Level Pressure over the North Atlantic.
; ==============================================================
; The slp.mon.mean file can be downloaded from:
; http://www.esrl.noaa.gov/psd/dat ... alysis.surface.html
; ==============================================================
; These files are loaded by default in NCL V6.2.0 and newer
; 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
; ==============================================================
; User defined parameters that specify region of globe and
; ==============================================================
latS =-90.
latN = 90.
lonL = -180.
lonR = 180
yrStrt = 1992
yrLast = 2018
season = "JJA" ; choose Dec-Jan-Feb seasonal mean
neof = 3 ; number of EOFs
optEOF = True
optEOF@jopt = 0 ; This is the default; most commonly used; no need to specify.
;;optEOF@jopt = 1 ; **only** if the correlation EOF is desired
optETS = False
; ==============================================================
; Open the file: Read only the user specified period
; ==============================================================
f = addfile ("hebing500hpa_low1_1_98.nc", "r")
TIME = f->time
YYYY = cd_calendar(TIME,-1)/100 ; entire file
iYYYY = ind(YYYY.ge.yrStrt .and. YYYY.le.yrLast)
lp=f->z(:,0,:,:);进行了数组降维,自动变成(:,:,:)4维变3维
; printVarSummary(lp)
slp = lp(iYYYY,:,:)
printVarSummary(slp) ; variable overview
; ==============================================================
; dataset longitudes span 0=>357.5
; Because EOFs of the North Atlantic Oscillation are desired
; use the "lonFlip" (contributed.ncl) to reorder
; longitudes to span -180 to 177.5: facilitate coordinate subscripting
; ==============================================================
slp = lonFlip( slp )
printVarSummary(slp) ; note the longitude coord
; ==============================================================
; compute desired global seasonal mean: month_to_season (contributed.ncl)
; ==============================================================
SLP = month_to_season (slp, season);求了夏季平均
nyrs = dimsizes(SLP&time)
print(SLP)
; =================================================================
; create weights: sqrt(cos(lat)) [or sqrt(gw) ]
; =================================================================
rad = 4.*atan(1.)/180.
clat = f->lat
clat = sqrt( cos(rad*clat) )
printVarSummary(clat) ; gw for gaussian grid
;lat = tofloat(p&lat)
; =================================================================
; weight all observations
; =================================================================
wSLP = SLP ; copy meta data
wSLP = SLP*conform(SLP, doubletofloat(clat), 1)
wSLP@long_name = "Wgt: "+wSLP@long_name
; =================================================================
; Reorder (lat,lon,time) the *weighted* input data
; Access the area of interest via coordinate subscripting
; =================================================================
xw = wSLP({lat|latS:latN},{lon|lonL:lonR},time|:)
x = wSLP(time|:,{lat|latS:latN},{lon|lonL:lonR})
eof = eofunc_Wrap(xw, neof, optEOF)
eof_ts = eofunc_ts_Wrap (xw, eof, optETS)
printVarSummary( eof ) ; examine EOF variables
printVarSummary( eof_ts )
;print(SLP)
; =================================================================
; Normalize time series: Sum spatial weights over the area of used
; =================================================================
dimxw = dimsizes( xw )
mln = dimxw(1)
sumWgt = mln*sum( doubletofloat(clat({lat|latS:latN})) )
eof_ts = eof_ts/sumWgt
; =================================================================
; Extract the YYYYMM from the time coordinate
; associated with eof_ts [same as SLP&time]
; =================================================================
yyyymm = cd_calendar(eof_ts&time,-2)/100
;;yrfrac = yyyymm_to_yyyyfrac(yyyymm, 0.0); not used here
;============================================================
; PLOTS
;============================================================
wks = gsn_open_wks("png","eofncl") ; send graphics to PNG file
plot = new(neof,graphic) ; create graphic array
; only needed if paneling
; EOF patterns
res = True
res@gsnDraw = False ; don't draw yet
res@gsnFrame = False ; don't advance frame yet
res@gsnAddCyclic = False ; plotted dataa are not cyclic
res@mpFillOn = False ; turn off map fill
res@mpMinLatF = latS ; zoom in on map
res@mpMaxLatF = latN
res@mpMinLonF = lonL
res@mpMaxLonF = lonR
res@cnFillOn = True ; turn on color fill
res@cnLinesOn = False ; True is default
;res@cnLineLabelsOn = False ; True is default
res@cnFillPalette = "BlWhRe" ; set color map
res@lbLabelBarOn = False ; turn off individual lb's
; set symmetric plot min/max
symMinMaxPlt(eof, 16, False, res) ; contributed.ncl
; panel plot only resources
resP = True ; modify the panel plot
resP@gsnMaximize = True ; large format
resP@gsnPanelLabelBar = True ; add common colorbar
yStrt = yyyymm(0)/100
yLast = yyyymm(nyrs-1)/100
resP@gsnPanelMainString = "SLP: "+season+": "+yStrt+"-"+yLast
;*******************************************
; first plot
;*******************************************
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) ; now draw as one plot
;*******************************************
; second plot
;*******************************************
; EOF time series [bar form]
rts = True
rts@gsnDraw = False ; don't draw yet
rts@gsnFrame = False ; don't advance frame yet
rts@gsnScale = True ; force text scaling
; these four resources allow the user to stretch the plot size, and
; decide exactly where on the page to draw it.
rts@vpHeightF = 0.40 ; Changes the aspect ratio
rts@vpWidthF = 0.85
rts@vpXF = 0.10 ; change start locations
rts@vpYF = 0.75 ; the plot
rts@tiYAxisString = "m" ; y-axis label
rts@gsnYRefLine = 0. ; reference line
rts@gsnXYBarChart = True ; create bar char隐去的话,就会把时间序列图的红蓝柱状图画为折线图
rts@gsnAboveYRefLineColor = "red" ; above ref line fill red
rts@gsnBelowYRefLineColor = "blue" ; below ref line fill blue
; panel plot only resources
rtsP = True ; modify the panel plot
rtsP@gsnMaximize = True ; large format
rtsP@gsnPanelMainString = "SLP: "+season+": "+yStrt+"-"+yLast
year = yyyymm/100
; create individual plots
do n=0,neof-1
rts@gsnLeftString = "EOF "+(n+1)
rts@gsnRightString = sprintf("%5.1f", eof@pcvar(n)) +"%"
plot(n) = gsn_csm_xy (wks,year,eof_ts(n,:),rts)
end do
gsn_panel(wks,plot,(/neof,1/),rtsP) ; now draw as one plot
end
|
|