Ephemeris
Ephemeris
Ephemeris
Ephemeris Functions
This document describes a series of MATLAB scripts and functions that compute ephemerides
of the moon, sun, planets and stars. Routines are provided with different levels of fidelity along
with demonstration scripts that illustrate the proper interaction with many of these functions.
MATLAB scripts are also provided that calculate both apparent geocentric and topocentric
coordinates of these objects using MATLAB versions of Fortran subroutines from the Naval
Observatory Vector Astrometry Subroutines (NOVAS) software suite.
The next ten MATLAB functions are based on the algorithms described in Low-Precision
Formulae for Planetary Positions, T. C. Van Flandern and K. F. Pulkkinen, The Astrophysical
Journal Supplement Series, 41:391-411, November 1979. To the precision of this algorithm (one
arc minute) these coordinates can be considered to be true-of-date.
t JD 2451545
T t / 36525 1
Each function uses fundamental trigonometric arguments (in revolutions) of the following form:
Gs 0.993126 0.00273777850t
G2 0.140023 0.00445036173t
G4 0.053856 0.00145561327t
G5 0.056531 0.00023080893t
F4 0.849694 0.00145569465t
L4 0.987353 0.00145575328t
The heliocentric, ecliptic longitude , latitude and distance r are computed from series
involving these arguments. These series are of the form
where the unit of r is Astronomical Units (AU). In these functions, the value of AU is equal to
149597870.691 kilometers.
page 1
Orbital Mechanics with MATLAB
cos cos
r r cos sin
sin
This function calculates the true-of-date geocentric right ascension, declination and position
vector of the Sun.
% solar ephemeris
% input
% output
This function calculates the true-of-date geocentric right ascension, declination and position
vector of the Moon.
% lunar ephemeris
% input
% output
page 2
Orbital Mechanics with MATLAB
This function calculates the true-of-date heliocentric ecliptic position vector of Mercury.
% input
% output
This function calculates the true-of-date heliocentric ecliptic position vector of Venus.
% input
% output
This function calculates the true-of-date heliocentric ecliptic position vector of the Earth.
% input
page 3
Orbital Mechanics with MATLAB
% output
This function calculates the true-of-date heliocentric ecliptic position vector of Mars.
% input
% output
This function calculates the true-of-date heliocentric ecliptic position vector of Jupiter.
% input
% output
This function calculates the true-of-date heliocentric ecliptic position vector of Saturn.
page 4
Orbital Mechanics with MATLAB
% input
% output
This function calculates the true-of-date heliocentric ecliptic position vector of Uranus.
% input
% output
This function calculates the true-of-date heliocentric ecliptic position vector of Neptune.
% input
% output
page 5
Orbital Mechanics with MATLAB
This function calculates the heliocentric position vector of Pluto relative to the ecliptic and
equinox of J2000. This algorithm is based on the method described in Chapter 36 of
Astronomical Algorithms by Jean Meeus.
The fundamental time argument for this method is a function of the Julian Ephemeris Date JED
as follows:
JED 2451545
T
36525
The heliocentric ecliptic coordinates of Pluto are computed from series of the form
43
m A sin B cos
i 1
where
m coordinate mean value
iJ jS kP
J , S , P mean longitudes of Jupiter, Saturn and Pluto
i, j, k integer constants
A, B coefficients of periodic term
% input
% output
This MATLAB function computes a true-of-date geocentric ephemeris of the Sun based on the
data and numerical methods described in the book, Planetary Programs and Tables by Pierre
Bretagnon and Jean-Louis Simon.
page 6
Orbital Mechanics with MATLAB
The fundamental time argument of this method is the number of days relative to the Julian epoch
January 1, 2000 normalized with respect to 3652500 Julian days. This value can be calculated
for any Julian Ephemeris Date JED with the following expression
JED 2451545
U
3652500
The geocentric, ecliptic mean longitude of the Sun is calculated with a trigonometric series of the
form
50
sm 0 1 U li sin i i U
i 1
The geocentric distance of the Sun is calculated with another series of the form
50
rs r0 r1 U ri cos i i U
i 1
The longitude of the Sun is corrected for the effect of aberration (in radians) with the following
equation:
sa 107 993 17 cos 3.10 62830.14 U
where
A1 2.18 3375.70U 0.36U 2
A2 3.51 125666.39 U 0.10U 2
The apparent, geocentric ecliptic longitude of the Sun is determined as the combination of these
three components with the next equation
s sm sa
The three components of the geocentric, ecliptic position vector of the Sun are given by
xs rs cos s
y s rs sin s
zs 0
The apparent geocentric, equatorial right ascension s and declination s of the Sun can be
found from
page 7
Orbital Mechanics with MATLAB
where is the true obliquity of the ecliptic. This number is calculated from the mean obliquity
of the ecliptic m and the nutation in obliquity in this function with the following
expressions:
m
m 107 4090928 446cos A1 28cos A2
107U 226938 U 75 U 96926 U 2491 12104U
Finally, we can compute the three components of the apparent, geocentric equatorial position
vector of the Sun with the following three expressions:
rx r cos s cos s
ry r sin s cos s
rz r sin s
This function requires initialization the first time it is called. The following statement in the
main MATLAB script will accomplish this:
suncoef = 1;
This variable should also be placed in a global statement at the beginning of the main script
that calls this function.
% input
% output
page 8
Orbital Mechanics with MATLAB
This function calculates the osculating classical orbital elements of the Moon in the mean ecliptic
and mean equinox of date coordinate system. It is based on the book Lunar Tables and
Programs From 4000 B.C. TO A.D. 8000 by Michelle Chapront-Touze and Jean Chapront. This
book and its optional companion software are available from Willmann-Bell (www.willbell.com).
JED 2451545
t
36525
The osculating orbital elements are calculated from series of the form
a 383397.6 Sa tSa
where
30
Sa an cos n0 n1t n 2 104 t 2 n3106 t 3 n 4 108 t 4
n 1
3
Sa an cos n 0 n1t
n 1
The first few multipliers and trigonometric arguments for this orbital element are
n an n0 n1 n 2 n 3 n 4
1 3400.4 235.7004 890534.2230 -32.601 3.664 -1.769
2 -635.6 100.7370 413335.3554 -122.571 -10.684 5.028
% input
page 9
Orbital Mechanics with MATLAB
% output
This software suite includes a script called demo_elp.m that demonstrates how to interact with
this function. The following is a typical user interaction with this script.
program demo_elp
? 3
page 10
Orbital Mechanics with MATLAB
5.35
5.25
5.2
5.15
5.1
5.05
4.95
01/01/01 04/01/01 07/01/01 10/01/01 01/01/02
Calendar Date
This MATLAB function calculates the position and velocity vectors of the planets with respect
to the mean ecliptic and equinox of date. These calculations are based on the algorithm
described in Chapter 30 of Astronomical Algorithms by Jean Meeus. Each orbital element is
represented by a cubic polynomial of the form
JED 2451545
T
36525
% planetary ephemeris
% input
page 11
Orbital Mechanics with MATLAB
% output
This MATLAB function calculates the position and velocity vectors of the planets with respect
to the mean ecliptic and equinox of J2000. These calculations are based on the algorithm
described in Chapter 30 of Astronomical Algorithms by Jean Meeus. Each orbital element is
represented by a cubic polynomial of the form
JED 2451545
T
36525
% planetary ephemeris
% input
% output
This MATLAB function calculates the position and velocity vectors of the planets with respect
to the Earth mean ecliptic and equinox of J2000. The source ephemeris is a JPL binary file
which provides planetary coordinates in the Earth mean equator and equinox of J2000 system.
These state vectors are transformed to the ecliptic frame using the following transformation
matrix:
page 12
Orbital Mechanics with MATLAB
1 -0.000000479966 0
0.000000440360 0.917482137087 0.397776982902
-0.000000190919 -0.397776982902 0.917482137087
% input
% output
Please note that the eq2000 transformation matrix must be provided to this function using a
global eq2000 statement in this function and the main script. The main script provides this
matrix using the following MATLAB source code.
This MATLAB function and script demonstrate how to read SLP96 binary ephemeris files
created using the Fortran programs and ASCII data files provided by the Institut de Mecanique
Celeste et de Calcul des Ephemerides (IMCCE), and calculate the position and velocity vectors
of a planet or the moon in either the J2000 FK5 or dynamical coordinate systems. The slp96.m
function was ported to MATLAB using the Fortran source code subroutine provided by the
IMCCE. These ASCII files and source code can be found on the Internet at
ftp://ftp.imcce.fr/pub/ephem/sun/slp96/.
page 13
Orbital Mechanics with MATLAB
The slp96 function requires initialization the first time it is called. The following statement in
the main MATLAB script will accomplish this:
islp96 = 1;
This variable should also be placed in a global statement at the beginning of the main script
which calls this function.
demo_slp is a simple MATLAB script that demonstrates how to call the slp96 routine. A
sample binary file (slp96.bin) for IBM-PC compatible computers can be downloaded from the
Celestial and Orbital Mechanics web site.
The following is a summary of the inputs and outputs for this MATLAB function:
function [result, ierr] = slp96 (tjd, ibody, icent, ipv, iframe, icoord)
% input
% ipv=1 : position.
% ipv=2 : position and velocity.
page 14
Orbital Mechanics with MATLAB
% output
% position
% velocity
% position
% velocity
% ierr=0 : no error
% ierr=10 : file error
% ierr=11 : date error (tjd)
% ierr=12 : body error (ibody)
% ierr=13 : frame center error (icent)
% ierr=14 : position-velocity error (ipv)
% ierr=15 : frame error (iframe)
% ierr=16 : coordinates error (icoord)
page 15
Orbital Mechanics with MATLAB
<1> Mercury
<2> Venus
<3> Earth-Moon barycenter
<4> Mars
<5> Jupiter
<6> Saturn
<7> Uranus
<8> Neptune
<9> void
<10> Moon
<11> Sun
<12> Earth
page 16
Orbital Mechanics with MATLAB
? 12
program demo_slp
state vector
This MATLAB function and main script demonstrate how to read binary ephemeris files created
using the Fortran programs and ASCII data files provided by the Jet Propulsion Laboratory, and
calculate the position and velocity vectors of a planet, the sun or the Moon. The jplephem.m
function was ported to MATLAB using the Fortran source code subroutine provided by JPL.
These ASCII files can be found on the Internet at ftp://ssd.jpl.nasa.gov/pub/eph/planets/ascii/. A
page 17
Orbital Mechanics with MATLAB
CD ROM containing these ASCII data files and the companion Fortran source code is also
available from Willmann-Bell, www.willbell.com.
The jplephem function requires initialization the first time it is called. The following statement
in the main MATLAB script will accomplish this:
iephem = 1;
This variable should also be placed in a global statement at the beginning of the main script
which calls this function. The value of the Astronomical Unit, in kilometers, used in a particular
JPL ephemeris is available as the constant au which is placed in global by the jplephem
function described below.
demo_jpl is a simple MATLAB script that demonstrates how to call the jplephem routine.
Binary ephemeris files for IBM-PC compatible computers can be downloaded from the Celestial
and Orbital Mechanics web site. The coordinates calculated by this function are with respect to
the International Celestial Reference System (ICRS) which is described in “The International
Celestial Reference Frame as Realized by Very Long Baseline Interferometry”, C. Ma, E.
Arias, T. Eubanks, A. Fey, A. Gontier, C. Jacobs, O. Sovers, B. Archinal and P. Charlot, The
Astronomical Journal, 116:516-546, 1998, July.
% input
% 1 = mercury 8 = neptune
% 2 = venus 9 = pluto
% 3 = earth 10 = moon
% 4 = mars 11 = sun
% 5 = jupiter 12 = solar-system barycenter
% 6 = saturn 13 = earth-moon barycenter
% 7 = uranus 14 = nutations (longitude and obliq)
% 15 = librations, if on ephemeris file
% output
page 18
Orbital Mechanics with MATLAB
The following is a typical user interaction with this script using the DE421 ephemeris file.
<1> Mercury
<2> Venus
<3> Earth
<4> Mars
<5> Jupiter
<6> Saturn
<7> Uranus
<8> Neptune
<9> Pluto
<10> Moon
<11> Sun
<1> Mercury
<2> Venus
<3> Earth
<4> Mars
<5> Jupiter
<6> Saturn
<7> Uranus
<8> Neptune
<9> Pluto
<10> Moon
<11> Sun
<12> solar-system barycenter
<13> Earth-Moon barycenter
page 19
Orbital Mechanics with MATLAB
program demo_jpl
state vector
Please note the following extracted from JPL IOM 343R-08-003, dated 31-March 2008.
In a resolution adopted by the International Astronomical Union in 2006 (GA26.3), the time
scale TDB (Temps Dynamique Barycentrique, Barycentric Dynamical Time) was defined to be
consistent with the JPL ephemeris time.
The axes of the ephemeris are oriented with respect to the International Celestial Reference
Frame (ICRF).
Furthermore, the relationship between the ICRF and EME 2000 frames is described in the
moon_080317.tf text file which is located on the Internet at
ftp://naif.jpl.nasa.gov/pub/naif/generic_kernels/fk/satellites/,
The IERS Celestial Reference Frame (ICRF) is offset from the J2000 reference frame (equivalent
to EME 2000) by a small rotation; the J2000 pole offset magnitude is about 18 milliarcseconds
(mas) and the equinox offset magnitude is approximately 78 milliarcseconds.
A MATLAB function (j2000_icrs.m) that transforms vectors between these two systems
follows later in this section.
page 20
Orbital Mechanics with MATLAB
This MATLAB function and script demonstrate how to read the INPOP06C binary ephemeris
file and calculate the position and velocity vectors of a planet, the sun or the Moon. The
jplephem_inpop.m function is identical to the jplephem.m described above with a minor
update for the format of the INPOP06C binary file. This binary file for several computer
platforms can be found at http://www.imcce.fr/fr/presentation/equipes/ASD/inpop/.
The jplephem_inpop function requires initialization the first time it is called. The following
statement in the main MATLAB script will accomplish this:
iephem = 1;
This variable should also be placed in a global statement at the beginning of the main script
which calls this function.
demo_inpop is a simple MATLAB script that demonstrates how to interact with the
jplephem_inpop routine.
<1> Mercury
<2> Venus
<3> Earth
<4> Mars
<5> Jupiter
<6> Saturn
<7> Uranus
<8> Neptune
<9> Pluto
<10> Moon
<11> Sun
<1> Mercury
page 21
Orbital Mechanics with MATLAB
<2> Venus
<3> Earth
<4> Mars
<5> Jupiter
<6> Saturn
<7> Uranus
<8> Neptune
<9> Pluto
<10> Moon
<11> Sun
<12> solar-system barycenter
<13> Earth-Moon barycenter
program demo_inpop
state vector
This MATLAB function determines the position and velocity vectors of a heliocentric celestial
body such as an asteroid or comet.
% input
page 22
Orbital Mechanics with MATLAB
% output
The state vector is output in the same coordinate system as the input orbital elements.
The orbital elements of an asteroid or comet relative to the ecliptic and equinox of J2000
coordinate system can be obtained from the JPL Small-Body Database Browser
(http://ssd.jpl.nasa.gov/sbdb.cgi) or the MPC database at Harvard (http://cfa-www.harvard.edu).
The software determines the mean anomaly of the asteroid or comet at any simulation time JD
using the following equation:
s s
M
a 3
t pp
a3
JD JD
pp
where s is the gravitational constant of the sun, a is the semimajor axis of the celestial body,
and t pp is the time since perihelion passage.
The semimajor axis is determined from the perihelion distance rp and orbital eccentricity e
according to
rp
a
1 e
This MATLAB function uses kepler1.m to calculate the true anomaly.
page 23
Orbital Mechanics with MATLAB
This MATLAB function returns the transformation matrix from the mean dynamical equator and
equinox at J2000 to the International Celestial Reference System (ICRS). There are two options
for this matrix based on different data types.
% input
% output
To transform coordinates from the ICRS system to the J2000 system, the programmer should use
the transpose of the matrix returned by this function.
This MATLAB function determines the apparent geocentric and topocentric coordinates of a
planet or the Moon. The source ephemeris for this routine is a JPL binary file. The algorithms
used in this function are based on the Fortran versions found in NOVAS.
function [ra, dec, dis] = applan1 (tjd, ujd, l, n, topo, glon, glat, ht)
% input
page 24
Orbital Mechanics with MATLAB
% output
This software suite includes a script called demo_aplanet1 that demonstrates how to use this
function. The following is a typical user interaction with this demonstration script.
<1> Mercury
<2> Venus
<3> Earth
<4> Mars
<5> Jupiter
<6> Saturn
<7> Uranus
<8> Neptune
<9> Pluto
<10> Sun
<11> Moon
<1> geocentric
<2> topocentric
page 25
Orbital Mechanics with MATLAB
'Moon'
This MATLAB function determines the apparent geocentric and topocentric coordinates of a
planet or the Moon. The source ephemeris for this routine is the SLP96 binary file slp96.bin.
The algorithms used in this function are based on the Fortran versions found in NOVAS.
function [ra, dec, dis] = applan2(tjd, ujd, l, n, topo, glon, glat, ht)
page 26
Orbital Mechanics with MATLAB
% input
% output
This software collection includes a script called demo_aplanet2 which demonstrates how to
use this function. The user interaction with this script is identical to the interaction with the
demo_aplanet1 script described above.
This MATLAB function determines the apparent geocentric and topocentric coordinates of a
star. The source ephemeris for this routine is a JPL binary file.
This software suite includes scripts that demonstrate how to calculate the apparent topocentric
and geocentric coordinates of a star. The first script is called demo_astar1 and it uses a JPL
binary ephemeris file as its source ephemeris. The second script is called demo_astar2 and it
uses SLP96 as its source ephemeris. These applications use several functions ported to
MATLAB from the Fortran versions of the NOVAS (Naval Observatory Vector Astrometry
Subroutines) source code that was developed at the United States Naval Observatory.
(1) precession
(2) nutation
(3) aberration
(4) gravitational deflection of light
(5) proper motion
(6) parallax
page 27
Orbital Mechanics with MATLAB
Please note that this program does not include a correction for atmospheric refraction. For
extragalatic objects the proper motions, parallax and radial velocity should all be set to 0.
An excellent discussion about these corrections can be found in “Mean and Apparent Place
Computations in the New IAU System. III. Apparent, Topocentric, and Astrometric Places of
Planets and Stars”, G.H. Kaplan, J.A. Hughes, P.K. Seidelmann, C.A. Smith and B.D. Yallop,
The Astronomical Journal, Vol. 97, No. 4, pages 1197-1210, 1989.
The syntax and arguments for the MATLAB function that actually performs most of the
calculations are as follows:
function [ra, dec] = apstar1 (tjd, ujd, n, topo, glon, glat, ht, ...
ram, decm, pmra, pmdec, parlax, radvel)
% input
% output
page 28
Orbital Mechanics with MATLAB
The demo_astar software will prompt you for the calendar date, universal time, observer
coordinates, the name of the star data file and the type of ephemeris (topocentric or geocentric).
The following is a typical star data file named altair.dat. Do not delete any lines of text or
data as the software expects to find exactly 20 lines of information.
star name
ALTAIR
parallax (arcseconds)
0.1981
The following is the syntax of the MATLAB function that reads this data file.
% required by star*.m
% input
% output
page 29
Orbital Mechanics with MATLAB
The following is a typical user interaction with the demo_astar1 (and demo_astar2) scripts.
It illustrates the topocentric coordinates of the star Altair relative to a sea level observer at 40
north latitude and 105 west longitude, at 0 hours UT.
<1> geocentric
<2> topocentric
ALTAIR
page 30
Orbital Mechanics with MATLAB
This MATLAB function determines the apparent geocentric and topocentric coordinates of a
star. The source ephemeris for this routine is the SLP96 binary file slp96.bin.
function [ra, dec] = apstar2 (tjd, ujd, n, topo, glon, glat, ht, ...
ram, decm, pmra, pmdec, parlax, radvel)
% input
% output
The prior discussion about the demo_apstar1 script also applies to the demonstration
demo_apstar2 script included with this software suite.
page 31
Orbital Mechanics with MATLAB
These files can be downloaded from the Celestial and Orbital Mechanics website.
page 32