Search in sources :

Example 1 with Bias

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

the class BiasTest method testEstimateBias.

@SuppressWarnings("unchecked")
@Test
public void testEstimateBias() 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, 0.001);
    // create perfect range measurements
    final Propagator propagator = EstimationTestUtils.createPropagator(context.initialOrbit, propagatorBuilder);
    final List<ObservedMeasurement<?>> measurements = EstimationTestUtils.createMeasurements(propagator, new RangeMeasurementCreator(context), 1.0, 3.0, 300.0);
    // create range biases: one bias for each station
    final RandomGenerator random = new Well19937a(0x0c4b69da5d64b35al);
    final Bias<?>[] stationsRangeBiases = new Bias<?>[context.stations.size()];
    final double[] realStationsBiases = new double[context.stations.size()];
    for (int i = 0; i < context.stations.size(); ++i) {
        final TopocentricFrame base = context.stations.get(i).getBaseFrame();
        stationsRangeBiases[i] = new Bias<Range>(new String[] { base.getName() + " range bias" }, new double[] { 0.0 }, new double[] { 1.0 }, new double[] { Double.NEGATIVE_INFINITY }, new double[] { Double.POSITIVE_INFINITY });
        realStationsBiases[i] = 2 * random.nextDouble() - 1;
    }
    // create orbit estimator
    final BatchLSEstimator estimator = new BatchLSEstimator(new LevenbergMarquardtOptimizer(), propagatorBuilder);
    // add the measurements, with both spacecraft and stations biases
    for (final ObservedMeasurement<?> measurement : measurements) {
        final Range range = (Range) measurement;
        for (int i = 0; i < context.stations.size(); ++i) {
            if (range.getStation() == context.stations.get(i)) {
                double biasedRange = range.getObservedValue()[0] + realStationsBiases[i];
                final Range m = new Range(range.getStation(), range.getDate(), biasedRange, range.getTheoreticalStandardDeviation()[0], range.getBaseWeight()[0]);
                m.addModifier((Bias<Range>) stationsRangeBiases[i]);
                estimator.addMeasurement(m);
            }
        }
    }
    estimator.setParametersConvergenceThreshold(1.0e-3);
    estimator.setMaxIterations(10);
    estimator.setMaxEvaluations(20);
    // we want to estimate the biases
    for (Bias<?> bias : stationsRangeBiases) {
        for (final ParameterDriver driver : bias.getParametersDrivers()) {
            driver.setSelected(true);
        }
    }
    EstimationTestUtils.checkFit(context, estimator, 2, 3, 0.0, 7.2e-7, 0.0, 2.1e-6, 0.0, 3.7e-7, 0.0, 1.7e-10);
    for (int i = 0; i < stationsRangeBiases.length; ++i) {
        Assert.assertEquals(realStationsBiases[i], stationsRangeBiases[i].getParametersDrivers().get(0).getValue(), 3.3e-6);
    }
}
Also used : Context(org.orekit.estimation.Context) Bias(org.orekit.estimation.measurements.modifiers.Bias) TopocentricFrame(org.orekit.frames.TopocentricFrame) Well19937a(org.hipparchus.random.Well19937a) Range(org.orekit.estimation.measurements.Range) ParameterDriver(org.orekit.utils.ParameterDriver) RandomGenerator(org.hipparchus.random.RandomGenerator) BatchLSEstimator(org.orekit.estimation.leastsquares.BatchLSEstimator) LevenbergMarquardtOptimizer(org.hipparchus.optim.nonlinear.vector.leastsquares.LevenbergMarquardtOptimizer) NumericalPropagatorBuilder(org.orekit.propagation.conversion.NumericalPropagatorBuilder) Propagator(org.orekit.propagation.Propagator) RangeMeasurementCreator(org.orekit.estimation.measurements.RangeMeasurementCreator) ObservedMeasurement(org.orekit.estimation.measurements.ObservedMeasurement) Test(org.junit.Test)

Aggregations

LevenbergMarquardtOptimizer (org.hipparchus.optim.nonlinear.vector.leastsquares.LevenbergMarquardtOptimizer)1 RandomGenerator (org.hipparchus.random.RandomGenerator)1 Well19937a (org.hipparchus.random.Well19937a)1 Test (org.junit.Test)1 Context (org.orekit.estimation.Context)1 BatchLSEstimator (org.orekit.estimation.leastsquares.BatchLSEstimator)1 ObservedMeasurement (org.orekit.estimation.measurements.ObservedMeasurement)1 Range (org.orekit.estimation.measurements.Range)1 RangeMeasurementCreator (org.orekit.estimation.measurements.RangeMeasurementCreator)1 Bias (org.orekit.estimation.measurements.modifiers.Bias)1 TopocentricFrame (org.orekit.frames.TopocentricFrame)1 Propagator (org.orekit.propagation.Propagator)1 NumericalPropagatorBuilder (org.orekit.propagation.conversion.NumericalPropagatorBuilder)1 ParameterDriver (org.orekit.utils.ParameterDriver)1