Search in sources :

Example 41 with DateComponents

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

the class ITRFProviderWithoutTidalEffectsTest method testMSLIBTransformJ2000_TerVrai.

@Test
public void testMSLIBTransformJ2000_TerVrai() throws OrekitException {
    AbsoluteDate date = new AbsoluteDate(new DateComponents(2003, 10, 14), new TimeComponents(02, 00, 00), TimeScalesFactory.getUTC());
    Transform trans = FramesFactory.getEME2000().getTransformTo(FramesFactory.getTIRF(IERSConventions.IERS_2010), date);
    // Positions
    Vector3D posTIRF = trans.transformPosition(new Vector3D(6500000.0, -1234567.0, 4000000.0));
    Assert.assertEquals(0, 3011109.361 - posTIRF.getX(), 0.38);
    Assert.assertEquals(0, -5889822.669 - posTIRF.getY(), 0.38);
    Assert.assertEquals(0, 4002170.039 - posTIRF.getZ(), 0.27);
}
Also used : Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) DateComponents(org.orekit.time.DateComponents) TimeComponents(org.orekit.time.TimeComponents) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 42 with DateComponents

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

the class ITRFProviderWithoutTidalEffectsTest method testMontenbruck.

@Test
public void testMontenbruck() throws OrekitException {
    AbsoluteDate t0 = new AbsoluteDate(new DateComponents(1999, 3, 4), TimeComponents.H00, TimeScalesFactory.getGPS());
    Transform trans = FramesFactory.getITRF(IERSConventions.IERS_2010, true).getTransformTo(FramesFactory.getGCRF(), t0);
    PVCoordinates pvWGS = new PVCoordinates(new Vector3D(19440953.805, 16881609.273, -6777115.092), new Vector3D(-811.1827456, -257.3799137, -3068.9508125));
    checkPV(new PVCoordinates(new Vector3D(-23830592.685, -9747073.881, -6779831.010), new Vector3D(1561.9646362, -1754.3454485, -3068.8504996)), trans.transformPVCoordinates(pvWGS), 0.146, 3.43e-5);
}
Also used : Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) PVCoordinates(org.orekit.utils.PVCoordinates) DateComponents(org.orekit.time.DateComponents) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 43 with DateComponents

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

the class FieldSpacecraftStateTest method doTestShiftVsEcksteinHechlerError.

private <T extends RealFieldElement<T>> void doTestShiftVsEcksteinHechlerError(final Field<T> field) throws OrekitException {
    T zero = field.getZero();
    T mass = zero.add(2500.);
    T a = zero.add(rOrbit.getA());
    T e = zero.add(rOrbit.getE());
    T i = zero.add(rOrbit.getI());
    T pa = zero.add(1.9674147913622104);
    T raan = zero.add(FastMath.toRadians(261));
    T lv = zero.add(0);
    final double ae = 6.378137e6;
    final double c20 = -1.08263e-3;
    final double c30 = 2.54e-6;
    final double c40 = 1.62e-6;
    final double c50 = 2.3e-7;
    final double c60 = -5.5e-7;
    // polynomial models for interpolation error in position, velocity, acceleration and attitude
    // these models grow as follows
    // interpolation time (s)    position error (m)   velocity error (m/s)   acceleration error (m/s²)  attitude error (°)
    // 60                        2                    0.07                  0.002               0.00002
    // 120                       12                    0.3                   0.005               0.00009
    // 300                      170                    1.6                   0.012               0.0009
    // 600                     1200                    5.7                   0.024               0.006
    // 900                     3600                   10.6                   0.034               0.02
    // the expected maximum residuals with respect to these models are about 0.4m, 0.5mm/s, 8μm/s² and 3e-6°
    PolynomialFunction pModel = new PolynomialFunction(new double[] { 1.5664070631933846e-01, 7.5504722733047560e-03, -8.2460562451009510e-05, 6.9546332080305580e-06, -1.7045365367533077e-09, -4.2187860791066264e-13 });
    PolynomialFunction vModel = new PolynomialFunction(new double[] { -3.5472364019908720e-04, 1.6568103861124980e-05, 1.9637913327830596e-05, -3.4248792843039766e-09, -5.6565135131014254e-12, 1.4730170946808630e-15 });
    PolynomialFunction aModel = new PolynomialFunction(new double[] { 3.0731707577766896e-06, 3.9770746399850350e-05, 1.9779039254538660e-09, 8.0263328220724900e-12, -1.5600835252366078e-14, 1.1785257001549687e-18 });
    PolynomialFunction rModel = new PolynomialFunction(new double[] { -2.7689062063188115e-06, 1.7406542538258334e-07, 2.5109795349592287e-09, 2.0399322661074575e-11, 9.9126348912426750e-15, -3.5015638905729510e-18 });
    FieldAbsoluteDate<T> date = new FieldAbsoluteDate<>(field, new DateComponents(2004, 01, 01), TimeComponents.H00, TimeScalesFactory.getUTC());
    FieldKeplerianOrbit<T> orbit = new FieldKeplerianOrbit<>(a, e, i, pa, raan, lv, PositionAngle.TRUE, FramesFactory.getEME2000(), date, mu);
    BodyCenterPointing attitudeLaw = new BodyCenterPointing(orbit.getFrame(), earth);
    FieldPropagator<T> propagator = new FieldEcksteinHechlerPropagator<>(orbit, attitudeLaw, mass, ae, mu, c20, c30, c40, c50, c60);
    FieldAbsoluteDate<T> centerDate = orbit.getDate().shiftedBy(100.0);
    FieldSpacecraftState<T> centerState = propagator.propagate(centerDate);
    double maxResidualP = 0;
    double maxResidualV = 0;
    double maxResidualA = 0;
    double maxResidualR = 0;
    for (T dt = field.getZero(); dt.getReal() < 900.0; dt = dt.add(5)) {
        FieldSpacecraftState<T> shifted = centerState.shiftedBy(dt);
        FieldSpacecraftState<T> propagated = propagator.propagate(centerDate.shiftedBy(dt));
        FieldPVCoordinates<T> dpv = new FieldPVCoordinates<>(propagated.getPVCoordinates(), shifted.getPVCoordinates());
        double residualP = pModel.value(dt.getReal()) - dpv.getPosition().getNorm().getReal();
        double residualV = vModel.value(dt.getReal()) - dpv.getVelocity().getNorm().getReal();
        double residualA = aModel.value(dt.getReal()) - dpv.getAcceleration().getNorm().getReal();
        double residualR = rModel.value(dt.getReal()) - FastMath.toDegrees(FieldRotation.distance(shifted.getAttitude().getRotation(), propagated.getAttitude().getRotation()).getReal());
        maxResidualP = FastMath.max(maxResidualP, FastMath.abs(residualP));
        maxResidualV = FastMath.max(maxResidualV, FastMath.abs(residualV));
        maxResidualA = FastMath.max(maxResidualA, FastMath.abs(residualA));
        maxResidualR = FastMath.max(maxResidualR, FastMath.abs(residualR));
    }
    Assert.assertEquals(0.40, maxResidualP, 0.01);
    Assert.assertEquals(4.9e-4, maxResidualV, 1.0e-5);
    Assert.assertEquals(2.8e-6, maxResidualR, 1.0e-1);
}
Also used : PolynomialFunction(org.hipparchus.analysis.polynomials.PolynomialFunction) DateComponents(org.orekit.time.DateComponents) FieldKeplerianOrbit(org.orekit.orbits.FieldKeplerianOrbit) BodyCenterPointing(org.orekit.attitudes.BodyCenterPointing) FieldEcksteinHechlerPropagator(org.orekit.propagation.analytical.FieldEcksteinHechlerPropagator) FieldPVCoordinates(org.orekit.utils.FieldPVCoordinates) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate)

Example 44 with DateComponents

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

the class FieldSpacecraftStateTest method doTestTransform.

