[ncl-talk] Defining an arbitrary variable that holds no data

Dave Allured - NOAA Affiliate dave.allured at noaa.gov
Thu Aug 18 20:02:04 MDT 2016


Greg,

CF conventions section 5.6 does not explain that attribute holders such as
"crs" in their examples are scalar variables that actually hold a single
value.  The examples in 5.6 show only the netcdf headers.  If the netcdf
data section was also excerpted, you might see something like crs = 1 or
crs = -999, where these are simply dummy scalar values.  CF does not care
what the data value of an attribute holder is, or even whether it is scalar
or array.

There are two ways to create true scalar file variables in NCL.  Here is
one way:

   crs = 1
   crs!0 = "ncl_scalar"
   crs at grid_mapping_name = "latitude_longitude"
   (etc.)

   f->crs = crs

Please see this FAQ for the full explanation:
http://www.ncl.ucar.edu/FAQ/#file_io_007

If you skipped ' crs!0 = "ncl_scalar" ', you would get a dummy dimension
such as "ncl3", and crs would still be a legal CF grid mapping variable.

--Dave


On Thu, Aug 18, 2016 at 5:31 PM, Greg Deemer <greg.deemer at nsidc.org> wrote:

> NCL Talk,
>
> I’m wanting to define and write a variable that holds attributes about my
> dataset projection. An example of the CF conventions for defining the
> latitude and longitude on a spherical Earth following section 5.6 in the CF
> metadata conventions handbook is as follows:
>
> **********************
>                                         dimensions:
>       lat = 18 ;
>       lon = 36 ;
>
>                                             variables:
>       double lat(lat) ;
>       double lon(lon) ;
>       float temp(lat, lon) ;
>
>                                                 temp:long_name =
> "temperature" ;
>         temp:units = "K" ;
>         temp:grid_mapping = "crs" ;
>
>                                               int crs ;
>         crs:grid_mapping_name = "latitude_longitude";
>         crs:longitude_of_prime_meridian = 0.0 ;
>         crs:semi_major_axis = 6378137.0 ;
>         crs:inverse_flattening = 298.257223563;”
> ***********************
>
> My question is simply: “How do I define crs as int, without assigning
> values?”
>
> I tried:
> Crs = 1, which returns "int crs(ncl3) ;” in the NetCDF header.
> Crs = integer, which returns an error
>
> Thanks,
> Greg
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160818/42632d53/attachment.html 


More information about the ncl-talk mailing list