Search in sources :

Example 36 with BoundedPropagator

use of org.orekit.propagation.BoundedPropagator in project Orekit by CS-SI.

the class IntegratedEphemerisTest method testGetFrame.

@Test
public void testGetFrame() throws OrekitException {
    // setup
    AbsoluteDate finalDate = initialOrbit.getDate().shiftedBy(Constants.JULIAN_DAY);
    numericalPropagator.setEphemerisMode();
    numericalPropagator.setInitialState(new SpacecraftState(initialOrbit));
    numericalPropagator.propagate(finalDate);
    Assert.assertTrue(numericalPropagator.getCalls() < 3200);
    BoundedPropagator ephemeris = numericalPropagator.getGeneratedEphemeris();
    // action
    Assert.assertNotNull(ephemeris.getFrame());
    Assert.assertSame(ephemeris.getFrame(), numericalPropagator.getFrame());
}
Also used : SpacecraftState(org.orekit.propagation.SpacecraftState) BoundedPropagator(org.orekit.propagation.BoundedPropagator) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 37 with BoundedPropagator

use of org.orekit.propagation.BoundedPropagator in project Orekit by CS-SI.

the class IntegratedEphemerisTest method testNormalKeplerIntegration.

@Test
public void testNormalKeplerIntegration() throws OrekitException {
    // Keplerian propagator definition
    KeplerianPropagator keplerEx = new KeplerianPropagator(initialOrbit);
    // Integrated ephemeris
    // Propagation
    AbsoluteDate finalDate = initialOrbit.getDate().shiftedBy(Constants.JULIAN_DAY);
    numericalPropagator.setEphemerisMode();
    numericalPropagator.setInitialState(new SpacecraftState(initialOrbit));
    numericalPropagator.propagate(finalDate);
    Assert.assertTrue(numericalPropagator.getCalls() < 3200);
    BoundedPropagator ephemeris = numericalPropagator.getGeneratedEphemeris();
    // tests
    for (int i = 1; i <= Constants.JULIAN_DAY; i++) {
        AbsoluteDate intermediateDate = initialOrbit.getDate().shiftedBy(i);
        SpacecraftState keplerIntermediateOrbit = keplerEx.propagate(intermediateDate);
        SpacecraftState numericIntermediateOrbit = ephemeris.propagate(intermediateDate);
        Vector3D kepPosition = keplerIntermediateOrbit.getPVCoordinates().getPosition();
        Vector3D numPosition = numericIntermediateOrbit.getPVCoordinates().getPosition();
        Assert.assertEquals(0, kepPosition.subtract(numPosition).getNorm(), 0.06);
    }
    // test inv
    AbsoluteDate intermediateDate = initialOrbit.getDate().shiftedBy(41589);
    SpacecraftState keplerIntermediateOrbit = keplerEx.propagate(intermediateDate);
    SpacecraftState state = keplerEx.propagate(finalDate);
    numericalPropagator.setInitialState(state);
    numericalPropagator.setEphemerisMode();
    numericalPropagator.propagate(initialOrbit.getDate());
    BoundedPropagator invEphemeris = numericalPropagator.getGeneratedEphemeris();
    SpacecraftState numericIntermediateOrbit = invEphemeris.propagate(intermediateDate);
    Vector3D kepPosition = keplerIntermediateOrbit.getPVCoordinates().getPosition();
    Vector3D numPosition = numericIntermediateOrbit.getPVCoordinates().getPosition();
    Assert.assertEquals(0, kepPosition.subtract(numPosition).getNorm(), 10e-2);
}
Also used : KeplerianPropagator(org.orekit.propagation.analytical.KeplerianPropagator) SpacecraftState(org.orekit.propagation.SpacecraftState) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) BoundedPropagator(org.orekit.propagation.BoundedPropagator) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 38 with BoundedPropagator

use of org.orekit.propagation.BoundedPropagator in project Orekit by CS-SI.

the class KeplerianPropagatorTest method ephemeris.

@Test
public void ephemeris() 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, 3.986004415e14);
    KeplerianPropagator propagator = new KeplerianPropagator(orbit);
    propagator.setEphemerisMode();
    AbsoluteDate farTarget = AbsoluteDate.J2000_EPOCH.shiftedBy(10000.0);
    propagator.setEphemerisMode();
    propagator.propagate(farTarget);
    BoundedPropagator ephemeris = propagator.getGeneratedEphemeris();
    Assert.assertEquals(0.0, ephemeris.getMinDate().durationFrom(orbit.getDate()), 1.0e10);
    Assert.assertEquals(0.0, ephemeris.getMaxDate().durationFrom(farTarget), 1.0e10);
}
Also used : KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) BoundedPropagator(org.orekit.propagation.BoundedPropagator) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 39 with BoundedPropagator

use of org.orekit.propagation.BoundedPropagator in project Orekit by CS-SI.

the class BatchLSEstimatorTest method testMultiSat.

@Test
public void testMultiSat() throws OrekitException {
    Context context = EstimationTestUtils.eccentricContext("regular-data:potential:tides");
    final NumericalPropagatorBuilder propagatorBuilder1 = context.createBuilder(OrbitType.KEPLERIAN, PositionAngle.TRUE, true, 1.0e-6, 60.0, 1.0);
    final NumericalPropagatorBuilder propagatorBuilder2 = context.createBuilder(OrbitType.KEPLERIAN, PositionAngle.TRUE, true, 1.0e-6, 60.0, 1.0);
    // Create perfect inter-satellites range measurements
    final TimeStampedPVCoordinates original = context.initialOrbit.getPVCoordinates();
    final Orbit closeOrbit = new CartesianOrbit(new TimeStampedPVCoordinates(context.initialOrbit.getDate(), original.getPosition().add(new Vector3D(1000, 2000, 3000)), original.getVelocity().add(new Vector3D(-0.03, 0.01, 0.02))), context.initialOrbit.getFrame(), context.initialOrbit.getMu());
    final Propagator closePropagator = EstimationTestUtils.createPropagator(closeOrbit, propagatorBuilder2);
    closePropagator.setEphemerisMode();
    closePropagator.propagate(context.initialOrbit.getDate().shiftedBy(3.5 * closeOrbit.getKeplerianPeriod()));
    final BoundedPropagator ephemeris = closePropagator.getGeneratedEphemeris();
    Propagator propagator1 = EstimationTestUtils.createPropagator(context.initialOrbit, propagatorBuilder1);
    final List<ObservedMeasurement<?>> r12 = EstimationTestUtils.createMeasurements(propagator1, new InterSatellitesRangeMeasurementCreator(ephemeris), 1.0, 3.0, 300.0);
    // create perfect range measurements for first satellite
    propagator1 = EstimationTestUtils.createPropagator(context.initialOrbit, propagatorBuilder1);
    final List<ObservedMeasurement<?>> r1 = EstimationTestUtils.createMeasurements(propagator1, new RangeMeasurementCreator(context), 1.0, 3.0, 300.0);
    // create orbit estimator
    final BatchLSEstimator estimator = new BatchLSEstimator(new LevenbergMarquardtOptimizer(), propagatorBuilder1, propagatorBuilder2);
    for (final ObservedMeasurement<?> interSat : r12) {
        estimator.addMeasurement(interSat);
    }
    for (final ObservedMeasurement<?> range : r1) {
        estimator.addMeasurement(range);
    }
    estimator.setParametersConvergenceThreshold(1.0e-2);
    estimator.setMaxIterations(10);
    estimator.setMaxEvaluations(20);
    estimator.setObserver(new BatchLSObserver() {

        int lastIter = 0;

        int lastEval = 0;

        /**
         * {@inheritDoc}
         */
        @Override
        public void evaluationPerformed(int iterationsCount, int evaluationscount, Orbit[] orbits, ParameterDriversList estimatedOrbitalParameters, ParameterDriversList estimatedPropagatorParameters, ParameterDriversList estimatedMeasurementsParameters, EstimationsProvider evaluationsProvider, Evaluation lspEvaluation) throws OrekitException {
            if (iterationsCount == lastIter) {
                Assert.assertEquals(lastEval + 1, evaluationscount);
            } else {
                Assert.assertEquals(lastIter + 1, iterationsCount);
            }
            lastIter = iterationsCount;
            lastEval = evaluationscount;
            Assert.assertEquals(r12.size() + r1.size(), evaluationsProvider.getNumber());
            try {
                evaluationsProvider.getEstimatedMeasurement(-1);
                Assert.fail("an exception should have been thrown");
            } catch (OrekitException oe) {
                Assert.assertEquals(LocalizedCoreFormats.OUT_OF_RANGE_SIMPLE, oe.getSpecifier());
            }
            try {
                evaluationsProvider.getEstimatedMeasurement(r12.size() + r1.size());
                Assert.fail("an exception should have been thrown");
            } catch (OrekitException oe) {
                Assert.assertEquals(LocalizedCoreFormats.OUT_OF_RANGE_SIMPLE, oe.getSpecifier());
            }
            AbsoluteDate previous = AbsoluteDate.PAST_INFINITY;
            for (int i = 0; i < evaluationsProvider.getNumber(); ++i) {
                AbsoluteDate current = evaluationsProvider.getEstimatedMeasurement(i).getDate();
                Assert.assertTrue(current.compareTo(previous) >= 0);
                previous = current;
            }
        }
    });
    List<DelegatingDriver> parameters = estimator.getOrbitalParametersDrivers(true).getDrivers();
    ParameterDriver a0Driver = parameters.get(0);
    Assert.assertEquals("a[0]", a0Driver.getName());
    a0Driver.setValue(a0Driver.getValue() + 1.2);
    a0Driver.setReferenceDate(AbsoluteDate.GALILEO_EPOCH);
    ParameterDriver a1Driver = parameters.get(6);
    Assert.assertEquals("a[1]", a1Driver.getName());
    a1Driver.setValue(a1Driver.getValue() - 5.4);
    a1Driver.setReferenceDate(AbsoluteDate.GALILEO_EPOCH);
    final Orbit before = new KeplerianOrbit(parameters.get(6).getValue(), parameters.get(7).getValue(), parameters.get(8).getValue(), parameters.get(9).getValue(), parameters.get(10).getValue(), parameters.get(11).getValue(), PositionAngle.TRUE, closeOrbit.getFrame(), closeOrbit.getDate(), closeOrbit.getMu());
    Assert.assertEquals(4.7246, Vector3D.distance(closeOrbit.getPVCoordinates().getPosition(), before.getPVCoordinates().getPosition()), 1.0e-3);
    Assert.assertEquals(0.0010514, Vector3D.distance(closeOrbit.getPVCoordinates().getVelocity(), before.getPVCoordinates().getVelocity()), 1.0e-6);
    EstimationTestUtils.checkFit(context, estimator, 2, 3, 0.0, 2.3e-06, 0.0, 6.6e-06, 0.0, 6.2e-07, 0.0, 2.8e-10);
    final Orbit determined = new KeplerianOrbit(parameters.get(6).getValue(), parameters.get(7).getValue(), parameters.get(8).getValue(), parameters.get(9).getValue(), parameters.get(10).getValue(), parameters.get(11).getValue(), PositionAngle.TRUE, closeOrbit.getFrame(), closeOrbit.getDate(), closeOrbit.getMu());
    Assert.assertEquals(0.0, Vector3D.distance(closeOrbit.getPVCoordinates().getPosition(), determined.getPVCoordinates().getPosition()), 1.6e-6);
    Assert.assertEquals(0.0, Vector3D.distance(closeOrbit.getPVCoordinates().getVelocity(), determined.getPVCoordinates().getVelocity()), 1.6e-9);
    // got a default one
    for (final ParameterDriver driver : estimator.getOrbitalParametersDrivers(true).getDrivers()) {
        if (driver.getName().startsWith("a[")) {
            // user-specified reference date
            Assert.assertEquals(0, driver.getReferenceDate().durationFrom(AbsoluteDate.GALILEO_EPOCH), 1.0e-15);
        } else {
            // default reference date
            Assert.assertEquals(0, driver.getReferenceDate().durationFrom(propagatorBuilder1.getInitialOrbitDate()), 1.0e-15);
        }
    }
}
Also used : CartesianOrbit(org.orekit.orbits.CartesianOrbit) TimeStampedPVCoordinates(org.orekit.utils.TimeStampedPVCoordinates) AbsoluteDate(org.orekit.time.AbsoluteDate) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) ParameterDriversList(org.orekit.utils.ParameterDriversList) BoundedPropagator(org.orekit.propagation.BoundedPropagator) Propagator(org.orekit.propagation.Propagator) OrekitException(org.orekit.errors.OrekitException) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) DelegatingDriver(org.orekit.utils.ParameterDriversList.DelegatingDriver) BoundedPropagator(org.orekit.propagation.BoundedPropagator) ObservedMeasurement(org.orekit.estimation.measurements.ObservedMeasurement) EstimationsProvider(org.orekit.estimation.measurements.EstimationsProvider) Context(org.orekit.estimation.Context) Evaluation(org.hipparchus.optim.nonlinear.vector.leastsquares.LeastSquaresProblem.Evaluation) Orbit(org.orekit.orbits.Orbit) CartesianOrbit(org.orekit.orbits.CartesianOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) ParameterDriver(org.orekit.utils.ParameterDriver) LevenbergMarquardtOptimizer(org.hipparchus.optim.nonlinear.vector.leastsquares.LevenbergMarquardtOptimizer) NumericalPropagatorBuilder(org.orekit.propagation.conversion.NumericalPropagatorBuilder) InterSatellitesRangeMeasurementCreator(org.orekit.estimation.measurements.InterSatellitesRangeMeasurementCreator) RangeMeasurementCreator(org.orekit.estimation.measurements.RangeMeasurementCreator) InterSatellitesRangeMeasurementCreator(org.orekit.estimation.measurements.InterSatellitesRangeMeasurementCreator) Test(org.junit.Test)

