<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hi Owanda,<br>
I see you have 2 dimensional latitudes/longitudes. However, the file
is not CF (or COARDS)-compliant, in that the 2D lat/lon arrays have
named dimensions "lat" and "lon". Looking at the latitude/longitude
arrays it looks like they are repeating. (Try typing ncdump -v lon
AFRICA_UC-WRF311_CTL_ERAINT_MM_50km_1989-2008_pr.nc | less)<br>
<br>
Thus, we can strip out one set of latitudes/longitudes and assign
them as 1 dimensional latitude/longitude coordinate variables, and
then subset them using coordinate subscripting: (you should verify
that this is OK by examining the data file in more detail)<br>
<br>
pr = f->pr ; (:,:,:)<br>
pr = (/ pr*86400 /)<br>
pr@units = "Kg/m2-day"<br>
printVarSummary(pr) ; variable overview<br>
<br>
pr&lat = f->lat(:,0)<br>
pr&lon = f->lon(0,:)<br>
<br>
x = pr(:,{latS:latN},{lonL:lonR})<br>
delete(pr)<br>
<br>
I have attached a modified version of your script. If you have
further questions on this matter, please respond to ncl-talk. <br>
Good luck,<br>
Adam<br>
<br>
On 02/28/2012 09:33 AM, Owanda Otieno wrote:
<blockquote
cite="mid:CAF23Le__aKpjBH6k3Ap00FNyJZ924UiP49g8OacAZg5bY-_5zQ@mail.gmail.com"
type="cite"><br>
<div class="gmail_quote">
<div class="HOEnZb">
<div class="h5">
<div class="gmail_quote">Dear all,<br>
Have been experiencing a couple of problems in eof
analysis using some of the scripts on ncl sites. Through
have tried using some of the experiences before, posted
online, have not managed to solve my difficulties. <br>
Any suggestion is really appreciated.<br>
<b><br>
Please see process below;</b><br>
<br>
Variable: eof_ts<br>
Type: float<br>
Total Size: 2880 bytes<br>
720 values<br>
Number of Dimensions: 2<br>
Dimensions and sizes: [evn | 3] x [time | 240]<br>
Coordinates:<br>
evn: [1..3]<br>
Number Of Attributes: 3<br>
ts_mean : ( -59.76283, -171.605, 35.54322 )<br>
matrix : covariance<br>
_FillValue : 1e+30<br>
(0) check_for_y_lat_coord: Warning: Data either does
not contain a valid latitude coordinate array or doesn't
contain one at all.<br>
(0) A valid latitude coordinate array should have a
'units' attribute equal to one of the following values:<br>
(0) 'degrees_north' 'degrees-north' 'degree_north'
'degrees north' 'degrees_N' 'Degrees_north' 'degree_N'
'degreeN' 'degreesN' 'deg north'<br>
<br>
.<br>
.<br>
.<br>
'degrees_north' 'degrees-north' 'degree_north'
'degrees north' 'degrees_N' 'Degrees_north' 'degree_N'
'degreeN' 'degreesN' 'deg north'<br>
(0) check_for_lon_coord: Warning: Data either does not
contain a valid longitude coordinate array or doesn't
contain one at all.<br>
(0) A valid longitude coordinate array should have a
'units' attribute equal to one of the following values:<br>
(0) 'degrees_east' 'degrees-east' 'degree_east'
'degrees east' 'degrees_E' 'Degrees_east' 'degree_E'
'degreeE' 'degreesE' 'deg east'<br>
fatal:No coordinate variable exists for dimension (time)
in variable (eof_ts)<br>
fatal:Execute: Error occurred at or near line 144 in file
eofcordex3.ncl<br>
<br>
<br>
<b style="background-color:rgb(255,0,0)"><span></span></b><font
style="color:rgb(51,0,51)" size="4"><b><span> modified
scipt :</span><span
style="background-color:rgb(255,0,0)"></span></b></font><b><span
style="background-color:rgb(255,0,0)"><br>
</span></b><b style="background-color:rgb(255,0,0)"><br>
</b>;
==============================================================<br>
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"<br>
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"<br>
load
"$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"<br>
<br>
begin<br>
;
==============================================================<br>
; User defined parameters that specify region of globe and<br>
;
==============================================================<br>
latS = -12.<br>
latN = 23. <br>
lonL = 20.<br>
lonR = 60.<br>
<br>
yrStrt = 1989<br>
yrLast = 2008<br>
<br>
season = "MAM" <br>
<br>
neof = 3 <br>
optEOF = True <br>
optEOF@jopt = 0 <br>
optETS = False<br>
<br>
;
==============================================================<br>
; Open the file: Read only the user specified period<br>
;
==============================================================<br>
dir = "/scratch/DATA/CORDEX/UC-WRF/"<br>
f = addfile
(dir+"AFRICA_UC-WRF311_CTL_ERAINT_MM_50km_1989-2008_pr.nc",
"r")<br>
<br>
TIME = f->time<br>
YYYY = cd_calendar(TIME, -1)/100<br>
iYYYY = ind(YYYY.ge.yrStrt .and. YYYY.le.yrLast)<br>
<br>
pr = f->pr(:,:,:)<br>
print(dimsizes(pr))<br>
x = pr*86400<br>
printVarSummary(x) ; variable overview<br>
<br>
nlat = 249<br>
nlon = 209<br>
lat = latGlobeFo(nlat, "lat", "latitude", "degrees_north")<br>
lon = lonGlobeFo(nlon, "lon", "longitude", "degrees_east")<br>
<br>
printVarSummary(lat)<br>
printVarSummary(lon)<br>
<br>
x!0 = "time"<br>
x!1 = "lat"<br>
x!2 = "lon"<br>
; x&lat = x&lat<br>
; x&lon = x&lon<br>
<br>
; x&time = Months<br>
; x&lat = "degrees_north"<br>
; x&lon = "degrees_east"<br>
<br>
printVarSummary(x)<br>
<br>
; x&lat@units = "degrees_north"<br>
; x&lon@units = "degrees_east"<br>
;
==============================================================<br>
;compute desired monthly climatology and monthly anomalies<br>
;===============================================================<br>
<br>
xClm = clmMonTLL(x)<br>
printVarSummary(xClm)<br>
<br>
xAnom = calcMonAnomTLL(x,xClm)<br>
printVarSummary(xAnom)<br>
<br>
;
================================================================<br>
; Reorder (lat,lon,time) the *weighted* input data<br>
; Access the area of interest via coordinate subscripting<br>
;
================================================================<br>
; xr = xAnom(lat|:,lon|:,time|:)<br>
xr = x(lat|:,lon|:,time|:)<br>
<br>
eof = eofunc_Wrap(xr, neof, optEOF) <br>
; eof =-1*eof<br>
eof_ts = eofunc_ts_Wrap (xr, eof, optETS)<br>
<br>
printVarSummary( eof ) <br>
printVarSummary( eof_ts )<br>
<br>
;============================================================<br>
; PLOTS<br>
;============================================================<br>
xwks = gsn_open_wks("x11","eof")<br>
pswks =
gsn_open_wks("eps","Africa-WRF-Cordex_eof-mam1989-2008") <br>
gsn_define_colormap(xwks,"BlWhRe") ; choose
colormap<br>
gsn_define_colormap(pswks,"BlWhRe")<br>
plot = new(neof,graphic) ; create graphic
array<br>
; only needed if
paneling<br>
; EOF patterns<br>
<br>
res = True <br>
res@gsnDraw = False ; don't draw yet<br>
res@gsnFrame = False ; don't advance
frame yet<br>
res@gsnSpreadColors = True ; spread out
color table<br>
res@gsnAddCyclic = False ; plotted dataa
are not cyclic<br>
<br>
res@mpFillOn = False ; turn
off map fill<br>
res@mpOutlineBoundarySets = "National" <br>
res@mpGeophysicalLineColor = "Navy"<br>
; res@mpGeophysicalLineThickness = 1.5<br>
<br>
res@mpMinLatF = latS ; zoom in on map<br>
res@mpMaxLatF = latN<br>
res@mpMinLonF = lonL<br>
res@mpMaxLonF = lonR<br>
<br>
res@cnFillOn = True ; turn on color
fill<br>
res@cnLinesOn = False ; True is
default<br>
; res@cnLineLabelsOn = False ; True is
default<br>
res@lbLabelBarOn = False ; turn off
individual lb's<br>
<br>
; set symmetric
plot min/max<br>
symMinMaxPlt(eof, 16, False, res) ;
contributed.ncl<br>
<br>
; panel plot only resources<br>
resP = True ; modify the
panel plot<br>
resP@gsnMaximize = True ; large format<br>
resP@gsnPanelLabelBar = True ; add common
colorbar<br>
resP@lbLabelAutoStride = True ; auto stride on
<br>
<br>
;*******************************************<br>
; first plot<br>
;*******************************************<br>
do n=0,neof-1<br>
res@gsnLeftString = "EOF "+(n+1)<br>
res@gsnRightString = sprintf("%5.1f", eof@pcvar(n))
+"%"<br>
plot(n)=gsn_csm_contour_map_ce(xwks,eof(n,:,:),res)<br>
plot(n)=gsn_csm_contour_map_ce(pswks,eof(n,:,:),res)<br>
end do<br>
gsn_panel(xwks,plot,(/neof,1/),resP) ; now draw as
one plot<br>
gsn_panel(pswks,plot,(/neof,1/),resP)<br>
<br>
;*******************************************<br>
; second plot<br>
;*******************************************<br>
;; EOF time series [bar form]<br>
<br>
time = eof_ts&time<br>
do n=0,neof-1<br>
ascii_file1 = "WRF-cordex_eof1-mam1989-2008.txt" <br>
ascii_file2 = "WRF-cordex_eof2-mam1989-2008.txt"<br>
ascii_file3 = "WRF-cordex_eof3-mam1989-2008.txt"<br>
<br>
asciiwrite(ascii_file1,eof_ts(0,:))<br>
asciiwrite(ascii_file2,eof_ts(1,:))<br>
asciiwrite(ascii_file3,eof_ts(2,:))<br>
end do<br>
end<br>
<br>
script also attached.<br>
<br>
You can find my data here : <a moz-do-not-send="true"
href="https://dropbox.uconn.edu/dropbox?n=AFRICA_UC-WRF311_CTL_ERAINT_MM_50km_1989-2008_pr.nc&p=WzAFDxwPm1IMFjpIL"
target="_blank">https://dropbox.uconn.edu/dropbox?n=AFRICA_UC-WRF311_CTL_ERAINT_MM_50km_1989-2008_pr.nc&p=WzAFDxwPm1IMFjpIL</a><br>
<br>
<font color="#888888">Thanks in advance.</font><span><font
color="#888888"><br>
-- <br>
Owanda Otieno<br>
Department of Natural Resources and the Environment<br>
University of Connecticut<br>
1376 Storrs Road, Unit 4087<br>
Storrs, CT 06269-4087<br>
Phone: <a moz-do-not-send="true"
href="tel:%28860%29%20486-1876" value="+18604861876"
target="_blank">(860) 486-1876</a><br>
<br>
</font></span></div>
<br>
<br clear="all">
<br>
-- <br>
Owanda Otieno<br>
Department of Natural Resources and the Environment<br>
University of Connecticut<br>
1376 Storrs Road, Unit 4087<br>
Storrs, CT 06269-4087<br>
Phone: <a moz-do-not-send="true"
href="tel:%28860%29%20486-1876" value="+18604861876"
target="_blank">(860) 486-1876</a><br>
<br>
</div>
</div>
</div>
<br>
<br clear="all">
<br>
-- <br>
Owanda Otieno<br>
Department of Natural Resources and the Environment<br>
University of Connecticut<br>
1376 Storrs Road, Unit 4087<br>
Storrs, CT 06269-4087<br>
Phone: (860) 486-1876<br>
<br>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
<a class="moz-txt-link-freetext" href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a></pre>
</blockquote>
<br>
<pre class="moz-signature" cols="72">--
______________________________________________________________
Adam Phillips <a class="moz-txt-link-abbreviated" href="mailto:asphilli@ucar.edu">asphilli@ucar.edu</a>
NCAR/Climate and Global Dynamics Division (303) 497-1726
P.O. Box 3000                                
Boulder, CO 80307-3000 <a class="moz-txt-link-freetext" href="http://www.cgd.ucar.edu/cas/asphilli">http://www.cgd.ucar.edu/cas/asphilli</a>
</pre>
</body>
</html>