private <T extends RealFieldElement<T>> void doTestTransform(final Field<T> field) throws OrekitException {
    T zero = field.getZero();
    T a = zero.add(rOrbit.getA());
    T e = zero.add(rOrbit.getE());
    T i = zero.add(rOrbit.getI());
    T pa = zero.add(1.9674147913622104);
    T raan = zero.add(FastMath.toRadians(261));
    T lv = zero.add(0);
    T mass = zero.add(2500);
    FieldAbsoluteDate<T> date = new FieldAbsoluteDate<>(field, new DateComponents(2004, 01, 01), TimeComponents.H00, TimeScalesFactory.getUTC());
    FieldKeplerianOrbit<T> orbit = new FieldKeplerianOrbit<>(a, e, i, pa, raan, lv, PositionAngle.TRUE, FramesFactory.getEME2000(), date, mu);
    BodyCenterPointing attitudeLaw = new BodyCenterPointing(orbit.getFrame(), earth);
    FieldKeplerianPropagator<T> propagator = new FieldKeplerianPropagator<>(orbit, attitudeLaw, mu, mass);
    double maxDP = 0;
    double maxDV = 0;
    double maxDA = 0;
    for (double t = 0; t < orbit.getKeplerianPeriod().getReal(); t += 60) {
        final FieldSpacecraftState<T> state = propagator.propagate(orbit.getDate().shiftedBy(zero.add(t)));
        final Transform transform = state.toSpacecraftState().toTransform().getInverse();
        PVCoordinates pv = transform.transformPVCoordinates(PVCoordinates.ZERO);
        PVCoordinates dPV = new PVCoordinates(pv, state.getPVCoordinates().toPVCoordinates());
        Vector3D mZDirection = transform.transformVector(Vector3D.MINUS_K);
        double alpha = Vector3D.angle(mZDirection, state.getPVCoordinates().toPVCoordinates().getPosition());
        maxDP = FastMath.max(maxDP, dPV.getPosition().getNorm());
        maxDV = FastMath.max(maxDV, dPV.getVelocity().getNorm());
        maxDA = FastMath.max(maxDA, FastMath.toDegrees(alpha));
    }
    Assert.assertEquals(0.0, maxDP, 1.0e-6);
    Assert.assertEquals(0.0, maxDV, 1.0e-9);
    Assert.assertEquals(0.0, maxDA, 1.0e-12);
}
Also used : FieldPVCoordinates(org.orekit.utils.FieldPVCoordinates) PVCoordinates(org.orekit.utils.PVCoordinates) DateComponents(org.orekit.time.DateComponents) FieldKeplerianOrbit(org.orekit.orbits.FieldKeplerianOrbit) FieldKeplerianPropagator(org.orekit.propagation.analytical.FieldKeplerianPropagator) BodyCenterPointing(org.orekit.attitudes.BodyCenterPointing) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) Transform(org.orekit.frames.Transform) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate)

Example 45 with DateComponents

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

the class FieldSpacecraftStateTest method doTestAdditionalStates.

