Implement auto-downloading of IERS-A data - #4436
Conversation
|
And of course this needs to smoothly handle the case where the network turns out to be unavailable. First, use a timeout for the initial download of IERS-A. If this times out, then fall through to the standard IERS-B with a warning. (Note that in this case any extrapolation will generate an exception). Likewise if the currently cached IERS-A is too old and then the subsequent download of IERS-A fails, also fall through to IERS-B with a warning (which would also say how old the current file is). |
There was a problem hiding this comment.
I don't understand why a separate class instead of a new argument to the existing class's open method.
There was a problem hiding this comment.
I did think about that. My first issue is that the IERS class is already pretty confusing to me, so adding an option that completely changes the behavior (and in fact the class of the output) of open() is just too much.
The other problem that convinced me a new class is the best way is that all of the existing options to IERS.open() are moot in this case. Thus you would need to raise an exception if any args or kwargs besides the auto_update option were provided. That just seems like a bad API.
There was a problem hiding this comment.
Yeah, I thought that might be your thinking, and that makes sense.
If it were possible I would change the existing hierarchy such that there's some hidden _IERSBase class that is the same as the current IERS class, and what you're calling IERS_Auto would become just IERS. I wonder if it isn't too late to make that change since direct use of IERS isn't particularly advertised in the docs.
|
I still feel like if someone wanted to tackle #3961 that would make this mostly moot, but this is simpler for now... |
The caching is the easy part of this, and if someone does #3961 then that will be quickly inserted in here. The hard part (conceptually) is plugging a new default behavior deep into Time and Coordinates without screwing things up, while allowing for back-compatibility. |
|
One more thing is that it wouldn't be too hard to have "on-demand" downloading which is triggered by actually trying to do a conversion that is in a time range where newer data would help. The exact algorithm for this would depend on details of the IERS bulletin files. This tighter coupling is not ideal, but on the whole probably worth doing to prevent unnecessary network access. |
|
@mhvk @eteq - I have done a bunch of work on the auto-download of IERS data and I think this is getting very close. This PR is based on #4810 because it won't work without that. I know this is not going to be entirely straightforward to review, but please plan to carve out some time in advance of the code freeze. Some of the logic behind the behavior is a bit intricate, but I've tried to be fairly verbose in the code comments. Some known issues:
|
| @@ -0,0 +1,165 @@ | |||
| .. _utils: | |||
There was a problem hiding this comment.
@taldcroft , if you are talking about .../utils/index.rst:5: WARNING: duplicate label utils, other instance in .../utils/iers.rst Sphinx warning, it means that this label has been used. Change it to something more unique like .. _utils-iers: would fix the warning. Of course, you also have to change any references to this particular label (but not the other conflicting one).
There was a problem hiding this comment.
@pllim - thanks! I got sidetracked about the error it was reporting and usually expect Sphinx messages to be misleading or useless. In this case though I should have been able to see it.
|
OK, now something strange has come up. It looks like the IERS-B values that are supplied in the This came up in regression testing. |
|
Yikes, that is not good at all! Though now that you mention it, I vaguely recall that I saw that the two columns were not identical before (it is already strange that they have different number of significant digits, though the errors you find are clearly larger than this). There may be errors in initial versions of IERS B that are corrected but not propagated to IERS A. Sigh. |
|
So who is right? It's easy enough to use the actual available IERS-B values (that are bundled with astropy) in IERS_Auto. |
|
IERS B is supposed to have final values. |
| # radec_actual = ra=3.3094193224314625 deg, dec=15.183757021354532 deg | ||
| # distance = 2.6285 arcsec | ||
| assert distance < 5 * u.arcsec | ||
| assert distance < 10 * u.arcsec |
There was a problem hiding this comment.
Did this get worse? That seems very strange!
There was a problem hiding this comment.
Yeah, I'm also confused by this. I just tried a merge of this branch locally and found that 5 still works just fine...?
There was a problem hiding this comment.
This was probably due to the iers-b issue. I agree it should be possible to revert this change.
There was a problem hiding this comment.
Actually this is still a problem. @eteq - maybe you ran tests without --remote-data (which falls back to the IERS-B values)?
I think the source of difference is that with IERS_Auto you get the last available values for UT1-UTC instead of zero (for out-of-range IERS-B). That gives a time diff of 0.6 sec, which can mean up to 0.6 * 15 arcsec.
Looking at the testing for AltAz, I wonder if the discrepancies are related to time diffs?
Anyway, I propose that changing to the original 5 arcsec tolerance to 10 arcsec should be OK now that we understand it.
There was a problem hiding this comment.
OK, that sounds good. When you change the line, could you add a comment to remind us?
|
@taldcroft - I've started looking at this. Overall, it looks good, though I want to think a bit more whether it isn't possible to make more minimal changes to One annoyance: now that |
|
OK, I have some inkling of what's going on here: if you look at http://datacenter.iers.org/web/guest/eop you can see the original sources of the IERS_B files. There you'll see the curious fact that the official IERS B bulletin and the one that The That's a long way of saying: the B bulletin is probably always more right. It's also unclear where/when |
|
Oh, and one related note (not particularly critical here but could be fixed at the same time): @mhvk, is there a specific reason for getting IERS B from http://hpiers.obspm.fr/iers/eop/eopc04/eopc04_IAU2000.62-now instead of http://datacenter.iers.org/eop/-/somos/5Rgv/latest/214 ? The latter seem more "official" but hard to know... |
|
You might see something similar to #4896 with |
|
@taldcroft - I think not extrapolating is better (or setting to |
|
I think setting to |
|
Good point re: long time scales. I'm convinced (just make sure to add a quick note about that in API changes, is this is a small but possibly important change for anyone who actually cares about it) |
|
@taldcroft - still needs a changelog entry (including my suggestion of an "API change" mention for the changed extrapolation), but maybe you meant to do that post-rebase. With that, looks pretty solid! |
|
@eteq - yes, I had forgotten about the changelog, but compensated now by putting in 4 separate entries! Rebased version pushed. The commit in 274a10a might be controversial. I discovered that the So I can't say exactly what is going on here (just too long working on this), except that I think that previously the tests were "accidentally" passing by virtue of effectively zeroing out |
|
Huh, strange about the
So my hunch is that If the tests pass, I say we merge! |
Make IERS-A consistent with B and fix issue with table behaviors [skip ci] WIP on IERS caching [skip ci] Abstract out checking of interpolation indices to a method [skip ci] Intermediate commit, rebase later [skip ci] Add in logic for updating based on predictive times Mostly functional version with tests Add test IERS-A files Catch error downloading new IERS file Skip a doctest and make sure IERS table URL matches Remove IERS_HINT which no longer applies Add sanity check when extending IERS table Update documentation Get more tests passing Improve docs Fix some tests and whitespace cleanup
|
π |
Implement auto-downloading of IERS data
|
backported to 1.2.x in 7048693 |

This is a candidate implementation to resolve #3275.
I'm putting this up prior to writing tests or even having it pass existing tests because it may be controversial. π I've been thinking about this over the last week and have started at least four different versions. The trick is maintaining possibly strict back-compatible behavior (for the minority with this requirement) while introducing a default, SIMPLE behavior that just works for the majority. I find the existing IERS a bit confusing because of all the options that are supported.
The key is defaulting to auto-downloading and using IERS-A when required, by use of a new class
IERS_Auto. The exact caching mechanism is TBD, but as mentioned we know in advance exactly when the source file is updated, so it is a really easy problem in this case. In this implementation I just put in a config var that specifies how old the cached file can be. Don't worry about this bit. However, I will say that I thought about fine-tuned optimizations like @mhvk suggested in #3275 and in the end rejected them as just too complicated. I think it's better to have a simple scheme that can be explained and understood by users and developers in a sentence or two.What is more important is automatically using IERS-A via the
IERS_Autoclass inTimeandCoordinates. This means that when a user first requires IERS values the file will always get downloaded. Supplying an IERS-A file with astropy is a bit pointless because it will always get superceded very shortly.The auto-download behavior can be fully reverted to the current 1.1 behavior by setting a config var
astropy.utils.data.iers.conf.auto_downloadto False (default = True). Users that require the legacy strict IERS-B can do this.Another important idea: the
IERS_Autoclass is exempted from range checking because it is assured of having the most recent available data. This means the (possibly-clipped) interpolation is always within the confidence bounds of current Earth rotation knowledge. For actual use cases in astronomy (particularly observation planning) everything just works as well as it can given our best knowledge of Earth rotation. All the adhoc workarounds currently suggested would go away.Of course the downside is that (in the default behavoir) reproducibility to numerical precision would go away. But someone would be free to write a script with auto-download disabled and thus get reproducible behavior. And in all cases reproducibility to within confidence limits of Earth rotation parameters would not be affected.