[AstroPy] Use of separation

Stuart P Littlefair s.littlefair at sheffield.ac.uk
Fri Mar 26 05:00:56 EDT 2021


It is counterintuitive. The point is that the separation of two objects doesn’t make sense without a coordinate frame in which that separation is measured. 

A celestial object may be in the same direction as the moon when viewed from the earth (a GCRS frame), but the two will not line up for an observer at the centre of the solar system (an ICRS frame). 

So when you calculate the separation between two coordinates that are measured in different frames, you *have* to choose one or the other frames to measure the separation in. 

The unintuitive nature of this code comes from the assumption of the user that “get_sun” or “get_moon” will return a coordinate in the same frame as “pointing”, which is not true. 

Stuart Littlefair
Dept. of Physics & Astronomy
Univ. of Sheffield, Sheffield, S3 7RH

email: s.littlefair at shef.ac.uk
Phone: +44 114 2224525
Sent from my iPhone

> On 26 Mar 2021, at 08:35, Emil Lenc <elenc at me.com> wrote:
> 
> Hi Stuart,
> 
> Oh, thanks, I had completely overlooked this in the documentation. I’d have to admit that this is indeed unintuitive behaviour! So much so that I’m actually not sure how to reliably determine the separation in this instance? It also seems to be at odds with their example where they state
> 
>> Also note that the two input coordinates were not in the same frame — one is automatically converted to match the other, ensuring that even though they are in different frames, the separation is determined consistently.
> 
> Is it just that because the frame used to determine the moon’s coordinates is a bit odd? It seems a bit odd to convert the RA/Dec of the moon to another SkyCoord (with the same frame as my pointing coordinate) to ensure that the result is consistent … though perhaps I am just doing this wrong (sorry, coordinates and frames are not my strong point)?
> 
> Cheers,
> 
> Emil.
> 
>> On 26 Mar 2021, at 18:50, Stuart P Littlefair <s.littlefair at sheffield.ac.uk> wrote:
>> 
>> Hi Emil
>> 
>> The documentation for separation has an explanation of this. 
>> 
>> https://docs.astropy.org/en/stable/api/astropy.coordinates.SkyCoord.html#astropy.coordinates.SkyCoord.separation
>> 
>> “ If the other coordinate object is in a different frame, it is first transformed to the frame of this object. This can lead to unintuitive behavior if not accounted for. Particularly of note is that self.separation(other) and other.separation(self) may not give the same answer in this case.“
>> 
>> Stuart Littlefair
>> Dept. of Physics & Astronomy
>> Univ. of Sheffield, Sheffield, S3 7RH
>> 
>> email: s.littlefair at shef.ac.uk
>> Phone: +44 114 2224525
>> Sent from my iPhone
>> 
>>> On 26 Mar 2021, at 07:45, Emil Lenc <elenc at me.com> wrote:
>>> 
>>> Hi All,
>>> 
>>> I’ve been trying to determine the separation between a point in the sky and the moon and I’ve come across a strange situation that I don’t quite understand. Depending on how I determine the separation I get two very different results i.e. if I determine the separation between the moon and the sky location as opposed to the separation between the sky location and the moon. I expected that these should give the same result but they don't. Here is a simple script to demonstrate what I mean:
>>> 
>>> from astropy import units as u
>>> from astropy.time import Time
>>> from astropy.coordinates import EarthLocation, Angle, SkyCoord
>>> from astropy.coordinates import get_moon
>>> 
>>> # Where are we observing from?
>>> latitude = Angle("-26:41:46.0", unit=u.deg)
>>> longitude = Angle("116:38:13.0", unit=u.deg)
>>> observing_location = EarthLocation(lat=latitude, lon=longitude)
>>> 
>>> # When are we observing?
>>> t = Time("2021-03-04 21:51:58", format='iso', scale='utc')
>>> 
>>> # Where is the moon?
>>> moon = get_moon(t, observing_location)
>>> pointing = SkyCoord("15h33m45.000s -18d40m3.793s", frame='fk5’)
>>> 
>>> # Print out the location of the moon
>>> dir_str = moon.to_string(style='hmsdms')
>>> print("Moon (at specified location) is at: %s" %(dir_str))
>>> 
>>> # Print out the location of the pointing
>>> dir_str = pointing.to_string(style='hmsdms')
>>> print("Pointing is at: %s" %(dir_str))
>>> 
>>> # Determine the separation between the moon and the pointing
>>> sep = moon.separation(pointing).deg
>>> print("Moon separation from pointing = %0.1f deg" %(sep))
>>> 
>>> # Determine the separation between the pointing and the moon
>>> sep = pointing.separation(moon).deg
>>> print("Pointing separation from Moon = %0.1f deg\n" %(sep))
>>> 
>>> The result of running this script producing the following result:
>>> 
>>> Moon (at specified location) is at: 15h48m35.4296s -18d29m19.3018s
>>> Pointing is at: 15h33m45s -18d40m03.793s
>>> Moon separation from pointing = 3.5 deg
>>> Pointing separation from Moon = 71.5 deg
>>> 
>>> Does anyone understand why the second case giving a result of 71.5 degrees? Any help would be greatly appreciated.
>>> 
>>> Best regards,
>>> 
>>> Emil.
>>> 
>>> _______________________________________________
>>> AstroPy mailing list
>>> AstroPy at python.org
>>> https://mail.python.org/mailman/listinfo/astropy
>> _______________________________________________
>> AstroPy mailing list
>> AstroPy at python.org
>> https://mail.python.org/mailman/listinfo/astropy
> 
> _______________________________________________
> AstroPy mailing list
> AstroPy at python.org
> https://mail.python.org/mailman/listinfo/astropy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.python.org/pipermail/astropy/attachments/20210326/980b57da/attachment.html>


More information about the AstroPy mailing list