Multiple file access functions¶
The following group of functions should be the preferred method to access to the library. They allow to access to multiple ephemeris files at the same time, even by multiple threads.
When an error occurs, these functions execute error handlers according to the behavior defined by the function calcephpy.seterrorhandler()
.
Time notes¶
The functions calcephpy.CalcephBin.compute()
, calcephpy.CalcephBin.compute_unit()
, calcephpy.CalcephBin.compute_order()
, calcephpy.CalcephBin.orient_unit()
, ... only accept a date expressed in the same timescale as the ephemeris files, which can be retrieved using the function calcephpy.CalcephBin.gettimescale()
. Ephemeris files are generally expressed using the timescale TDB.
If a date, expressed in the TT (Terrestrial Time) timescale, is supplied to them, these functions will return an erroneous position of the order of several tens of meters for the planets.
If a date, expressed in the Coordinated Universal Time (UTC), is supplied to them, these functions will return a very large erroneous position over several thousand kilometers for the planets.
Thread notes¶
If the standard I/O functions such as fread are not reentrant then the CALCEPH I/O functions using them will not be reentrant either.
It's not safe for two threads to call the functions with the same object of type CalcephBin
if and only if the function calcephpy.CalcephBin.isthreadsafe()
returns a nonzero value. A previous call to the function calcephpy.CalcephBin.prefetch()
is required for the function calcephpy.CalcephBin.isthreadsafe()
to return a nonzero value.
It's safe for two threads to access simultaneously to the same ephemeris file with two different objects of type CalcephBin
. In this case, each thread must open the same file.
Usage¶
The following examples, that can be found in the directory examples of the library sources, show the typical usage of this group of functions.
The example in Python language is pymultiple.py
.
Functions¶
calcephpy.CalcephBin.open¶

calcephpy.CalcephBin.
open
(filename) → eph¶  Parameters
filename (str)  pathname of the file
 Returns
ephemeris descriptor
 Return type
calcephpy.CalcephBin
This function opens the file whose pathname is the string pointed to by filename, reads the two header blocks of this file and returns an ephemeris descriptor associated to it. This file must be compliant to the format specified by the 'original JPL binary' , 'INPOP 2.0 binary' or 'SPICE' ephemeris file. At the moment, supported SPICE files are the following :
text Planetary Constants Kernel (KPL/PCK) files
binary PCK (DAF/PCK) files.
binary SPK (DAF/SPK) files containing segments of type 1, 2, 3, 5, 8, 9, 12, 13, 17, 18, 19, 20, 21, 102, 103 and 120.
meta kernel (KPL/MK) files.
frame kernel (KPL/FK) files. Only a basic support is provided.
Just after the call of calcephpy.CalcephBin.open()
, the function calcephpy.CalcephBin.prefetch()
should be called to accelerate future computations.
The function calcephpy.CalcephBin.close()
must be called to free allocated memory by this function.
The following example opens the ephemeris file example1.dat
from calcephpy import *
peph = CalcephBin.open("example1.dat")
# ... computation ...
peph.close()
calcephpy.CalcephBin.open¶

calcephpy.CalcephBin.
open
(array_filename) → eph¶  Parameters
array_filename (list)  array of pathname of the files
 Returns
ephemeris descriptor
 Return type
calcephpy.CalcephBin
This function opens n files whose pathnames are the string pointed to by array_filename, reads the header blocks of these files and returns an ephemeris descriptor associated to them.
These files must have the same type (e.g., all files are SPICE files or original JPL files). This file must be compliant to the format specified by the 'original JPL binary' , 'INPOP 2.0 or 3.0 binary' or 'SPICE' ephemeris file. At the moment, supported SPICE files are the following :
text Planetary Constants Kernel (KPL/PCK) files
binary PCK (DAF/PCK) files.
binary SPK (DAF/SPK) files containing segments of type 1, 2, 3, 5, 8, 9, 12, 13, 17, 18, 19, 20, 21, 102, 103 and 120.
meta kernel (KPL/MK) files.
frame kernel (KPL/FK) files. Only a basic support is provided.
Just after the call of calcephpy.CalcephBin.open()
, the function calcephpy.CalcephBin.prefetch()
should be called to accelerate future computations.
The function calcephpy.CalcephBin.close()
must be called to free allocated memory by this function.
The following example opens the ephemeris file example1.bsp and example1.tpc
from calcephpy import CalcephBin
peph = CalcephBin.open(['example1.bsp', 'example1.tpc'])
# ... computation ...
peph.close()
calcephpy.CalcephBin.prefetch¶

calcephpy.CalcephBin.
prefetch
()¶
This function prefetches to the main memory all files associated to the ephemeris descriptor.
This prefetching operation will accelerate the further computations performed with calcephpy.CalcephBin.compute()
, calcephpy.CalcephBin.compute_unit()
, calcephpy.CalcephBin.compute_order()
, calcephpy.CalcephBin.orient_unit()
, ... .
It requires that the file is smaller than the main memory. If multiple threads (e.g. threads of openMP or Posix Pthreads) prefetch the data for the same ephemeris file, the used memory will remain the same as if the prefetch operation was done by a single thread if and if the endianess of the file is the same as the computer and if the operating system, such as Linux, MacOS X other unix, supports the function mmap.
calcephpy.CalcephBin.isthreadsafe¶

