Skip to content

Negative dates in CF and cftime  #71

@RayCramer

Description

@RayCramer

It has been suggested that my issue may be of interest/discussed/resolved through this group. I’ll present the questions pre-emptively as it may help understand the description of my problem:
Are CF dates constrained as being positive years?
Are code updates planned/required to allow for the use of the ISO/DIS 8601-2 standard to allow for negative dates?

We have NetCDF data files (with SeaDataNet and CF conventions) with a date channel as http://vocab.nerc.ac.uk/collection/P01/current/CJDY1101/
double TIME(INSTANCE) ;
TIME:long_name = "Chronological Julian Date" ;
TIME:sdn_parameter_urn = "SDN:P01::CJDY1101" ;
TIME:sdn_parameter_name = "Julian Date (chronological)" ;
TIME:sdn_uom_urn = "SDN:P06::UTAA" ;
TIME:sdn_uom_name = "Days" ;
TIME:units = "days since -4713-01-01T00:00:00Z" ;
TIME:standard_name = "time" ;
TIME:axis = "T" ;
TIME:ancillary_variables = "TIME_SEADATANET_QC" ;
TIME:calendar = "julian" ;
TIME:_FillValue = -99999. ;
byte TIME_SEADATANET_QC(INSTANCE) ;
….

Running the data file through the CFchecker software (http://pumatest.nerc.ac.uk/cgi-bin/cf-checker.pl) fails with
File "netcdftime/_netcdftime.pyx", line 715, in netcdftime._netcdftime.utime.init (netcdftime/_netcdftime.c:11201)
ValueError: negative reference year in time units, must be >= 1

This was reported to the CFchecker software, with the response from the developer that
cfunits is throwing the error
"netCDF4-python throws an error if real world calendars have negative years (https://github.com/Unidata/cftime/blob/master/cftime/_cftime.pyx#L140-L147)"

The following trail seems to imply that we are working correctly with the date, in particular having a negative year for the time origin:
http://cfconventions.org/Conformance/conformance.html

https://www.unidata.ucar.edu/software/netcdf/docs/BestPractices.html#bp_Calendar-Date-Time
refers to the udunits using ISO8601

https://en.wikipedia.org/wiki/ISO_8601
refers to
To represent years before 0000 or after 9999, the standard also permits the expansion of the year representation but only by prior agreement between the sender and the receiver.

https://www.iso.org/news/2017/02/Ref2164.html
refers to simply adding a minus sign.

https://www.unidata.ucar.edu/software/thredds/current/netcdf-java/CDM/CalendarDateTime.html refers to a minus date.

I hope this rather long description makes some sort of sense.
Ray

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions