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

Greg Deemer greg.deemer at nsidc.org
Fri Aug 19 15:28:49 MDT 2016


Dear David, 

Thank you for such a helpful explanation in addition to a code example. I’ve been able to incorporate this into my script and it works properly. I will check out the FAQ page for more info. 

Best regards,
Greg Deemer
NSIDC User Services

From:  Dave Allured - NOAA Affiliate <dave.allured at noaa.gov>
Date:  Thursday, August 18, 2016 at 8:02 PM
To:  Greg Deemer <greg.deemer at nsidc.org>
Cc:  <ncl-talk at ucar.edu>
Subject:  Re: [ncl-talk] Defining an arbitrary variable that holds no data

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/20160819/b1e0000e/attachment.html 


More information about the ncl-talk mailing list