calcephpy.CalcephBin.
isthreadsafe
()¶
This function returns 1 if multiple threads can access the same ephemeris ephemeris descriptor, otherwise 0.
A previous call to the function calcephpy.CalcephBin.prefetch()
is required, and the library should becompiled with enablethread=yes on Unixlike operating system, for the function calcephpy.CalcephBin.isthreadsafe()
to return a nonzero value. If the file is not encoded with the same endian as the current hardware, then function may return 0.
If this function returns 1, severals threads may use the same ephemeris descriptor for the computational functions calcephpy.CalcephBin.compute()
, .... It allows to use the same object for parallel loops.
calcephpy.CalcephBin.compute¶

calcephpy.CalcephBin.
compute
(JD0, time, target, center) → PV¶  Parameters
JD0 (float/list/numpy.ndarray)  Integer part of the Julian date (TDB or TCB)
time (float/list/numpy.ndarray)  Fraction part of the Julian date (TDB or TCB)
target (int)  The body or reference point whose coordinates are required (see the list, below).
center (int)  The origin of the coordinate system (see the list, below). If target is 14, 15, 16 or 17 (nutation, libration, TTTDB or TCGTCB), center must be 0.
 Returns
Depending on the target value, an array to receive the cartesian position (x,y,z) and the velocity (xdot, ydot, zdot), or a time scale transformation value, or the angles of the librations of the Moon and their derivatives, or the nutation angles and their derivatives.
 Return type
list
This function reads, if needed, in the ephemeris file self and interpolates a single object, usually the position and velocity of one body (target) relative to another (center) for the time JD0+time and stores the results to PV. The ephemeris file self must have been previously opened with the function calcephpy.CalcephBin.open()
.
The returned array PV has the following properties
If the target is TTTDB, only the first element of this array will get the result. The time scale transformation TTTDB is expressed in seconds.
If the target is TCGTCB, only the first element of this array will get the result. The time scale transformation TCGTCB is expressed in seconds.
If the target is Librations, the array contains the angles of the librations of the Moon and their derivatives. The angles of the librations of the Moon are expressed in radians and their derivatives are expressed in radians per day.
If the target is Nutations, the array contains the nutation angles and their derivatives. The nutation angles are expressed in radians and their derivatives are expressed in radians per day.
Otherwise the returned values is the cartesian position (x,y,z), expressed in Astronomical Unit (au), and the velocity (xdot, ydot, zdot), expressed in Astronomical Unit per day (au/day).
If JD0 and time are list or NumPy's array (1D) of doubleprecision floatingpoint values, the returned array PV is a list of 6 arrays. Each array contain a single component of position or velocity (e.g., PV[0] contains the coordinate X, PV[1] contains the coordinate Y, ...) .
The date (JD0, time) should be expressed in the same timescale as the ephemeris files, which can be retrieved using the function calcephpy.CalcephBin.gettimescale()
. To get the best numerical precision for the interpolation, the time is splitted in two floatingpoint numbers. The argument JD0 should be an integer and time should be a fraction of the day. But you may call this function with time=0 and JD0, the desired time, if you don't take care about numerical precision.
Warning
If a date, expressed in the Coordinated Universal Time (UTC), is supplied to this function, a very large erroneous position will be returned.
The possible values for target and center are :
value 
meaning 

1 
Mercury Barycenter 
2 
Venus Barycenter 
3 
Earth 
4 
Mars Barycenter 
5 
Jupiter Barycenter 
6 
Saturn Barycenter 
7 
Uranus Barycenter 
8 
Neptune Barycenter 
9 
Pluto Barycenter 
10 
Moon 
11 
Sun 
12 
Solar Sytem barycenter 
13 
Earthmoon barycenter 
14 
Nutation angles 
15 
Librations 
16 
TTTDB 
17 
TCGTCB 
asteroid number + CALCEPH_ASTEROID 
asteroid 
These accepted values by this function are the same as the value for the JPL function PLEPH, except for the values TTTDB, TCGTCB and asteroids.
For example, the value "CALCEPH_ASTEROID+4" for target or center specifies the asteroid Vesta.
The following example prints the heliocentric coordinates of Mars at time=2442457.5 and at 2442457.9
from calcephpy import *
def printcoord(PV,name):
print('{0} :\n{1}\n'.format(name,PV))
jd0=2442457
dt1=0.5E0
dt2=0.9E0
peph = CalcephBin.open("example1.dat")
PV1 = peph.compute(jd0, dt1, 4, 11)
printcoord(PV1,"heliocentric coordinates of Mars")
PV2 = peph.compute(jd0, dt2, 4, 11)
printcoord(PV2,"heliocentric coordinates of Mars")
peph.close()
calcephpy.CalcephBin.compute_unit¶

calcephpy.CalcephBin.
compute_unit
(JD0, time, target, center, unit) → PV¶  Parameters
JD0 (float/list/numpy.ndarray)  Integer part of the Julian date (TDB or TCB)
time (float/list/numpy.ndarray)  Fraction part of the Julian date (TDB or TCB)
target (int)  The body or reference point whose coordinates are required. The numbering system depends on the parameter unit.
center (int)  The origin of the coordinate system. The numbering system depends on the parameter unit.
unit (int) 
The units of PV.This integer is a sum of some unit constants (CALCEPH_UNIT_???) and/or the constantUSE_NAIFID
.If the unit containsUSE_NAIFID
, the NAIF identification numbering system is used for the target and the center (NAIF identification numbers for the list).If the unit doesnot containUSE_NAIFID
, the old number system is used for the target and the center (see the list in the functioncalcephpy.CalcephBin.compute()
).
 Returns
Depending on the target value, an array to receive the cartesian position (x,y,z) and the velocity (xdot, ydot, zdot), or a time scale transformation value, or the angles of the librations of the Moon and their derivatives, or the nutation angles and their derivatives.
 Return type
