SuperNOVAS v1.2
The NOVAS C library, made better
Loading...
Searching...
No Matches
eph_manager.c File Reference

Functions

short ephem_close (void)
 
short ephem_open (const char *ephem_name, double *jd_begin, double *jd_end, short *de_number)
 
int interpolate (const double *buf, const double *t, long ncf, long na, double *position, double *velocity)
 
short planet_ephemeris (const double tjd[2], enum de_planet target, enum de_planet origin, double *position, double *velocity)
 
int split (double tt, double *fr)
 
short state (const double *jed, enum de_planet target, double *target_pos, double *target_vel)
 

Variables

double * BUFFER
 (for internal use) Array containing Chebyshev coefficients of position.
 
double EM_RATIO
 (for internal use)
 
FILE * EPHFILE = NULL
 (for internal use) The currently open JPL DE planetary ephemeris file
 
int IPT [3][12]
 (for internal use)
 
double JPLAU
 (for internal use)
 
short KM
 Flag that defines physical units of the output states.
 
int LPT [3]
 (for internal use)
 
long NP
 (for internal use)
 
long NRL
 (for internal use) Current record number buffered
 
long NV
 (for internal use)
 
double PC [18]
 (for internal use)
 
long RECORD_LENGTH
 (for internal use)
 
double SS [3]
 (for internal use)
 
double TWOT
 (for internal use)
 
double VC [18]
 (for internal use)
 

Detailed Description

Author
G. Kaplan and A. Kovacs

SuperNOVAS planetary ephemeris manager for the planet_eph_manager and planet_eph_manager_hp() functions.

This module exposes a lot of its own internal state variables globally. You probably should not access them from outside this module, but they are kept ad globals to ensure compatibility with existing NOVAS C applications that might access those values.

Based on the NOVAS C Edition, Version 3.1:

U. S. Naval Observatory
Astronomical Applications Dept.
Washington, DC
http://www.usno.navy.mil/USNO/astronomical-applications

See also
solsys2.c

Function Documentation

◆ ephem_close()

short ephem_close ( void  )

Closes a JPL planetary ephemeris file and frees the memory.

REFERENCES:

  1. Standish, E.M. and Newhall, X X (1988). "The JPL Export Planetary Ephemeris"; JPL document dated 17 June 1988.

NOTES:

  1. Includes fix for the known resource leak issue in NOVAS C 3.1.
Returns
0 if the file successfully closed or was closed already, or else EOF.
See also
ephem_open()

References BUFFER, and EPHFILE.

◆ ephem_open()

short ephem_open ( const char *  ephem_name,
double *  jd_begin,
double *  jd_end,
short *  de_number 
)

This function opens a JPL planetary ephemeris file and sets initial values. This function must be called prior to calls to the other JPL ephemeris functions.

REFERENCES:

  1. Standish, E.M. and Newhall, X X (1988). "The JPL Export Planetary Ephemeris"; JPL document dated 17 June 1988.
Parameters
ephem_nameName/path of the direct-access ephemeris file.
[out]jd_begin[day] Beginning Julian date of the ephemeris file. It may be NULL if not required.
[out]jd_end[day] Ending Julian date of the ephemeris file. It may be NULL if not required.
[out]de_numberDE number of the ephemeris file opened. It may be NULL if not required.
Returns
0 if successful, or -1 if any of the arhuments is NULL, or else 1 if the file could no be opened, 2–10 if (= line + 1) if there was an error reading the header line, or 11 if the type of DE file is not supported.
See also
ephem_close()

References BUFFER, EM_RATIO, EPHFILE, IPT, JPLAU, KM, LPT, NP, NRL, NV, PC, RECORD_LENGTH, SS, TWOT, and VC.

◆ interpolate()

int interpolate ( const double *  buf,
const double *  t,
long  ncf,
long  na,
double *  position,
double *  velocity 
)

Differentiates and interpolates a set of Chebyshev coefficients to give position and velocity.

REFERENCES:

  1. Standish, E.M. and Newhall, X X (1988). "The JPL Export Planetary Ephemeris"; JPL document dated 17 June 1988.
Parameters
bufArray of Chebyshev coefficients of position.
tt[0] is fractional time interval covered by coefficients at which interpolation is desired (0 <= t[0] <= 1). t[1] is length of whole interval in input time units.
ncfNumber of coefficients per component.
naNumber of sets of coefficients in full array (i.e., number of sub-intervals in full interval).
[out]positionPosition array of requested object.
[out]velocityVelocity array of requested object.
Returns
0 if successful, or -1 if one of the input arrays or output pointer arguments is NULL.

References NP, NV, PC, TWOT, and VC.

◆ planet_ephemeris()

short planet_ephemeris ( const double  tjd[2],
enum de_planet  target,
enum de_planet  origin,
double *  position,
double *  velocity 
)

Retries planet position and velocity data from the JPL planetary ephemeris

(If nutations are desired, set 'target' = 13; 'center' will be ignored on that call.)

REFERENCES:

  1. Standish, E.M. and Newhall, X X (1988). "The JPL Export Planetary Ephemeris"; JPL document dated 17 June 1988.
Parameters
tjd[day] Two-element array containing the Julian date, which may be split any way (although the first element is usually the "integer" part, and the second element is the "fractional" part). Julian date is in the TDB or "T_eph" time scale.
targetThe integer code (see above) for the planet for which coordinates are requested, e.g. DE_JUPITER.
originThe integer code of the planet or position relative to which coordinates are measured.
[out]position[AU] Position vector array of target relative to center, measured in AU.
[out]velocity[AU/day] Velocity vector array of target relative to center, measured in AU/day.
Returns
0 if successful, or -1 if one of the pointer arguments is NULL, or else the error returned from state().
See also
ephem_open()

References EM_RATIO, and state().

◆ split()

int split ( double  tt,
double *  fr 
)

reaks up a double number into a double integer part and a fractional part.

Parameters
ttInput number.
[out]fr2-element output array; fr[0] contains integer part, fr[1] contains fractional part. For negative input numbers, fr[0] contains the next more negative integer; fr[1] contains a positive fraction.
Returns
0 if successful, or -1 if the output pointer argument is NULL.

◆ state()

short state ( const double *  jed,
enum de_planet  target,
double *  target_pos,
double *  target_vel 
)

Reads and interpolates the JPL planetary ephemeris file.

For ease in programming, the user may put the entire epoch in jed[0] and set jed[1] = 0. For maximum interpolation accuracy, set jed[0] = the most recent midnight at or before interpolation epoch, and set jed[1] = fractional part of a day elapsed between jed[0] and epoch. As an alternative, it may prove convenient to set jed[0] = some fixed epoch, such as start of the integration and jed[1] = elapsed interval between then and epoch.

REFERENCES:

  1. Standish, E.M. and Newhall, X X (1988). "The JPL Export Planetary Ephemeris"; JPL document dated 17 June 1988.
Parameters
jed[day] 2-element Julian date (TDB) at which interpolation is wanted. Any combination of jed[0]+jed[1] which falls within the time span on the file is a permissible epoch. See Note 1 below. target (short)
targetThe integer code (see above) for the planet for which coordinates are requested, e.g. DE_JUPITER.
[out]target_pos[AU] The barycentric position vector array of the requested object, in AU.
[out]target_vel[AU/day] The barycentric velocity vector array of the requested object, in AU/Day.
Returns
0 if successful, -1 if any of the pointer arguments is NULL, or else 1 if there was an error reading the ephemeris file, or 2 if the epoch is out of range.

References BUFFER, ephem_close(), EPHFILE, interpolate(), IPT, JPLAU, KM, NRL, RECORD_LENGTH, split(), and SS.

Variable Documentation

◆ KM

short KM

Flag that defines physical units of the output states.

Flag that defines physical units of the output states. 1: km and km/sec; 0: AU and AU/day. Its default value is 0 (KM determines time unit for nutations. Angle unit is always radians.)