1
$\begingroup$

I wrote a program based on this tutorial: http://www.stjarnhimlen.se/comp/ppcomp.html to calculate altitude and azimuth of a celestial object. When I compare the calculated RA/Dec values to the ones from Stellarium, they are very accurate. But when I compare the Alt/Az values to the ones from Stellarium, there is an error of about 2 degrees! I use the following method to calculate Alt, Az:

GMST0 = Ls + 180_degrees # Ls = Sun's longitude
GMST = GMST0 + UT
LST  = GMST + local_longitude
HA = LST - RA

x = cos(HA) * cos(Decl)
y = sin(HA) * cos(Decl)
z = sin(Decl)

xhor = x * sin(lat) - z * cos(lat)
yhor = y
zhor = x * cos(lat) + z * sin(lat)

az  = atan2( yhor, xhor ) + 180_degrees
alt = asin( zhor ) = atan2( zhor, sqrt(xhor*xhor+yhor*yhor) )

Some specific example:

Test date 15.09.2018, time 15:00 UT Planet: Mercury

Coordinates: +47.55777777° +8.89888888

What stellarium says:

RA = 11h 18m 13.26s

Dec = +6°25'08.5"

Az = +250°21'13.2"

Alt = +25°25'00.1"

What my program says:

RA = 11h 18m 14s

Dec = 6° 25' 6.59"

Az = +248° 49' 6.9"

Alt = +26° 33' 16.43"

Thanks in advance!

$\endgroup$
  • 1
    $\begingroup$ Could you give us some specific examples? Is the 2 degree consistent with different latitudes/longitudes/ra/dec, or does it vary based on the input parameters? My vague first suspicion is that, because the Earth is an ellipsoid and not a sphere, your zenith direction ("surface normal") isn't exactly opposite the direction to the center of the Earth. $\endgroup$ – barrycarter Sep 15 '18 at 14:34
  • $\begingroup$ The 2 degree error is not consistent, it's just the maximum error, but a lot of calculations (especially azimuth) were off by about 2°. I'll edit the question with some specific examples. $\endgroup$ – Michael Siebenmann Sep 15 '18 at 14:42
  • $\begingroup$ Stellarium usually gives both precessed and unprecessed coordinates. Are you using J2000 or current precession. The difference is small, but might be enough to explain the error. I may look into this deeper, but this was just a thought I had. $\endgroup$ – barrycarter Sep 15 '18 at 15:09
  • $\begingroup$ It says "Precession is computed in a simplified way, by a simple addition to the ecliptic longitude" on the website. $\endgroup$ – Michael Siebenmann Sep 19 '18 at 15:43
  • $\begingroup$ An interesting thing is that the azimuth always is about 1.5° under the expected value, except for the moon. $\endgroup$ – Michael Siebenmann Sep 19 '18 at 18:08
2
$\begingroup$

The algorithm on that page is very simplistic and is probably the source of a good portion of that error. It's best to test your code using a very accurate ephemeris, even if your final goal is to have a much more simple ephemeris implementation. DE405, or VSOP87 would be good alternatives.

A small error in GMST can have a big effect on Alt/Az computations, I would expect that the simplicity of the algorithm on the page produces a good sized error in GMST.

Another common source of error is differences in time scales. You need to make sure you propperly account for things like leap seconds, which that page specifically says it ignores. You need to convert UTC to Terrestrial Time by subtracting 37.0 + 32.184 (where 37 is the current number of leap seconds).

Also make sure you're not comparing different coordinate systems. Like J2000 vs "Of Date", or coordinates adjusted for atmospheric refraction.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.