Skip to content

Separation between moon and target not reversible #12189

Closed

Description

@astrom-tom

Description

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:

c2 = c.SkyCoord(moon.ra.value, moon.dec.value, frame='fk5', unit='deg')
sep = c1.separation(c2)
sep2 = c2.separation(c1)

I get: sep = sep2 = 86.05242730221599 which is slightly different from one of the previous value but this time the reference does not matter.

System Details

Linux-5.9.16-1-MANJARO-x86_64-with-glibc2.33
Python 3.9.2 (default, Mar 3 2021, 20:02:32)
[GCC 7.3.0]
Numpy 1.21.2
astropy 4.3.1
Scipy 1.7.1
Matplotlib 3.4.3

Activity

  1. pllim commented on Sep 23, 2021

    @pllim
    Member

    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.

  2. astrom-tom commented on Sep 23, 2021

    @astrom-tom
    Author

    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

  3. adrn commented on Sep 24, 2021

    @adrn
    Member

    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?

  4. dhomeier commented on Sep 24, 2021

    @dhomeier
    Contributor

    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.

  5. StuartLittlefair commented on Nov 9, 2021

    @StuartLittlefair
    Contributor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions