Re: cordinate error

From: Adam Phillips <asphilli_at_nyahnyahspammersnyahnyah>
Date: Fri Feb 24 2012 - 17:00:08 MST

Hi Owanda,
You're assigning dimension names but you are not assigning coordinate
variables:

       x!0 = "time" ; assign dimension names
       x!1 = "lat"
       x!2 = "lon"

As you're planning on plotting your monthly timeseries, it is likely
better to convert the time to fractions of year:
       time = cd_calendar(f->time, 4)

and then assign the time, lat, and lon arrays as coordinate variables to
the x array:

       x&time = time ; assign coordinate variables
       x&lat = lat
       x&lon = lon

Hope that helps. If not, please respond to ncl-talk.
Adam

On 02/24/2012 02:15 PM, Owanda Otieno wrote:
>
> Dear all,
> I am trying do compute eof using modified sample scripts from NCL
> websites.
> I have been getting a couple of error massages about coordinate
> naming. Through online search have gotten a couple of similar problems
> and their suggested solutions, which have tried without any success.
>
> *Part of the massage I receive is shown below:*
>
>
> Variable: eof_ts
> Type: float
> Total Size: 2880 bytes
> 720 values
> Number of Dimensions: 2
> Dimensions and sizes: [evn | 3] x [time | 240]
> Coordinates:
> evn: [1..3]
> Number Of Attributes: 3
> ts_mean : ( -59.76283, -171.605, 35.54322 )
> matrix : covariance
> _FillValue : 1e+30
> (0) check_for_y_lat_coord: Warning: Data either does not contain a
> valid latitude coordinate array or doesn't contain one at all.
> (0) A valid latitude coordinate array should have a 'units'
> attribute equal to one of the following values:
> (0) 'degrees_north' 'degrees-north' 'degree_north' 'degrees
> north' 'degrees_N' 'Degrees_north' 'degree_N' 'degreeN' 'degreesN'
> 'deg north'
>
> .
> .
> .
> 'degrees_north' 'degrees-north' 'degree_north' 'degrees north'
> 'degrees_N' 'Degrees_north' 'degree_N' 'degreeN' 'degreesN' 'deg north'
> (0) check_for_lon_coord: Warning: Data either does not contain a
> valid longitude coordinate array or doesn't contain one at all.
> (0) A valid longitude coordinate array should have a 'units'
> attribute equal to one of the following values:
> (0) 'degrees_east' 'degrees-east' 'degree_east' 'degrees east'
> 'degrees_E' 'Degrees_east' 'degree_E' 'degreeE' 'degreesE' 'deg east'
> fatal:No coordinate variable exists for dimension (time) in variable
> (eof_ts)
> fatal:Execute: Error occurred at or near line 144 in file eofcordex3.ncl
>
>
> ***My scipt :**
> **
> *; ==============================================================
> 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 = -12.
> latN = 23.
> lonL = 20.
> lonR = 60.
>
> yrStrt = 1989
> yrLast = 2008
>
> season = "MAM"
>
> neof = 3
> optEOF = True
> optEOF@jopt = 0
> optETS = False
>
> ; ==============================================================
> ; Open the file: Read only the user specified period
> ; ==============================================================
> dir = "/scratch/DATA/CORDEX/UC-WRF/"
> f = addfile
> (dir+"AFRICA_UC-WRF311_CTL_ERAINT_MM_50km_1989-2008_pr.nc", "r")
>
> TIME = f->time
> YYYY = cd_calendar(TIME, -1)/100
> iYYYY = ind(YYYY.ge.yrStrt .and. YYYY.le.yrLast)
>
> pr = f->pr(:,:,:)
> print(dimsizes(pr))
> x = pr*86400
> printVarSummary(x) ; variable overview
>
> nlat = 249
> nlon = 209
> lat = latGlobeFo(nlat, "lat", "latitude", "degrees_north")
> lon = lonGlobeFo(nlon, "lon", "longitude", "degrees_east")
>
> printVarSummary(lat)
> printVarSummary(lon)
>
> x!0 = "time"
> x!1 = "lat"
> x!2 = "lon"
> ; x&lat = x&lat
> ; x&lon = x&lon
>
> ; x&time = Months
> ; x&lat = "degrees_north"
> ; x&lon = "degrees_east"
>
> printVarSummary(x)
>
> ; x&lat@units = "degrees_north"
> ; x&lon@units = "degrees_east"
> ; ==============================================================
> ;compute desired monthly climatology and monthly anomalies
> ;===============================================================
>
> xClm = clmMonTLL(x)
> printVarSummary(xClm)
>
> xAnom = calcMonAnomTLL(x,xClm)
> printVarSummary(xAnom)
>
> ; ================================================================
> ; Reorder (lat,lon,time) the *weighted* input data
> ; Access the area of interest via coordinate subscripting
> ; ================================================================
> ; xr = xAnom(lat|:,lon|:,time|:)
> xr = x(lat|:,lon|:,time|:)
>
> eof = eofunc_Wrap(xr, neof, optEOF)
> ; eof =-1*eof
> eof_ts = eofunc_ts_Wrap (xr, eof, optETS)
>
> printVarSummary( eof )
> printVarSummary( eof_ts )
>
> ;============================================================
> ; PLOTS
> ;============================================================
> xwks = gsn_open_wks("x11","eof")
> pswks = gsn_open_wks("eps","Africa-WRF-Cordex_eof-mam1989-2008")
> gsn_define_colormap(xwks,"BlWhRe") ; choose colormap
> gsn_define_colormap(pswks,"BlWhRe")
> 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@gsnSpreadColors = True ; spread out color table
> res@gsnAddCyclic = False ; plotted dataa are not cyclic
>
> res@mpFillOn = False ; turn off map fill
> res@mpOutlineBoundarySets = "National"
> res@mpGeophysicalLineColor = "Navy"
> ; res@mpGeophysicalLineThickness = 1.5
>
> 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@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
> resP@lbLabelAutoStride = True ; auto stride on
>
> ;*******************************************
> ; 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_ce(xwks,eof(n,:,:),res)
> plot(n)=gsn_csm_contour_map_ce(pswks,eof(n,:,:),res)
> end do
> gsn_panel(xwks,plot,(/neof,1/),resP) ; now draw as one plot
> gsn_panel(pswks,plot,(/neof,1/),resP)
>
> ;*******************************************
> ; second plot
> ;*******************************************
> ;; EOF time series [bar form]
>
> time = eof_ts&time
> do n=0,neof-1
> ascii_file1 = "WRF-cordex_eof1-mam1989-2008.txt"
> ascii_file2 = "WRF-cordex_eof2-mam1989-2008.txt"
> ascii_file3 = "WRF-cordex_eof3-mam1989-2008.txt"
>
> asciiwrite(ascii_file1,eof_ts(0,:))
> asciiwrite(ascii_file2,eof_ts(1,:))
> asciiwrite(ascii_file3,eof_ts(2,:))
> end do
> end
>
> You can find my data here :
> https://dropbox.uconn.edu/dropbox?n=AFRICA_UC-WRF311_CTL_ERAINT_MM_50km_1989-2008_pr.nc&p=WzAFDxwPm1IMFjpIL
> <https://dropbox.uconn.edu/dropbox?n=AFRICA_UC-WRF311_CTL_ERAINT_MM_50km_1989-2008_pr.nc&p=WzAFDxwPm1IMFjpIL>
> my script is also attached.
>
> Any suggestion appreciated
> Thanks
> --
> Owanda Otieno
> Department of Natural Resources and the Environment
> University of Connecticut
> 1376 Storrs Road, Unit 4087
> Storrs, CT 06269-4087
> Phone: (860) 486-1876 <tel:%28860%29%20486-1876>
>
>
>
>
> --
> Owanda Otieno
> Department of Natural Resources and the Environment
> University of Connecticut
> 1376 Storrs Road, Unit 4087
> Storrs, CT 06269-4087
> Phone: (860) 486-1876
>
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

-- 
______________________________________________________________
Adam Phillips                                asphilli@ucar.edu
NCAR/Climate and Global Dynamics Division       (303) 497-1726
P.O. Box 3000				
Boulder, CO 80307-3000    http://www.cgd.ucar.edu/cas/asphilli

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Feb 24 17:00:20 2012

This archive was generated by hypermail 2.1.8 : Mon Mar 05 2012 - 14:12:07 MST