list
This function is similar to the function calcephpy.CalcephBin.compute()
, except that the units of the output are specified.
This function reads, if needed, in the ephemeris file self and interpolates a single object, usually the position and velocity of one body (target) relative to another (center) for the time JD0+time and stores the results to PV. The ephemeris file self must have been previously opened with the function calcephpy.CalcephBin.open()
.
The output values are expressed in the units specified by unit.
This function checks the units if invalid combinations of units are given to the function.
The date (JD0, time) should be expressed in the same timescale as the ephemeris files, which can be retrieved using the function calcephpy.CalcephBin.gettimescale()
.
Warning
If a date, expressed in the Coordinated Universal Time (UTC), is supplied to this function, a very large erroneous position will be returned.
The returned array PV has the following properties
If the target is the time scale transformation TTTDB, only the first element of this array will get the result.
If the target is the time scale transformation TCGTCB, only the first element of this array will get the result.
If the target is Librations, the array contains the angles of the librations of the Moon and their derivatives.
If the target is Nutations, the array contains the nutation angles and their derivatives.
Otherwise the returned value is the cartesian position (x,y,z) and the velocity (xdot, ydot, zdot).
If JD0 and time are list or NumPy's array (1D) of doubleprecision floatingpoint values, the returned array PV is a list of 6 arrays. Each array contain a single component of position or velocity (e.g., PV[0] contains the coordinate X, PV[1] contains the coordinate Y, ...) .
The values stored in the array PV are expressed in the following units
The position and velocity are expressed in Astronomical Unit (au) if unit contains
UNIT_AU
.The position and velocity are expressed in kilometers if unit contains
UNIT_KM
.The velocity, TTTDB, TCGTCB, the derivatives of the angles of the nutation, or the derivatives of the librations of the Moon or are expressed in days if unit contains
UNIT_DAY
.The velocity, TTTDB, TCGTCB, the derivatives of the angles of the nutation, or the derivatives of the librations of the Moon are expressed in seconds if unit contains
UNIT_SEC
.The angles of the librations of the Moon or the nutation angles are expressed in radians if unit contains
UNIT_RAD
.
For example, to get the position and velocities expressed in kilometers and kilometers/seconds, the unit must be set to UNIT_KM
+ UNIT_SEC
.
The following example prints the heliocentric coordinates of Mars at time=2442457.5
from calcephpy import *
def printcoord(PV,name):
print('{0} :\n{1}\n'.format(name,PV))
jd0=2442457
dt=0.5E0
peph = CalcephBin.open("example1.dat")
PV1 = peph.compute_unit(jd0, dt, 4, 11, Constants.UNIT_KM+Constants.UNIT_SEC)
printcoord(PV1,"heliocentric coordinates of Mars")
PV2 = peph.compute_unit(jd0, dt, NaifId.MARS_BARYCENTER, NaifId.SUN,
Constants.UNIT_KM+Constants.UNIT_SEC+Constants.USE_NAIFID)
printcoord(PV2,"heliocentric coordinates of Mars")
peph.close()
calcephpy.CalcephBin.orient_unit¶

calcephpy.CalcephBin.
orient_unit
(JD0, time, target, unit) → PV¶  Parameters
JD0 (float/list/numpy.ndarray)  Integer part of the Julian date (TDB or TCB)
time (float/list/numpy.ndarray)  Fraction part of the Julian date (TDB or TCB)
target (int)  The body whose orientations are requested. The numbering system depends on the parameter unit.
unit (int) 
The units of PV.This integer is a sum of some unit constants (CALCEPH_UNIT_???) and/or the constantUSE_NAIFID
.If the unit containsUSE_NAIFID
, the NAIF identification numbering system is used for the target (NAIF identification numbers for the list).If the unit does not containUSE_NAIFID
, the old number system is used for the target (see the list in the functioncalcephpy.CalcephBin.compute()
).
 Returns
An array to receive the euler angles, or nutation angles, and their derivatives for the orientation of the body.
 Return type
list
This function reads, if needed, in the ephemeris file self and interpolates the orientation of a single body (target) for the time JD0+time and stores the results to PV. The ephemeris file self must have been previously opened with the function calcephpy.CalcephBin.open()
.
The output values are expressed in the units specified by unit.
The date (JD0, time) should be expressed in the same timescale as the ephemeris files, which can be retrieved using the function calcephpy.CalcephBin.gettimescale()
.
This function checks the units if invalid combinations of units are given to the function.
The returned array PV has the following properties
If unit contains
OUTPUT_NUTATIONANGLES
, the array contains the nutation angles and their derivatives for the orientation of the body. At the present moment, only the nutation for the earth are supported in the original DE files.If unit contains
OUTPUT_EULERANGLES
, or doesnot containOUTPUT_NUTATIONANGLES
, the array contains the euler angles and their derivatives for the orientation of the body.
If JD0 and time are list or NumPy's array (1D) of doubleprecision floatingpoint values, the returned array PV is a list of 6 arrays. Each array contain a single component of orientation.
The values stored in the array PV are expressed in the following units
For example, to get the nutation angles of the Earth and their derivatives expressed in radian and radian/seconds using the NAIF identification numbering system, the target must be set to NAIFID_EARTH and the unit must be set to OUTPUT_NUTATIONANGLES
+ UNIT_RAD
+ UNIT_SEC
.
The following example prints the angles of libration of the Moon at time=2442457.5
from calcephpy import *
jd0=2442457
dt=0.5E0
peph = CalcephBin.open("example1.dat")
PV = peph.orient_unit(jd0, dt, NaifId.MOON,
Constants.USE_NAIFID+Constants.UNIT_RAD+Constants.UNIT_SEC)
print(PV)
peph.close()
calcephpy.CalcephBin.rotangmom_unit¶

calcephpy.CalcephBin.
rotangmom_unit
(JD0, time, target, unit) → PV¶  Parameters
JD0 (float)  Integer part of the Julian date (TDB or TCB)
time (float)  Fraction part of the Julian date (TDB or TCB)
target (int)  The body whose orientations are requested. The numbering system depends on the parameter unit.
unit (int) 
The units of PV.This integer is a sum of some unit constants (CALCEPH_UNIT_???) and/or the constantUSE_NAIFID
.If the unit containsUSE_NAIFID
, the NAIF identification numbering system is used for the target (NAIF identification numbers for the list).If the unit does not containUSE_NAIFID
, the old number system is used for the target (see the list in the functioncalcephpy.CalcephBin.compute()
).
 Returns
An array to receive the angular momentum due to its rotation, divided by the product of the mass and of the square of the radius, and the derivatives, of the body.
 Return type
list
This function reads, if needed, in the ephemeris file self and interpolates the angular momentum vector due to the rotation of the body, divided by the product of the mass and of the square of the radius , of a single body (target) for the time JD0+time and stores the results to PV. The ephemeris file self must have been previously opened with the function calcephpy.CalcephBin.open()
. The angular momentum , due to the rotation of the body, is defined as the product of the inertia matrix by the angular velocity vector . So the returned value is
The date (JD0, time) should be expressed in the same timescale as the ephemeris files, which can be retrieved using the function calcephpy.CalcephBin.gettimescale()
.
The output values are expressed in the units specified by unit.
This function checks the units if invalid combinations of units are given to the function.
The values stored in the array PV are expressed in the following units
The following example prints the angular momentum, due to its rotation, for the Earth at time=2451419.5
 s int j;
double jd0=2451419; double dt1=0.5E0; t_calcephbin *peph; double G[6];
/* open the ephemeris file */ peph = calceph_open("example2_rotangmom.dat"); if (peph) {
calceph_prefetch(peph);
 calceph_rotangmom_unit(peph, jd0, dt1, NAIFID_EARTH,
CALCEPH_USE_NAIFID+CALCEPH_UNIT_SEC, G);
for(j=0; j<6; j++) printf("%23.16En", G[j]);
/* close the ephemeris file */ calceph_close(peph);
}
from calcephpy import *
jd0=2451419
dt=0.5E0
peph = CalcephBin.open("example2_rotangmom.dat")
G = peph.rotangmom_unit(jd0, dt, NaifId.EARTH,
Constants.USE_NAIFID+Constants.UNIT_SEC)
print(G)
peph.close()
calcephpy.CalcephBin.compute_order¶

calcephpy.CalcephBin.
compute_order
(JD0, time, target, center, unit, order) → PVAJ¶  Parameters
JD0 (float/list/numpy.ndarray)  Integer part of the Julian date (TDB or TCB)
time (float/list/numpy.ndarray)  Fraction part of the Julian date (TDB or TCB)
target (int)  The body or reference point whose coordinates are required. The numbering system depends on the parameter unit.
center (int)  The origin of the coordinate system. The numbering system depends on the parameter unit.
unit (int) 
The units of PVAJ.This integer is a sum of some unit constants (CALCEPH_UNIT_???) and/or the constantUSE_NAIFID
.If the unit containsUSE_NAIFID
, the NAIF identification numbering system is used for the target and the center (NAIF identification numbers for the list).If the unit doesnot containUSE_NAIFID
, the old number system is used for the target and the center (see the list in the functioncalcephpy.CalcephBin.compute()
).order (int) 
The order of derivatives
= 0 , only the position is computed. The first three numbers of PVAJ are valid for the results.
= 1 , only the position and velocity are computed. The first six numbers of PVAJ are valid for the results.
= 2 , only the position, velocity and acceleration are computed. The first nine numbers of PVAJ are valid for the results.
= 3 , the position, velocity and acceleration and jerk are computed. The first twelve numbers of PVAJ are valid for the results.
If order equals to 1, the behavior of
calcephpy.CalcephBin.compute_order()
is the same ascalcephpy.CalcephBin.compute_unit()
.
 Returns
Depending on the target value, an array to receive the cartesian position (x,y,z), the velocity (xdot, ydot, zdot), the acceleration and the jerk, or a time scale transformation value, or the angles of the librations of the Moon and their successive derivatives, or the nutation angles and their successive derivatives.
 Return type
