Search in sources :

Example 16 with DateComponents

use of org.orekit.time.DateComponents in project Orekit by CS-SI.

the class IERSConventionsTest method testTidalCorrection2010.

@Test
public void testTidalCorrection2010() throws OrekitException {
    // the reference value has been computed using the September 2007 version
    // of interp.f from ftp://hpiers.obspm.fr/iers/models/ adding input/output
    // parameters for LOD (which was already computed in the underlying routines),
    // with the following driver program:
    // 
    // PROGRAM OR_TEST
    // IMPLICIT NONE
    // INTEGER J, N
    // PARAMETER (N = 4)
    // INTEGER MJD(N)
    // DOUBLE PRECISION TTTAI, TAIUTC
    // PARAMETER (TAIUTC = 32.000D0)
    // PARAMETER (TTTAI  = 32.184D0)
    // DOUBLE PRECISION RJD(N), UT1(N), LOD(N), X(N), Y(N), H(5)
    // DOUBLE PRECISION RJD_INT, UT1_INT, LOD_INT, X_INT, Y_INT
    // DATA(MJD(J),   UT1(J),     LOD(J),      X(J),      Y(J),
    // &     J=1,4)/
    // &    52653, -0.2979055D0, 0.0005744D0, -0.120344D0, 0.217095D0,
    // &    52654, -0.2984238D0, 0.0004224D0, -0.121680D0, 0.219400D0,
    // &    52655, -0.2987682D0, 0.0002878D0, -0.122915D0, 0.221760D0,
    // &    52656, -0.2989957D0, 0.0001778D0, -0.124248D0, 0.224294D0/
    // C
    // DATA(H(J),J=1,5)/0.0D0, 3600.0D0, 7200.0D0, 43200.0D0, 86400.0D0/
    // C
    // DO 10 J = 1, N
    // RJD(J) = MJD(J) + (TTTAI + TAIUTC) / 86400.0D0
    // 10   CONTINUE
    // C
    // DO 20 J = 1, 5
    // RJD_INT = RJD(2) + H(J) / 86400.0D0
    // CALL INTERP(RJD,X,Y,UT1,LOD,N,
    // &                RJD_INT,X_INT,Y_INT,UT1_INT,LOD_INT)
    // WRITE(6, 30) H(J),UT1_INT,LOD_INT,X_INT,Y_INT
    // 20   CONTINUE
    // 30   FORMAT(F7.1,4(1X, F20.17))
    // C
    // END PROGRAM
    // 
    // the output of this test reads:
    // 0.0 -0.29840026968370659  0.00045312852893139 -0.12196223480123573  0.21922730818562719
    // 3600.0 -0.29841834564816189  0.00041710864863793 -0.12213345007640604  0.21927433626001305
    // 7200.0 -0.29843503870494986  0.00039207574457087 -0.12222881007999241  0.21932415788122142
    // 43200.0 -0.29866930257052676  0.00042895046506082 -0.12247697694276605  0.22105450666130921
    // 86400.0 -0.29874235341010519  0.00035460263868306 -0.12312252389660779  0.22161364352515728
    Utils.setLoaders(IERSConventions.IERS_2010, Utils.buildEOPList(IERSConventions.IERS_2010, ITRFVersion.ITRF_2008, new double[][] { { 52653, -0.2979055, 0.0005744, -0.120344, 0.217095, 0.0, 0.0, 0.0, 0.0 }, { 52654, -0.2984238, 0.0004224, -0.121680, 0.219400, 0.0, 0.0, 0.0, 0.0 }, { 52655, -0.2987682, 0.0002878, -0.122915, 0.221760, 0.0, 0.0, 0.0, 0.0 }, { 52656, -0.2989957, 0.0001778, -0.124248, 0.224294, 0.0, 0.0, 0.0, 0.0 } }));
    EOPHistory eopHistory = FramesFactory.getEOPHistory(IERSConventions.IERS_2010, false);
    final AbsoluteDate t0 = new AbsoluteDate(new DateComponents(DateComponents.MODIFIED_JULIAN_EPOCH, 52654), TimeScalesFactory.getUTC());
    for (double[] row : new double[][] { { 0.0, -0.29840026968370659, 0.00045312852893139, -0.12196223480123573, 0.21922730818562719 }, { 3600.0, -0.29841834564816189, 0.00041710864863793, -0.12213345007640604, 0.21927433626001305 }, { 7200.0, -0.29843503870494986, 0.00039207574457087, -0.12222881007999241, 0.21932415788122142 }, { 43200.0, -0.29866930257052676, 0.00042895046506082, -0.12247697694276605, 0.22105450666130921 }, { 86400.0, -0.29874235341010519, 0.00035460263868306, -0.12312252389660779, 0.22161364352515728 } }) {
        AbsoluteDate date = t0.shiftedBy(row[0]);
        Assert.assertEquals(row[1], eopHistory.getUT1MinusUTC(date), 2.5e-12);
        Assert.assertEquals(row[2], eopHistory.getLOD(date), 4.3e-11);
        Assert.assertEquals(row[3] * Constants.ARC_SECONDS_TO_RADIANS, eopHistory.getPoleCorrection(date).getXp(), 1.6e-10);
        Assert.assertEquals(row[4] * Constants.ARC_SECONDS_TO_RADIANS, eopHistory.getPoleCorrection(date).getYp(), 0.7e-10);
    }
}
Also used : DateComponents(org.orekit.time.DateComponents) EOPHistory(org.orekit.frames.EOPHistory) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 17 with DateComponents

use of org.orekit.time.DateComponents in project Orekit by CS-SI.

the class JPLEphemeridesLoader method extractDate.

/**
 * Extract a date from a record.
 * @param record record to parse
 * @param offset offset of the double within the record
 * @return extracted date
 */
private AbsoluteDate extractDate(final byte[] record, final int offset) {
    final double t = extractDouble(record, offset);
    int jDay = (int) FastMath.floor(t);
    double seconds = (t + 0.5 - jDay) * Constants.JULIAN_DAY;
    if (seconds >= Constants.JULIAN_DAY) {
        ++jDay;
        seconds -= Constants.JULIAN_DAY;
    }
    return new AbsoluteDate(new DateComponents(DateComponents.JULIAN_EPOCH, jDay), new TimeComponents(seconds), timeScale);
}
Also used : DateComponents(org.orekit.time.DateComponents) TimeComponents(org.orekit.time.TimeComponents) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate)

Example 18 with DateComponents

use of org.orekit.time.DateComponents in project Orekit by CS-SI.

the class ThirdBodyAttractionTest method testGlobalStateJacobian.

@Test
public void testGlobalStateJacobian() throws OrekitException {
    // initialization
    AbsoluteDate date = new AbsoluteDate(new DateComponents(2003, 03, 01), new TimeComponents(13, 59, 27.816), TimeScalesFactory.getUTC());
    double i = FastMath.toRadians(98.7);
    double omega = FastMath.toRadians(93.0);
    double OMEGA = FastMath.toRadians(15.0 * 22.5);
    Orbit orbit = new KeplerianOrbit(7201009.7124401, 1e-3, i, omega, OMEGA, 0, PositionAngle.MEAN, FramesFactory.getEME2000(), date, Constants.EIGEN5C_EARTH_MU);
    OrbitType integrationType = OrbitType.CARTESIAN;
    double[][] tolerances = NumericalPropagator.tolerances(0.01, orbit, integrationType);
    NumericalPropagator propagator = new NumericalPropagator(new DormandPrince853Integrator(1.0e-3, 120, tolerances[0], tolerances[1]));
    propagator.setOrbitType(integrationType);
    final CelestialBody moon = CelestialBodyFactory.getMoon();
    final ThirdBodyAttraction forceModel = new ThirdBodyAttraction(moon);
    propagator.addForceModel(forceModel);
    SpacecraftState state0 = new SpacecraftState(orbit);
    checkStateJacobian(propagator, state0, date.shiftedBy(3.5 * 3600.0), 1e4, tolerances[0], 2.0e-9);
}
Also used : EquinoctialOrbit(org.orekit.orbits.EquinoctialOrbit) CartesianOrbit(org.orekit.orbits.CartesianOrbit) FieldKeplerianOrbit(org.orekit.orbits.FieldKeplerianOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) Orbit(org.orekit.orbits.Orbit) DateComponents(org.orekit.time.DateComponents) TimeComponents(org.orekit.time.TimeComponents) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) SpacecraftState(org.orekit.propagation.SpacecraftState) FieldSpacecraftState(org.orekit.propagation.FieldSpacecraftState) NumericalPropagator(org.orekit.propagation.numerical.NumericalPropagator) FieldNumericalPropagator(org.orekit.propagation.numerical.FieldNumericalPropagator) CelestialBody(org.orekit.bodies.CelestialBody) FieldKeplerianOrbit(org.orekit.orbits.FieldKeplerianOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) OrbitType(org.orekit.orbits.OrbitType) DormandPrince853Integrator(org.hipparchus.ode.nonstiff.DormandPrince853Integrator) AbstractLegacyForceModelTest(org.orekit.forces.AbstractLegacyForceModelTest) Test(org.junit.Test)