private <T extends RealFieldElement<T>> void doTestAdditionalStates(final Field<T> field) throws OrekitException {
    T zero = field.getZero();
    T a = zero.add(rOrbit.getA());
    T e = zero.add(rOrbit.getE());
    T i = zero.add(rOrbit.getI());
    T pa = zero.add(1.9674147913622104);
    T raan = zero.add(FastMath.toRadians(261));
    T lv = zero.add(0);
    T mass = zero.add(2500);
    FieldAbsoluteDate<T> date = new FieldAbsoluteDate<>(field, new DateComponents(2004, 01, 01), TimeComponents.H00, TimeScalesFactory.getUTC());
    FieldKeplerianOrbit<T> orbit = new FieldKeplerianOrbit<>(a, e, i, pa, raan, lv, PositionAngle.TRUE, FramesFactory.getEME2000(), date, mu);
    BodyCenterPointing attitudeLaw = new BodyCenterPointing(orbit.getFrame(), earth);
    FieldKeplerianPropagator<T> propagator = new FieldKeplerianPropagator<>(orbit, attitudeLaw, mu, mass);
    final FieldSpacecraftState<T> state = propagator.propagate(orbit.getDate().shiftedBy(60));
    T[] add = MathArrays.buildArray(field, 2);
    add[0] = zero.add(1.);
    add[1] = zero.add(2.);
    final FieldSpacecraftState<T> extended = state.addAdditionalState("test-1", add).addAdditionalState("test-2", zero.add(42.0));
    Assert.assertEquals(0, state.getAdditionalStates().size());
    Assert.assertFalse(state.hasAdditionalState("test-1"));
    try {
        state.getAdditionalState("test-1");
        Assert.fail("an exception should have been thrown");
    } catch (OrekitException oe) {
        Assert.assertEquals(oe.getSpecifier(), OrekitMessages.UNKNOWN_ADDITIONAL_STATE);
        Assert.assertEquals(oe.getParts()[0], "test-1");
    }
    try {
        state.ensureCompatibleAdditionalStates(extended);
        Assert.fail("an exception should have been thrown");
    } catch (OrekitException oe) {
        Assert.assertEquals(oe.getSpecifier(), OrekitMessages.UNKNOWN_ADDITIONAL_STATE);
        Assert.assertTrue(oe.getParts()[0].toString().startsWith("test-"));
    }
    try {
        extended.ensureCompatibleAdditionalStates(state);
        Assert.fail("an exception should have been thrown");
    } catch (OrekitException oe) {
        Assert.assertEquals(oe.getSpecifier(), OrekitMessages.UNKNOWN_ADDITIONAL_STATE);
        Assert.assertTrue(oe.getParts()[0].toString().startsWith("test-"));
    }
    try {
        T[] kk = MathArrays.buildArray(field, 7);
        extended.ensureCompatibleAdditionalStates(extended.addAdditionalState("test-2", kk));
        Assert.fail("an exception should have been thrown");
    } catch (MathIllegalStateException mise) {
        Assert.assertEquals(LocalizedCoreFormats.DIMENSIONS_MISMATCH, mise.getSpecifier());
        Assert.assertEquals(7, ((Integer) mise.getParts()[0]).intValue());
    }
    Assert.assertEquals(2, extended.getAdditionalStates().size());
    Assert.assertTrue(extended.hasAdditionalState("test-1"));
    Assert.assertTrue(extended.hasAdditionalState("test-2"));
    Assert.assertEquals(1.0, extended.getAdditionalState("test-1")[0].getReal(), 1.0e-15);
    Assert.assertEquals(2.0, extended.getAdditionalState("test-1")[1].getReal(), 1.0e-15);
    Assert.assertEquals(42.0, extended.getAdditionalState("test-2")[0].getReal(), 1.0e-15);
    // test various constructors
    T[] dd = MathArrays.buildArray(field, 1);
    dd[0] = zero.add(-6.0);
    Map<String, T[]> map = new HashMap<String, T[]>();
    map.put("test-3", dd);
    FieldSpacecraftState<T> sO = new FieldSpacecraftState<>(state.getOrbit(), map);
    Assert.assertEquals(-6.0, sO.getAdditionalState("test-3")[0].getReal(), 1.0e-15);
    FieldSpacecraftState<T> sOA = new FieldSpacecraftState<>(state.getOrbit(), state.getAttitude(), map);
    Assert.assertEquals(-6.0, sOA.getAdditionalState("test-3")[0].getReal(), 1.0e-15);
    FieldSpacecraftState<T> sOM = new FieldSpacecraftState<>(state.getOrbit(), state.getMass(), map);
    Assert.assertEquals(-6.0, sOM.getAdditionalState("test-3")[0].getReal(), 1.0e-15);
    FieldSpacecraftState<T> sOAM = new FieldSpacecraftState<>(state.getOrbit(), state.getAttitude(), state.getMass(), map);
    Assert.assertEquals(-6.0, sOAM.getAdditionalState("test-3")[0].getReal(), 1.0e-15);
    FieldSpacecraftState<T> sFromDouble = new FieldSpacecraftState<>(field, sOAM.toSpacecraftState());
    Assert.assertEquals(-6.0, sFromDouble.getAdditionalState("test-3")[0].getReal(), 1.0e-15);
}
Also used : HashMap(java.util.HashMap) DateComponents(org.orekit.time.DateComponents) MathIllegalStateException(org.hipparchus.exception.MathIllegalStateException) FieldKeplerianOrbit(org.orekit.orbits.FieldKeplerianOrbit) FieldKeplerianPropagator(org.orekit.propagation.analytical.FieldKeplerianPropagator) BodyCenterPointing(org.orekit.attitudes.BodyCenterPointing) OrekitException(org.orekit.errors.OrekitException) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate)

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