Search in sources :

Example 61 with Context

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

the class TropoModifierTest method testRangeTropoModifier.

@Test
public void testRangeTropoModifier() 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
    for (final GroundStation station : context.stations) {
        station.getEastOffsetDriver().setSelected(true);
        station.getNorthOffsetDriver().setSelected(true);
        station.getZenithOffsetDriver().setSelected(true);
    }
    final Propagator propagator = EstimationTestUtils.createPropagator(context.initialOrbit, propagatorBuilder);
    final List<ObservedMeasurement<?>> measurements = EstimationTestUtils.createMeasurements(propagator, new RangeMeasurementCreator(context), 1.0, 3.0, 300.0);
    propagator.setSlaveMode();
    final RangeTroposphericDelayModifier modifier = new RangeTroposphericDelayModifier(SaastamoinenModel.getStandardModel());
    for (final ObservedMeasurement<?> measurement : measurements) {
        final AbsoluteDate date = measurement.getDate();
        final SpacecraftState refState = propagator.propagate(date);
        Range range = (Range) measurement;
        EstimatedMeasurement<Range> evalNoMod = range.estimate(0, 0, new SpacecraftState[] { refState });
        // add modifier
        range.addModifier(modifier);
        EstimatedMeasurement<Range> eval = range.estimate(0, 0, new SpacecraftState[] { refState });
        final double diffMeters = eval.getEstimatedValue()[0] - evalNoMod.getEstimatedValue()[0];
        final double epsilon = 1e-6;
        Assert.assertTrue(Precision.compareTo(diffMeters, 12., epsilon) < 0);
        Assert.assertTrue(Precision.compareTo(diffMeters, 0., epsilon) > 0);
    }
}
Also used : Context(org.orekit.estimation.Context) GroundStation(org.orekit.estimation.measurements.GroundStation) TurnAroundRange(org.orekit.estimation.measurements.TurnAroundRange) Range(org.orekit.estimation.measurements.Range) RangeTroposphericDelayModifier(org.orekit.estimation.measurements.modifiers.RangeTroposphericDelayModifier) TurnAroundRangeTroposphericDelayModifier(org.orekit.estimation.measurements.modifiers.TurnAroundRangeTroposphericDelayModifier) AbsoluteDate(org.orekit.time.AbsoluteDate) SpacecraftState(org.orekit.propagation.SpacecraftState) NumericalPropagatorBuilder(org.orekit.propagation.conversion.NumericalPropagatorBuilder) Propagator(org.orekit.propagation.Propagator) RangeMeasurementCreator(org.orekit.estimation.measurements.RangeMeasurementCreator) TurnAroundRangeMeasurementCreator(org.orekit.estimation.measurements.TurnAroundRangeMeasurementCreator) ObservedMeasurement(org.orekit.estimation.measurements.ObservedMeasurement) Test(org.junit.Test)

Example 62 with Context

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

the class KalmanEstimatorTest method testEquinoctialRightAscensionDeclination.

/**
 * Perfect right-ascension/declination measurements with a perfect start
 * Equinoctial formalism
 * @throws OrekitException
 */
@Test
public void testEquinoctialRightAscensionDeclination() throws OrekitException {
    // Create context
    Context context = EstimationTestUtils.eccentricContext("regular-data:potential:tides");
    // Create initial orbit and propagator builder
    final OrbitType orbitType = OrbitType.EQUINOCTIAL;
    final PositionAngle positionAngle = PositionAngle.TRUE;
    final boolean perfectStart = true;
    final double minStep = 1.e-6;
    final double maxStep = 60.;
    final double dP = 1.;
    final NumericalPropagatorBuilder propagatorBuilder = context.createBuilder(orbitType, positionAngle, perfectStart, minStep, maxStep, dP);
    // Create perfect range measurements
    final Propagator propagator = EstimationTestUtils.createPropagator(context.initialOrbit, propagatorBuilder);
    final List<ObservedMeasurement<?>> measurements = EstimationTestUtils.createMeasurements(propagator, new AngularRaDecMeasurementCreator(context), 1.0, 4.0, 60.0);
    // Reference propagator for estimation performances
    final NumericalPropagator referencePropagator = propagatorBuilder.buildPropagator(propagatorBuilder.getSelectedNormalizedParameters());
    // Reference position/velocity at last measurement date
    final Orbit refOrbit = referencePropagator.propagate(measurements.get(measurements.size() - 1).getDate()).getOrbit();
    // Cartesian covariance matrix initialization
    final RealMatrix cartesianP = MatrixUtils.createRealDiagonalMatrix(new double[] { 1e-4, 1e-4, 1e-4, 1e-10, 1e-10, 1e-10 });
    // Jacobian of the orbital parameters w/r to Cartesian
    final Orbit initialOrbit = orbitType.convertType(context.initialOrbit);
    final double[][] dYdC = new double[6][6];
    initialOrbit.getJacobianWrtCartesian(positionAngle, dYdC);
    final RealMatrix Jac = MatrixUtils.createRealMatrix(dYdC);
    // Keplerian initial covariance matrix
    final RealMatrix initialP = Jac.multiply(cartesianP.multiply(Jac.transpose()));
    // Process noise matrix
    final RealMatrix cartesianQ = MatrixUtils.createRealDiagonalMatrix(new double[] { 1.e-6, 1.e-6, 1.e-6, 1.e-12, 1.e-12, 1.e-12 });
    final RealMatrix Q = Jac.multiply(cartesianQ.multiply(Jac.transpose()));
    // Build the Kalman filter
    final KalmanEstimatorBuilder kalmanBuilder = new KalmanEstimatorBuilder();
    kalmanBuilder.builder(propagatorBuilder);
    kalmanBuilder.estimatedMeasurementsParameters(new ParameterDriversList());
    kalmanBuilder.initialCovarianceMatrix(initialP);
    kalmanBuilder.processNoiseMatrixProvider(new ConstantProcessNoise(Q));
    final KalmanEstimator kalman = kalmanBuilder.build();
    // Filter the measurements and check the results
    final double expectedDeltaPos = 0.;
    final double posEps = 1.53e-5;
    final double expectedDeltaVel = 0.;
    final double velEps = 5.04e-9;
    final double[] expectedSigmasPos = { 0.356902, 1.297507, 1.798551 };
    final double sigmaPosEps = 1e-6;
    final double[] expectedSigmasVel = { 2.468745e-4, 5.810027e-4, 3.887394e-4 };
    final double sigmaVelEps = 1e-10;
    EstimationTestUtils.checkKalmanFit(context, kalman, measurements, refOrbit, positionAngle, expectedDeltaPos, posEps, expectedDeltaVel, velEps, expectedSigmasPos, sigmaPosEps, expectedSigmasVel, sigmaVelEps);
}
Also used : Context(org.orekit.estimation.Context) Orbit(org.orekit.orbits.Orbit) AngularRaDecMeasurementCreator(org.orekit.estimation.measurements.AngularRaDecMeasurementCreator) PositionAngle(org.orekit.orbits.PositionAngle) RealMatrix(org.hipparchus.linear.RealMatrix) NumericalPropagator(org.orekit.propagation.numerical.NumericalPropagator) ParameterDriversList(org.orekit.utils.ParameterDriversList) NumericalPropagatorBuilder(org.orekit.propagation.conversion.NumericalPropagatorBuilder) Propagator(org.orekit.propagation.Propagator) NumericalPropagator(org.orekit.propagation.numerical.NumericalPropagator) OrbitType(org.orekit.orbits.OrbitType) ObservedMeasurement(org.orekit.estimation.measurements.ObservedMeasurement) Test(org.junit.Test)

Example 63 with Context

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

the class PVTest method testPVWithSingleStandardDeviations.

