You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Unexpected behavior with SkyCoord.separation method #6633
I noticed an unexpected behavior when computing separations between two sets of SkyCoords. When one of the SkyCoods is an array and the other is a single value, array.separation(value) produces the correct result but value.separation(array) does not. Here's a simple example involving computing the distance between the Kepler field and the moon.
FYI: I updated your comment above to add loc = EarthLocation.of_site('KPNO') (which was undefined before) - the exact site doesn't really matter, just need some Earth location to pass to get_moon().
In any case, yes, I can confirm that I see what you see in the plot! No immediate solution or explanation, but will take a look.
On second thought, I have an idea for what's going on, but haven't yet looked at .separation() to be sure (will get back to you shortly).
get_moon() returns the Moon's position in the GCRS frame, which is axis-aligned with the ICRS frame but is centered on the Earth's center of mass. I suspect that when you do moon.separation(kepler), it's converting the kepler ICRS position to the GCRS frame, then computing the separation in this time-dependent frame. When you do kepler.separation(moon), it's converting the GCRS moon position to the ICRS frame, and computing the separation there. It's not immediately obvious to me why the resulting curves look the way they do, but this small test seems to confirm: if I do this instead
@adrn is right. It may not be particularly intuitive - I’ve been bitten by this myself in the past - but this is the expected, and I think correct, behaviour.
posA.separation(posB) calculates the separation of A and B, in the frame of object A. The mistake is to think that separation gives the separation on the sky, when it does not.
Thanks for looking into this! If this is the expected behavior than that's great. It might help others if the docs were a little more explicit about this.
- The get_moon docstring doesn't say anything about the coordinates being in the GCRS frame.
- I imagine that calculating target/moon and target/sun separations is a pretty common use-case of the astropy package, so if the separation method is counter intuitive, this should be stated explicitly.
Cheers,
Erik
On Sep 30, 2017, at 11:39 PM, StuartLittlefair ***@***.***> wrote:
@adrn is right. It may not be particularly intuitive - I’ve been bitten by this myself in the past - but this is the expected, and I think correct, behaviour.
posA.separation(posB) calculates the separation of A and B, in the frame of object A. The mistake is to think that separation gives the separation on the sky, when it does not.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
Activity
adrn commentedon Oct 1, 2017
Hi Erik --
FYI: I updated your comment above to add
loc = EarthLocation.of_site('KPNO')(which was undefined before) - the exact site doesn't really matter, just need some Earth location to pass toget_moon().In any case, yes, I can confirm that I see what you see in the plot! No immediate solution or explanation, but will take a look.
cc @eteq @mhvk
adrn commentedon Oct 1, 2017
On second thought, I have an idea for what's going on, but haven't yet looked at
.separation()to be sure (will get back to you shortly).get_moon()returns the Moon's position in the GCRS frame, which is axis-aligned with the ICRS frame but is centered on the Earth's center of mass. I suspect that when you domoon.separation(kepler), it's converting thekeplerICRS position to the GCRS frame, then computing the separation in this time-dependent frame. When you dokepler.separation(moon), it's converting the GCRSmoonposition to the ICRS frame, and computing the separation there. It's not immediately obvious to me why the resulting curves look the way they do, but this small test seems to confirm: if I do this insteadI get:

StuartLittlefair commentedon Oct 1, 2017
@adrn is right. It may not be particularly intuitive - I’ve been bitten by this myself in the past - but this is the expected, and I think correct, behaviour.
posA.separation(posB)calculates the separation of A and B, in the frame of object A. The mistake is to think thatseparationgives the separation on the sky, when it does not.petigura commentedon Oct 1, 2017
adrn commentedon Oct 1, 2017
I totally agree! This is a documentation fail. Thanks for bringing this up!
ricozan commentedon Dec 28, 2017
I just want to clarify that when dealing with the moon and a target, e.g for preparing observations one should use:
moon.separation( target )
thanks! I was also puzzled by this and I'm glad I found this post.