list
This function is similar to the function calcephpy.CalcephBin.compute_unit()
, except that the order of the computed derivatives is specified.
This function reads, if needed, in the ephemeris file self and interpolates a single object, usually the position and their derivatives of one body (target) relative to another (center) for the time JD0+time and stores the results to PVAJ. The ephemeris file self must have been previously opened with the function calcephpy.CalcephBin.open()
.
The order of the derivatives are specified by order. The output values are expressed in the units specified by unit.
The returned array PVAJ has the following properties
If the target is the time scale transformation TTTDB, only the first elements of each component will get the result.
If the target is the time scale transformation TCGTCB, only the first elements of each component will get the result.
If the target is Librations, the array contains the angles of the librations of the Moon and their successive derivatives.
If the target is Nutations, the array contains the nutation angles and their successive derivatives.
Otherwise the returned value is the cartesian position (x,y,z), the velocity (xdot, ydot, zdot), the jerk and the acceleration.
The returned array PVAJ must be large enough to store the results.
PVAJ[1:3] contain the position (x,y,z) and is always valid.
PVAJ[4:6] contain the velocity (dx/dt,dy/dt,dz/dt) and is only valid if order is greater or equal to 1.
PVAJ[7:9] contain the acceleration (d^2x/dt^2,d^2y/dt^2,d^2z/dt^2) and is only valid if order is greater or equal to 2.
PVAJ[10:12] contain the jerk (d^3x/dt^3,d^3y/dt^3,d^3z/dt^3) and is only valid if order is equal to 3.
If JD0 and time are list or NumPy's array (1D) of doubleprecision floatingpoint values, the returned array PVAJ is a list of 3*(order+1) arrays. Each array contain a single component of position, velocity ... (e.g., PV[0] contains the coordinate X, PV[1] contains the coordinate Y, ...) .
The date (JD0, time) should be expressed in the same timescale as the ephemeris files, which can be retrieved using the function calcephpy.CalcephBin.gettimescale()
.
Warning
If a date, expressed in the Coordinated Universal Time (UTC), is supplied to this function, a very large erroneous position will be returned.
The values stored in the array PVAJ are expressed in the following units
The position, velocity, acceleration and jerk are expressed in Astronomical Unit (au) if unit contains
UNIT_AU
.The position, velocity, acceleration and jerk are expressed in kilometers if unit contains
UNIT_KM
.The velocity, acceleration, jerk, TTTDB, TCGTCB or the derivatives of the angles of the librations of the Moon are expressed in days if unit contains
UNIT_DAY
.The velocity, acceleration, jerk, TTTDB, TCGTCB or the derivatives of the angles of the librations of the Moon are expressed in seconds if unit contains
UNIT_SEC
.The angles of the librations of the Moon are expressed in radians if unit contains
UNIT_RAD
.
For example, to get the positions, velocities, accelerations and jerks expressed in kilometers and kilometers/seconds, the unit must be set to UNIT_KM
+ UNIT_SEC
.
This function checks the units if invalid combinations of units are given to the function.
The following example prints the heliocentric coordinates of Mars at time=2442457.5
from calcephpy import *
jd0=2442457
dt=0.5E0
peph = CalcephBin.open("example1.dat")
# compute only the heliocentric position of Mars in km
P = peph.compute_order(jd0, dt, NaifId.MARS_BARYCENTER, NaifId.SUN,
Constants.UNIT_KM+Constants.UNIT_SEC+Constants.USE_NAIFID, 0)
print(P)
# compute positions, velocities, accelerations and jerks of Mars in km and seconds
PVAJ = peph.compute_order(jd0, dt, NaifId.MARS_BARYCENTER, NaifId.SUN,
Constants.UNIT_KM+Constants.UNIT_SEC+Constants.USE_NAIFID, 3)
print(PVAJ)
peph.close()
calcephpy.CalcephBin.orient_order¶

calcephpy.CalcephBin.
orient_order
(JD0, time, target, unit, order) → PVAJ¶  Parameters
JD0 (float/list/numpy.ndarray)  Integer part of the Julian date (TDB or TCB)
time (float/list/numpy.ndarray)  Fraction part of the Julian date (TDB or TCB)
target (int)  The body whose orientations are requested. The numbering system depends on the parameter unit.
unit (int) 
The units of PV.This integer is a sum of some unit constants (CALCEPH_UNIT_???) and/or the constantUSE_NAIFID
.If the unit containsUSE_NAIFID
, the NAIF identification numbering system is used for the target (NAIF identification numbers for the list).If the unit does not containUSE_NAIFID
, the old number system is used for the target (see the list in the functioncalcephpy.CalcephBin.compute()
).order (int) 
The order of derivatives.
= 0 , only the angles is computed. The first three numbers of PVAJ are valid for the results.
= 1 , only the angles and the first derivative are computed. The first six numbers of PVAJ are valid for the results.
= 2 , only the angles and the first and second derivatives are computed. The first nine numbers of PVAJ are valid for the results.
= 3 , the angles and the first, second and third derivatives are computed. The first twelve numbers of PVAJ are valid for the results.
If order equals to 1, the behavior of
calcephpy.CalcephBin.orient_order()
is the same ascalcephpy.CalcephBin.orient_unit()
.
 Returns
An array to receive the euler angles, or nutation angles, and their derivatives for the orientation of the body.
 Return type
list
This function is similar to the function calcephpy.CalcephBin.orient_unit()
, except that the order of the computed derivatives is specified.
This function reads, if needed, in the ephemeris file self and interpolates the orientation of a single body (target) for the time JD0+time and stores the results to PVAJ.
The order of the derivatives are specified by order. The ephemeris file self must have been previously opened with the function calcephpy.CalcephBin.open()
.
The output values are expressed in the units specified by unit.
This function checks the units if invalid combinations of units are given to the function.
The returned array PVAJ has the following properties
If unit contains
OUTPUT_NUTATIONANGLES
, the array contains the nutation angles and their successive derivatives for the orientation of the body. At the present moment, only the nutation for the earth are supported in the original DE files.If unit contains
OUTPUT_EULERANGLES
, or doesnot containOUTPUT_NUTATIONANGLES
, the array contains the euler angles and their successive derivatives for the orientation of the body.
The returned array PVAJ must be large enough to store the results.
PVAJ[1:3] contain the angles and is always valid.
PVAJ[4:6] contain the first derivative and is only valid if order is greater or equal to 1.
PVAJ[7:9] contain the second derivative and is only valid if order is greater or equal to 2.
PVAJ[10:12] contain the third derivative and is only valid if order is equal to 3.
If JD0 and time are list or NumPy's array (1D) of doubleprecision floatingpoint values, the returned array PVAJ is a list of 3*(order+1) arrays. Each array contain a single component of the orientation.
The values stored in the array PVAJ are expressed in the following units
The date (JD0, time) should be expressed in the same timescale as the ephemeris files, which can be retrieved using the function calcephpy.CalcephBin.gettimescale()
.
The following example prints only the angles of libration of the Moon at time=2442457.5
from calcephpy import *
jd0=2442457
dt=0.5E0
peph = CalcephBin.open("example1.dat")
P = peph.orient_order(jd0, dt, NaifId.MOON,
Constants.USE_NAIFID+Constants.UNIT_RAD+Constants.UNIT_SEC, 0)
print(P)
peph.close()
calcephpy.CalcephBin.rotangmom_order¶

