Repository navigation
Let IERS table used in time/coordinates determined by science state - #9244
Conversation
610d35a to
70c0cd2
Compare
|
Very nice! But what about the global variables iers.IERS.iers_table and friends? Those will by default evade the control of earth_rotation_table. They don't seem to be much used in astropy itself (apart from IERS_Auto's no-network fallback), but are we setting up users for an unpleasant surprise when they use them? As it stands, they always have the value of "the last IERS table of this class that was opened". They are documented in the docstrings in iers.py. They make it awkward to obtain an IERS_Auto instance that isn't shared with anyone (you have to manually reset IERS_Auto.iers_table to None before and after your IERS_Auto.open()) - and if you don't, since IERS_Auto is mutable it can mutate under you if someone else requests a new value while you're working. |
|
@aarchiba - very good points. Might it make most sense to deprecate It would seem reasonably unlikely that anybody except PINT wants full control over the IERS tables, so I mostly want to be sure that we get it right for PINT! |
I do think those should disappear. Shame we can't (easily) make them properties that emit a DeprecationWarning when accessed... I can do the metaclass thing if you want, it does work. But maybe we just need to think through what users (if any) actually expect from these class attributes and only support that.
I was thinking about this - if we could count on IERS_Auto to keep IERS B up to date, and if we could just look at the columns in it that carry untouched IERS B data, we could drop the keep-things-up-to-date code we now have. Of course, as long as we're supporting python 2 we also need to work with astropy 2.0, so this is a down-the-road consideration. But I'm not sure astropy actually needs separate auto-updating IERS A and B classes. |
Not sure whether "we" is PINT or astropy here. If the latter, than we're approaching to the final drop of python2 super quickly, so no need to include that in any considerations. |
|
@aarchiba - I think that updating As for deprecating |
Sorry, yes, that was unclear. As I understand it, astropy's support of python2 is basically over; nothing since astropy 2.0 works on python2, and I don't expect this to make it in to that maintenance branch. So as long as PINT supports python2, it needs to work with that aging version of astropy. PINT's support of python2 is under discussion, but a number of key pieces of pulsar software do not work on python3, including one by one of the PINT maintainers. (And of course they are awkward to compile and install, so users may delay upgrading them.) So there will be a desire for PINT to keep working with python2 for some time yet. |
|
@eteq, @taldcroft - would you be able to review this new |
taldcroft
left a comment
There was a problem hiding this comment.
Looks generally good. I didn't know about ScienceState! I reviewed the parts relevant to time and left some minor comments.
| return table | ||
|
|
||
|
|
||
| class earth_rotation_table(ScienceState): |
There was a problem hiding this comment.
Might it be worth overriding the __repr__ so it does not try to print the whole IERS table? That isn't really helping out, and basically <ScienceState earth_rotation_table: IERS_A> is what users would want to see.
There was a problem hiding this comment.
Good idea. Since for that it is by far the easiest to adjust ScienceState as well, let me also ping @astrofrog (@astrofrog, I changed it such that the context repr never is more than 1 line)
| -------- | ||
| To temporarily use the IERS-B file packaged with astropy: | ||
|
|
||
| >>> from astropy.utils import iers |
There was a problem hiding this comment.
Don't these code blocks need to be indented with a leading ... packaged with astropy:: (two colons)? Or maybe I'm missing advances in sphinx/rst docs?
There was a problem hiding this comment.
Yes, I think those were not run the way I had it. Corrected...
| assert allclose_sec(t._delta_ut1_utc, -0.58682110003124965) | ||
|
|
||
|
|
||
| @pytest.mark.skipif('not HAS_IERS_A') |
There was a problem hiding this comment.
This diff is unfortunately not helpful, but I did a by-eye compare of the files for master and this branch. I'm just trying to make sure the existing test has not been changed substantively. You did change the way the delta and status values are computed. I think it's equivalent, but maybe life would be easier if you just left in the original two tests test_ut1_iers_A and test_ut1_iers_Auto and then add tests on top? This is finicky code so any time I see an existing test modified it rings bells.
I note that in the new do_ut1_prediction_test there is no check on the jd value being different for the non-context manager case.
def test_ut1_iers_A(self):
tnow = Time.now()
iers_a = iers.IERS_A.open()
tnow.delta_ut1_utc, status = iers_a.ut1_utc(tnow, return_status=True)
assert status == iers.FROM_IERS_A_PREDICTION
tnow_ut1_jd = tnow.ut1.jd
assert tnow_ut1_jd != tnow.jd
There was a problem hiding this comment.
OK, I reorganized the file so the diff is more obvious, and re-instated the .jd test (I had removed it since it is possible, at least in principle, that delta_ut1_utc equals 0. Though probably sufficiently unlikely that one might ignore that - much more likely something is wrong when the jd doesn't change...
70c0cd2 to
d35a45d
Compare
eteq
left a comment
There was a problem hiding this comment.
I like this pretty much as-is with just one change to suggest (and am approving on the theory that it is straightforward to implement): instead of earth_rotation_table it should be earth_orientation_table because it's not just rotation, these also have the polar motion and so on.
|
My logic was that IERS stands for "Earth Rotation (and Reference System)" and "orientation" misses the leap second aspect (while rotation does include wobbling...). But if you feel strongly, I will change; need to rebase anyway... |
|
@mhvk - IERS the organization has rotation in its name, but (admittedly, rather inconsistently), the files from their authoritative source (https://datacenter.iers.org/eop.php) are called "Earth orientation parameters", so I think "orientation". I guess really do be really pedantic it could be |
|
(So I guess that means I do feel strongly...) |
|
Last try: why would |
|
@mhvk - to me "rotation" is only the Earth spinning on its axis, and any motion of the axis is "orientation" not "rotation". But I admit this is deep down the pedantic road... (As a citation, I give https://en.wikipedia.org/wiki/Earth_orientation_parameters, but when I look at that it's still a bit ambiguous because it does say oreintation parameters are "irregularities in the rotation of the Earth"...) |
|
I'll go for |
|
Yeah orientation sounds reasonable to me (I can see arguments both ways but that'd be my choice if I had to pick a side) |
Mostly following ScienceState repr change.
d35a45d to
a0d2f27
Compare
|
OK, changed to |
|
So is this a merge if CI passes then? |
Addresses the first item in #9227, that it would be good to allow users to determine what IERS table is used for all time and coordinate transformations in astropy (specifically, this is to help PINT use an up-to-date IERS-B file rather than
IERS_Auto).Here, this is done with a new
iers.earth_rotation_tablescience state class, which is check in time and coordinates.cc @aarchiba
EDIT: changed name to
earth_rotation_table