-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Fix coordinate transformations near Earth #4254
Conversation
Background for those other than @eteq: this bug was discovered when I was trying to compute the position of the moon using My test code computes the alt/az position of the moon using PyEphem and compares it to the alt/az position I get from
When I run the same script with |
from .builtin_frames import ITRS | ||
|
||
return ITRS(x=self.x, y=self.y, z=self.z) | ||
|
||
def get_itrs(self, obstime): |
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.
If we define obstime=None
here (or whatever is necessary to make it use the "default obstime"), you can just do itrs = property(get_itrs)
and remove the duplicate definition above.
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.
good point! will do.
@eteq - so far only looked at the |
@bmorris3 : Hmm, I got a few errors relating to
which is a lot closer than before. Is there any chance you're running from an old version of my |
@mhvk - You may well be right that I think that's better tackled separately for v1.2, though, as it's definitely not just a "bug fix". |
Good point @mhvk - just pushed up a new commit doing just what you suggested there. |
So is this ready to be merged? I'd like to release v1.0.6 ASAP. |
@embray Well, it doesn't look like anyone has reviewed the transformation code yet... So we could merge it given the tests are passing and such, but it would probably be better if someone other than me would review the distance calculations... (@adrn or @astrofrog?) |
@eteq - from #4254 (comment), it seemed there was still a problem at the ~degree level. Has that been resolved? |
It can be delayed for 1.0.7 if need be. Or merged provisionally since it at least superficially fixes the problem...?? |
Sorry -- won't have time to review in detail before, say, Nov. 1 :( |
Alright, I made some more adjustments to @bmorris3's moon test code and also tested this on a branch that includes both this (#4254) and #4255 - see https://gist.github.com/eteq/08dba433082e57b7f2af for what actually yields this:
Whereas a branch with just this gives the last two as:
So with that, the difference @mhvk is mentioning between PyEphem and astropy are at the <~half a degree level, which is also the disagreement between Skyfield and PyEphem (which are both by the same author and conceptually similar, but with somewhat different ephemerides). At that level I'm willing to chalk it up to subtle differences in how the various frames are to be interpreted (e.g., the ICRS/GCRS difference in the last two lines are because ICRS->AltAz includes aberration, light deflection by the sun, etc., which of course is not relevant for the moon but might be for objects elsewhere in the solar system). |
So unless someone thinks they can merge it within the next, say, day (is that your timescale for 1.0.6, @embray?), we should probably just merge and do a "live" review, as this is a big improvement over master/1.0.5 ... Of course there's nothing to stop us from merging and then getting a more thorough review when someone has time, with a follow-on PR fixing any major issues. |
I'm thinking more like the next hour, but yeah :) |
distance = altaz_coo.separation_3d(altaz_coo.location.itrs) | ||
locitrs = altaz_coo.location.get_itrs(altaz_coo.obstime) | ||
|
||
# To compute the distance in a way that is reversable with cirs_to_altaz |
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.
This block is in particular could use review/somebody else considering it. The geometry is rather confusing, but most importantly, I'm not certain how numerically stable this solution to the SSA trig problem is. So if anyone else knows a trick for this particular geometric calculation I'd love to hear it.
Hah, ok, that works too @embray - if you want to pull the trigger to make sure this makes 1.0.6, feel free to do so. I'd still appreciate whatever review this can get by someone willing to take the time to wrap their brain around the distance calculations, though! |
@eteq Maybe open an issue to ensure that this gets further review? |
Agreed that it is better to have something we at least think is correct! I'm happy to have this merged as long as we have a new issue with a very specific test case (the moon seems fine...). Ideally, for that, we also involve @brandon-rhodes. |
Fix coordinate transformations near Earth
Fix coordinate transformations near Earth
Just to note, when I backported this to v1.0.6 I had to remove some stuff related to galactic coordinates, I think it was?, that wasn't applicable to 1.0.x. But I confirmed that the other tests passed. |
@embray - am I right that 60edc62 is the commit that backported this to v1.0.x ? That seems to be the right diff, but the commit message doesn't seem right... That's not really a big deal, except that I wonder if it will confuse some of the backporting tools/log parsers? But the backporting all looks find in terms of the actual content! Will create a new issue shortly to prompt someone to do a review. |
Weird about the commit message. I think I might know how that happened. Now I need to make sure the other commit messages on that branch are correct.... I will fix it. |
This PR closes #4221. It turns out the problems there were a bit more complicated because there were two intertwined bugs:
AltAz
'sEarthLocation
. It turns out thatITRS
coordinate corresponding to theEarthLocation
was not correctly being set to theobstime
of theAltAz
, but rather defaulting to J2000. So distance were all computed relative to the J2000 location of the Earth rather than the currentobstime
. So this lead to distance errors of order 1-2 AU at any time other than J2000. This PR addresses that problem by creating a way to get theITRS
from anEarthLocation
with a particularobstime
, and then using that in the transformation.There's actually a lot more in this PR then just those fixes, but it's essentially all tests (new ones or reorganization of old ones), because figuring out the root cause of these issues involved a ton of testing the various transform steps. In any event, these tests should make solar-system scale transformations a fair bit better tested.
Note that I also tried backporting this to v1.0.x - there are some conflicts... nothing major, but I should probably do the backporting once this gets merged so that we can be sure the right things get backported. Backporting to 1.1.x should be clean, though.
@embray @astrofrog - this fix should actually go into both 1.0.x and 1.1.x, so I'm correct that I should milestone it for 1.0.6, right?
cc @bmorris3 @adrn @mhvk