Skip to content

Change epoch of TimeUnixTAI to 1970-01-01T00:00:00.0 TAI, fixes #11245 - #11249

Merged
taldcroft merged 1 commit into
astropy:masterfrom
maxnoe:fix_unix_tai
Jan 22, 2021
Merged

taldcroft merged 1 commit into
astropy:masterfrom
maxnoe:fix_unix_tai

Conversation

@maxnoe

@maxnoe maxnoe commented Jan 14, 2021

Copy link
Copy Markdown
Member
  • TimeUnixTAI (name unix_tai) used the epoch 1970-01-01T00:00:00 UTC
    since its introduction in astropy 4.2, however, contrary to the
    documented behaviour, this is not the definition of CLOCK_TAI on linux
    and no system using this epoch is known.

  • This switches the epoch to 1970-01-01T00:00:00.0 TAI to match the
    intended defintion of being compatible to CLOCK_TAI on linux and also
    is the definition of the now obselete and not yet released
    TimeUnixPTP, which is removed in this commit.

Fixes #11245

@github-actions github-actions Bot added the time label Jan 14, 2021
@maxnoe

maxnoe commented Jan 14, 2021

Copy link
Copy Markdown
Member Author

@mhvk @pllim @r-owen

@pllim pllim added this to the v4.2.1 milestone Jan 14, 2021
@pllim pllim added the Bug label Jan 14, 2021
@pllim
pllim requested review from mhvk and taldcroft January 14, 2021 17:57
@pllim

pllim commented Jan 14, 2021

Copy link
Copy Markdown
Member

As @taldcroft mentioned in #11245, #11143 is slated for 4.3 and not yet released. However, you requested this to be milestoned to 4.2.x, so what other PR is this reverting that was released in 4.2; Can you please clarify? Thanks!

@mhvk mhvk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good, thanks! One thing to add is a quick change for the epoch for unix_tai listed in docs/time/index.rst (in "Time from epoch formats"; I hope I caught everything...)

Comment thread astropy/time/formats.py Resolved
@mhvk

mhvk commented Jan 14, 2021

Copy link
Copy Markdown
Contributor

Oops, failure is real too: the format list in one of the docstrings needs to be adjusted.

@maxnoe

maxnoe commented Jan 14, 2021

Copy link
Copy Markdown
Member Author

@pllim

TL;DR

This is a bug fix for a feature introduced in 4.2 which makes an already merged feature planned for 4.3 obsolete.
This is why this is milestoned for 4.2.x but reverts a PR milestoned 4.3.

Summarizing the discussions in #11245 and #11143 the situation and how we got here is as follows:

We now realized, that the proper epoch for TimeUnixTAI should have been 1970-01-01T00:00:00.0 TAI.
This makes UnixTimePTP unecessary, so it is removed.

@r-owen r-owen left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thank you for making this change.

Comment thread astropy/time/formats.py Resolved
@taldcroft

Copy link
Copy Markdown
Member

Sorry @maxnoe, you kind of beat me to it, but I was planning to literally revert #11143 by hitting the revert button on GitHub. I think that is cleaner than taking it out as part of this fix.

@taldcroft

Copy link
Copy Markdown
Member

Then this fix will be nothing more than changing '1970-01-01 00:00:08' to '1970-01-01 00:00:00' in the right places and fixing tests.

@taldcroft

Copy link
Copy Markdown
Member

Doing it this way makes backporting this change possible, at least if I understand things.

@maxnoe

maxnoe commented Jan 14, 2021

Copy link
Copy Markdown
Member Author

Yes I agree, will rebase.

@maxnoe

maxnoe commented Jan 14, 2021

Copy link
Copy Markdown
Member Author

Done, this now only contains the changes to TimeUnixTAI and the TimeUnixPTP PR can be reverted via github.

@taldcroft

Copy link
Copy Markdown
Member

See #11251.

@maxnoe

maxnoe commented Jan 15, 2021

Copy link
Copy Markdown
Member Author

@pllim I misread the changelog. UnixTimeTAI was already part of 4.1, so we should milestone for the next 4.1.x release here.

