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.

Discrepancy transforming `SkyCoord` to `AltAz`

See original GitHub issue

Description

I have come across a discrepancy that I cannot explain when converting SkyCoord (RA/Dec) to AltAz. In short, I get slightly but significantly different results using the equation of celestial navigation (as described here) and SkyCoord.transform_to.

Expected behavior

SkyCoord.transform_to should match the trigonometric result from the celestial navigation equation.

Actual behavior

There is a small difference between results.

Steps to Reproduce

  1. Use the online celestial to horizon coordinates calculator available here to convert location + time + RA/Dec to an Alt/Az:
Screenshot 2021-07-20 at 14 56 25

(Note that this calculator uses your local time as an input, rather than the observer’s).

This result is consistent with what I get using my own implementation of the celestial navigation equation.

  1. Use astropy to do the same calculation:
from datetime import datetime
from astropy import units as u
from astropy.time import Time
from astropy.coordinates import AltAz, EarthLocation, SkyCoord

location = EarthLocation(lat=0 * u.deg, lon=0 * u.deg)
skycoord = SkyCoord(ra=0 * u.deg, dec=0 * u.deg)

# Time at longitude = 0 == UTC
time = Time(datetime(2021, 1, 1, 0, 0), scale="utc", location=location)

altaz_frame = AltAz(obstime=time, location=location)
altaz = skycoord.transform_to(altaz_frame)
print(altaz.alt.to_value("deg"), altaz.az.to_value("deg"))

# Prints: -10.59990770524396 270.1166107257178

Is there an explanation for this difference? Thanks!

System Details

macOS-10.16-x86_64-i386-64bit Python 3.8.5 (default, Sep 4 2020, 02:22:02) [Clang 10.0.0 ] Numpy 1.20.1 astropy 4.2.1 Scipy 1.6.2 Matplotlib 3.4.2

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
mkbrewercommented, Aug 10, 2021

Since the problem here is with the calculator rather than Astropy and there has been no further discussion on this issue for nearly three weeks, I believe that this issue should be closed.

0reactions
mkbrewercommented, Jul 22, 2021

There is also the fact that the calculator uses UTC rather than UT1 to calculate sidereal time.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Astronomical Coordinate Systems (astropy.coordinates)
The best way to start using coordinates is to use the SkyCoord class. ... also makes it possible to convert from celestial coordinates...
Read more >
Premature broadcasting of coordinates in transforms creates ...
Description In summary, when transforming coordinate frames we broadcast before transforming, which ought not to be necessary.
Read more >
Coordinate Transformation (RA,DEC --> AZ, ALT)
... import SkyCoord, EarthLocation ### for transformations from RA DEC to ALT AZ ... The difference in brightness is realized through color and...
Read more >
Coords 2: Transforming between coordinate systems
SkyCoord objects; Transform to different coordinate systems on the sky; Transform to ... Transform frames to get to altitude-azimuth ("AltAz").
Read more >
AstroPy: how to transform a SkyCoord object in the GCRS ...
EDIT 3: I have managed to change at least the obsgeoloc but it makes no difference, I get the same equatorial coordinates, unless...
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