Skip to content

Fix loading of IERS data files - #9204

Closed
aarchiba wants to merge 10 commits into
astropy:masterfrom
aarchiba:iers_bug
Closed

aarchiba wants to merge 10 commits into
astropy:masterfrom
aarchiba:iers_bug

Conversation

@aarchiba

@aarchiba aarchiba commented Sep 6, 2019

Copy link
Copy Markdown
Contributor

This test suite has them marked as xfail, but there are some troubling anomalies in the handling of the IERS B data. Tests demonstrate, and currently xfail:

  • The IERS B data is not loaded into the IERS_Auto object if new IERS A data is not available, even though the IERS B file is present.
  • When new IERS A data is available, the columns dX_2000A_B and dY_2000A_B are not loaded in from the (potentially new) IERS B data that is available, unlike UT1_UTC_B, PM_X_B, and PM_Y_B.

Also, not exactly a bug, but it is good to have tests to let us know when this has occurred:

  • The IERS will occasionally change existing, old, IERS B entries when releasing a new IERS B file. This can lead to surprising non-reproducibility, and it argues for ensuring that the version of IERS B distributed with astropy is recent (in hopes that they do not often change the old entries).

@astropy-bot astropy-bot Bot added the utils label Sep 6, 2019
@aarchiba aarchiba changed the title Test loading of IERS data files to reveal several bugs Fix loading of IERS data files Sep 9, 2019
@aarchiba

This comment has been minimized.

@taldcroft

Copy link
Copy Markdown
Member

@aarchiba - thanks for this! I haven't looked at this in detail yet but it is on my to-do list unless @mhvk gets there first.

@taldcroft
taldcroft requested review from mhvk and taldcroft September 9, 2019 17:48
@aarchiba

Copy link
Copy Markdown
Contributor Author

I believe that the PR now fixes both bugs (and has tests). It also tests for changes in IERS B between astropy's built-in IERS B and the published one on the places where they overlap. There remains an awkwardness to do with IERS_Auto and IERS B, specifically that IERS_Auto never updates the IERS B data.

@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.

Thanks very much for this! Some initial comments. Note that I still haven't quite wrapped my head around the various things we actually want, and perhaps we should try to enumerate that. Is it roughly the following?

  1. IERS_Auto should make "best estimate from A and B" for all five columns, not just the three UT1_UTC, PM_X and PM_Y (included here).
  2. IERS_Auto without on-line connection should make a look-alike file from the IERS_B file (included here).
  3. It should be possible to have IERS_B be up to date (not included here).
  4. Any update on IERS_B should propagate to IERS_Auto (not included here).

I think (1) is uncontroversial. (2) is less obvious to me - if we do it, I think all columns should be populated, also *_A ones (or at least the column with the flag). I'd like to understand, though, whether it is useful to have those extra columns, or perhaps rather, whether it still would be useful if we did have (3) and possibly (4).

Comment thread astropy/utils/iers/iers.py Resolved
Comment thread astropy/utils/iers/iers.py Resolved
Comment thread astropy/utils/iers/iers.py Resolved
Comment thread astropy/utils/iers/iers.py Resolved
in the downloaded IERS-A table.
"""
iers_b = IERS_B.open()
iers_b = IERS_B.open(IERS_B_FILE)

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.

I think I'd prefer to change the docstring and use whatever IERS_B is available (possibly newer than bundled).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It turns out this makes testing extremely frustrating. The astropy cache provides a kind of shared global state that makes systematic testing very difficult - I finally gave up and did this when the previous approach gave me unpredictable results. (Note that PR #9182 provides a solution to this particular problem.) I think the solution is actually a larger structural change.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think with adequate documentation this could be made to work:

  • If the user wants a specific table version, use IERS_B.open("iers_b.table")
  • If the user wants the built-in version, use IERS_B.open(IERS_B_FILE)
  • If the user wants the cached version, falling back to IERS_B_FILE or raising an error for IERS_A, they can just do IERS_B.open()
  • If the user wants auto-updating, use IERS_Auto.open() (which starts with whatever is in cache).

This works for earth_rotation_table as well as direct use of the tables.

It's still different from now, where using no-argument open gets you whatever is stored in the class-wide cls.iers_table. But I can make that change fairly easily.

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.

Agreed that from a user perspective, with the new earth_rotation_table, it is possible to select whatever one wants. Here, it is about the behaviour of IERS_Auto - where does it gets its IERS-B values. Choices are:

  • Use IERS-A IERS-B values (but those are not quite OK);
  • Use bundled IERS-B file (but can be out of date; would happen with your change);
  • Use whatever the current default is - bundled until something specific downloaded prior to IERS_Auto() (current behaviour; note: currently, any IERS_B_URL downloaded in a previous session is ignored);
  • Use most current already downloaded version (i.e., as current, but do not ignore previously downloaded IERS-B);
  • Ensure IERS-B is kept up to date in the same way IERS-A is.

For this PR, my tendency would be to document the present state...

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.

Is this now resolved?



@pytest.mark.parametrize("keyword,atol", test_columns)
@pytest.mark.xfail(

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.

Since we turned expected failures that fail to fail into failures (parse that!), this seems a bit risky: don't really want CI to start failing when we update the bundled IERS_B and a downloaded IERS_B actually agrees with it! I guess we need some kind of "allowed fail".

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Well, I don't know - maybe it's good if something lets us know when we've changed the bug profile of the code base? The sequence will be: someone drops in a new IERS B table, the test suite grinds to a halt with XPASS, they say "huh", they remove the xfail notification, hopefully leaving an explanation, problem done.

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.

I guess the question then becomes why we are testing what IERS is doing? The tests should test that our code makes sense. In principle, we could run it with snippets of files for which the outcome is guaranteed to be correct (that's done with some IERS_A snippets in iers/tests/data)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is a different category of test, I guess - not "does our code do something wrong?" but "has upstream done anything we need to know about?". Maybe not appropriate as part of the test suite, exactly, but I think maybe we do need to know about it?

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.

Not being familiar with IERS updates and such, I just want to point out that we have set pytest to fail on XPASS with:

xfail_strict = true

As a result, if XPASS starts to happen, CI will fail even for unrelated push events (e.g., someone else's PR). Is this what you are going for? If not, I would advise to rethink this test setup.

@mhvk

mhvk commented Sep 15, 2019

Copy link
Copy Markdown
Contributor

@aarchiba - I factored out the addition of dX..., dY... to #9237, so that we can at least get that uncontroversial piece in (rebased it of a commit of yours, so credited appropriately).

For the default for off-line of just using IERS B (current) versus making it a mock-up of the IERS A/B combination, I'm less sure what the best path is. We may be better off lopping off items in #9227.

@bsipocz

bsipocz commented Sep 17, 2019

Copy link
Copy Markdown
Member

Now that #9237 is merged, this needs a rebase.

IERS_Auto merges in columns from the IERS B table. But as it stood,
the version of IERS B that was used was difficult to control. Now
it always uses the version built in to astropy.
@bsipocz bsipocz added this to the v4.0 milestone Sep 17, 2019

@pllim pllim 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.

@mhvk and @taldcroft , do you have time to do a final review before feature freeze? Thanks!

in the downloaded IERS-A table.
"""
iers_b = IERS_B.open()
iers_b = IERS_B.open(IERS_B_FILE)

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.

