[ncl-talk] writing nanosecond data to a netcdf file

Dave Allured - NOAA Affiliate dave.allured at noaa.gov
Wed Jun 1 10:22:49 MDT 2016


Dave V,

You are asking for nanosecond accuracy over a time range of 31 years.  This
requires 60 bits of numeric precision.  This exceeds the precision of data
type double, which is commonly used for storing time in Netcdf files.

Several solutions come to mind.  For ease of use and greatest
compatibility, I recommend storing the time values as fixed length strings
of Netcdf type character (*not* Netcdf "string").  Order the digits from
greatest to least significance, and retain leading zeros in the
substrings.  Always use 4-digit year numbers.

Modifying your example slightly, I suggest a character template such as
"YYYY-MM-DD HH:MM:SS.SSSSSSSSS".

Include a "units" attribute such as "date/time".  Also include the
"calendar" attribute set to "gregorian".

Other accurate solutions using pure numeric encoding are fairly easy with
NCL and Netcdf, but they have compatibility issues.  Do you really need
pure numeric time values for your application?

--Dave A.


On Mon, May 23, 2016 at 1:51 PM, Vollaro, David <dvollaro at albany.edu> wrote:

> Hi,
>
> I have an ascii dataset that has data to nanosecond accuracy.  I want to
> read it and store it as netCDF.  I was going to try to set the output time
> variable with the unit attribute as:
>
>  tatts at units = "nanoseconds since 1985-01-01 00:00:00.00000000"
>
> However I am not sure how to convert the gregorian date:
>
> cd_inv_calendar does not have any parameters smaller than seconds.
>
> Thanks for any help you can provide.
>
> sample time: 01/16/15 02:56:50.724470242
>
> Dave
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160601/1e001fdf/attachment.html 


More information about the ncl-talk mailing list