Skip to content
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

DOC: explicitly define numpy.datetime64 semantics #20774

Merged
merged 1 commit into from
Feb 16, 2022

Conversation

miccoli
Copy link
Contributor

@miccoli miccoli commented Jan 10, 2022

Explicity state datetime64 semantics:

  • adoption of proleptic Gregorian Calendar
  • Astronomical year numbering
  • 86400 s constant length of day.

Add some exmples of shortcomings of the above semnatics with ref. to
UTC timescale (missing leap seconds) and UT timescale (variable
legth of day).

Closes GH-20675

Explicity state datetime64 semantics:
- adoption of proleptic Gregorian Calendar
- Astronomical year numbering
- 86400 s constant length of day.

Add some exmples of shortcomings of the above semnatics with ref. to
UTC timescale (missing leap seconds) and UT timescale (variable
legth of day).

Closes numpyGH-20675

The computed results, `50491123200` seconds, is obtained as the elapsed
number of days (`584388`) times `86400` seconds; this is the number of
seconds of a clock in sync with earth rotation. The exact value in SI
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused here, wouldn't a clock in sync with the earths rotation be UTC?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, by defnition a clock in sync with earth rotation would be UT1 or, disregarding polar motion, simply UT. It is known that the earth is slowing down its rotation rate, therefore one UT1 second is not a uniform time scale. UTC on the contrary ticks at exactly one SI second rate, and therefore is "uniform". It is the stepping provided by the leap seconds that keeps UTC within 0.9s from UT1 and hence earth rotation.

UTC is a "realized" time scale, so it is not define before its inception (1972 with current rules, 1963 with a different stepping mechanism).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe note that the value of second will change as the earth's rotation rate changes..

@miccoli
Copy link
Contributor Author

miccoli commented Feb 13, 2022

This PR is slowly drifting into oblivion... probably because it is considered low priority.

Let me try an apology and clarify the motivation. First of all, numpy docs should explicitly state that the proleptic Gregorian calendar with astronomical year numbering is adopted.

  1. Dates before 1582 are ambiguous. Quoting ISO 8601 (Date and time — Representations for information interchange)

    Usage of the Gregorian calendar for identifying dates preceding its introduction (15 October 1582) should only be by mutual agreement of the communicating partners.

    This requires that the calendar system should be explicitly defined, as e.g. the Python datetime docs do.

  2. Astronomical year numbering is not ambiguous (year zero and negative years do not exist in the BC/AD system used in historical year numbering) but casual users may wrongly assume that year 100BC is year -100.

Finally the assumption of 86400 second per year is at odds with current civil time usage, because UTC has positive and negative leap seconds. A brief remainder of this fact could be useful and is introduced by this PR.

The final part of the PR simply oultines the fact that timestamping distant past event with µs granularity makes little sense, if the adopted timescale is not carefully discussed. In other words we have only an approximate knowledge of the UT timescale in the past (and also in the future, since earth rotation is impredictable with this accuracy) so that the achievable precision (given by the datetime64 granularity) is several order of magnitude smaller than any sensible accuracy.

@charris
Copy link
Member

charris commented Feb 13, 2022

Sorry for letting this slip by, I did intend to merge it with some clarifications.

@miccoli
Copy link
Contributor Author

miccoli commented Feb 13, 2022

Sorry for letting this slip by, I did intend to merge it with some clarifications.

No problem for the delay, this is just a minor correction to the docs.

As what regards your request of clarification, I think that we can safely omit the last example, that shows the difference between an uniform SI second time scale (like TAI or TT) and an earth rotation timescale like UT. The discussion of TT vs UT1 is in fact beyond the mere datetime64 semantics, and can be misleading for users not interested in astronomy. Moreover users interested in astronomy would use more specialized libraries, like astropy.

Let me know if you think that I should delete the last example.

@charris
Copy link
Member

charris commented Feb 13, 2022

I think the difference between uniform seconds and earth rotation seconds is interesting and worth knowing about, it just needs to be clear why fixing a (solar?) day to 86400 seconds results in non-uniform seconds.

@charris charris merged commit 924791e into numpy:main Feb 16, 2022
@charris
Copy link
Member

charris commented Feb 16, 2022

Thanks @miccoli .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DOC: "datetime64" explicilty define the calendar semantics as "proleptic Gregorian" with fixed length of day.
2 participants