-
-
Notifications
You must be signed in to change notification settings - Fork 2k
First attempt at IERS A, B table classes, interpolation of UT1-UTC. #1145
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
Conversation
astropy/utils/iers/iers.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that the mixture of boolean and integer values in this expression is confusing. The fact that False == 0 and True == 1 in Python is more a historical accident and shouldn't be treated as such in expressions. I'd rather see this broken up into some easier to parse boolean expressions and conditional operators.
|
Nice--I like that this makes use of Also, I don't think the file path for the tables ( |
|
@iguananaut - thanks for the comments. I implemented the easy ones, just so this doesn't stall altogether. But I'm a bit unclear about how to proceed, so I thought it would be good to try to clarify what behaviour is expected, following partly your last comments on #351, with questions where I do not really know what to do. Starting from the perspective of
Here, an implicit assumption is made: we do not want to load the IERS table on startup or on just any invocation of Time, but we also do not want to have to reload the whole ascii table for any new UT1 request. So, should the table stay around for the session? Or be garbage collected with Time? How does one implement this? Somehow attach it to the life Time class copy? Note that most of this should be in IERS, not in Time, since IERS also provides polar motion (PM_x, PM_y), which is needed for coordinates. Finally, what if someone insists on using IERS B. Maybe that is a Suggestions most welcome! (same from @taldcroft, @cdeil, @eteq, @astrofrog, @mdboom) |
|
The previous bug I introduced makes clear I should start writing tests. Will do so once there is some consensus on the approach being a good one. |
This one is simple enough. Although the
Regarding automatic downloading I'm not sure. I think there should be a I'm not sure what's best though. The recent tzinfo discussions on Python-dev might be instructive in determining how best to handle this. |
|
This one is simple enough. Although the Glad to hear it is simple... I really had no idea but as you used a term I did not know (memoize), some googling did the trick. I'll think about class vs function and will try this at home ;-)
I'm tending against the automatic download (nicer if results are predictable, independent of the existence of an internet connection). Since it also is easier, I'll just start with that. One more practical question: what would be the logical place to store the data in the package? A data subdirectory? Or rather a top-level data directory (joining cextern, docs, etc.) Added comment: how do you get the quoting of someone's message? clearly, ">" from an e-mail did not work... (perhaps I have just lost all options to mark by sending an e-mail. very odd). |
|
@mhvk - this is precisely the sort of situation the That will automatically download the file if it's not present, and if it is, it will use the cached version. One thing currently missing from this function is a way to specify when a cached file should be refreshed. So far it hasn't been needed, but in this case it's pretty obvious you want to periodically get the bulletins once they're out-of-date. So that leads to a strong reason to implement this behavior (and I added #1162 to address this). Also, I am strongly against any behavior other than defaulting to downloading the latest bulletin. IERS A comes out weekly, while B is monthly. We certainly don't want to update the source code that frequently, so we have to download it by default if we want to keep it up-to-date. I wouldn't be averse to including one copy in source (which we explicitly don't keep very up-to-date) just so the code works when offline, but then there needs to be a warning along the lines of "couldn't get IERS data. Orientation parameters and DUT1 (UTC-UT1) might be quite wrong." if someone tries to use the source code version if e.g. they are offline. |
My inclination would be effectively lazy-loading the latest table into the cache only at the point when the existing table (either from the source tree or from the cache) does not cover the time span required. I.e. if you are doing transforms in year 2001 then nothing will ever happen, but if you are doing transforms for last week then it will see that the existing table doesn't have those DUT1 values and update the cache file accordingly. This should happen automatically by default. I would have logging output concerning the download at the debug level so for typical users everything is seamless and just works without too much chatter. I feel pretty strongly that if valid IERS data are not available for a given transformation then this should result in an exception, not a warning. Getting the wrong answer (by a lot or a little) is not an option for The implication here is that if a user is really offline and needs to do transforms at dates more recent than their cached file, they will have to set |
The table should be loaded the first time it is needed and then stay around for the session as a module global. I am never sure about the very best way to do this (maybe @iguananaut) has an opinion, but I usually use one of two options:
I sort of like 2 better. |
I realized you already have I think something like this should work. The use of a |
|
Thanks for the detailed comments: |
|
A bit too many commits, and possibly the disappearance of one of my comments, but anyway, it is now possible to do: which gives |
|
@taldcroft, @eteq, @iguananaut - I have been thinking a bit about how to proceed with IERS/UT1 and believe it would be better to split off "how to deal with (down)loading the right file" from "how to read IERS and pass UT1-UTC to Time". As what I have nearly completes the latter, I'd suggest to get it working first, assuming a fixed IERS file in some standard astropy location. This would allow us to focus on one part at the time. Does this make sense? If so, could you check that you think my set-up is OK? A specific question I had was about best practice in memoizing the table: should I just be keeping the columns that are actually used (saving memory)? (As it is, I keep the full table, but it is easy to change.) For this part, the two questions from the IERS file perspective, are: p.s. I did think a little on whether the current structure is OK for the downloading/user-cache stuff, and concluded it was easily done as part of the |
|
@mhvk - Sure it's fine to "down-scope" this to just parsing for now and separately deal with the download. That makes sense given #1162 is probably needed for that part anyway. I am with @taldcroft that an exception should be raised if the table is "out-of-date" though. For your two questions:
(I'll let @taldcroft address the question of how to best store the table - I'm not sure, myself.) |
|
Oh, and @mhvk - it looks like somethings weird with your branch here, and there's an unnecessary merge. The following should do the trick: (This assumes your remote for the main astropy repo is called "astropy", and yours is called "mhvk" - in practice probably one of them will be called "origin" - which one depends on exactly how you first cloned your local copy) Even better, you might instead replace the second-to-last step with I've backed up this branch on my repo (https://github.com/eteq/astropy/tree/mhvk-time-ut1-backup-old), so if you get into any trouble with this, I can help you restore it. |
|
@eteq - OK, I rebased. Also some answers (and questions)
|
|
@taldcroft, @eteq, @iguananaut - now added documentation within the files as well as further tests (to ensure it doesn't inadvertently break again). I think it is in decent state; if you think so too, I can add further documentation -- I guess this would be both in |
|
@mhvk - awesome. For my part I'm a little swamped now and won't be able to give this big-ish PR a proper look until next week. @iguananaut is on travel as well at the moment, not sure when he returns. |
astropy/time/core.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure it makes sense for this to be an instance-level variable. Perhaps it should instead be a module-level ConfigurationItem? Or is there some use case I'm not recognizing where someone would definitely want to use A or B simultaneously for different objects?
|
@mhvk - this is looking on the right track to me too - I left a few comments inline, although I didn't do a terribly thorough review of the actual implementation (as I'm not completely up on the time internals). Oh, and regarding your One final thought: it looks like you're not testing the A parser, quite reasonable given that you wanted to implement the download for that separately. Can you just add a note somewhere prominent in the A source code that indicates it has not yet been tested? Once the downloading is taken care of, we can add a test for it and remove that note, but I wouldn't want someone to try to use it and not realize it's unfinished (or have us forget to add the relevant test, seeing as how B is being tested). |
|
@eteq - I just sent a new commit, which addresses some of the issues you raised:
p.s. Am confused with the one failed travis test, which seems entirely unrelated to my PR (2098.10). |
|
@mhvk - responding below to your items
Along the same lines, I don't understand why
Finally, the travis failure was apparently some random glitch - I re-ran the build (something that only the repo owners can do, annoyingly), and it now appears to be passing. |
astropy/utils/iers/iers.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we make this "just work" by instead going to the A table as needed and issuing a warning rather than exception?
|
@eteq - some more thoughts (before adjusting too much)
@taldcroft - I'm hoping to postpone the "just work" part for IERS A, since we agreed this would not be included in the standard astropy package and it thus requires having set up the automatic downloads, etc., which I think is much better done as a separate PR (definitely after I get proper barycentering to work...). 2&3) I think I see what you are saying, but am not completely sure about the conclusion. As it is, users can put there own IERS files as keywords to the |
|
@mhvk - re: 2&3: my interpretation of what you've done here is that we generally don't expect the users to be using If they want to do something unusual with |
|
@taldcroft - I rethought the IERS A vs B case, and ended up concluding that it might be better to stick to IERS B by default for now. Partly, it seems better for the default to be "final values or an exception" and partly it is that as long as the automatic download is not implemented, predictions might too easily get used where final values are available. But it is also because I wasn't quite sure how to deal with the configuration item, and thought choices might well change when we do the downloading. Hence, apart from documentation updates, the main change here is to implement a Finally: I do see your concern over the memoization, but am unsure how to address it... |
|
@mhvk - I agree with your approach now and the scope seems good. We can (will) come back to this. |
|
@taldcroft - I think I got them all. Updated the example with |
|
@mhvk - this looks OK now, you just need to rebase to clear up the merge conflict. Thanks! |
Correct bug introduced with previous commit
Correction to linkage to Time
Cleanup of interfaces
|
@taldcroft - OK, rebased. |
Provide IERS A, B table classes for interpolation of UT1-UTC.
A start at addressing #351 (tried but could not convert that one to a pull request).
At present, no integration at all with Time yet, and for now one has to download IERS A (http://maia.usno.navy.mil/ser7/finals2000A.all) or IERS B (http://hpiers.obspm.fr/iers/eop/eopc04/eopc04_IAU2000.62-now) and have it in one's working directory (though this is configurable). Also, IERS A and B return different types (masked and normal Columns).
Nevertheless, one can already do the following:
gives (note: leap second)
But does not go to present
So, maybe better to use IERS_A:
which gives