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
Separation between moon and target not reversible #12189
When I want to compute the distance between the moon and an object I get two different value based on which reference I use (the moon of the object)
Expected behavior
It should be exactly the same
Actual behavior
The separation between the moon and the target is different.
Steps to Reproduce
import astropy.units as u
from astropy import coordinates as c
import astropy.time as TIME
##get a position on earth
obs = c.EarthLocation.of_site('Keck Observatory')
##and a time
start_time = '2018-01-23T01:01:05.813'
starttime = TIME.Time(start_time, format='isot', scale='utc')
##get the moon information
moon = c.get_moon(starttime, location=obs)
##and get a target
RA = 97.00
DEC = 4.9
c1 = c.SkyCoord(RA, DEC, frame='fk5', unit='deg')
##and compute the separation
moon_sep = moon.separation(c1)
moon_sep2 = c1.separation(moon)
if you print moon_sep and moon_sep2 you will get 86.05756420797839 and 30.615793847554087.
By the way, if I create a SkyCoord object manually from the moon coordinates:
I feel like similar questions have been asked several times. I vaguely remember the explanation being something about frame of reference. Either that, or that is no moon! Maybe @adrn could clarify for real.
I did not really find anything so I allowed myself to post it there. In any case, if this is a known behavior I guess it would be useful to mention it in the webpage about separation here
I think the docs cover the first case, but not the second. We did have a similar issue about why the separation is not exactly reversible even within the same coordinate system in #11434. That's mainly about the position angle; I think the separation should in fact be symmetrical, but while the differences here are somewhat above general numerical precision, they may be within the precision of the algorithms used here.
I don't think the docs cover the second case @dhomeier, but the code is likely correct. Certainly, moon_sep should not be the same as sep or sep2.
The general point is still the same: the separation of two points depends critical on your frame of reference.
moon_sep is the separation of two points in spacetime, in the topocentric frame with Keck as the origin and the obstime provided. Computing this separation means converting c1 from the FK5 frame into the topocentric frame, which involves all sorts of things like parallax and aberration, so the RA and Dec of c1 in the topocentric frame is not the same as it is in FK5.
When calculating sep or sep2 all of these effects have been ignored, which is why neither sep or sep2 are the same as moon_sep.
Activity
pllim commentedon Sep 23, 2021
I feel like similar questions have been asked several times. I vaguely remember the explanation being something about frame of reference. Either that, or that is no moon! Maybe @adrn could clarify for real.
astrom-tom commentedon Sep 23, 2021
I did not really find anything so I allowed myself to post it there. In any case, if this is a known behavior I guess it would be useful to mention it in the webpage about separation here
adrn commentedon Sep 24, 2021
We have an entry in the "Common mistakes" section of the coordinates documentation here: https://docs.astropy.org/en/stable/coordinates/common_errors.html?highlight=moon#object-separation
If it would have helped you for us to link from the Separation docs, we could add a "Warning" to that page. Would you be interested in contributing that change?
dhomeier commentedon Sep 24, 2021
I think the docs cover the first case, but not the second. We did have a similar issue about why the separation is not exactly reversible even within the same coordinate system in #11434. That's mainly about the position angle; I think the separation should in fact be symmetrical, but while the differences here are somewhat above general numerical precision, they may be within the precision of the algorithms used here.
StuartLittlefair commentedon Nov 9, 2021
I don't think the docs cover the second case @dhomeier, but the code is likely correct. Certainly,
moon_sepshould not be the same asseporsep2.The general point is still the same: the separation of two points depends critical on your frame of reference.
moon_sepis the separation of two points in spacetime, in the topocentric frame with Keck as the origin and the obstime provided. Computing this separation means convertingc1from theFK5frame into the topocentric frame, which involves all sorts of things like parallax and aberration, so the RA and Dec ofc1in the topocentric frame is not the same as it is in FK5.When calculating
seporsep2all of these effects have been ignored, which is why neitherseporsep2are the same asmoon_sep.