calcephpy.CalcephBin.
rotangmom_order
(JD0, time, target, unit, order) → PVAJ¶  Parameters
JD0 (float)  Integer part of the Julian date (TDB or TCB)
time (float)  Fraction part of the Julian date (TDB or TCB)
target (int)  The body whose orientations are requested. The numbering system depends on the parameter unit.
unit (int) 
The units of PV.This integer is a sum of some unit constants (CALCEPH_UNIT_???) and/or the constantUSE_NAIFID
.If the unit containsUSE_NAIFID
, the NAIF identification numbering system is used for the target (NAIF identification numbers for the list).If the unit does not containUSE_NAIFID
, the old number system is used for the target (see the list in the functioncalcephpy.CalcephBin.compute()
).order (int) 
The order of derivatives.
= 0 , only the angular momentum is computed. The first three numbers of PVAJ are valid for the results.
= 1 , only the angular momentum and the first derivative are computed. The first six numbers of PVAJ are valid for the results.
= 2 , only the angular momentum and the first and second derivatives are computed. The first nine numbers of PVAJ are valid for the results.
= 3 , the angular momentum and the first, second and third derivatives are computed. The first twelve numbers of PVAJ are valid for the results.
If order equals to 1, the behavior of
calcephpy.CalcephBin.rotangmom_order()
is the same ascalcephpy.CalcephBin.rotangmom_unit()
.
 Returns
An array to receive the angular momentum due to its rotation, divided by the product of the mass and of the square of the radius, and their different order of the derivatives, of the body.
 Return type
list
This function is similar to the function calcephpy.CalcephBin.orient_unit()
, except that the order of the computed derivatives is specified.
This function reads, if needed, in the ephemeris file self and interpolates the angular momentum vector due to the rotation of the body, divided by the product of the mass and of the square of the radius , of a single body (target) for the time JD0+time and stores the results to PVAJ. The angular momentum , due to the rotation of the body, is defined as the product of the inertia matrix by the angular velocity vector . So the returned value is
The order of the derivatives are specified by order. The ephemeris file self must have been previously opened with the function calcephpy.CalcephBin.open()
.
The output values are expressed in the units specified by unit.
This function checks the units if invalid combinations of units are given to the function.
The returned array PVAJ must be large enough to store the results.
PVAJ[1:3] contain the angular momentum and is always valid.
PVAJ[4:6] contain the first derivative and is only valid if order is greater or equal to 1.
PVAJ[7:9] contain the second derivative and is only valid if order is greater or equal to 2.
PVAJ[10:12] contain the third derivative and is only valid if order is equal to 3.
The values stored in the array PVAJ are expressed in the following units
The date (JD0, time) should be expressed in the same timescale as the ephemeris files, which can be retrieved using the function calcephpy.CalcephBin.gettimescale()
.
The following example prints only the angular momentum, due to its rotation, of the Earth at time=2451419.5
from calcephpy import *
jd0=2451419
dt=0.5E0
peph = CalcephBin.open("example2_rotangmom.dat")
G = peph.rotangmom_order(jd0, dt, NaifId.EARTH,
Constants.USE_NAIFID+Constants.UNIT_SEC, 0)
print(G)
peph.close()
calcephpy.CalcephBin.getconstant¶

calcephpy.CalcephBin.
getconstant
(name) → value¶  Parameters
name (str)  name of the constant
 Returns
first value of the constant
 Return type
float
This function returns the value associated to the constant name in the header of the ephemeris file self. Only the first value is returned if multiple values are associated to a constant, such as a list of values.
This function is the same function as calcephpy.CalcephBin.getconstantsd()
.
The following example prints the value of the astronomical unit stored in the ephemeris file
from calcephpy import *
peph = CalcephBin.open("example1.dat")
AU = peph.getconstant("AU")
print(AU)
peph.close()
calcephpy.CalcephBin.getconstantsd¶

calcephpy.CalcephBin.
getconstantsd
(name) → value¶  Parameters
name (str)  name of the constant
 Returns
first value of the constant
 Return type
float
This function returns, as a floatingpoint number, the value associated to the constant name in the header of the ephemeris file self. Only the first value is returned if multiple values are associated to a constant, such as a list of values. The value must be a floatingpoint or integer number, otherwise an error is reported.
This function is the same function as calcephpy.CalcephBin.getconstant()
.
The following example prints the value of the astronomical unit stored in the ephemeris file
from calcephpy import *
peph = CalcephBin.open("example1.dat")
AU = peph.getconstantsd("AU")
print(AU)
peph.close()
calcephpy.CalcephBin.getconstantvd¶

calcephpy.CalcephBin.
getconstantvd
(name) → arrayvalue¶  Parameters
name (str)  name of the constant
 Returns
array of values for the constant
 Return type
list
This function returns, as floatingpoint numbers, all values associated to the constant name in the header of the ephemeris file self.
The values must be floatingpoint or integer numbers, otherwise an error is reported.
The following example prints the body radii of the earth stored in the ephemeris file
from calcephpy import *
peph = CalcephBin.open("example1.dat")
radii = peph.getconstantvd("BODY399_RADII")
print(radii)
peph.close()
calcephpy.CalcephBin.getconstantss¶

