Search in sources :

Example 46 with TimeStampedPVCoordinates

use of org.orekit.utils.TimeStampedPVCoordinates in project Orekit by CS-SI.

the class KeplerianOrbitTest method testPositionAngleHyperbolicDerivatives.

@Test
public void testPositionAngleHyperbolicDerivatives() throws OrekitException {
    final AbsoluteDate date = new AbsoluteDate("2003-05-01T00:00:20.000", TimeScalesFactory.getUTC());
    final Vector3D position = new Vector3D(224267911.905821, 290251613.109399, 45534292.777492);
    final Vector3D velocity = new Vector3D(-1494.068165293, 1124.771027677, 526.915286134);
    final Vector3D acceleration = new Vector3D(-0.001295920501, -0.002233045187, -0.000349906292);
    final TimeStampedPVCoordinates pv = new TimeStampedPVCoordinates(date, position, velocity, acceleration);
    final Frame frame = FramesFactory.getEME2000();
    final double mu = Constants.EIGEN5C_EARTH_MU;
    final KeplerianOrbit orbit = new KeplerianOrbit(pv, frame, mu);
    for (PositionAngle type : PositionAngle.values()) {
        final KeplerianOrbit rebuilt = new KeplerianOrbit(orbit.getA(), orbit.getE(), orbit.getI(), orbit.getPerigeeArgument(), orbit.getRightAscensionOfAscendingNode(), orbit.getAnomaly(type), orbit.getADot(), orbit.getEDot(), orbit.getIDot(), orbit.getPerigeeArgumentDot(), orbit.getRightAscensionOfAscendingNodeDot(), orbit.getAnomalyDot(type), type, orbit.getFrame(), orbit.getDate(), orbit.getMu());
        Assert.assertThat(rebuilt.getA(), relativelyCloseTo(orbit.getA(), 1));
        Assert.assertThat(rebuilt.getE(), relativelyCloseTo(orbit.getE(), 1));
        Assert.assertThat(rebuilt.getI(), relativelyCloseTo(orbit.getI(), 1));
        Assert.assertThat(rebuilt.getPerigeeArgument(), relativelyCloseTo(orbit.getPerigeeArgument(), 1));
        Assert.assertThat(rebuilt.getRightAscensionOfAscendingNode(), relativelyCloseTo(orbit.getRightAscensionOfAscendingNode(), 1));
        Assert.assertThat(rebuilt.getADot(), relativelyCloseTo(orbit.getADot(), 1));
        Assert.assertThat(rebuilt.getEDot(), relativelyCloseTo(orbit.getEDot(), 1));
        Assert.assertThat(rebuilt.getIDot(), relativelyCloseTo(orbit.getIDot(), 1));
        Assert.assertThat(rebuilt.getPerigeeArgumentDot(), relativelyCloseTo(orbit.getPerigeeArgumentDot(), 1));
        Assert.assertThat(rebuilt.getRightAscensionOfAscendingNodeDot(), relativelyCloseTo(orbit.getRightAscensionOfAscendingNodeDot(), 1));
        for (PositionAngle type2 : PositionAngle.values()) {
            Assert.assertThat(rebuilt.getAnomaly(type2), relativelyCloseTo(orbit.getAnomaly(type2), 2));
            Assert.assertThat(rebuilt.getAnomalyDot(type2), relativelyCloseTo(orbit.getAnomalyDot(type2), 4));
        }
    }
}
Also used : Frame(org.orekit.frames.Frame) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) TimeStampedPVCoordinates(org.orekit.utils.TimeStampedPVCoordinates) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 47 with TimeStampedPVCoordinates

use of org.orekit.utils.TimeStampedPVCoordinates in project Orekit by CS-SI.

the class KeplerianOrbitTest method testNonKeplerianEllipticDerivatives.