Is this now resolved?



@pytest.mark.parametrize("keyword,atol", test_columns)
@pytest.mark.xfail(

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.

Not being familiar with IERS updates and such, I just want to point out that we have set pytest to fail on XPASS with:

xfail_strict = true

As a result, if XPASS starts to happen, CI will fail even for unrelated push events (e.g., someone else's PR). Is this what you are going for? If not, I would advise to rethink this test setup.

@pllim

pllim commented Oct 24, 2019

Copy link
Copy Markdown
Member

Also needs a change log. Thanks for your patience, @aarchiba !

@mhvk

mhvk commented Oct 24, 2019

Copy link
Copy Markdown
Contributor

@aarchiba - your PR directly led to #9244, which I think solves most of the probllems, hopefully more elegantly. Given that, is this PR still useful? My sense would be to eventually deprecate the caching on classes, and move to having IERS_A_Auto() and IERS_B_Auto() classes, with IERS_Auto providing the former if possible, and the latter if not.

@aarchiba

Copy link
Copy Markdown
Contributor Author

Yes I need to take a look at this and see what if any of it is relevant in light of the ScienceState stuff - maybe just the tests, maybe nothing, maybe there is some useful code here.

@aarchiba

Copy link
Copy Markdown
Contributor Author

Some of the tests are probably still useful to make sure that table merging does something sensible, and we might still need the from_iers_b to cover when IERS A is not available. It's a little bit hard to judge as is - maybe I should rebase it on top of #9244 ? Does that make sense? I mean I think this only makes sense as an extension of the ScienceState work.

I think, too, it's fair to say that this PR is not needed to introduce any new features or make significant API changes, just to (I hope) enhance testing and reveal and fix bugs. So perhaps it can wait for #9244 ?

@pllim

pllim commented Oct 28, 2019

Copy link
Copy Markdown
Member

#9244 is merged. Is this still on track for 4.0?

@bsipocz

bsipocz commented Nov 14, 2019

Copy link
Copy Markdown
Member

What's the status here?

@bsipocz

bsipocz commented Nov 19, 2019

Copy link
Copy Markdown
Member

@aarchiba @mhvk @pllim - What are the plans with this in respect of 4.0?

@pllim

pllim commented Nov 19, 2019

Copy link
Copy Markdown
Member

Let's punt this to 4.0.1.

@pllim pllim modified the milestones: v4.0, v4.0.1 Nov 19, 2019
@pllim

pllim commented Dec 12, 2019

Copy link
Copy Markdown
Member

This now has conflict.

@taldcroft
taldcroft removed their request for review December 12, 2019 22:15
@astropy-bot

astropy-bot Bot commented Feb 20, 2020

Copy link
Copy Markdown

Hi humans 👋 - this pull request hasn't had any new commits for approximately 5 months. I plan to close this in a month if the pull request doesn't have any new commits by then.

In lieu of a stalled pull request, please consider closing this and open an issue instead if a reminder is needed to revisit in the future. Maintainers may also choose to add keep-open label to keep this PR open but it is discouraged unless absolutely necessary.

If this PR still needs to be reviewed, as an author, you can rebase it to reset the clock.

If you believe I commented on this pull request incorrectly, please report this here.

@bsipocz bsipocz modified the milestones: v4.0.1, v4.0.2 Mar 21, 2020
@astropy-bot astropy-bot Bot added the closed-by-bot Closed by stale bot label Mar 23, 2020
@astropy-bot

astropy-bot Bot commented Mar 23, 2020

Copy link
Copy Markdown

I'm going to close this pull request as per my previous message. If you think what is being added/fixed here is still important, please remember to open an issue to keep track of it. Thanks!

If this is the first time I am commenting on this issue, or if you believe I closed this issue incorrectly, please report this here.

@astropy-bot astropy-bot Bot closed this Mar 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug closed-by-bot Closed by stale bot utils

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants