Hi Users,
I'm trying to compute EOF by masking domains outside the Atlantic Ocean using the eof_3.ncl script: http://www.ncl.ucar.edu/Applications/Scripts/eof_3.ncl. This has not worked (Pse note: Unlike the said example I'm NOT reading several files, may be this is where my confusion starts).
1) It's indicated thus in the user defined paramers:
region = 6 ; Atlantic
My question is: Does ncl have already predefined regions? Can someone refer me to the appropriate documentation/listing?
(If none, then I think that the major problem for a newbie like me is modifying the code for several files* to work well for only a file).
2) To mask the Atlantic, I merely say:
sst = mask(sst,sst.ne.region,False) ; to mask the region
When I run the code, both the eof and eof_ts are ALL undefined.
Thanks in advance for any suggestions.
Hyacinth
; ==============================================================
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 = -45.
latN = 70.
lonL = -105.
lonR = 20.
region = 6
yrStrt = 1950
yrLast = 2008
season = "JJA" ; choose Jun-Jul-Aug seasonal mean
neof = 2 ; 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 ("/home/nnamchi/work/ictp2011/ocean/HadISST_sst.nc", "r")
; f = addfile ("/home/nnamchi/work/datasets/sst.mnmean.nc","r")
TIME = f->time
YYYY = ut_calendar(TIME,-1)/100 ; entire file
iYYYY = ind(YYYY.ge.yrStrt .and. YYYY.le.yrLast)
sst = f->sst(iYYYY,:,:)
printVarSummary(sst) ; 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
; ==============================================================
; sst = lonFlip( sst )
; printVarSummary(sst) ; note the longitude coord
;=================================================;
; Remove the annual cycle
;=================================================;
xClm = clmMonTLL(sst)
printVarSummary(xClm) ; (12,nlat,nlon)
sst = calcMonAnomTLL (sst, xClm) ; replace with anonamlies
sst@long_name = "ANOMALIES: "+sst@long_name
; ==============================================================
; compute desired global seasonal mean: month_to_season (contributed.ncl)
; ==============================================================
;=================================================;
; Mask out all regions but that sprcified by the user =>'region'
;=================================================;
sst = mask(sst,sst.ne.region,False) ; data for region
;========================================================================
SLP = month_to_season (sst, season)
nyrs = dimsizes(SLP&time)
;==================================================================
; create weights: sqrt(cos(lat)) [or sqrt(gw) ]
; =================================================================
rad = 4.*atan(1.)/180.
clat = f->lat
clat = sqrt( cos(rad*clat) ) ; gw for gaussian grid
; =================================================================
; weight all observations
; =================================================================
wSLP = SLP ; copy meta data
wSLP = SLP*conform(SLP, 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
; =================================================================
x = wSLP({lat|latS:latN},{lon|lonL:lonR},time|:)
eof = eofunc_Wrap(x, neof, optEOF)
eof_ts = eofunc_ts_Wrap (x, eof, optETS)
; eof = eof
printVarSummary( eof ) ; examine EOF variables
printVarSummary( eof_ts )
print(eof_ts)
; system ("rm eof_ts.dat")
; asciiwrite("eof_ts.dat", eof_ts)
; =================================================================
; Normalize time series: Sum spatial weights over the area of used
; =================================================================
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Jan 18 06:46:25 2012
This archive was generated by hypermail 2.1.8 : Mon Jan 23 2012 - 12:45:14 MST