@Test
public void testNonKeplerianEllipticDerivatives() throws OrekitException {
    final AbsoluteDate date = new AbsoluteDate("2003-05-01T00:00:20.000", TimeScalesFactory.getUTC());
    final Vector3D position = new Vector3D(6896874.444705, 1956581.072644, -147476.245054);
    final Vector3D velocity = new Vector3D(166.816407662, -1106.783301861, -7372.745712770);
    final Vector3D acceleration = new Vector3D(-7.466182457944, -2.118153357345, 0.160004048437);
    final TimeStampedPVCoordinates pv = new TimeStampedPVCoordinates(date, position, velocity, acceleration);
    final Frame frame = FramesFactory.getEME2000();
    final double mu = Constants.EIGEN5C_EARTH_MU;
    final KeplerianOrbit orbit = new KeplerianOrbit(pv, frame, mu);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getA()), orbit.getADot(), 4.3e-8);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getEquinoctialEx()), orbit.getEquinoctialExDot(), 2.1e-15);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getEquinoctialEy()), orbit.getEquinoctialEyDot(), 5.3e-16);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getHx()), orbit.getHxDot(), 1.6e-15);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getHy()), orbit.getHyDot(), 7.3e-17);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getLv()), orbit.getLvDot(), 1.1e-14);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getLE()), orbit.getLEDot(), 7.2e-15);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getLM()), orbit.getLMDot(), 4.7e-15);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getE()), orbit.getEDot(), 6.9e-16);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getI()), orbit.getIDot(), 5.8e-16);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getPerigeeArgument()), orbit.getPerigeeArgumentDot(), 1.5e-12);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getRightAscensionOfAscendingNode()), orbit.getRightAscensionOfAscendingNodeDot(), 1.5e-15);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getTrueAnomaly()), orbit.getTrueAnomalyDot(), 1.5e-12);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getEccentricAnomaly()), orbit.getEccentricAnomalyDot(), 1.5e-12);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getMeanAnomaly()), orbit.getMeanAnomalyDot(), 1.5e-12);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getAnomaly(PositionAngle.TRUE)), orbit.getAnomalyDot(PositionAngle.TRUE), 1.5e-12);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getAnomaly(PositionAngle.ECCENTRIC)), orbit.getAnomalyDot(PositionAngle.ECCENTRIC), 1.5e-12);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getAnomaly(PositionAngle.MEAN)), orbit.getAnomalyDot(PositionAngle.MEAN), 1.5e-12);
}
Also used : TimeStampedPVCoordinates(org.orekit.utils.TimeStampedPVCoordinates) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Frame(org.orekit.frames.Frame) ObjectInputStream(java.io.ObjectInputStream) RealMatrixPreservingVisitor(org.hipparchus.linear.RealMatrixPreservingVisitor) Function(java.util.function.Function) PVCoordinates(org.orekit.utils.PVCoordinates) ArrayList(java.util.ArrayList) DSFactory(org.hipparchus.analysis.differentiation.DSFactory) ByteArrayInputStream(java.io.ByteArrayInputStream) After(org.junit.After) ObjectOutputStream(java.io.ObjectOutputStream) FastMath(org.hipparchus.util.FastMath) EcksteinHechlerPropagator(org.orekit.propagation.analytical.EcksteinHechlerPropagator) Utils(org.orekit.Utils) Before(org.junit.Before) Constants(org.orekit.utils.Constants) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) UnivariateFunction(org.hipparchus.analysis.UnivariateFunction) FramesFactory(org.orekit.frames.FramesFactory) OrekitMatchers.relativelyCloseTo(org.orekit.OrekitMatchers.relativelyCloseTo) IOException(java.io.IOException) Test(org.junit.Test) OrekitIllegalArgumentException(org.orekit.errors.OrekitIllegalArgumentException) MathUtils(org.hipparchus.util.MathUtils) OrekitMessages(org.orekit.errors.OrekitMessages) List(java.util.List) UnivariateDifferentiableFunction(org.hipparchus.analysis.differentiation.UnivariateDifferentiableFunction) FiniteDifferencesDifferentiator(org.hipparchus.analysis.differentiation.FiniteDifferencesDifferentiator) OrekitException(org.orekit.errors.OrekitException) TimeScalesFactory(org.orekit.time.TimeScalesFactory) MatrixUtils(org.hipparchus.linear.MatrixUtils) Transform(org.orekit.frames.Transform) Assert(org.junit.Assert) AbsoluteDate(org.orekit.time.AbsoluteDate) Frame(org.orekit.frames.Frame) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) TimeStampedPVCoordinates(org.orekit.utils.TimeStampedPVCoordinates) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 48 with TimeStampedPVCoordinates

use of org.orekit.utils.TimeStampedPVCoordinates in project Orekit by CS-SI.

the class EcksteinHechlerPropagatorTest method testAcceleration.

