question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unexpected behavior with SkyCoord.separation method

See original GitHub issue

Dear Astropy,

Thanks for such a useful project!

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.

Cheers,

Erik

%pylab inline
from astropy.time import Time
import astropy.coordinates
from astropy.coordinates import SkyCoord, EarthLocation
from astropy import units as u

loc = EarthLocation.of_site('KPNO')

t0 = Time('2017-01-01 00:00:00', scale='utc')
t = t0 + np.arange(0.,365,1) * u.day
moon = astropy.coordinates.get_moon(t,location=loc)
kepler = SkyCoord('19h22m', '+44d30m', frame='icrs')

sep = moon.separation(kepler)
plot(t.datetime, sep.degree)

sep = kepler.separation(moon)
plot(t.datetime, sep.degree)

image

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
petiguracommented, Oct 1, 2017

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 notifications@github.com 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.

0reactions
ricozancommented, 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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Separations, Offsets, Catalog Matching, and Related ... - Astropy
The on-sky separation can be computed with the astropy.coordinates. ... SkyCoord.separation() methods, which computes the great-circle distance (not the ...
Read more >
SkyCoord — Astropy v5.2
A convenience method to create and return a new SkyCoord from the data in an astropy ... Computes on-sky separation between this coordinate...
Read more >
Table Operations — Astropy v5.2
Aggregation is the process of applying a specified reduction function to the values within each group for each non-key column. This function must...
Read more >
Using the SkyCoord High-Level Class — Astropy v5.2
The SkyCoord class has a number of convenience methods that are useful in ... Single coordinate string with a LON and LAT value...
Read more >
Astropy Documentation - Read the Docs
from astropy.coordinates import SkyCoord. >>> coordinate = SkyCoord(123.4*u.deg, ... The Astropy Project is a process intended to facilitate.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found