calcephpy.CalcephBin.
getconstantss
(name) → value¶  Parameters
name (str)  name of the constant
 Returns
first value of the constant
 Return type
str
This function returns, as a string of character, the value associated to the constant name in the header of the ephemeris file self. Only the first value is returned if multiple values are associated to a constant, such as a list of values. The value must be a string, otherwise an error is reported.
The following example prints the value of the unit stored in the ephemeris file
from calcephpy import *
peph = CalcephBin.open("example1.dat")
UNIT = peph.getconstantss("UNIT")
print(UNIT)
peph.close()
calcephpy.CalcephBin.getconstantvs¶

calcephpy.CalcephBin.
getconstantvs
(name) → arrayvalue¶  Parameters
name (str)  name of the constant
 Returns
array of values for the constant
 Return type
list
This function returns, as strings of characters, all values associated to the constant name in the header of the ephemeris file self.
The values must be strings, otherwise an error is reported.
The following example prints the units of the mission stored in the ephemeris file
from calcephpy import *
peph = CalcephBin.open("example1.dat")
mission_units = peph.getconstantvs("MISSION_UNITS")
print(mission_units)
peph.close()
calcephpy.CalcephBin.getconstantcount¶

calcephpy.CalcephBin.
getconstantcount
()¶  Returns
number of constants
 Return type
int
This function returns the number of constants available in the header of the ephemeris file self.
The following example prints the number of available constants stored in the ephemeris file
from calcephpy import *
peph = CalcephBin.open("example1.dat")
n = peph.getconstantcount()
print("number of constants", n)
peph.close()
calcephpy.CalcephBin.getconstantindex¶

calcephpy.CalcephBin.
getconstantindex
(index) → name, value¶  Parameters
index (int)  index of the constant, between 1 and
calcephpy.CalcephBin.getconstantcount()
 Returns
name of the constant, first value of the constant
 Return type
str, float
This function returns the name and its value of the constant available at the specified index in the header of the ephemeris file self. The value of index must be between 1 and calcephpy.CalcephBin.getconstantcount()
.
Only the first value is returned if multiple values are associated to a constant, such as a list of values. If the first value is not an floatingpoint number, such as a string, then the function returns 0 without raising an error.
The following example displays the name of the constants, stored in the ephemeris file, and their values
from calcephpy import *
peph = CalcephBin.open("example1.dat")
n = peph.getconstantcount()
for j in range(1, n+1):
name, value = peph.getconstantindex(j)
print(name, value)
peph.close()
calcephpy.CalcephBin.getfileversion¶

calcephpy.CalcephBin.
getfileversion
()¶  Returns
version of the ephemeris file
 Return type
str
This function returns the version of the ephemeris file, as a string. For example, the argument version will contain 'INPOP10B', 'EPM2017' or 'DE405', ... .
If the file is an original JPL binary planetary ephemeris, then the version of the file can always be determined. If the file is a spice kernel, the version of the file is retrieved from the constant INPOP_PCK_VERSION, EPM_PCK_VERSION, or PCK_VERSION.
The following example prints the version of the ephemeris file.
from calcephpy import *
peph = CalcephBin.open("example1.dat")
version = peph.getfileversion()
print(version)
peph.close()
calcephpy.CalcephBin.gettimescale¶

calcephpy.CalcephBin.
gettimescale
()¶  Returns
time scale of the ephemeris file
 Return type
int
 This function returns the timescale of the ephemeris file self :
1 if the quantities of all bodies are expressed in the TDB time scale.
2 if the quantities of all bodies are expressed in the TCB time scale.
The following example prints the time scale available in the ephemeris file
from calcephpy import *
peph = CalcephBin.open("example1.dat")
timescale = peph.gettimescale()
print(timescale)
peph.close()
calcephpy.CalcephBin.gettimespan¶

calcephpy.CalcephBin.
gettimespan
() → firsttime, lasttime, continuous¶  Returns
first and last available time, availability of the quantities of the bodies over the time span
 Return type
float, float, int
This function returns the first and last time available in the ephemeris file self. The Julian date for the first and last time are expressed in the time scale returned by calcephpy.CalcephBin.gettimescale()
.
It returns the following value in the parameter continuous :
1 if the quantities of all bodies are available for any time between the first and last time.
2 if the quantities of some bodies are available on discontinuous time intervals between the first and last time.
3 if the quantities of each body are available on a continuous time interval between the first and last time, but not available for any time between the first and last time.
The following example prints the first and last time available in the ephemeris file
from calcephpy import *
peph = CalcephBin.open("example1.dat")
firsttime, lasttime, continuous = peph.gettimespan()
print(firsttime, lasttime, continuous)
peph.close()
calcephpy.CalcephBin.getpositionrecordcount¶

calcephpy.CalcephBin.
getpositionrecordcount
()¶  Returns
number of position's records
 Return type
int
This function returns the number of position's records available in the ephemeris file self. Usually, the number of records is equal to the number of bodies in the ephemeris file if the timespan is continuous. If the timespan is discontinuous for the target and center bodies, then each different timespan is counted as a different record. If the ephemeris file contain timescale transformations' records, such as TTTDB or TCGTCB, then these records are included in the returned value.
The following example prints the number of position's records available in the ephemeris file
from calcephpy import *
peph = CalcephBin.open("example1.dat")
n = peph.getpositionrecordcount()
print("number of position's record", n)
peph.close()
calcephpy.CalcephBin.getpositionrecordindex¶

