I'm trying to write a Mathematica application that allows users to choose their date of departure and time-of-flight for an interplanetary transfer mission (currently only working for Earth-Mars transfers), which is then animated (similar to NASA's trajectory browser except not as cool).

So far I've managed to get the Lambert solver and 3-body Sun-Earth-Mars numerical model working, but now I need to figure out how to get ephemeris data automatically from JPL's Horizons ephemeris when a user selects their departure date and TOF. I thought about trying to incorporate the Horizons telnet service into the application, but it might be quite tough to get that working, and the position and velocity data that is given doesn't seem to be in a Mathematica friendly format which might require lots of string matching/replacing.

Another alternative would be to somehow download and tabulate years worth of ephemeris data into a spreadsheet and extract it from there upon request, but this also seems like a laborious task. My question is therefore this:

How do normal trajectory planners/plotters get their ephemeris data?


1 Answer 1


Using the SPICE toolkit and a recent ephemeris file like DE430 (a 120 MB download). You will also need a recent leap seconds kernel.

The toolkit provides interfaces for Fortran, C, IDL, and Matlab, but not Mathematica. You can use the C version of the toolkit, and Mathematica's MathLink or LibraryLink to access the toolkit.

There are many, many functions in the toolkit, but you'll only need a handful. For example, you can use furnsh_c() to load the ephemeris file and the leap seconds file, and spkezr_c() to get the position and velocity of the specified body at the specified time, in the specified reference frame.

  • 1
    $\begingroup$ Seconded. SPICE is an absolute must nowadays, it greatly simplifies many routine tasks (and some not so routine ones). $\endgroup$ Feb 9, 2014 at 0:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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