;=====================================================================;
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"
;======================================================================
begin
;******************************************
;Define hyperslab
;*****************************************
maxlat = 90.
minlat = -90.
minlon = 0.
maxlon = 360.
plev = 500.
yrst = 1980
yren = 2004
diri = "~/datasets/atm/"
fili = "ncep_geoz_1960_2004"
fyrst = 1960
varNam = "hgt"
;********************************
;read in data
;*****************************
;start/end time index
st = (yrst - fyrst) * 12
en = ((yren - fyrst) * 12) + 11
fi = addfile(diri+fili+".nc", "r")
x = fi->$varNam$(time|st:en, {level|plev}, {lat|minlat:maxlat},
{lon|minlon:maxlon})
dimz = dimsizes(x)
ntim = dimz(0)
nlat = dimz(1)
nloc = nlat * dimz(2)
; COSINE WGT
lat = x&lat
rad = 3.14157/180.
do nl=0,nlat-1 ; wgt gph by
sqrt(cos(latitude))
x(nl,:,:) = x(nl,:,:)*cos(lat(nl)*rad)
end do
;create 2-d array: rows = time, column = locn.
x2d = new((/ntim, nloc/), typeof(x))
do tt = 0, ntim-1
x2d(tt,:) = ndtooned(x(tt,:,:))
end do
;alternatively, I tried the method here with the same result...
; x2d = onedtond(ndtooned(x), (/ntim, nloc/))
;eof
;2d EOF - results in pcvar = 98%
check_2d = eofunc(x2d, 5, False)
print("2d eof - "+check_2d_at_pcvar)
;EOF on original data, pcvar is reasonable
check_3d = eofunc(x, 5, False)
print("3d eof - "+check_3d_at_pcvar)
;Rearrange 2d array back into 3ds, pcvar is same as for original 3d
array case
x3d = new(dimz, typeof(x))
do tt = 0, ntim-1
x3d(tt,:,:) = onedtond(x2d(tt,:),(/dimz(1), dimz(2)/))
end do
check_ret = eofunc(x3d, 5, opt)
print("regrid "+check_ret_at_pcvar)
end
============================
Room A113
UCLA Department of Geography
1255 Bunche Hall
Los Angeles CA 90095-1524
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed May 02 2007 - 15:11:41 MDT
This archive was generated by hypermail 2.2.0 : Tue May 08 2007 - 09:54:33 MDT