@Test
public void testAcceleration() throws OrekitException {
    final KeplerianOrbit orbit = new KeplerianOrbit(7.8e6, 0.032, 0.4, 0.1, 0.2, 0.3, PositionAngle.TRUE, FramesFactory.getEME2000(), AbsoluteDate.J2000_EPOCH, provider.getMu());
    EcksteinHechlerPropagator propagator = new EcksteinHechlerPropagator(orbit, provider);
    AbsoluteDate target = AbsoluteDate.J2000_EPOCH.shiftedBy(10000.0);
    List<TimeStampedPVCoordinates> sample = new ArrayList<TimeStampedPVCoordinates>();
    for (double dt : Arrays.asList(-0.5, 0.0, 0.5)) {
        sample.add(propagator.propagate(target.shiftedBy(dt)).getPVCoordinates());
    }
    TimeStampedPVCoordinates interpolated = TimeStampedPVCoordinates.interpolate(target, CartesianDerivativesFilter.USE_P, sample);
    Vector3D computedP = sample.get(1).getPosition();
    Vector3D computedV = sample.get(1).getVelocity();
    Vector3D referenceP = interpolated.getPosition();
    Vector3D referenceV = interpolated.getVelocity();
    Vector3D computedA = sample.get(1).getAcceleration();
    Vector3D referenceA = interpolated.getAcceleration();
    final CircularOrbit propagated = (CircularOrbit) OrbitType.CIRCULAR.convertType(propagator.propagateOrbit(target));
    final CircularOrbit keplerian = new CircularOrbit(propagated.getA(), propagated.getCircularEx(), propagated.getCircularEy(), propagated.getI(), propagated.getRightAscensionOfAscendingNode(), propagated.getAlphaM(), PositionAngle.MEAN, propagated.getFrame(), propagated.getDate(), propagated.getMu());
    Vector3D keplerianP = keplerian.getPVCoordinates().getPosition();
    Vector3D keplerianV = keplerian.getPVCoordinates().getVelocity();
    Vector3D keplerianA = keplerian.getPVCoordinates().getAcceleration();
    // perturbed orbit position should be similar to Keplerian orbit position
    Assert.assertEquals(0.0, Vector3D.distance(referenceP, computedP), 1.0e-15);
    Assert.assertEquals(0.0, Vector3D.distance(referenceP, keplerianP), 4.0e-9);
    // perturbed orbit velocity should be equal to Keplerian orbit because
    // it was in fact reconstructed from Cartesian coordinates
    double computationErrorV = Vector3D.distance(referenceV, computedV);
    double nonKeplerianEffectV = Vector3D.distance(referenceV, keplerianV);
    Assert.assertEquals(nonKeplerianEffectV, computationErrorV, 9.0e-13);
    Assert.assertEquals(2.2e-4, computationErrorV, 3.0e-6);
    // perturbed orbit acceleration should be different from Keplerian orbit because
    // Keplerian orbit doesn't take orbit shape changes into account
    // perturbed orbit acceleration should be consistent with position evolution
    double computationErrorA = Vector3D.distance(referenceA, computedA);
    double nonKeplerianEffectA = Vector3D.distance(referenceA, keplerianA);
    Assert.assertEquals(1.0e-7, computationErrorA, 6.0e-9);
    Assert.assertEquals(6.37e-3, nonKeplerianEffectA, 7.0e-6);
    Assert.assertTrue(computationErrorA < nonKeplerianEffectA / 60000);
}
Also used : CircularOrbit(org.orekit.orbits.CircularOrbit) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) ArrayList(java.util.ArrayList) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) TimeStampedPVCoordinates(org.orekit.utils.TimeStampedPVCoordinates) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 49 with TimeStampedPVCoordinates

use of org.orekit.utils.TimeStampedPVCoordinates in project Orekit by CS-SI.

the class EphemerisTest method testSerialization.

@Test
public void testSerialization() throws OrekitException, IOException, ClassNotFoundException {
    propagator.setAttitudeProvider(new LofOffset(inertialFrame, LOFType.VVLH));
    int numberOfIntervals = 150;
    double deltaT = finalDate.durationFrom(initDate) / numberOfIntervals;
    List<SpacecraftState> states = new ArrayList<SpacecraftState>(numberOfIntervals + 1);
    for (int j = 0; j <= numberOfIntervals; j++) {
        states.add(propagator.propagate(initDate.shiftedBy((j * deltaT))));
    }
    int numInterpolationPoints = 2;
    Ephemeris ephemPropagator = new Ephemeris(states, numInterpolationPoints, 1.25);
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(bos);
    oos.writeObject(ephemPropagator);
    Assert.assertTrue(bos.size() > 30000);
    Assert.assertTrue(bos.size() < 31000);
    ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
    ObjectInputStream ois = new ObjectInputStream(bis);
    Ephemeris deserialized = (Ephemeris) ois.readObject();
    Assert.assertEquals(deserialized.getMinDate(), ephemPropagator.getMinDate());
    Assert.assertEquals(deserialized.getMaxDate(), ephemPropagator.getMaxDate());
    Assert.assertEquals(deserialized.getExtrapolationThreshold(), ephemPropagator.getExtrapolationThreshold(), 1.0e-15);
    for (double dt = 0; dt < finalDate.durationFrom(initDate); dt += 10.0) {
        AbsoluteDate date = initDate.shiftedBy(dt);
        TimeStampedPVCoordinates pvRef = ephemPropagator.getPVCoordinates(date, inertialFrame);
        TimeStampedPVCoordinates pv = deserialized.getPVCoordinates(date, inertialFrame);
        Assert.assertEquals(0.0, Vector3D.distance(pvRef.getPosition(), pv.getPosition()), 1.0e-15);
        Assert.assertEquals(0.0, Vector3D.distance(pvRef.getVelocity(), pv.getVelocity()), 1.0e-15);
        Assert.assertEquals(0.0, Vector3D.distance(pvRef.getAcceleration(), pv.getAcceleration()), 1.0e-15);
    }
}
Also used : ArrayList(java.util.ArrayList) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectOutputStream(java.io.ObjectOutputStream) TimeStampedPVCoordinates(org.orekit.utils.TimeStampedPVCoordinates) AbsoluteDate(org.orekit.time.AbsoluteDate) SpacecraftState(org.orekit.propagation.SpacecraftState) ByteArrayInputStream(java.io.ByteArrayInputStream) LofOffset(org.orekit.attitudes.LofOffset) ObjectInputStream(java.io.ObjectInputStream) Test(org.junit.Test)