calcephpy.CalcephBin.
getpositionrecordindex
(index) → target, center, firsttime, lasttime, frame¶  Parameters
index (int)  index of the position's record, between 1 and
calcephpy.CalcephBin.getpositionrecordcount()
 Returns
 target : the target bodycenter : the origin bodyfirsttime : julian date of the first timelasttime : julian date of the last timeframe : reference frame (see the list, below)
 Return type
int, int, float, float, int
This function returns the target and origin bodies, the first and last time, and the reference frame available at the specified index for the position's records of the ephemeris file self.
The NAIF identification numbering system is used for the target and center integers (NAIF identification numbers for the list).
The Julian date for the first and last time are expressed in the time scale returned by calcephpy.CalcephBin.gettimescale()
.
It returns the following value in the parameter frame :
value 
Name 

1 
ICRF 
The following example displays the position's records stored in the ephemeris file.
from calcephpy import *
peph = CalcephBin.open("example1.dat")
n = peph.getpositionrecordcount()
for j in range(1, n+1):
itarget, icenter, firsttime, lasttime, iframe = peph.getpositionrecordindex(j)
print(itarget, icenter, firsttime, lasttime, iframe)
peph.close()
calcephpy.CalcephBin.getpositionrecordindex2¶

calcephpy.CalcephBin.
getpositionrecordindex2
(index) → target, center, firsttime, lasttime, frame, segid¶  Parameters
index (int)  index of the position's record, between 1 and
calcephpy.CalcephBin.getpositionrecordcount()
 Returns
 target : the target bodycenter : the origin bodyfirsttime : julian date of the first timelasttime : julian date of the last timeframe : reference frame (see the list, below)segid : segment type (see the details, below)
 Return type
int, int, float, float, int, int
This function returns the target and origin bodies, the first and last time, the reference frame, and the segment type available at the specified index for the position's records of the ephemeris file self.
The NAIF identification numbering system is used for the target and center integers (NAIF identification numbers for the list).
The Julian date for the first and last time are expressed in the time scale returned by calcephpy.CalcephBin.gettimescale()
.
It returns the following value in the parameter frame :
value 
Name 

1 
ICRF 
It returns in the parameter segid one of the predefined constants Constants.SEGTYPE_... (Constants).
The following example displays the position's records stored in the ephemeris file.
from calcephpy import *
peph = CalcephBin.open("example1.dat")
n = peph.getpositionrecordcount()
for j in range(1, n+1):
itarget, icenter, firsttime, lasttime, iframe, iseg = peph.getpositionrecordindex2(j)
print(itarget, icenter, firsttime, lasttime, iframe, iseg)
peph.close()
calcephpy.CalcephBin.getorientrecordcount¶

calcephpy.CalcephBin.
getorientrecordcount
()¶  Returns
number of orientation's records
 Return type
int
This function returns the number of orientation's records available in the ephemeris file self. Usually, the number of records is equal to the number of bodies in the ephemeris file if the timespan is continuous. If the timespan is discontinuous for the target body, then each different timespan is counted as a different record.
The following example prints the number of orientation's records available in the ephemeris file
from calcephpy import *
peph = CalcephBin.open("example1.dat")
n = peph.getorientrecordcount()
print("number of orientation's record", n)
peph.close()
calcephpy.CalcephBin.getorientrecordindex¶

calcephpy.CalcephBin.
getorientrecordindex
(index) → target, firsttime, lasttime, frame¶  Parameters
index (int)  index of the orientation's record, between 1 and
calcephpy.CalcephBin.getorientrecordcount()
 Returns
 target : the target bodyfirsttime : julian date of the first timelasttime : julian date of the last timeframe : reference frame (see the list, below)
 Return type
int, float, float, int
This function returns the target body, the first and last time, and the reference frame available at the specified index for the orientation's records of the ephemeris file self.
The NAIF identification numbering system is used for the target body (NAIF identification numbers for the list).
The Julian date for the first and last time are expressed in the time scale returned by calcephpy.CalcephBin.gettimescale()
.
It returns the following value in the parameter frame :
value 
Name 

1 
ICRF 
The following example displays the orientation's records stored in the ephemeris file.
from calcephpy import *
peph = CalcephBin.open("example1.dat")
n = peph.getorientrecordcount()
for j in range(1, n+1):
itarget, firsttime, lasttime, iframe = peph.getorientrecordindex(j)
print(itarget, firsttime, lasttime, iframe)
peph.close()
calcephpy.CalcephBin.getorientrecordindex2¶

calcephpy.CalcephBin.
getorientrecordindex2
(index) → target, firsttime, lasttime, frame, segid¶  Parameters
index (int)  index of the orientation's record, between 1 and
calcephpy.CalcephBin.getorientrecordcount()
 Returns
 target : the target bodyfirsttime : julian date of the first timelasttime : julian date of the last timeframe : reference frame (see the list, below)segid : segment type (see the details, below)
 Return type
int, float, float, int, int
This function returns the target body, the first and last time, the reference frame and the segment type available at the specified index for the orientation's records of the ephemeris file self.
The NAIF identification numbering system is used for the target body (NAIF identification numbers for the list).
The Julian date for the first and last time are expressed in the time scale returned by calcephpy.CalcephBin.gettimescale()
.
It returns the following value in the parameter frame :
value 
Name 

1 
ICRF 
It returns in the parameter segid one of the predefined constants Constants.SEGTYPE_... (Constants).
The following example displays the orientation's records stored in the ephemeris file.
from calcephpy import *
peph = CalcephBin.open("example1.dat")
n = peph.getorientrecordcount()
for j in range(1, n+1):
itarget, firsttime, lasttime, iframe, iseg = peph.getorientrecordindex2(j)
print(itarget, firsttime, lasttime, iframe, iseg)
peph.close()