/**
 * Test the PV constructor with standard deviations for position and velocity given as 2 double.
 * @throws OrekitException
 */
@Test
public void testPVWithSingleStandardDeviations() throws OrekitException {
    // Context
    Context context = EstimationTestUtils.eccentricContext("regular-data:potential:tides");
    // Dummy P, V, T
    final Vector3D position = context.initialOrbit.getPVCoordinates().getPosition();
    final Vector3D velocity = context.initialOrbit.getPVCoordinates().getVelocity();
    final AbsoluteDate date = context.initialOrbit.getDate();
    // Initialize standard deviations and weight
    final double sigmaP = 10.;
    final double sigmaV = 0.1;
    final double baseWeight = 0.5;
    // Reference covariance matrix and correlation coefficients
    final double[][] Pref = new double[6][6];
    for (int i = 0; i < 3; i++) {
        Pref[i][i] = FastMath.pow(sigmaP, 2);
        Pref[i + 3][i + 3] = FastMath.pow(sigmaV, 2);
    }
    final double[][] corrCoefRef = MatrixUtils.createRealIdentityMatrix(6).getData();
    // Reference propagator numbers
    final int[] propNumRef = { 0, 2 };
    // Create PV measurements
    final PV[] pvs = new PV[2];
    pvs[0] = new PV(date, position, velocity, sigmaP, sigmaV, baseWeight);
    pvs[1] = new PV(date, position, velocity, sigmaP, sigmaV, baseWeight, propNumRef[1]);
    // Tolerance
    // tolerance
    final double eps = 1e-20;
    // Check data
    for (int k = 0; k < pvs.length; k++) {
        final PV pv = pvs[k];
        // Propagator numbers
        assertEquals(propNumRef[k], pv.getPropagatorsIndices().get(0), eps);
        // Weights
        for (int i = 0; i < 6; i++) {
            assertEquals(baseWeight, pv.getBaseWeight()[i], eps);
        }
        // Sigmas
        for (int i = 0; i < 3; i++) {
            assertEquals(sigmaP, pv.getTheoreticalStandardDeviation()[i], eps);
            assertEquals(sigmaV, pv.getTheoreticalStandardDeviation()[i + 3], eps);
        }
        // Covariances
        final double[][] P = pv.getCovarianceMatrix();
        // Substract with ref and get the norm
        final double normP = MatrixUtils.createRealMatrix(P).subtract(MatrixUtils.createRealMatrix(Pref)).getNorm();
        assertEquals(0., normP, eps);
        // Correlation coef
        final double[][] corrCoef = pv.getCorrelationCoefficientsMatrix();
        // Substract with ref and get the norm
        final double normCorrCoef = MatrixUtils.createRealMatrix(corrCoef).subtract(MatrixUtils.createRealMatrix(corrCoefRef)).getNorm();
        assertEquals(0., normCorrCoef, eps);
    }
}
Also used : Context(org.orekit.estimation.Context) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 64 with Context

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

the class PVTest method testPVWithVectorStandardDeviations.

/**
 * Test the PV constructor with standard deviations for position and velocity given as a 6-sized vector.
 * @throws OrekitException
 */
@Test
public void testPVWithVectorStandardDeviations() throws OrekitException {
    // Context
    Context context = EstimationTestUtils.eccentricContext("regular-data:potential:tides");
    // Dummy P, V, T
    final Vector3D position = context.initialOrbit.getPVCoordinates().getPosition();
    final Vector3D velocity = context.initialOrbit.getPVCoordinates().getVelocity();
    final AbsoluteDate date = context.initialOrbit.getDate();
    // Initialize standard deviations and weight
    final double[] sigmaP = { 10., 20., 30. };
    final double[] sigmaV = { 0.1, 0.2, 0.3 };
    final double[] sigmaPV = { 10., 20., 30., 0.1, 0.2, 0.3 };
    final double baseWeight = 0.5;
    // Reference covariance matrix and correlation coefficients
    final double[][] Pref = new double[6][6];
    for (int i = 0; i < 3; i++) {
        Pref[i][i] = FastMath.pow(sigmaP[i], 2);
        Pref[i + 3][i + 3] = FastMath.pow(sigmaV[i], 2);
    }
    final double[][] corrCoefRef = MatrixUtils.createRealIdentityMatrix(6).getData();
    // Reference propagator numbers
    final int[] propNumRef = { 0, 2, 0, 10 };
    // Create PV measurements
    final PV[] pvs = new PV[4];
    pvs[0] = new PV(date, position, velocity, sigmaP, sigmaV, baseWeight);
    pvs[1] = new PV(date, position, velocity, sigmaP, sigmaV, baseWeight, propNumRef[1]);
    pvs[2] = new PV(date, position, velocity, sigmaPV, baseWeight);
    pvs[3] = new PV(date, position, velocity, sigmaPV, baseWeight, propNumRef[3]);
    // Tolerance
    // tolerance
    final double eps = 1e-20;
    // Check data
    for (int k = 0; k < pvs.length; k++) {
        final PV pv = pvs[k];
        // Propagator numbers
        assertEquals(propNumRef[k], pv.getPropagatorsIndices().get(0), eps);
        // Weights
        for (int i = 0; i < 6; i++) {
            assertEquals(baseWeight, pv.getBaseWeight()[i], eps);
        }
        // Sigmas
        for (int i = 0; i < 3; i++) {
            assertEquals(sigmaP[i], pv.getTheoreticalStandardDeviation()[i], eps);
            assertEquals(sigmaV[i], pv.getTheoreticalStandardDeviation()[i + 3], eps);
        }
        // Covariances
        final double[][] P = pv.getCovarianceMatrix();
        // Substract with ref and get the norm
        final double normP = MatrixUtils.createRealMatrix(P).subtract(MatrixUtils.createRealMatrix(Pref)).getNorm();
        assertEquals(0., normP, eps);
        // Correlation coef
        final double[][] corrCoef = pv.getCorrelationCoefficientsMatrix();
        // Substract with ref and get the norm
        final double normCorrCoef = MatrixUtils.createRealMatrix(corrCoef).subtract(MatrixUtils.createRealMatrix(corrCoefRef)).getNorm();
        assertEquals(0., normCorrCoef, eps);
    }
}
Also used : Context(org.orekit.estimation.Context) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 65 with Context

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

the class PVTest method testPVWithTwoCovarianceMatrices.

/**
 * Test the PV constructor with two 3x3 covariance matrix (one for position, the other for velocity) as input.
 * @throws OrekitException
 */
@Test
public void testPVWithTwoCovarianceMatrices() throws OrekitException {
    // Context
    Context context = EstimationTestUtils.eccentricContext("regular-data:potential:tides");
    // Dummy P, V, T
    final Vector3D position = context.initialOrbit.getPVCoordinates().getPosition();
    final Vector3D velocity = context.initialOrbit.getPVCoordinates().getVelocity();
    final AbsoluteDate date = context.initialOrbit.getDate();
    // Initialize standard deviations and weight
    final double[][] positionP = { { 100., 400., 1200. }, { 400., 400., 1800. }, { 1200., 1800., 900. } };
    final double[][] velocityP = { { 0.01, 0.04, 0.12 }, { 0.04, 0.04, 0.18 }, { 0.12, 0.18, 0.09 } };
    final double baseWeight = 0.5;
    // Reference covariance matrix and correlation coefficients
    final double[][] Pref = new double[6][6];
    for (int i = 0; i < 3; i++) {
        for (int j = i; j < 3; j++) {
            Pref[i][j] = positionP[i][j];
            Pref[j][i] = positionP[i][j];
            Pref[i + 3][j + 3] = velocityP[i][j];
            Pref[j + 3][i + 3] = velocityP[i][j];
        }
    }
    final double[][] corrCoefRef3 = { { 1., 2., 4. }, { 2., 1., 3. }, { 4., 3., 1. } };
    final double[][] corrCoefRef = new double[6][6];
    for (int i = 0; i < 3; i++) {
        for (int j = i; j < 3; j++) {
            corrCoefRef[i][j] = corrCoefRef3[i][j];
            corrCoefRef[j][i] = corrCoefRef3[i][j];
            corrCoefRef[i + 3][j + 3] = corrCoefRef3[i][j];
            corrCoefRef[j + 3][i + 3] = corrCoefRef3[i][j];
        }
    }
    // Reference propagator numbers
    final int[] propNumRef = { 0, 2 };
    // Reference standard deviations
    final double[] sigmaP = { 10., 20., 30. };
    final double[] sigmaV = { 0.1, 0.2, 0.3 };
    // Create PV measurements
    final PV[] pvs = new PV[2];
    pvs[0] = new PV(date, position, velocity, positionP, velocityP, baseWeight);
    pvs[1] = new PV(date, position, velocity, positionP, velocityP, baseWeight, propNumRef[1]);
    // Tolerance
    // tolerance
    final double eps = 6.7e-16;
    // Check data
    for (int k = 0; k < pvs.length; k++) {
        final PV pv = pvs[k];
        // Propagator numbers
        assertEquals(propNumRef[k], pv.getPropagatorsIndices().get(0), eps);
        // Weights
        for (int i = 0; i < 6; i++) {
            assertEquals(baseWeight, pv.getBaseWeight()[i], eps);
        }
        // Sigmas
        for (int i = 0; i < 3; i++) {
            assertEquals(sigmaP[i], pv.getTheoreticalStandardDeviation()[i], eps);
            assertEquals(sigmaV[i], pv.getTheoreticalStandardDeviation()[i + 3], eps);
        }
        // Covariances
        final double[][] P = pv.getCovarianceMatrix();
        // Substract with ref and get the norm
        final double normP = MatrixUtils.createRealMatrix(P).subtract(MatrixUtils.createRealMatrix(Pref)).getNorm();
        assertEquals(0., normP, eps);
        // Correlation coef
        final double[][] corrCoef = pv.getCorrelationCoefficientsMatrix();
        // Substract with ref and get the norm
        final double normCorrCoef = MatrixUtils.createRealMatrix(corrCoef).subtract(MatrixUtils.createRealMatrix(corrCoefRef)).getNorm();
        assertEquals(0., normCorrCoef, eps);
    }
}
Also used : Context(org.orekit.estimation.Context) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Aggregations

Context (org.orekit.estimation.Context)74 Propagator (org.orekit.propagation.Propagator)67 NumericalPropagatorBuilder (org.orekit.propagation.conversion.NumericalPropagatorBuilder)67 Test (org.junit.Test)60 AbsoluteDate (org.orekit.time.AbsoluteDate)49 ObservedMeasurement (org.orekit.estimation.measurements.ObservedMeasurement)40 SpacecraftState (org.orekit.propagation.SpacecraftState)35 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)28 ParameterDriver (org.orekit.utils.ParameterDriver)21 OrekitException (org.orekit.errors.OrekitException)18 Median (org.hipparchus.stat.descriptive.rank.Median)17 RangeMeasurementCreator (org.orekit.estimation.measurements.RangeMeasurementCreator)17 Orbit (org.orekit.orbits.Orbit)17 ParameterDriversList (org.orekit.utils.ParameterDriversList)16 ArrayList (java.util.ArrayList)14 Max (org.hipparchus.stat.descriptive.rank.Max)14 BoundedPropagator (org.orekit.propagation.BoundedPropagator)13 RealMatrix (org.hipparchus.linear.RealMatrix)12 LevenbergMarquardtOptimizer (org.hipparchus.optim.nonlinear.vector.leastsquares.LevenbergMarquardtOptimizer)12 StateFunction (org.orekit.utils.StateFunction)11