JEphem site
tig API
Build classes

jephem.astro
Class AstroContext

java.lang.Object
  |
  +--jephem.astro.AstroContext
All Implemented Interfaces:
SolarSystemConstants, SpaceConstants, TimeConstants, UnitsConstants

public class AstroContext
extends java.lang.Object
implements SolarSystemConstants, SpaceConstants, TimeConstants, UnitsConstants

Conductor of ephemeris calculation.
Each time a calculation needs to be done, a AstroContext object must be created ; this AstroContext is then in charge of the coherence of calculations.

An AstroContext is characterized by :

  • its julian day
  • its bodies, an array of instances of class Body.


  • The main method is calcBodyCoords() whose role is :
  • For each body, call the appropriate low-level computation classes depending on the required precision.
  • Perform the necessary coordinate transformations to express the coordinates in the right frame.
  • Perform the conversions to get the right units for positions and velocities.

  • Field Summary
    static java.lang.String JEPHEM
              Constant used to designate JEphem as the astro engine.
    static java.lang.String SWISS_EPHEMERIS
              Constant used to designate Swiss Ephemeris as the astro engine.
     
    Fields inherited from interface jephem.astro.solarsystem.SolarSystemConstants
    E0_1900, E0_1950, E0_2000, EARTH, JUPITER, KM_PER_AU, MARS, MERCURY, MOON, NB_BODIES, NEPTUNE, PLUTO, SATURN, SIDERAL_RATE, SUN, URANUS, VENUS
     
    Fields inherited from interface jephem.astro.spacetime.SpaceConstants
    CARTESIAN, COORD_V0, COORD_V1, COORD_V2, COORD_X0, COORD_X1, COORD_X2, COORDGROUP_DELTA_BETA_LAMBDA, COORDGROUP_DIST_ALPHA_DELTA, COORDGROUP_RLB, COORDGROUP_XYZ, FRAME_EC_HELIO_GEOMETRIC, FRAME_ECLIPTIC, FRAME_EQUATORIAL, FRAME_GALACTIC, FRAME_HORIZONTAL_TOPOCENTRIC, FRAME_THEORY, LIGHT_VELOCITY, NB_COORDS, SPHERICAL
     
    Fields inherited from interface jephem.astro.spacetime.TimeConstants
    DAYS_PER_CENTURY, DAYS_PER_MILLENIUM, DAYS_PER_YEAR, JD1900, JD2000, JD2100, SECONDS_PER_DAY, TT_TDB, UTC
     
    Fields inherited from interface jephem.astro.spacetime.UnitsConstants
    ANGULAR_SPEED_UNIT_ARCSEC_PER_DAY, ANGULAR_SPEED_UNIT_ARCSEC_PER_S, ANGULAR_SPEED_UNIT_DEG_PER_DAY, ANGULAR_SPEED_UNIT_DEG_PER_S, ANGULAR_SPEED_UNIT_RAD_PER_DAY, ANGULAR_UNIT_ARCSEC, ANGULAR_UNIT_DEG, ANGULAR_UNIT_RAD, BASE_ANGULAR_SPEED_UNIT, BASE_ANGULAR_UNIT, BASE_DISTANCE_UNIT, BASE_LINEAR_SPEED_UNIT, DEGREES_DECIMAL, DEGREES_DMS, DELTA_BETWEEN_BASES, DISTANCE_UNIT_AU, DISTANCE_UNIT_KM, DISTANCE_UNIT_M, LINEAR_SPEED_UNIT_AU_PER_D, LINEAR_SPEED_UNIT_KM_PER_D, LINEAR_SPEED_UNIT_KM_PER_HOUR, LINEAR_SPEED_UNIT_M_PER_S, TYPE_ANGULAR, TYPE_ANGULAR_SPEED, TYPE_DISTANCE, TYPE_LINEAR_SPEED, UNITGROUP_AU_AU_AU, UNITGROUP_AU_DEG_DEG, UNITGROUP_AU_RAD_RAD, UNITGROUP_AUD_AUD_AUD, UNITGROUP_KM_KM_KM
     
    Constructor Summary
    AstroContext(double jd, int timeFrame, int[] bodyIndexes)
              The only constructor.
     
    Method Summary
     void calcBodyCoords(int frame, boolean velocities)
              Call to calcBodyCoords(int, int, double, boolean, int[]) with default values : sphereCart is set to spherical, units are set to ua, degrees, degrees for the positions and to ua/d, deg/d, deg/d for the velocities.
     void calcBodyCoords(int frame, int sphereCart, double precision, boolean velocities, int[] units)
              Main calculation method for body coordinate calculation.
     Body[] getBodies()
              Returns the bodies handled by this AstroContext.
     Body getBody(int whichBody)
              Returns the Body handled by this AstroContext whose index is 'whichBody'.
     double getJd()
              Returns the julian day of this AstroContext.
    static void setAstroEngine(java.lang.String astroEngine)
              Permits to indicate which implementation to use for the computations.
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Field Detail

    JEPHEM

    public static final java.lang.String JEPHEM
    Constant used to designate JEphem as the astro engine.

    See Also:
    Constant Field Values

    SWISS_EPHEMERIS

    public static final java.lang.String SWISS_EPHEMERIS
    Constant used to designate Swiss Ephemeris as the astro engine.

    See Also:
    Constant Field Values
    Constructor Detail

    AstroContext

    public AstroContext(double jd,
                        int timeFrame,
                        int[] bodyIndexes)
    The only constructor.
    Example of use, in a class implementing SolarSystemConstants (for constant names) :
      int[] bodyIndexes = {MERCURY, VENUS};
      AstroContext ac = new AstroContext(jd, bodyIndexes);

    Parameters:
    jd - Number of Julian Days elapsed since jan 0.5 4712 BC.
    timeFrame - The time frame used to express 'jds'. Use TimeConstants constants.
    bodyIndexes - Array containing indexes of bodies this AstroContext must handle ; use constants from SolarSystemConstants.
    Method Detail

    calcBodyCoords

    public void calcBodyCoords(int frame,
                               boolean velocities)
                        throws AstroException
    Call to calcBodyCoords(int, int, double, boolean, int[]) with default values :
  • sphereCart is set to spherical,
  • units are set to ua, degrees, degrees for the positions and to ua/d, deg/d, deg/d for the velocities.
  • AstroException

    calcBodyCoords

    public void calcBodyCoords(int frame,
                               int sphereCart,
                               double precision,
                               boolean velocities,
                               int[] units)
                        throws AstroException
    Main calculation method for body coordinate calculation.
    The calculation will be done for all the bodies of this AstroContext.

    Parameters:
    frame - Coordinate system in which the coordinates are expressed ; use SpaceConstants constants.
    sphereCart - Expression mode of the coordinates (spherical, cartesian) ; Use SpaceConstants constants.
    precision - Precision required for the calculations, expressed in arcseconds.
    velocities - Indicates if the velocities need to be also calculated.
    units - the desired units to express the coordinates. Use UnitsConstants constants.
    WARNING : this array must contain 3 or 6 elements (depending on parameter 'velocities'), and contain units of the right type (linear, angular etc...).
    Throws:
    AstroException - if an unrecoverable error occured during computation.

    getBodies

    public Body[] getBodies()
    Returns the bodies handled by this AstroContext.


    getBody

    public Body getBody(int whichBody)
    Returns the Body handled by this AstroContext whose index is 'whichBody'.

    Parameters:
    whichBody - the index charcterizing the body to retrieve, using SolarSystemConstants constants.
    Returns:
    the corresponding body if it is handled by this AstroContext, null otherwise.

    getJd

    public double getJd()
    Returns the julian day of this AstroContext.


    setAstroEngine

    public static void setAstroEngine(java.lang.String astroEngine)
    Permits to indicate which implementation to use for the computations.
    If not set, JEphem is used.

    Parameters:
    astroEngine - Use constants of this class to specify it.

    JEphem site
    tig API
    Build classes