New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Units in date2num / num2date #434
Comments
The problem with time units such as "months" is that they are not well defined. In contrast to days, hours, etc. the length of a month depends on the calendar used and even varies between different months. A few words about this issue can be found in the CF conventions: http://cfconventions.org/Data/cf-conventions/cf-conventions-1.6/build/cf-conventions.html#time-coordinate
|
We could convert "months since" to "seconds since" using 1 month = year/12 = 2629743.831225 seconds. Same for "weeks since" and "years since". This is how netcdf-java does it (http://www.unidata.ucar.edu/software/thredds/current/netcdf-java/CDM/CalendarDateTime.html). It may lead to confusion though, and cause more problems than it solves. |
My two cents is that it's better to give an error and force users to convert such ill-defined units explicitly. |
I would agree. The Udunits definition of "month" is practically never what is meant by encoders of "months since ...", so giving an error would be safe and clear. |
We already do throw an error, so it seems like no change in the current behavior is needed. Closing now... |
Thanks for all replies - by the way, is there something like a users mailing list? |
There's no mailing list right now. Wish github had a better mechanism for discussions. |
While the udunits definition of month is not what is ever meant, that is a udunits flaw, not a flaw in the standard. units of months since with a calendar of 360_day is perfectly well defined and there is no reason why this cannot be properly coded. |
A pull request allowing |
👍 to @bennoblumenthal's comment. |
In the documentation for num2date and date2num, it says that "units" in the arguments list should be: "a string of the form 'time units since reference time' describing the time units. time units can be days, hours, minutes, seconds, milliseconds or microseconds." Now I on several occasions encountered data where the time unit is set as, e.g., "months since yyyy-mm-dd hh:mm:ss". Is there any way or planned implementation to deal with such longer-timestep units as well?
The text was updated successfully, but these errors were encountered: