/** Header for mopsephem library

$Id: mopsephem.h 523 2005-08-01 23:17:20Z grav $
*/

#ifndef __MOPSEPHEM__
#define __MOPSEPHEM__

enum {
    EBADINPUT = 100,        ///< bad orbital input params (general)
    EBADQ,                  ///< bad input Q
    EBADE,                  ///< bad input e
    EBADI,                  ///< bad input i
    ESUNGRAZER,             ///< |time_peri_mjd - epoch_mjd| < 5 && q < .05AU
    EJPLEPHEM = 200,        ///< 200+ == failure in JPL ephem lib
};


///< Struct to hold input orbital parameters.
typedef struct {
    double q_au;            ///< perihelion distance
    double e;               ///< eccentricity
    double i_deg;           ///< inclination
    double node_deg;        ///< node of ascending longitude
    double arg_peri_deg;    ///< argument of perihelion
    double time_peri_mjd;   ///< time of perihelion
    double h_v;             ///< absolute magnitude
    double t_epoch_mjd;     ///< epoch of orbital elements
} ORBIT_BLK;


///< Struct to hold XYZ positions
typedef struct {
    double ex;  ///< Earth XYZ
    double ey;
    double ez;
    double ox;  ///< Object XYZ
    double oy;
    double oz;
} XYZ_BLK;


///< Struct to hold output ephemeris parameters.
//            ssd_run_simple(&t_epoch, elems, obscod, &t_eph_ut, src_matrix, &h_v, &ra, &dec, &mag, &errcod);
typedef struct {
    double ra_deg;          ///< predited RA
    double dec_deg;         ///< predited declination
    double mag;             ///< predited magnitude
    double src_matrix;      ///< error matrix
} EPHEM_BLK;

///< Initialize JPL integrator.
int mopsephem_init(void);

///< Compute an ephemeris.
int mopsephem_compute_ephemeris(
        ORBIT_BLK *orbit,   ///< input orbit block
        EPHEM_BLK *ephem,   ///< output ephem block
        double epoch_mjd,   ///< epoch of prediction
        char *station       ///< Earth station ID (Mauna Kea = "568"
);

///< Compute an XYZ (Earth + object) ephemeris.
int mopsephem_compute_xyz(
        ORBIT_BLK *orbit,   ///< input orbit block
        XYZ_BLK *xyz,       ///< output XYZ coords block
        double epoch_mjd,   ///< epoch of prediction
        char *station       ///< Earth station ID (Mauna Kea = "568"
);

#endif