Example 40 with BoundedPropagator

use of org.orekit.propagation.BoundedPropagator in project Orekit by CS-SI.

the class EphemerisEventsTest method checkEphem.

private void checkEphem(OrbitType type) throws IllegalArgumentException, OrekitException {
    initDate = new AbsoluteDate(new DateComponents(2004, 01, 01), TimeComponents.H00, TimeScalesFactory.getUTC());
    finalDate = new AbsoluteDate(new DateComponents(2004, 01, 02), TimeComponents.H00, TimeScalesFactory.getUTC());
    BoundedPropagator ephem = buildEphem(type);
    ephem.addEventDetector(buildEclipsDetector(type));
    AbsoluteDate computeEnd = new AbsoluteDate(finalDate, -1000.0);
    ephem.setSlaveMode();
    SpacecraftState state = ephem.propagate(computeEnd);
    Assert.assertEquals(computeEnd, state.getDate());
    Assert.assertEquals(14, inEclipsecounter);
    Assert.assertEquals(14, outEclipsecounter);
}
Also used : SpacecraftState(org.orekit.propagation.SpacecraftState) DateComponents(org.orekit.time.DateComponents) BoundedPropagator(org.orekit.propagation.BoundedPropagator) AbsoluteDate(org.orekit.time.AbsoluteDate)

Aggregations

BoundedPropagator (org.orekit.propagation.BoundedPropagator)50 Test (org.junit.Test)44 AbsoluteDate (org.orekit.time.AbsoluteDate)41 SpacecraftState (org.orekit.propagation.SpacecraftState)32 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)20 KeplerianOrbit (org.orekit.orbits.KeplerianOrbit)20 Orbit (org.orekit.orbits.Orbit)19 Frame (org.orekit.frames.Frame)16 CartesianOrbit (org.orekit.orbits.CartesianOrbit)15 CircularOrbit (org.orekit.orbits.CircularOrbit)15 TimeStampedPVCoordinates (org.orekit.utils.TimeStampedPVCoordinates)14 OrekitException (org.orekit.errors.OrekitException)12 PVCoordinates (org.orekit.utils.PVCoordinates)10 Propagator (org.orekit.propagation.Propagator)9 TimeScale (org.orekit.time.TimeScale)9 LofOffset (org.orekit.attitudes.LofOffset)8 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)8 ByteArrayInputStream (java.io.ByteArrayInputStream)7 FieldSpacecraftState (org.orekit.propagation.FieldSpacecraftState)7 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6