Re: 2D coordinate variables

Steve Hankin (hankin@rogue.pmel.noaa.gov)
Thu, 15 May 1997 13:46:34 -0700

Hi John and John,

It's proposal season and things are hectic ... but I was driven by curiosity to
see how the two suggested file layouts would behave in Ferret.

Indeed, sample_1.cdf, which looks clean but violates the NetCDF conventions by
matching a dimension name to a 2D variable gives this result (edited):

yes? use sample_1
 *** Unknown error code:       500 ***
             Expected: lon Found: not a 1D variable

I guess that qualifies as "croaking" -- or at least "spitting up".

The alternative strategy, ref_atts.cdf, which uses attributes to point out the
connections, works fine and is quite usable in Ferret. But, of course, the
automatic connections between the variable and its coordinate system are lost.

(In Ferret V.5 you can give the command

	yes? SHADE/K=1 MYDATA[T=whatever], LONARR, LATARR

This is a human-created connection between the variables ... but it will give
you the plot on the curvilinear coordinate system -- and it fits well into the
proposed styles.)

	- steve

> ======================================================================
> netcdf sample_1 {
> dimensions:
>         lon = 4 ;
>         lat = 3 ;
>         lev = 2 ;
>         time = UNLIMITED ; // (1 currently)
> variables:
>         float lon(lat,lon) ;
>         float lat(lat,lon) ;
>         float lev(lev) ;
>         double time(time) ;
> 	float mydata(time, lev, lat, lon) ;
>
> data:
>
>  lev = 1000, 2000 ;
>
>  time = 24 ;
>
>  lon = 10, 20, 30, 40,
>        11, 21, 31, 41,
>        12, 22, 32, 42 ;
>
>  lat = 1.0, 2.0, 3.0, 4.0,
>        1.1, 2.1, 3.1, 4.1,
>        1.2, 2.2, 3.2, 4.2 ;
>
>  mydata = 1,2,3,4,
>           5,6,7,8,
> 	  9,10,11,12,
> 	  13,14,15,16,
> 	  17,18,19,20,
> 	  21,22,23,24 ;
> }

======================================================================
netcdf ref_atts {
dimensions:
        ni = 4 ;
        nj = 3 ;
        lev = 2 ;
        time = UNLIMITED ; // (1 currently)
variables:
        float lev(lev) ;
        double time(time) ;
	float mydata(time, lev, nj, ni) ;  // this def'n retains 4-D shape
	   mydata:nj = "latarr";   // => get latitudes from variable "latarr"
	   mydata:ni = "lonarr";   // => get longitudes from variable "lonarr"
	float latarr(ni,nj) ;	 // you'll have to be smart enuough to realize
	float lonarr(ni,nj) ;    // how to interpret this (ie, from its shape)

data:

 lev = 1000, 2000 ;

 time = 24 ;

 lonarr = 10, 20, 30, 40,
          11, 21, 31, 41,
          12, 22, 32, 42 ;

 latarr = 1.0, 2.0, 3.0, 4.0,
          1.1, 2.1, 3.1, 4.1,
          1.2, 2.2, 3.2, 4.2 ;

 mydata = 1,2,3,4,
          5,6,7,8,
	  9,10,11,12,
	  13,14,15,16,
	  17,18,19,20,
	  21,22,23,24 ;
}



-- 

		|  NOAA/PMEL               |  ph. (206) 526-6080  
Steve Hankin	|  7600 Sand Point Way NE  |  FAX (206) 526-6744
		|  Seattle, WA 98115-0070  |  hankin@pmel.noaa.gov