2008 Unidata NetCDF Workshop for Developers and Data Providers > Best Practices
8.5 Calendar Date and Time
Represent calendar dates and times with standards and conventions.
Two strategies for storing a date/time into a netCDF variable are:
- as a string using a standard encoding and calendar (e.g. ISO
8601), OK for a
single date/time
- as a numeric value and a unit that includes the reference time,
better for multiple times and makes it easier to compute differences
between dates
Unidata's udunits
package provides a convenient way to implement the second
strategy.
Recommendations
- If your data uses real, physical time that is well represented using the
Gregorian/Julian calendar, encode it as an interval from a reference time,
and add a units attribute which uses a udunits-compatible time unit. Readers
can use the udunits package to manipulate or format the date values.
- If your data uses a different calendar, use an existing convention such
as the CF convention, or create a new convention which clearly documents what
the calendar and encoding is. Make it compatible with existing date manipulation
packages if possible (e.g.
java.text.SimpleDate
).
- Add multiple sets of time encodings if necessary to allow different readers
to work as well as possible.
2008 Unidata NetCDF Workshop for Developers and Data Providers > Best Practices