Example 19 with DateComponents

use of org.orekit.time.DateComponents in project Orekit by CS-SI.

the class ThirdBodyAttractionTest method testSunContrib.

@Test(expected = OrekitException.class)
public void testSunContrib() throws OrekitException {
    // initialization
    AbsoluteDate date = new AbsoluteDate(new DateComponents(1970, 07, 01), new TimeComponents(13, 59, 27.816), TimeScalesFactory.getUTC());
    Orbit orbit = new EquinoctialOrbit(42164000, 10e-3, 10e-3, FastMath.tan(0.001745329) * FastMath.cos(2 * FastMath.PI / 3), FastMath.tan(0.001745329) * FastMath.sin(2 * FastMath.PI / 3), 0.1, PositionAngle.TRUE, FramesFactory.getEME2000(), date, mu);
    double period = 2 * FastMath.PI * orbit.getA() * FastMath.sqrt(orbit.getA() / orbit.getMu());
    // set up propagator
    NumericalPropagator calc = new NumericalPropagator(new GraggBulirschStoerIntegrator(10.0, period, 0, 1.0e-5));
    calc.addForceModel(new ThirdBodyAttraction(CelestialBodyFactory.getSun()));
    // set up step handler to perform checks
    calc.setMasterMode(FastMath.floor(period), new ReferenceChecker(date) {

        protected double hXRef(double t) {
            return -1.06757e-3 + 0.221415e-11 * t + 18.9421e-5 * FastMath.cos(3.9820426e-7 * t) - 7.59983e-5 * FastMath.sin(3.9820426e-7 * t);
        }

        protected double hYRef(double t) {
            return 1.43526e-3 + 7.49765e-11 * t + 6.9448e-5 * FastMath.cos(3.9820426e-7 * t) + 17.6083e-5 * FastMath.sin(3.9820426e-7 * t);
        }
    });
    AbsoluteDate finalDate = date.shiftedBy(365 * period);
    calc.setInitialState(new SpacecraftState(orbit));
    calc.propagate(finalDate);
}
Also used : SpacecraftState(org.orekit.propagation.SpacecraftState) FieldSpacecraftState(org.orekit.propagation.FieldSpacecraftState) GraggBulirschStoerIntegrator(org.hipparchus.ode.nonstiff.GraggBulirschStoerIntegrator) EquinoctialOrbit(org.orekit.orbits.EquinoctialOrbit) CartesianOrbit(org.orekit.orbits.CartesianOrbit) FieldKeplerianOrbit(org.orekit.orbits.FieldKeplerianOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) Orbit(org.orekit.orbits.Orbit) NumericalPropagator(org.orekit.propagation.numerical.NumericalPropagator) FieldNumericalPropagator(org.orekit.propagation.numerical.FieldNumericalPropagator) EquinoctialOrbit(org.orekit.orbits.EquinoctialOrbit) DateComponents(org.orekit.time.DateComponents) TimeComponents(org.orekit.time.TimeComponents) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) AbstractLegacyForceModelTest(org.orekit.forces.AbstractLegacyForceModelTest) Test(org.junit.Test)

Example 20 with DateComponents

use of org.orekit.time.DateComponents in project Orekit by CS-SI.

the class ConstantThrustManeuverTest method testForwardAndBackward.