Example 50 with TimeStampedPVCoordinates

use of org.orekit.utils.TimeStampedPVCoordinates in project Orekit by CS-SI.

the class LofOffsetPointingTest method checkField.

private <T extends RealFieldElement<T>> void checkField(final Field<T> field, final GroundPointing provider, final Orbit orbit, final AbsoluteDate date, final Frame frame) throws OrekitException {
    final Attitude attitudeD = provider.getAttitude(orbit, date, frame);
    final FieldOrbit<T> orbitF = new FieldSpacecraftState<>(field, new SpacecraftState(orbit)).getOrbit();
    final FieldAbsoluteDate<T> dateF = new FieldAbsoluteDate<>(field, date);
    final FieldAttitude<T> attitudeF = provider.getAttitude(orbitF, dateF, frame);
    Assert.assertEquals(0.0, Rotation.distance(attitudeD.getRotation(), attitudeF.getRotation().toRotation()), 1.0e-15);
    Assert.assertEquals(0.0, Vector3D.distance(attitudeD.getSpin(), attitudeF.getSpin().toVector3D()), 1.0e-15);
    Assert.assertEquals(0.0, Vector3D.distance(attitudeD.getRotationAcceleration(), attitudeF.getRotationAcceleration().toVector3D()), 1.0e-15);
    final TimeStampedPVCoordinates pvD = provider.getTargetPV(orbit, date, frame);
    final TimeStampedFieldPVCoordinates<T> pvF = provider.getTargetPV(orbitF, dateF, frame);
    Assert.assertEquals(0.0, Vector3D.distance(pvD.getPosition(), pvF.getPosition().toVector3D()), 9.0e-9);
    Assert.assertEquals(0.0, Vector3D.distance(pvD.getVelocity(), pvF.getVelocity().toVector3D()), 5.0e-9);
    Assert.assertEquals(0.0, Vector3D.distance(pvD.getAcceleration(), pvF.getAcceleration().toVector3D()), 4.0e-5);
}
Also used : FieldSpacecraftState(org.orekit.propagation.FieldSpacecraftState) SpacecraftState(org.orekit.propagation.SpacecraftState) TimeStampedPVCoordinates(org.orekit.utils.TimeStampedPVCoordinates) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate)

Aggregations

TimeStampedPVCoordinates (org.orekit.utils.TimeStampedPVCoordinates)103 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)64 Test (org.junit.Test)50 AbsoluteDate (org.orekit.time.AbsoluteDate)48 SpacecraftState (org.orekit.propagation.SpacecraftState)36 Frame (org.orekit.frames.Frame)27 ArrayList (java.util.ArrayList)24 FieldVector3D (org.hipparchus.geometry.euclidean.threed.FieldVector3D)23 Transform (org.orekit.frames.Transform)22 CartesianOrbit (org.orekit.orbits.CartesianOrbit)20 Orbit (org.orekit.orbits.Orbit)19 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)18 KeplerianOrbit (org.orekit.orbits.KeplerianOrbit)17 PVCoordinates (org.orekit.utils.PVCoordinates)17 OrekitException (org.orekit.errors.OrekitException)15 BoundedPropagator (org.orekit.propagation.BoundedPropagator)12 DSFactory (org.hipparchus.analysis.differentiation.DSFactory)11 CircularOrbit (org.orekit.orbits.CircularOrbit)11 Propagator (org.orekit.propagation.Propagator)11 FieldTransform (org.orekit.frames.FieldTransform)10