Commit 9ad52251 authored by Luc Maisonobe's avatar Luc Maisonobe

Improved phase measurement.

parent 0e52bb52
......@@ -47,7 +47,7 @@ import org.orekit.utils.TimeStampedPVCoordinates;
* @author Thierry Ceolin
* @author Luc Maisonobe
* @author Maxime Journot
* @since 8.0
* @since 9.2
*/
public class Phase extends AbstractMeasurement<Phase> {
......@@ -89,7 +89,6 @@ public class Phase extends AbstractMeasurement<Phase> {
* @param propagatorIndex index of the propagator related to this measurement
* @exception OrekitException if a {@link org.orekit.utils.ParameterDriver}
* name conflict occurs
* @since 9.0
*/
public Phase(final GroundStation station, final AbsoluteDate date,
final double phase, final double wavelength, final double sigma,
......@@ -105,7 +104,7 @@ public class Phase extends AbstractMeasurement<Phase> {
station.getPolarDriftXDriver(),
station.getPolarOffsetYDriver(),
station.getPolarDriftYDriver());
this.station = station;
this.station = station;
this.wavelength = wavelength;
}
......@@ -184,8 +183,8 @@ public class Phase extends AbstractMeasurement<Phase> {
});
// Phase value
final double cOver2 = Constants.SPEED_OF_LIGHT / wavelength;
final DerivativeStructure phase = tauD.multiply(cOver2);
final double cOverLambda = Constants.SPEED_OF_LIGHT / wavelength;
final DerivativeStructure phase = tauD.multiply(cOverLambda);
estimated.setEstimatedValue(phase.getValue());
......
/* Copyright 2002-2018 CS Systèmes d'Information
* Licensed to CS Systèmes d'Information (CS) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* CS licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.orekit.estimation.measurements.modifiers;
import java.util.Collections;
import java.util.List;
import org.hipparchus.util.FastMath;
import org.orekit.errors.OrekitException;
import org.orekit.estimation.measurements.EstimatedMeasurement;
import org.orekit.estimation.measurements.EstimationModifier;
import org.orekit.estimation.measurements.Phase;
import org.orekit.utils.ParameterDriver;
/** Class modifying theoretical phase measurement with ambiguity.
*
* @author Luc Maisonobe
* @since 9.2
*/
public class PhaseAmbiguityModifier implements EstimationModifier<Phase> {
/** Ambiguity scale factor.
* <p>
* We use a power of 2 to avoid numeric noise introduction
* in the multiplications/divisions sequences.
* </p>
*/
private static final double AMBIGUITY_SCALE = FastMath.scalb(1.0, 26);
/** Ambiguity parameter. */
private final ParameterDriver ambiguity;
/** Constructor.
* <p>
* It is expected that many different ambiguities will be used at the
* same time during an orbit determination, therefore they are keyed
* using a simple integer. All ambiguities using the same key will
* be enforced to be equal. It is the responsibility of the caller to
* use a proper counter to manage the ambiguities properly.
* </p>
* @param key key to identify the ambiguity
* @param ambiguity initial value of ambiguity
* @exception OrekitException if parameter scale is too close to zero (never happens)
*/
public PhaseAmbiguityModifier(final int key, final double ambiguity)
throws OrekitException {
this.ambiguity = new ParameterDriver("amgiguity-" + key,
ambiguity, AMBIGUITY_SCALE,
Double.NEGATIVE_INFINITY,
Double.POSITIVE_INFINITY);
}
/** {@inheritDoc} */
@Override
public List<ParameterDriver> getParametersDrivers() {
return Collections.singletonList(ambiguity);
}
@Override
public void modify(final EstimatedMeasurement<Phase> estimated)
throws OrekitException {
// apply the ambiguity to the measurement value
final double[] value = estimated.getEstimatedValue();
value[0] += ambiguity.getValue();
if (ambiguity.isSelected()) {
// add the partial derivatives
estimated.setParameterDerivatives(ambiguity, 1.0);
}
estimated.setEstimatedValue(value);
}
}
/* Copyright 2002-2018 CS Systèmes d'Information
* Licensed to CS Systèmes d'Information (CS) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* CS licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.orekit.estimation.measurements;
import java.util.Arrays;
import org.hipparchus.analysis.UnivariateFunction;
import org.hipparchus.analysis.solvers.BracketingNthOrderBrentSolver;
import org.hipparchus.analysis.solvers.UnivariateSolver;
import org.hipparchus.geometry.euclidean.threed.Vector3D;
import org.hipparchus.util.FastMath;
import org.orekit.errors.OrekitException;
import org.orekit.errors.OrekitExceptionWrapper;
import org.orekit.estimation.Context;
import org.orekit.estimation.measurements.modifiers.PhaseAmbiguityModifier;
import org.orekit.frames.Frame;
import org.orekit.frames.Transform;
import org.orekit.gnss.Frequency;
import org.orekit.propagation.SpacecraftState;
import org.orekit.time.AbsoluteDate;
import org.orekit.utils.Constants;
import org.orekit.utils.ParameterDriver;
public class PhaseMeasurementCreator extends MeasurementCreator {
private final Context context;
private final double wavelength;
private final PhaseAmbiguityModifier ambiguity;
private final Vector3D antennaPhaseCenter;
public PhaseMeasurementCreator(final Context context, final Frequency frequency, final int ambiguity)
throws OrekitException {
this(context, frequency, ambiguity, Vector3D.ZERO);
}
public PhaseMeasurementCreator(final Context context, final Frequency frequency,
final int ambiguity, final Vector3D antennaPhaseCenter)
throws OrekitException {
this.context = context;
this.wavelength = Constants.SPEED_OF_LIGHT / (1.0e6 * frequency.getMHzFrequency());
this.ambiguity = new PhaseAmbiguityModifier(0, ambiguity);
this.antennaPhaseCenter = antennaPhaseCenter;
}
public void init(SpacecraftState s0, AbsoluteDate t, double step) {
for (final GroundStation station : context.stations) {
for (ParameterDriver driver : Arrays.asList(station.getEastOffsetDriver(),
station.getNorthOffsetDriver(),
station.getZenithOffsetDriver(),
station.getPrimeMeridianOffsetDriver(),
station.getPrimeMeridianDriftDriver(),
station.getPolarOffsetXDriver(),
station.getPolarDriftXDriver(),
station.getPolarOffsetYDriver(),
station.getPolarDriftYDriver())) {
if (driver.getReferenceDate() == null) {
driver.setReferenceDate(s0.getDate());
}
}
}
}
public void handleStep(final SpacecraftState currentState, final boolean isLast)
throws OrekitException {
try {
double n = ambiguity.getParametersDrivers().get(0).getValue();
for (final GroundStation station : context.stations) {
final AbsoluteDate date = currentState.getDate();
final Frame inertial = currentState.getFrame();
final Vector3D position = currentState.toTransform().getInverse().transformPosition(antennaPhaseCenter);
if (station.getBaseFrame().getElevation(position, inertial, date) > FastMath.toRadians(30.0)) {
final UnivariateSolver solver = new BracketingNthOrderBrentSolver(1.0e-12, 5);
final double downLinkDelay = solver.solve(1000, new UnivariateFunction() {
public double value(final double x) throws OrekitExceptionWrapper {
try {
final Transform t = station.getOffsetToInertial(inertial, date.shiftedBy(x));
final double d = Vector3D.distance(position, t.transformPosition(Vector3D.ZERO));
return d - x * Constants.SPEED_OF_LIGHT;
} catch (OrekitException oe) {
throw new OrekitExceptionWrapper(oe);
}
}
}, -1.0, 1.0);
final AbsoluteDate receptionDate = currentState.getDate().shiftedBy(downLinkDelay);
final Vector3D stationAtReception =
station.getOffsetToInertial(inertial, receptionDate).transformPosition(Vector3D.ZERO);
final double downLinkDistance = Vector3D.distance(position, stationAtReception);
final Phase phase = new Phase(station, receptionDate,
downLinkDistance / wavelength - n,
wavelength, 1.0, 10);
phase.addModifier(ambiguity);
addMeasurement(phase);
}
}
} catch (OrekitExceptionWrapper oew) {
throw new OrekitException(oew.getException());
} catch (OrekitException oe) {
throw new OrekitException(oe);
}
}
}
/* Copyright 2002-2018 CS Systèmes d'Information
* Licensed to CS Systèmes d'Information (CS) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* CS licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.orekit.estimation.measurements;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Locale;
import org.hipparchus.stat.descriptive.moment.Mean;
import org.hipparchus.stat.descriptive.rank.Max;
import org.hipparchus.stat.descriptive.rank.Median;
import org.hipparchus.stat.descriptive.rank.Min;
import org.hipparchus.util.FastMath;
import org.junit.Assert;
import org.junit.Test;
import org.orekit.errors.OrekitException;
import org.orekit.estimation.Context;
import org.orekit.estimation.EstimationTestUtils;
import org.orekit.gnss.Frequency;
import org.orekit.orbits.OrbitType;
import org.orekit.orbits.PositionAngle;
import org.orekit.propagation.Propagator;
import org.orekit.propagation.SpacecraftState;
import org.orekit.propagation.conversion.NumericalPropagatorBuilder;
import org.orekit.propagation.sampling.OrekitStepInterpolator;
import org.orekit.time.AbsoluteDate;
import org.orekit.utils.Constants;
import org.orekit.utils.Differentiation;
import org.orekit.utils.ParameterDriver;
import org.orekit.utils.ParameterFunction;
import org.orekit.utils.StateFunction;
import org.orekit.utils.TimeStampedPVCoordinates;
public class PhaseTest {
/**
* Test the values of the phase comparing the observed values and the estimated values
* Both are calculated with a different algorithm
* @throws OrekitException
*/
@Test
public void testValues() throws OrekitException {
boolean printResults = false;
if (printResults) {
System.out.println("\nTest Phase Values\n");
}
// Run test
this.genericTestValues(printResults);
}
/**
* Test the values of the state derivatives using a numerical
* finite differences calculation as a reference
* @throws OrekitException
*/
@Test
public void testStateDerivatives() throws OrekitException {
boolean printResults = false;
if (printResults) {
System.out.println("\nTest Range Phase Derivatives - Finite Differences Comparison\n");
}
// Run test
double refErrorsPMedian = 1.1e-09;
double refErrorsPMean = 6.3e-09;
double refErrorsPMax = 4.3e-07;
double refErrorsVMedian = 1.4e-05;
double refErrorsVMean = 5.9e-05;
double refErrorsVMax = 2.2e-03;
this.genericTestStateDerivatives(printResults,
refErrorsPMedian, refErrorsPMean, refErrorsPMax,
refErrorsVMedian, refErrorsVMean, refErrorsVMax);
}
/**
* Test the values of the state derivatives with modifier using a numerical
* finite differences calculation as a reference
* @throws OrekitException
*/
@Test
public void testStateDerivativesWithModifier() throws OrekitException {
boolean printResults = false;
if (printResults) {
System.out.println("\nTest Phase State Derivatives with Modifier - Finite Differences Comparison\n");
}
// Run test
double refErrorsPMedian = 1.1e-09;
double refErrorsPMean = 6.3e-09;
double refErrorsPMax = 4.3e-07;
double refErrorsVMedian = 1.4e-05;
double refErrorsVMean = 5.9e-05;
double refErrorsVMax = 2.2e-03;
this.genericTestStateDerivatives(printResults,
refErrorsPMedian, refErrorsPMean, refErrorsPMax,
refErrorsVMedian, refErrorsVMean, refErrorsVMax);
}
/**
* Test the values of the parameters' derivatives using a numerical
* finite differences calculation as a reference
* @throws OrekitException
*/
@Test
public void testParameterDerivatives() throws OrekitException {
// Print the results ?
boolean printResults = false;
if (printResults) {
System.out.println("\nTest Phase Parameter Derivatives - Finite Differences Comparison\n");
}
// Run test
double refErrorsMedian = 1.1e-8;
double refErrorsMean = 8.2e-8;
double refErrorsMax = 5.1e-6;
this.genericTestParameterDerivatives(printResults,
refErrorsMedian, refErrorsMean, refErrorsMax);
}
/**
* Generic test function for values of the phase
* @param printResults Print the results ?
* @throws OrekitException
*/
void genericTestValues(final boolean printResults)
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 phase measurements
final Propagator propagator = EstimationTestUtils.createPropagator(context.initialOrbit,
propagatorBuilder);
final int ambiguity = 0;
final List<ObservedMeasurement<?>> measurements =
EstimationTestUtils.createMeasurements(propagator,
new PhaseMeasurementCreator(context,
Frequency.E01,
ambiguity),
1.0, 3.0, 300.0);
// Lists for results' storage - Used only for derivatives with respect to state
// "final" value to be seen by "handleStep" function of the propagator
final List<Double> absoluteErrors = new ArrayList<Double>();
final List<Double> relativeErrors = new ArrayList<Double>();
// Set master mode
// Use a lambda function to implement "handleStep" function
propagator.setMasterMode((OrekitStepInterpolator interpolator, boolean isLast) -> {
for (final ObservedMeasurement<?> measurement : measurements) {
// Play test if the measurement date is between interpolator previous and current date
if ((measurement.getDate().durationFrom(interpolator.getPreviousState().getDate()) > 0.) &&
(measurement.getDate().durationFrom(interpolator.getCurrentState().getDate()) <= 0.)
) {
// We intentionally propagate to a date which is close to the
// real spacecraft state but is *not* the accurate date, by
// compensating only part of the downlink delay. This is done
// in order to validate the partial derivatives with respect
// to velocity. If we had chosen the proper state date, the
// range would have depended only on the current position but
// not on the current velocity.
final double meanDelay = measurement.getObservedValue()[0] / Constants.SPEED_OF_LIGHT;
final AbsoluteDate date = measurement.getDate().shiftedBy(-0.75 * meanDelay);
final SpacecraftState state = interpolator.getInterpolatedState(date);
// Values of the Phase & errors
final double phaseObserved = measurement.getObservedValue()[0];
final EstimatedMeasurement<?> estimated = measurement.estimate(0, 0, new SpacecraftState[] { state });
final TimeStampedPVCoordinates[] participants = estimated.getParticipants();
Assert.assertEquals(2, participants.length);
Assert.assertEquals(1.0e6 * Frequency.E01.getMHzFrequency() * participants[1].getDate().durationFrom(participants[0].getDate()),
estimated.getEstimatedValue()[0] - ambiguity,
1.0e-7);
final double phaseEstimated = estimated.getEstimatedValue()[0] - ambiguity;
final double absoluteError = phaseEstimated - phaseObserved;
absoluteErrors.add(absoluteError);
relativeErrors.add(FastMath.abs(absoluteError) / FastMath.abs(phaseObserved));
// Print results on console ?
if (printResults) {
final AbsoluteDate measurementDate = measurement.getDate();
String stationName = ((Phase) measurement).getStation().getBaseFrame().getName();
System.out.format(Locale.US, "%-15s %-23s %-23s %19.6f %19.6f %13.6e %13.6e%n",
stationName, measurementDate, date,
phaseObserved, phaseEstimated,
FastMath.abs(phaseEstimated - phaseObserved),
FastMath.abs((phaseEstimated - phaseObserved) / phaseObserved));
}
} // End if measurement date between previous and current interpolator step
} // End for loop on the measurements
}); // End lambda function handlestep
// Print results on console ? Header
if (printResults) {
System.out.format(Locale.US, "%-15s %-23s %-23s %19s %19s %13s %13s%n",
"Station", "Measurement Date", "State Date",
"Range observed [m]", "Phase estimated [m]",
"ΔPhase [m]", "rel ΔPhase");
}
// Rewind the propagator to initial date
propagator.propagate(context.initialOrbit.getDate());
// Sort measurements chronologically
measurements.sort(Comparator.naturalOrder());
// Propagate to final measurement's date
propagator.propagate(measurements.get(measurements.size()-1).getDate());
// Convert lists to double array
final double[] absErrors = absoluteErrors.stream().mapToDouble(Double::doubleValue).toArray();
final double[] relErrors = relativeErrors.stream().mapToDouble(Double::doubleValue).toArray();
// Statistics' assertion
final double absErrorsMedian = new Median().evaluate(absErrors);
final double absErrorsMin = new Min().evaluate(absErrors);
final double absErrorsMax = new Max().evaluate(absErrors);
final double relErrorsMedian = new Median().evaluate(relErrors);
final double relErrorsMax = new Max().evaluate(relErrors);
// Print the results on console ? Final results
if (printResults) {
System.out.println();
System.out.println("Absolute errors median: " + absErrorsMedian);
System.out.println("Absolute errors min : " + absErrorsMin);
System.out.println("Absolute errors max : " + absErrorsMax);
System.out.println("Relative errors median: " + relErrorsMedian);
System.out.println("Relative errors max : " + relErrorsMax);
}
Assert.assertEquals(0.0, absErrorsMedian, 1.6e-7);
Assert.assertEquals(0.0, absErrorsMin, 1.2e-6);
Assert.assertEquals(0.0, absErrorsMax, 1.5e-6);
Assert.assertEquals(0.0, relErrorsMedian, 9.3e-15);
Assert.assertEquals(0.0, relErrorsMax, 2.6e-14);
}
void genericTestStateDerivatives(final boolean printResults,
final double refErrorsPMedian, final double refErrorsPMean, final double refErrorsPMax,
final double refErrorsVMedian, final double refErrorsVMean, final double refErrorsVMax)
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 int ambiguity = 123456789;
final List<ObservedMeasurement<?>> measurements =
EstimationTestUtils.createMeasurements(propagator,
new PhaseMeasurementCreator(context,
Frequency.E01,
ambiguity),
1.0, 3.0, 300.0);
// Lists for results' storage - Used only for derivatives with respect to state
// "final" value to be seen by "handleStep" function of the propagator
final List<Double> errorsP = new ArrayList<Double>();
final List<Double> errorsV = new ArrayList<Double>();
// Set master mode
// Use a lambda function to implement "handleStep" function
propagator.setMasterMode((OrekitStepInterpolator interpolator, boolean isLast) -> {
for (final ObservedMeasurement<?> measurement : measurements) {
// Play test if the measurement date is between interpolator previous and current date
if ((measurement.getDate().durationFrom(interpolator.getPreviousState().getDate()) > 0.) &&
(measurement.getDate().durationFrom(interpolator.getCurrentState().getDate()) <= 0.)
) {
// We intentionally propagate to a date which is close to the
// real spacecraft state but is *not* the accurate date, by
// compensating only part of the downlink delay. This is done
// in order to validate the partial derivatives with respect
// to velocity. If we had chosen the proper state date, the
// range would have depended only on the current position but
// not on the current velocity.
final double meanDelay = measurement.getObservedValue()[0] / Constants.SPEED_OF_LIGHT;
final AbsoluteDate date = measurement.getDate().shiftedBy(-0.75 * meanDelay);
final SpacecraftState state = interpolator.getInterpolatedState(date);
final double[][] jacobian = measurement.estimate(0, 0, new SpacecraftState[] { state }).getStateDerivatives(0);
// Jacobian reference value
final double[][] jacobianRef;
// Compute a reference value using finite differences
jacobianRef = Differentiation.differentiate(new StateFunction() {
public double[] value(final SpacecraftState state) throws OrekitException {
return measurement.estimate(0, 0, new SpacecraftState[] { state }).getEstimatedValue();
}
}, measurement.getDimension(), propagator.getAttitudeProvider(),
OrbitType.CARTESIAN, PositionAngle.TRUE, 2.0, 3).value(state);
Assert.assertEquals(jacobianRef.length, jacobian.length);
Assert.assertEquals(jacobianRef[0].length, jacobian[0].length);
// Errors & relative errors on the Jacobian
double [][] dJacobian = new double[jacobian.length][jacobian[0].length];
double [][] dJacobianRelative = new double[jacobian.length][jacobian[0].length];
for (int i = 0; i < jacobian.length; ++i) {
for (int j = 0; j < jacobian[i].length; ++j) {
dJacobian[i][j] = jacobian[i][j] - jacobianRef[i][j];
dJacobianRelative[i][j] = FastMath.abs(dJacobian[i][j]/jacobianRef[i][j]);
if (j < 3) { errorsP.add(dJacobianRelative[i][j]);
} else { errorsV.add(dJacobianRelative[i][j]); }
}
}
// Print values in console ?
if (printResults) {
String stationName = ((Phase) measurement).getStation().getBaseFrame().getName();
System.out.format(Locale.US, "%-15s %-23s %-23s " +
"%10.3e %10.3e %10.3e " +
"%10.3e %10.3e %10.3e " +
"%10.3e %10.3e %10.3e " +
"%10.3e %10.3e %10.3e%n",
stationName, measurement.getDate(), date,
dJacobian[0][0], dJacobian[0][1], dJacobian[0][2],
dJacobian[0][3], dJacobian[0][4], dJacobian[0][5],
dJacobianRelative[0][0], dJacobianRelative[0][1], dJacobianRelative[0][2],
dJacobianRelative[0][3], dJacobianRelative[0][4], dJacobianRelative[0][5]);
}
} // End if measurement date between previous and current interpolator step
} // End for loop on the measurements
});
// Print results on console ?
if (printResults) {
System.out.format(Locale.US, "%-15s %-23s %-23s " +
"%10s %10s %10s " +
"%10s %10s %10s " +
"%10s %10s %10s " +
"%10s %10s %10s%n",
"Station", "Measurement Date", "State Date",
"ΔdPx", "ΔdPy", "ΔdPz", "ΔdVx", "ΔdVy", "ΔdVz",
"rel ΔdPx", "rel ΔdPy", "rel ΔdPz",
"rel ΔdVx", "rel ΔdVy", "rel ΔdVz");
}
// Rewind the propagator to initial date
propagator.propagate(context.initialOrbit.getDate());
// Sort measurements chronologically
measurements.sort(Comparator.naturalOrder());
// Propagate to final measurement's date
propagator.propagate(measurements.get(measurements.size()-1).getDate());
// Convert lists to double[] and evaluate some statistics
final double relErrorsP[] = errorsP.stream().mapToDouble(Double::doubleValue).toArray();
final double relErrorsV[] = errorsV.stream().mapToDouble(Double::doubleValue).toArray();
final double errorsPMedian = new Median().evaluate(relErrorsP);
final double errorsPMean = new Mean().evaluate(relErrorsP);
final double errorsPMax = new Max().evaluate(relErrorsP);
final double errorsVMedian = new Median().evaluate(relErrorsV);
final double errorsVMean = new Mean().evaluate(relErrorsV);
final double errorsVMax = new Max().evaluate(relErrorsV);
// Print the results on console ?
if (printResults) {
System.out.println();
System.out.format(Locale.US, "Relative errors dΦ/dP -> Median: %6.3e / Mean: %6.3e / Max: %6.3e%n",
errorsPMedian, errorsPMean, errorsPMax);
System.out.format(Locale.US, "Relative errors dΦ/dV -> Median: %6.3e / Mean: %6.3e / Max: %6.3e%n",
errorsVMedian, errorsVMean, errorsVMax);
}
Assert.assertEquals(0.0, errorsPMedian, refErrorsPMedian);
Assert.assertEquals(0.0, errorsPMean, refErrorsPMean);
Assert.assertEquals(0.0, errorsPMax, refErrorsPMax);
Assert.assertEquals(0.0, errorsVMedian, refErrorsVMedian);
Assert.assertEquals(0.0, errorsVMean, refErrorsVMean);
Assert.assertEquals(0.0, errorsVMax, refErrorsVMax);
}
void genericTestParameterDerivatives(final boolean printResults,
final double refErrorsMedian, final double refErrorsMean, final double refErrorsMax)
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 int ambiguity = 123456789;
final List<ObservedMeasurement<?>> measurements =