Re: coordinate variable....clarification

From: Arindam Chakraborty <achakrab_at_nyahnyahspammersnyahnyah>
Date: Sun, 06 Jul 2008 15:13:38 -0400

Hi Erik,
    If a variable has a named dimension, it does not necessarily mean
that there is a coordinate associated with that dimension. A
coordinate-dimension is created when we associate the coordinate values
along a named dimension. In your case, 0th dimension of R is named
"time" but it is not a coordinate dimension (note that nothing is listed
under "Coordinates:" when you print R). You can make "time" a coordinate
dimension by assigning the coordinate values and units:

...
; I'm assuming 60 values of time is for 60 months starting at Jan2000
R&time = ispan(0,nt-1,1)
R&time_at_units = "months since 2000-01-16 00:00:00"

...
; now you can see "time" dimension is listed under the "Coordinates:":
print(R)
; so it is possible to extract the coordinate data values:
time = R&time
...

Please see the little example below which creates R as a single
dimensional variable: R = R(t) = t^2 (t=1,...,12)

Hope this helps.

regards,

arindam

;========================================
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
 nt = 12
 R = ispan(1,nt,1)^2
 R!0 = "time" ; assign dimension name
 R&time = ispan(1,nt,1) ; create coordinate dimension
 R&time_at_units = "months since 2007-12-16 00:00:00" ; assign units
 print(R)
 time = R&time
 print(time)
end
;==========================================================

Erik Noble wrote:
> hi.
>
> I have a variable R. I am trying to create a "time" variable from the
> coordinate variable in R, but I am getting an error (below). What to I
> need to change?
> Any help with understanding this would be appreciated.
> Sincerely,
> Erik Noble
>
>
> ncl 12> printVarSummary(R)
>
> Variable: R
> Type: float
> Total Size: 3636240 bytes
> 909060 values
> Number of Dimensions: 3
> Dimensions and sizes: [time | 60] x [lat | 109] x [lon | 139]
> Coordinates:
> Number Of Attributes: 4
> units : mm
> long_name : Accumulated Precipitation
> description : Precipitation Tendency
> _FillValue : -999
> ncl 13> time = R&time
> fatal:No coordinate variable exists for dimension (time) in variable (R)
> fatal:Execute: Error occurred at or near line 13
>
> ncl 14> N = dimsizes(time)
> fatal:Variable (time) is undefined
> fatal:Execute: Error occurred at or near line 14
> _______________________________________________
> ncl-talk mailing list
> ncl-talk_at_ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>

-- 
----------------------------
 ARINDAM CHAKRABORTY
 Department of Meteorology
 Florida State University
 Tallahassee, FL-32306, USA
 Tel: 850-644-3524 (O)
      850-524-0717 (C)
 Fax: 850-644-9642
____________________________
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Sun Jul 06 2008 - 13:13:38 MDT

This archive was generated by hypermail 2.2.0 : Sun Jul 06 2008 - 17:20:47 MDT