- 积分
- 4208
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2018-9-28
- 最后登录
- 1970-1-1
|

楼主 |
发表于 2019-12-7 21:04:59
|
显示全部楼层
这是全部的脚本
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
begin
;=========================提取数据========================
filename = "/cygdrive/E/Fudan_University/data/sst.mon.mean.nc"
f = addfile(filename, "r")
time0 = f->time
lat = f->lat({20:70})
lon = f->lon({100:260})
time = cd_calendar(time0, -5)
yr = time(:,0)
mon = time(:,1)
iYYYY = ind(yr.ge.1900 .and. yr.le.2018)
sst = f->sst(iYYYY,{20:70},{100:260})
nlat = dimsizes(lat)
nlon = dimsizes(lon)
ntime = dimsizes(sst&time)
xClm = clmMonTLL(sst) ; (12,lat,lon)
; printVarSummary(xClm)
xAnom = calcMonAnomTLL ( sst, xClm) ; (time, lat,lon)
; printVarSummary(xAnom)
xaave = wgt_areaave_Wrap(xAnom, 1.0, 1.0, 0)
copy_VarCoords(xAnom(:,0,0), xaave)
xAnom1 = xAnom-conform(xAnom, xaave, 0)
copy_VarCoords(xAnom, xAnom1)
; printVarSummary(xaave)
; printVarSummary(xAnom1)
; printMinMax(xAnom, True)
;*******************************************
; EOF
;*******************************************
neof = 2
optEOF = True
optEOF@jopt = 0 ; This is the default; most commonly used; no need to specify.
optETS = False
; =================================================================
; Reorder (lat,lon,time) the *weighted* input data
; Access the area of interest via coordinate subscripting
; =================================================================
rad = 4.*atan(1.)/180.
clat = lat(:)
clat = sqrt( cos(rad*clat) )
x1 = xAnom1(:,:,:)
x = x1*conform(x1, clat, 1)
copy_VarCoords(x1, x)
; printVarSummary(x)
X = x(lat|:,lon|:,time|:) ; Space x Time
eof = eofunc_Wrap( X, neof, optEOF)
eof = -1*eof
eof_ts = eofunc_ts_Wrap( X, eof, False)
eof_ts = dim_standardize_n( eof_ts, 0, 1) ; normalize
eof_regres = eof ; create an array w meta data
do ne = 0,neof-1
eof_regres(ne,:,:) = (/ regCoef(eof_ts(ne,:), xAnom1(lat|:,lon|:,time|:)) /)
end do
; yyyymm = cd_calendar(eof_ts&time,-2)/100
; year = yyyymm/100
; printVarSummary(eof)
; printVarSummary(eof_ts)
;*******************************************
; plots
;*******************************************
wksname1 = "/cygdrive/E/Fudan_University/Pictures/pdo_eof1"
wks1 = gsn_open_wks("png", wksname1)
wksname2 = "/cygdrive/E/Fudan_University/Pictures/pdo_pc1"
wks2 = gsn_open_wks("png", wksname2)
; ;
; This will not be necessary in V6.1.0 and later. Named colors can
; be used without having to first add them to the color map.
; only needed if paneling
res = True
res@gsnDraw = False
res@gsnFrame = False
res@gsnSpreadColors = True ; spread out color table
res@gsnSpreadColorEnd = -2 ; don't use added gray
res@gsnAddCyclic = False ; data not cyclic
res@mpCenterLonF = 190. ; defailt is 0 [GM]
res@mpMinLatF = min(x&lat)
res@mpMaxLatF = max(x&lat)
res@mpMinLonF = min(x&lon)
res@mpMaxLonF = max(x&lon)
res@mpFillDrawOrder = "PostDraw"
res@cnFillOn = True ; turn on color fill
res@cnLinesOn = True ; True is default
res@lbLabelBarOn = True ; turn off individual lb's
; set symmetric plot min/max
res@gsnLeftString = "EOF "+1
res@gsnRightString = sprintf("%5.1f",eof@pcvar(0)) +"%"
plot1 = gsn_csm_contour_map_ce(wks1,eof_regres(0,:,:),res)
;*******************************************
; time series (principal component) plot
;*******************************************
rts = True
rts@gsnDraw = False
rts@gsnFrame = False
; 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@gsnXYBarChart = True
rts@gsnYRefLine = 0.0
rts@gsnAboveYRefLineColor = "Red"
rts@gsnBelowYRefLineColor = "Blue"
year = cd_calendar(eof_ts&time,1)
tt = fspan(1,1428,1428)
rts@gsnLeftString = "EOF "+1
rts@gsnRightString = sprintf("%5.1f",eof@pcvar(0)) +"%"
plot2 = gsn_csm_xy (wks2,year,eof_ts(0,:),rts)
draw(plot1)
draw(plot2)
frame(wks1)
frame(wks2)
end |
|