JPL planetary ephemerides access software in C

A short manual for the latest release (1.6)

  • From our public FTP server ftp://ftp.astro.amu.edu.pl/pub/jpleph/version_1.6 you can download three files:
    • jplbin.h - a header file for both programs shown below
    • testeph.c - the main code for the ephemeris access (and test)
    • asc2eph.c - the revived old program for the conversion from the ASCII files to the binary ephemeris file, which additionally allows to specify the shorter time interval for the binary ephemeris.

Recently (in spring 2021) the FTP protocol was depreciated in many popular web browsers so I also include these files for a direct download in my main page devoted to the JPL ephemerides.

How to use testeph.c code

  • From the public JPL FTP server (ftp://ssd.jpl.nasa.gov/pub/eph/planets/Linux) you should download an ephemeris file. The latest versions are DE440 (short term) and DE441(long term). They can be accessed from the de440 or de441 subdirectories.
    • The short term ephemeris DE440 covers years from 1550 to 2650, the file name is linux_p1550p2650.440 and its size is slightly below 100 MB.
    • The long term ephemeris DE441covers years from -13000 to +17000, the file name is linux_m13000p17000.441 and its size is 2.6 GB !
  • In order to test your installation you should also download an appropriate test file: testpo.440 (858 kB) or testpo.441 (23 MB)

You should gather in the same directory all four files:     jplbin.h     testeph.c     ehemeris_file     test_file.

Next you should edit first two files to adjust them to the ephemeris version you want to use.

  • In the jplbin.h you should uncomment only one line that defined the ephemeris version. For DE441 the beginning of the jplbin.h should look like this:

/* UNCOMMENT ONE AND ONLY ONE OF THE FOLLOWING DENUM DEFINITIONS: */

/*#define DENUM 200*/
/*#define DENUM 403*/
/*#define DENUM 404*/
/*#define DENUM 405*/
/*#define DENUM 406*/
/*#define DENUM 421*/
/*#define DENUM 422*/
/*#define DENUM 430*/
/*#define DENUM 431*/
/*#define DENuM 440*/
#define DENUM 441
 
  • In the testeph.c file you should edit two lines specifying an ephemeris file and a test file. Assuming that you use DE441 and that all files are in the same directory (in other cases you can add appropriate paths) it these two lines should read:

/**** YOU PROBABLY HAVE TO ALTERNATE FOLLOWING TWO DEFINITIONS: ************/

#define TESTFILE "testpo.441"

#define EPHFILE  "linux_m13000p17000.441"

/***** THERE IS NO NEED TO MODIFY THE REST OF THIS SOURCE (I hope) *********/
 

In a normal situation no other edits are necessary.

  • Assuming that you have all necessary tools installed ( e.g. compiler! ):
    • just compile the testeph.c:     gcc -lm testeph.c -o testeph
    • and run:     ./testeph

The output of this run consists of a listing of all ephemeris constants and the results for all test points. In the last column there is a difference between the original value and the value obtained with my software. All differences should be smaller than 10-13.

Here are the examples of results of testing DE440 and DE441 on my computer:     res440.txt  (34 kB)    res441.txt  (360 kB).


How to use asc2eph.c code

The purpose of this program is to convert a series of the JPL ephemeris ASCII files into one binary file. The additional feature of this code is the ability to select a shorter time interval than the default one. The required time interval is specified in Julian Days and is rounded (in the direction outside the interval) to the nearest multiple of 32 days, counting from JD=2440400.5.

  • From the public JPL FTP server (ftp://ssd.jpl.nasa.gov/pub/eph/planets/ascii) you should download a set of ASCII files with the ephemeris coefficients as well as the header file. The header file is named header.XXX while ASCII files are named ascYZZZZZ.XXX, where:
    • XXX is the ephemeris number, for example 440 or 441,
    • Y is the single letter, 'm' or 'p' denoting negative (minus='m') or positive (plus='p') sign of the file number (approximately the starting year),
    • ZZZZZ is the five digit number of the file (left padded with zeroes if necessary).

In the last part of the jplbin.h file I have added (in version 1.6) definitions that allow to automatically generate ASCII file names for different ephemeris versions.

For example for the DE441 ephemeris the file numbers start with -13000 and end with +17000, with a step of 1000. This result in a file sequence:

 ascm13000.441
 ascm12000.441
 ascm11000.441
 ...
 ascm01000.441
 ascp00000.441
 ascp01000.441
 ...
 ascp15000.441
 ascp16000.441

One should understand that in this case for example the file ascp15000.441 covers the ephemeris data for years from +15000 to +16000. If you want to generate an ephemeris shorter than the whole default interval you can download only files that cover you needs.

There is no need to edit the source file asc2eph.c except the case when we want to specify some paths for the header and/or ASCII data files or change the name of the resulting binary ephemeris file (the default name is jpleph.XXX). Of course the jplbin.h file have to be adjusted!

Compiling is as usual: gcc -lm asc2eph.c -o asc2eph.

During the execution of this program you may accept the default time interval of the ephemeris or specify a shorter one.

The binary ephemeris obtained with asc2eph.c can be tested with testeph.c as described above.