Search in sources :

Example 6 with PVMeasurementCreator

use of org.orekit.estimation.measurements.PVMeasurementCreator in project Orekit by CS-SI.

the class BatchLSEstimatorTest method testKeplerPVBackward.

/**
 * Test PV measurements generation and backward propagation in least-square orbit determination.
 */
@Test
public void testKeplerPVBackward() throws OrekitException {
    Context context = EstimationTestUtils.eccentricContext("regular-data:potential:tides");
    final NumericalPropagatorBuilder propagatorBuilder = context.createBuilder(OrbitType.KEPLERIAN, PositionAngle.TRUE, true, 1.0e-6, 60.0, 1.0);
    // create perfect PV measurements
    final Propagator propagator = EstimationTestUtils.createPropagator(context.initialOrbit, propagatorBuilder);
    final List<ObservedMeasurement<?>> measurements = EstimationTestUtils.createMeasurements(propagator, new PVMeasurementCreator(), 0.0, -1.0, 300.0);
    // create orbit estimator
    final BatchLSEstimator estimator = new BatchLSEstimator(new LevenbergMarquardtOptimizer(), propagatorBuilder);
    for (final ObservedMeasurement<?> measurement : measurements) {
        estimator.addMeasurement(measurement);
    }
    estimator.setParametersConvergenceThreshold(1.0e-2);
    estimator.setMaxIterations(10);
    estimator.setMaxEvaluations(20);
    EstimationTestUtils.checkFit(context, estimator, 1, 2, 0.0, 8.3e-9, 0.0, 5.3e-8, 0.0, 5.6e-9, 0.0, 1.6e-12);
    RealMatrix normalizedCovariances = estimator.getOptimum().getCovariances(1.0e-10);
    RealMatrix physicalCovariances = estimator.getPhysicalCovariances(1.0e-10);
    Assert.assertEquals(6, normalizedCovariances.getRowDimension());
    Assert.assertEquals(6, normalizedCovariances.getColumnDimension());
    Assert.assertEquals(6, physicalCovariances.getRowDimension());
    Assert.assertEquals(6, physicalCovariances.getColumnDimension());
    Assert.assertEquals(0.00258, physicalCovariances.getEntry(0, 0), 1.0e-5);
}
Also used : Context(org.orekit.estimation.Context) LevenbergMarquardtOptimizer(org.hipparchus.optim.nonlinear.vector.leastsquares.LevenbergMarquardtOptimizer) RealMatrix(org.hipparchus.linear.RealMatrix) NumericalPropagatorBuilder(org.orekit.propagation.conversion.NumericalPropagatorBuilder) BoundedPropagator(org.orekit.propagation.BoundedPropagator) Propagator(org.orekit.propagation.Propagator) ObservedMeasurement(org.orekit.estimation.measurements.ObservedMeasurement) PVMeasurementCreator(org.orekit.estimation.measurements.PVMeasurementCreator) Test(org.junit.Test)

Example 7 with PVMeasurementCreator

use of org.orekit.estimation.measurements.PVMeasurementCreator in project Orekit by CS-SI.

the class ModelTest method testPerfectValue.

@Test
public void testPerfectValue() throws OrekitException {
    final Context context = EstimationTestUtils.eccentricContext("regular-data:potential:tides");
    final NumericalPropagatorBuilder propagatorBuilder = context.createBuilder(OrbitType.KEPLERIAN, PositionAngle.TRUE, true, 1.0e-6, 60.0, 0.001);
    final NumericalPropagatorBuilder[] builders = { propagatorBuilder };
    // create perfect PV measurements
    final Propagator propagator = EstimationTestUtils.createPropagator(context.initialOrbit, propagatorBuilder);
    final List<ObservedMeasurement<?>> measurements = EstimationTestUtils.createMeasurements(propagator, new PVMeasurementCreator(), 0.0, 1.0, 300.0);
    final ParameterDriversList estimatedMeasurementsParameters = new ParameterDriversList();
    for (ObservedMeasurement<?> measurement : measurements) {
        for (final ParameterDriver driver : measurement.getParametersDrivers()) {
            if (driver.isSelected()) {
                estimatedMeasurementsParameters.add(driver);
            }
        }
    }
    // create model
    final ModelObserver modelObserver = new ModelObserver() {

        /**
         * {@inheritDoc}
         */
        @Override
        public void modelCalled(final Orbit[] newOrbits, final Map<ObservedMeasurement<?>, EstimatedMeasurement<?>> newEvaluations) {
            Assert.assertEquals(1, newOrbits.length);
            Assert.assertEquals(0, context.initialOrbit.getDate().durationFrom(newOrbits[0].getDate()), 1.0e-15);
            Assert.assertEquals(0, Vector3D.distance(context.initialOrbit.getPVCoordinates().getPosition(), newOrbits[0].getPVCoordinates().getPosition()), 1.0e-15);
            Assert.assertEquals(measurements.size(), newEvaluations.size());
        }
    };
    final Model model = new Model(builders, measurements, estimatedMeasurementsParameters, modelObserver);
    model.setIterationsCounter(new Incrementor(100));
    model.setEvaluationsCounter(new Incrementor(100));
    // Test forward propagation flag to true
    assertEquals(true, model.isForwardPropagation());
    // evaluate model on perfect start point
    final double[] normalizedProp = propagatorBuilder.getSelectedNormalizedParameters();
    final double[] normalized = new double[normalizedProp.length + estimatedMeasurementsParameters.getNbParams()];
    System.arraycopy(normalizedProp, 0, normalized, 0, normalizedProp.length);
    int i = normalizedProp.length;
    for (final ParameterDriver driver : estimatedMeasurementsParameters.getDrivers()) {
        normalized[i++] = driver.getNormalizedValue();
    }
    Pair<RealVector, RealMatrix> value = model.value(new ArrayRealVector(normalized));
    int index = 0;
    for (ObservedMeasurement<?> measurement : measurements) {
        for (int k = 0; k < measurement.getDimension(); ++k) {
            // the value is already a weighted residual
            Assert.assertEquals(0.0, value.getFirst().getEntry(index++), 1.6e-7);
        }
    }
    Assert.assertEquals(index, value.getFirst().getDimension());
}
Also used : Context(org.orekit.estimation.Context) ArrayRealVector(org.hipparchus.linear.ArrayRealVector) Incrementor(org.hipparchus.util.Incrementor) ParameterDriver(org.orekit.utils.ParameterDriver) RealMatrix(org.hipparchus.linear.RealMatrix) ParameterDriversList(org.orekit.utils.ParameterDriversList) NumericalPropagatorBuilder(org.orekit.propagation.conversion.NumericalPropagatorBuilder) ArrayRealVector(org.hipparchus.linear.ArrayRealVector) RealVector(org.hipparchus.linear.RealVector) Propagator(org.orekit.propagation.Propagator) Map(java.util.Map) ObservedMeasurement(org.orekit.estimation.measurements.ObservedMeasurement) PVMeasurementCreator(org.orekit.estimation.measurements.PVMeasurementCreator) Test(org.junit.Test)

Example 8 with PVMeasurementCreator

use of org.orekit.estimation.measurements.PVMeasurementCreator in project Orekit by CS-SI.

the class IodLambertTest method testLambert.

@Test
public void testLambert() throws OrekitException {
    final Context context = EstimationTestUtils.eccentricContext("regular-data:potential:tides");
    final double mu = context.initialOrbit.getMu();
    final Frame frame = context.initialOrbit.getFrame();
    final NumericalPropagatorBuilder propagatorBuilder = context.createBuilder(OrbitType.KEPLERIAN, PositionAngle.TRUE, true, 1.0e-6, 60.0, 0.001);
    // create perfect range measurements
    final Propagator propagator = EstimationTestUtils.createPropagator(context.initialOrbit, propagatorBuilder);
    final List<ObservedMeasurement<?>> measurements = EstimationTestUtils.createMeasurements(propagator, new PVMeasurementCreator(), 0.0, 1.0, 60.0);
    // measurement data 1
    final int idMeasure1 = 0;
    final AbsoluteDate date1 = measurements.get(idMeasure1).getDate();
    /*final Vector3D stapos1 = context.stations.get(0)  // FIXME we need to access the station of the measurement
                                    .getBaseFrame()
                                    .getPVCoordinates(date1, frame)
                                    .getPosition();*/
    final Vector3D position1 = new Vector3D(measurements.get(idMeasure1).getObservedValue()[0], measurements.get(idMeasure1).getObservedValue()[1], measurements.get(idMeasure1).getObservedValue()[2]);
    // measurement data 2
    final int idMeasure2 = 10;
    final AbsoluteDate date2 = measurements.get(idMeasure2).getDate();
    /*final Vector3D stapos2 = context.stations.get(0)  // FIXME we need to access the station of the measurement
                        .getBaseFrame()
                        .getPVCoordinates(date2, frame)
                        .getPosition();*/
    final Vector3D position2 = new Vector3D(measurements.get(idMeasure2).getObservedValue()[0], measurements.get(idMeasure2).getObservedValue()[1], measurements.get(idMeasure2).getObservedValue()[2]);
    final int nRev = 0;
    // instantiate the IOD method
    final IodLambert iod = new IodLambert(mu);
    final KeplerianOrbit orbit = iod.estimate(frame, true, nRev, /*stapos1.add*/
    (position1), date1, /*stapos2.add*/
    (position2), date2);
    Assert.assertEquals(orbit.getA(), context.initialOrbit.getA(), 1.0e-9 * context.initialOrbit.getA());
    Assert.assertEquals(orbit.getE(), context.initialOrbit.getE(), 1.0e-9 * context.initialOrbit.getE());
    Assert.assertEquals(orbit.getI(), context.initialOrbit.getI(), 1.0e-9 * context.initialOrbit.getI());
}
Also used : Context(org.orekit.estimation.Context) Frame(org.orekit.frames.Frame) AbsoluteDate(org.orekit.time.AbsoluteDate) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) NumericalPropagatorBuilder(org.orekit.propagation.conversion.NumericalPropagatorBuilder) TLEPropagator(org.orekit.propagation.analytical.tle.TLEPropagator) Propagator(org.orekit.propagation.Propagator) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) ObservedMeasurement(org.orekit.estimation.measurements.ObservedMeasurement) PVMeasurementCreator(org.orekit.estimation.measurements.PVMeasurementCreator) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)8 Context (org.orekit.estimation.Context)8 ObservedMeasurement (org.orekit.estimation.measurements.ObservedMeasurement)8 PVMeasurementCreator (org.orekit.estimation.measurements.PVMeasurementCreator)8 Propagator (org.orekit.propagation.Propagator)8 NumericalPropagatorBuilder (org.orekit.propagation.conversion.NumericalPropagatorBuilder)8 RealMatrix (org.hipparchus.linear.RealMatrix)4 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)3 Frame (org.orekit.frames.Frame)3 KeplerianOrbit (org.orekit.orbits.KeplerianOrbit)3 ParameterDriversList (org.orekit.utils.ParameterDriversList)3 Map (java.util.Map)2 LevenbergMarquardtOptimizer (org.hipparchus.optim.nonlinear.vector.leastsquares.LevenbergMarquardtOptimizer)2 BoundedPropagator (org.orekit.propagation.BoundedPropagator)2 AbsoluteDate (org.orekit.time.AbsoluteDate)2 ParameterDriver (org.orekit.utils.ParameterDriver)2 ArrayRealVector (org.hipparchus.linear.ArrayRealVector)1 RealVector (org.hipparchus.linear.RealVector)1 Incrementor (org.hipparchus.util.Incrementor)1 PV (org.orekit.estimation.measurements.PV)1