@Test
public void testForwardAndBackward() throws OrekitException {
    final double isp = 318;
    final double mass = 2500;
    final double a = 24396159;
    final double e = 0.72831215;
    final double i = FastMath.toRadians(7);
    final double omega = FastMath.toRadians(180);
    final double OMEGA = FastMath.toRadians(261);
    final double lv = 0;
    final double duration = 3653.99;
    final double f = 420;
    final double delta = FastMath.toRadians(-7.4978);
    final double alpha = FastMath.toRadians(351);
    final AttitudeProvider law = new InertialProvider(new Rotation(new Vector3D(alpha, delta), Vector3D.PLUS_I));
    final AbsoluteDate initDate = new AbsoluteDate(new DateComponents(2004, 01, 01), new TimeComponents(23, 30, 00.000), TimeScalesFactory.getUTC());
    final Orbit orbit = new KeplerianOrbit(a, e, i, omega, OMEGA, lv, PositionAngle.TRUE, FramesFactory.getEME2000(), initDate, mu);
    final SpacecraftState initialState = new SpacecraftState(orbit, law.getAttitude(orbit, orbit.getDate(), orbit.getFrame()), mass);
    final AbsoluteDate fireDate = new AbsoluteDate(new DateComponents(2004, 01, 02), new TimeComponents(04, 15, 34.080), TimeScalesFactory.getUTC());
    final ConstantThrustManeuver maneuver = new ConstantThrustManeuver(fireDate, duration, f, isp, Vector3D.PLUS_I);
    Assert.assertEquals(f, maneuver.getThrust(), 1.0e-10);
    Assert.assertEquals(isp, maneuver.getISP(), 1.0e-10);
    double[][] tol = NumericalPropagator.tolerances(1.0, orbit, OrbitType.KEPLERIAN);
    AdaptiveStepsizeIntegrator integrator1 = new DormandPrince853Integrator(0.001, 1000, tol[0], tol[1]);
    integrator1.setInitialStepSize(60);
    final NumericalPropagator propagator1 = new NumericalPropagator(integrator1);
    propagator1.setInitialState(initialState);
    propagator1.setAttitudeProvider(law);
    propagator1.addForceModel(maneuver);
    final SpacecraftState finalState = propagator1.propagate(fireDate.shiftedBy(3800));
    AdaptiveStepsizeIntegrator integrator2 = new DormandPrince853Integrator(0.001, 1000, tol[0], tol[1]);
    integrator2.setInitialStepSize(60);
    final NumericalPropagator propagator2 = new NumericalPropagator(integrator2);
    propagator2.setInitialState(finalState);
    propagator2.setAttitudeProvider(law);
    propagator2.addForceModel(maneuver);
    final SpacecraftState recoveredState = propagator2.propagate(orbit.getDate());
    final Vector3D refPosition = initialState.getPVCoordinates().getPosition();
    final Vector3D recoveredPosition = recoveredState.getPVCoordinates().getPosition();
    Assert.assertEquals(0.0, Vector3D.distance(refPosition, recoveredPosition), 30.0);
    Assert.assertEquals(initialState.getMass(), recoveredState.getMass(), 1.5e-10);
}
Also used : CartesianOrbit(org.orekit.orbits.CartesianOrbit) FieldKeplerianOrbit(org.orekit.orbits.FieldKeplerianOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) Orbit(org.orekit.orbits.Orbit) CircularOrbit(org.orekit.orbits.CircularOrbit) AdaptiveStepsizeIntegrator(org.hipparchus.ode.nonstiff.AdaptiveStepsizeIntegrator) DateComponents(org.orekit.time.DateComponents) TimeComponents(org.orekit.time.TimeComponents) Rotation(org.hipparchus.geometry.euclidean.threed.Rotation) FieldRotation(org.hipparchus.geometry.euclidean.threed.FieldRotation) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) SpacecraftState(org.orekit.propagation.SpacecraftState) FieldSpacecraftState(org.orekit.propagation.FieldSpacecraftState) InertialProvider(org.orekit.attitudes.InertialProvider) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) NumericalPropagator(org.orekit.propagation.numerical.NumericalPropagator) FieldNumericalPropagator(org.orekit.propagation.numerical.FieldNumericalPropagator) FieldKeplerianOrbit(org.orekit.orbits.FieldKeplerianOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) DormandPrince853Integrator(org.hipparchus.ode.nonstiff.DormandPrince853Integrator) AttitudeProvider(org.orekit.attitudes.AttitudeProvider) AbstractLegacyForceModelTest(org.orekit.forces.AbstractLegacyForceModelTest) Test(org.junit.Test)

Aggregations

DateComponents (org.orekit.time.DateComponents)148 AbsoluteDate (org.orekit.time.AbsoluteDate)129 Test (org.junit.Test)98 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)87 TimeComponents (org.orekit.time.TimeComponents)87 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)64 KeplerianOrbit (org.orekit.orbits.KeplerianOrbit)62 Orbit (org.orekit.orbits.Orbit)47 FieldKeplerianOrbit (org.orekit.orbits.FieldKeplerianOrbit)46 SpacecraftState (org.orekit.propagation.SpacecraftState)45 PVCoordinates (org.orekit.utils.PVCoordinates)40 CartesianOrbit (org.orekit.orbits.CartesianOrbit)37 OrekitException (org.orekit.errors.OrekitException)34 FieldSpacecraftState (org.orekit.propagation.FieldSpacecraftState)33 OneAxisEllipsoid (org.orekit.bodies.OneAxisEllipsoid)28 AbstractLegacyForceModelTest (org.orekit.forces.AbstractLegacyForceModelTest)28 CircularOrbit (org.orekit.orbits.CircularOrbit)25 EquinoctialOrbit (org.orekit.orbits.EquinoctialOrbit)25 FieldVector3D (org.hipparchus.geometry.euclidean.threed.FieldVector3D)23 Rotation (org.hipparchus.geometry.euclidean.threed.Rotation)22