# Calculating RA/dec from JPL ephemeris data

I'm using JPL planetary ephemerides to calculate the position of planets. Using DE405 ephemeris (using a parser provided by Project Pluto with all tests passing). I am fetching the position of Mars with the observer set as the Earth (geocentric).

My first assumption is that the result is a set of geocentric equatorial coordinates in rectangular form (x, y, z). This may be incorrect.

My goal is to calculate RA/Dec. My second assumption is that I should use a formula converting from Cartesian to Spherical:

$r =\sqrt(x^2+y^2+z^2)$ $ra =\arctan(y/x)$ $dec = \pi/2 - arccos(z/r)$

Using Julian day 2457134 (21st Apr 2015, noon UTC), and cross-checking the result with NASA's Horizons service which apparently uses the same ephemeris (DE405) gets me almost there but my results are a little off:

x 1.721427968227801 y 1.5802812301744067 z 0.6897426775298559

RA 02h50m12.51s Dec +16°26'41.37"

Horizons:

RA 02h50m11.52s Dec +16°26'36.5"

I'm not sure what I'm missing. Do I have to factor distance of the planet due to the time it takes for light to reach us? Am I not using the correct time? Are my assumptions wrong?

• You may also need to correct for precession/nutation. I don't remember what frame DE405 uses, but DE431 uses a fixed J2000 frame. stackoverflow.com/questions/16293146/… may also be helpful.
– user21
Apr 23, 2015 at 17:01

Read the fine print under the Horizons output when you select an OBSERVER table. It says (emphasis mine)

R.A._(ICRF/J2000.0)_DEC =
J2000.0 astrometric right ascension and declination of target center. Adjusted for light-time. Units: HMS (HH MM SS.ff) and DMS (DD MM SS.f)

You could do the same, but it will take some extra work. The Mars you see at some time $t$ was emitted from Mars several minutes earlier than that. You need to find the $\Delta t$ such that the distance between Mars at time $t-\Delta t$ and Earth at time $t$ is equal to the speed of light times $\Delta t$. One correction will get you very close, a second will get you even closer.

Another issue is time. JPL uses its own time scale, JPL ephemeris time (Teph). This is a relativistic time scale. It differs from Terrestrial Time (TT) by at most a few milliseconds, so for most purposes you can use TT in lieu of Teph in your homebrew ephemeris calculator. TT currently differs from UTC by 67.184 seconds, and beginning in July (there's a leap second at the end of June), it will differ from UTC by 68.184 seconds.

Or you could just live with it. If you are using your calculations for your backyard telescope, the handful of arc seconds of error that results from not accounting for the finite speed of light is small.

• Thanks a lot for the answer! I assumed as much but got lost in the fine-print :) This helps me because I wasn't sure if I was starting from invalid assumptions, hence didn't know where to start. I'll take a stab at the light-time adjustment, just need to get my head around it. Apr 22, 2015 at 10:55
• A follow up: Following the advice from the answer, using Terrestrial Time, two corrections for light-time adjustment and calculating RA/Dec for Earth@T and Mars@T-Δt I get the exact result as Horizons! Beautiful. Thanks again David! Apr 22, 2015 at 12:27
• @NenadVukicevic - You're welcome. BTW, it's not the exact same results as Horizons. It looks like Horizons switched from using DE405 to DE431 about a year ago. DE405 is an outdated product from some previous millennium (1998, to be exact). It's about time they made that switch. The impact on backyard astronomy is negligible. The impact on spacecraft -- that's not so negligible. Apr 22, 2015 at 13:04
• After the leap second on 2017-01-01, TT - UTC = 69.184 Apr 17, 2017 at 22:19