Comment thread astropy/time/formats.py Outdated
class TimeUnix(TimeFromEpoch):
"""
Unix time: seconds from 1970-01-01 00:00:00 UTC, ignoring leap seconds.
Unix time (UTC): seconds from 1970-01-01 00:00:00 UTC, subject to leap seconds.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The words subject to are ambiguous. Please leave this as it was originally.

@maxnoe maxnoe Jan 15, 2021 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ignoring is just wrong. UTC is the only timescale that has leap seconds. Subject to may be ambiguous, but it is rightly so because it confers to the reader that it is not as simple as "ignoring" and that one needs to understand what is actually happening.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In this context "ignoring leap seconds" is equivalent to the definition of unix time which is computing the seconds since the epoch assuming exactly 86400 seconds in every day. The actual unix time on a computer is as simple as ignoring, no?

The value of Unix time on a computer is related to the UTC time name components (year, yday, hour, min, sec) according to the expression:

tm_sec + tm_min*60 + tm_hour*3600 + tm_yday*86 400 + (tm_year-70)*31 536 000 + ((tm_year-69)/4*86 400

Comment thread astropy/time/formats.py Outdated

For example, 946684800.0 in Unix time is midnight on January 1, 2000.

In unix time, each UTC day always has exactly 86400 seconds, even on

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please keep PR's in scope. I think that the new content is actually confusing the situation because of the mix here between POSIX unix time and astropy unix_time. In particular with the new text, the meaning of "NOTE: this quantity .." becomes ambiguous. I think the original paragraph is sufficient, so please just revert these new paragraphs.

Comment thread astropy/time/formats.py Outdated
and the linux CLOCK_TAI (https://www.cl.cam.ac.uk/~mgk25/posix-clocks.html).

For more information on this time format definition, see:
https://www-acc.gsi.de/wiki/Timing/TimingSystemButisInterface#Time

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm not sure this link is relevant in this context. The "time format definition" from the typical user perspective is quite simple and stated clearly in the first line. The link provides a lot of information on a complex protocol which uses TAI, but I didn't learn anything more about the time format definition.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This was copied from the PTP docs that were introduced and now reverted. Since the two formats are now the same I thought it should be merged.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I was thinking of PTP as the format introduced in the context of these physics libraries you reference, and unix_tai as the one for most astronomers. On re-reviewing this as a change to the unix_tai docs it just seems out of place and not a generally useful link for most users of the format.

Comment thread astropy/time/formats.py Resolved
Comment thread astropy/time/formats.py Resolved
Comment thread astropy/time/formats.py Outdated
>>> jyear = np.linspace(2000, 2001, 20)
>>> t = Time(jyear, format='jyear', scale='utc')
>>> plt.plot_date(t.plot_date, jyear)
>>> plt.plot_date(t.plot_date, jyear) # doctest: +IGNORE_OUTPUT

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why was this needed?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

because plot_date returns a Line object which lead to a doctest failure.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That makes sense, but makes me wonder why it was passing tests before. Did something else change in the meantime that made this doctest line suddenly start failing?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@maxnoe - did this fail for you locally or in the CI tests? (good to change regardless, but also good to understand indeed why this did not trigger problems before!)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It failed locally, did not check the CI, I fixed this together with other test failures so I don't know whether this also affected CI or whether something with my local setup was strange. Can change back to check.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actually, right now we instruct the test to be skipped:

__doctest_skip__ = ['TimePlotDate']

If with you IGNORE_OUTPUT, this works, perhaps we can change it to a matplotlib requirement?

__doctest_requires__ = {'TimePlotDate': ['matplotlib']}

(Though if you prefer to just leave things as they were, that's fine too!)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think this is best for another PR, will revert the change here.

Comment thread CHANGES.rst Resolved
@maxnoe

maxnoe commented Jan 18, 2021

Copy link
Copy Markdown
Member Author

@taldcroft I removed most of the docs changes and will open another PR about that.

We should get this fixed, so I don't want to discuss about leap second wordings here.

@taldcroft taldcroft left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just one last doc suggestion, otherwise good. Thanks @maxnoe !

Comment thread astropy/time/formats.py Resolved
Comment thread astropy/time/formats.py Resolved
…py#11245

* TimeUnixTAI (name unix_tai) used the epoch ``1970-01-01T00:00:00 UTC``
  since its introduction in astropy 4.1, however, contrary to the
  documented behaviour, this is not the definition of CLOCK_TAI on linux
  and no system using this epoch is known.

* This switches the epoch to ``1970-01-01T00:00:00.0 TAI`` to match the
  intended defintion of being compatible to CLOCK_TAI on linux and also
  is the definition of the now obselete and already removed ``TimeUnixPTP``,
  which was thus never part of a realeased version of astropy.

@taldcroft taldcroft left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @maxnoe !

@taldcroft

Copy link
Copy Markdown
Member

ci/circleci: image-tests-mpldev failure looks unrelated so merging this.

@taldcroft
taldcroft merged commit fc941c3 into astropy:master Jan 22, 2021
@maxnoe
maxnoe deleted the fix_unix_tai branch January 22, 2021 12:06
eteq pushed a commit that referenced this pull request Mar 25, 2021
Change epoch of TimeUnixTAI to 1970-01-01T00:00:00.0 TAI, fixes #11245
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.

The unix_tai time format appears to be off by 8 seconds

6 participants