Commit 400a7593 authored by Luc Maisonobe's avatar Luc Maisonobe

First tests on measurements generation.

parent 65354415
......@@ -61,7 +61,7 @@ public class AngularAzElBuilder extends AbstractMeasurementBuilder<AngularAzEl>
// create a dummy measurement
final AngularAzEl dummy = new AngularAzEl(station, state.getDate(),
new double[] {
Double.NaN, Double.NaN
0.0, 0.0
}, sigma, baseWeight, propagatorIndex);
for (final EstimationModifier<AngularAzEl> modifier : getModifiers()) {
dummy.addModifier(modifier);
......
......@@ -67,7 +67,7 @@ public class AngularRaDecBuilder extends AbstractMeasurementBuilder<AngularRaDec
// create a dummy measurement
final AngularRaDec dummy = new AngularRaDec(station, referenceFrame, state.getDate(),
new double[] {
Double.NaN, Double.NaN
0.0, 0.0
}, sigma, baseWeight, propagatorIndex);
for (final EstimationModifier<AngularRaDec> modifier : getModifiers()) {
dummy.addModifier(modifier);
......
......@@ -109,7 +109,7 @@ public class Generator {
@Override
public void handleStep(final List<OrekitStepInterpolator> interpolators, final boolean isLast) {
for (final Scheduler<?> scheduler : schedulers) {
scheduler.generate(interpolators);
measurements.addAll(scheduler.generate(interpolators));
}
}
......
/* 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.generation;
import java.util.SortedSet;
import org.hipparchus.random.RandomGenerator;
import org.hipparchus.random.Well19937a;
import org.hipparchus.util.FastMath;
import org.junit.Assert;
import org.junit.Before;
import org.orekit.estimation.Context;
import org.orekit.estimation.EstimationTestUtils;
import org.orekit.estimation.Force;
import org.orekit.estimation.measurements.GroundStation;
import org.orekit.estimation.measurements.ObservedMeasurement;
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.events.ElevationDetector;
import org.orekit.propagation.events.handlers.ContinueOnEvent;
import org.orekit.time.AbsoluteDate;
import org.orekit.time.FixedStepSelector;
import org.orekit.time.TimeScalesFactory;
public abstract class AbstractGroundMeasurementBuilderTest<T extends ObservedMeasurement<T>> {
protected abstract MeasurementBuilder<T> getBuilder(RandomGenerator random,
GroundStation groundStation);
private Propagator buildPropagator() {
return EstimationTestUtils.createPropagator(context.initialOrbit, propagatorBuilder);
}
protected void doTest(long seed, double startPeriod, double endPeriod, int expectedMeasurements, double tolerance) {
Generator generator = new Generator();
final double step = 60.0;
generator.addScheduler(new EventBasedScheduler<>(getBuilder(new Well19937a(seed), context.stations.get(0)),
new FixedStepSelector(step, TimeScalesFactory.getUTC()),
buildPropagator(),
new ElevationDetector(context.stations.get(0).getBaseFrame()).
withConstantElevation(FastMath.toRadians(5.0)).
withHandler(new ContinueOnEvent<>()),
SignSemantic.FEASIBLE_MEASUREMENT_WHEN_POSITIVE));
final double period = context.initialOrbit.getKeplerianPeriod();
AbsoluteDate t0 = context.initialOrbit.getDate().shiftedBy(startPeriod * period);
AbsoluteDate t1 = context.initialOrbit.getDate().shiftedBy(endPeriod * period);
SortedSet<ObservedMeasurement<?>> measurements = generator.generate(t0, t1);
Assert.assertEquals(expectedMeasurements, measurements.size());
Propagator propagator = buildPropagator();
double maxError = 0;
AbsoluteDate previous = null;
AbsoluteDate tInf = t0.compareTo(t1) < 0 ? t0 : t1;
AbsoluteDate tSup = t0.compareTo(t1) < 0 ? t1 : t0;
for (ObservedMeasurement<?> measurement : measurements) {
AbsoluteDate date = measurement.getDate();
double[] m = measurement.getObservedValue();
Assert.assertTrue(date.compareTo(tInf) >= 0);
Assert.assertTrue(date.compareTo(tSup) <= 0);
if (previous != null) {
// measurements are always chronological, even with backward propagation,
// due to the SortedSet (which is intended for combining several
// measurements types with different builders and schedulers)
Assert.assertTrue(date.durationFrom(previous) >= 0.999999 * step);
}
previous = date;
SpacecraftState state = propagator.propagate(date);
double[] e = measurement.estimate(0, 0, new SpacecraftState[] { state }).getEstimatedValue();
for (int i = 0; i < m.length; ++i) {
maxError = FastMath.max(maxError, FastMath.abs(e[i] - m[i]));
}
}
Assert.assertEquals(0.0, maxError, tolerance);
}
@Before
public void setUp() {
context = EstimationTestUtils.eccentricContext("regular-data:potential:tides");
propagatorBuilder = context.createBuilder(OrbitType.KEPLERIAN, PositionAngle.TRUE, true,
1.0e-6, 60.0, 0.001, Force.POTENTIAL,
Force.THIRD_BODY_SUN, Force.THIRD_BODY_MOON);
}
Context context;
NumericalPropagatorBuilder propagatorBuilder;
}
/* 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.generation;
import org.hipparchus.linear.MatrixUtils;
import org.hipparchus.linear.RealMatrix;
import org.hipparchus.random.CorrelatedRandomVectorGenerator;
import org.hipparchus.random.GaussianRandomGenerator;
import org.hipparchus.random.RandomGenerator;
import org.junit.Test;
import org.orekit.estimation.measurements.AngularAzEl;
import org.orekit.estimation.measurements.GroundStation;
public class AngularAzElBuilderTest extends AbstractGroundMeasurementBuilderTest<AngularAzEl> {
private static final double SIGMA = 1.0e-3;
protected MeasurementBuilder<AngularAzEl> getBuilder(final RandomGenerator random,
final GroundStation groundStation) {
final RealMatrix covariance = MatrixUtils.createRealDiagonalMatrix(new double[] { SIGMA * SIGMA, SIGMA * SIGMA });
return new AngularAzElBuilder(random == null ? null : new CorrelatedRandomVectorGenerator(covariance,
1.0e-10,
new GaussianRandomGenerator(random)),
groundStation, new double[] { SIGMA, SIGMA}, new double[] { 1.0, 1.0 }, 0);
}
@Test
public void testForward() {
doTest(0x527ebeb15d630624l, 0.4, 0.9, 128, 2.9 * SIGMA);
}
@Test
public void testBackward() {
doTest(0x5300b1314adab8cbl, -0.2, -0.6, 100, 2.6 * SIGMA);
}
}
/* 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.generation;
import org.hipparchus.linear.MatrixUtils;
import org.hipparchus.linear.RealMatrix;
import org.hipparchus.random.CorrelatedRandomVectorGenerator;
import org.hipparchus.random.GaussianRandomGenerator;
import org.hipparchus.random.RandomGenerator;
import org.junit.Test;
import org.orekit.estimation.measurements.AngularRaDec;
import org.orekit.estimation.measurements.GroundStation;
import org.orekit.frames.FramesFactory;
public class AngularRaDecBuilderTest extends AbstractGroundMeasurementBuilderTest<AngularRaDec> {
private static final double SIGMA = 1.0e-3;
protected MeasurementBuilder<AngularRaDec> getBuilder(final RandomGenerator random,
final GroundStation groundStation) {
final RealMatrix covariance = MatrixUtils.createRealDiagonalMatrix(new double[] { SIGMA * SIGMA, SIGMA * SIGMA });
return new AngularRaDecBuilder(random == null ? null : new CorrelatedRandomVectorGenerator(covariance,
1.0e-10,
new GaussianRandomGenerator(random)),
groundStation, FramesFactory.getEME2000(),
new double[] { SIGMA, SIGMA}, new double[] { 1.0, 1.0 }, 0);
}
@Test
public void testForward() {
doTest(0x5c845a8e6a11f7b3l, 0.4, 0.9, 128, 3.1 * SIGMA);
}
@Test
public void testBackward() {
doTest(0x24f750901da8cd2cl, -0.2, -0.6, 100, 2.7 * SIGMA);
}
}
/* 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.generation;
import org.hipparchus.linear.MatrixUtils;
import org.hipparchus.linear.RealMatrix;
import org.hipparchus.random.CorrelatedRandomVectorGenerator;
import org.hipparchus.random.GaussianRandomGenerator;
import org.hipparchus.random.RandomGenerator;
import org.junit.Test;
import org.orekit.estimation.measurements.GroundStation;
import org.orekit.estimation.measurements.Range;
public class RangeBuilderTest extends AbstractGroundMeasurementBuilderTest<Range> {
private static final double SIGMA = 10.0;
protected MeasurementBuilder<Range> getBuilder(final RandomGenerator random,
final GroundStation groundStation) {
final RealMatrix covariance = MatrixUtils.createRealDiagonalMatrix(new double[] { SIGMA * SIGMA });
return new RangeBuilder(random == null ? null : new CorrelatedRandomVectorGenerator(covariance,
1.0e-10,
new GaussianRandomGenerator(random)),
groundStation, true, SIGMA, 1.0, 0);
}
@Test
public void testForward() {
doTest(0x01e226dd859c2c9dl, 0.4, 0.9, 128, 2.7 * SIGMA);
}
@Test
public void testBackward() {
doTest(0xd4e49e3716605903l, -0.2, -0.6, 100, 3.2 * SIGMA);
}
}
/* 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.generation;
import org.hipparchus.linear.MatrixUtils;
import org.hipparchus.linear.RealMatrix;
import org.hipparchus.random.CorrelatedRandomVectorGenerator;
import org.hipparchus.random.GaussianRandomGenerator;
import org.hipparchus.random.RandomGenerator;
import org.junit.Test;
import org.orekit.estimation.measurements.GroundStation;
import org.orekit.estimation.measurements.RangeRate;
public class RangeRateBuilderTest extends AbstractGroundMeasurementBuilderTest<RangeRate> {
private static final double SIGMA = 0.01;
protected MeasurementBuilder<RangeRate> getBuilder(final RandomGenerator random,
final GroundStation groundStation) {
final RealMatrix covariance = MatrixUtils.createRealDiagonalMatrix(new double[] { SIGMA * SIGMA });
return new RangeRateBuilder(random == null ? null : new CorrelatedRandomVectorGenerator(covariance,
1.0e-10,
new GaussianRandomGenerator(random)),
groundStation, true, SIGMA, 1.0, 0);
}
@Test
public void testForward() {
doTest(0x02c925b8812d8992l, 0.4, 0.9, 128, 2.4 * SIGMA);
}
@Test
public void testBackward() {
doTest(0x34ce85d26d51cd91l, -0.2, -0.6, 100, 3.3 * SIGMA);
}
}
/* 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.generation;
import java.util.Map;
import java.util.SortedSet;
import org.hipparchus.linear.MatrixUtils;
import org.hipparchus.linear.RealMatrix;
import org.hipparchus.random.CorrelatedRandomVectorGenerator;
import org.hipparchus.random.GaussianRandomGenerator;
import org.hipparchus.random.RandomGenerator;
import org.hipparchus.random.Well19937a;
import org.hipparchus.util.FastMath;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.orekit.estimation.Context;
import org.orekit.estimation.EstimationTestUtils;
import org.orekit.estimation.Force;
import org.orekit.estimation.measurements.GroundStation;
import org.orekit.estimation.measurements.ObservedMeasurement;
import org.orekit.estimation.measurements.TurnAroundRange;
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.events.BooleanDetector;
import org.orekit.propagation.events.ElevationDetector;
import org.orekit.time.AbsoluteDate;
import org.orekit.time.FixedStepSelector;
import org.orekit.time.TimeScalesFactory;
public class TurnAroundRangeBuilderTest {
private static final double SIGMA = 10.0;
private MeasurementBuilder<TurnAroundRange> getBuilder(final RandomGenerator random,
final GroundStation master,
final GroundStation slave) {
final RealMatrix covariance = MatrixUtils.createRealDiagonalMatrix(new double[] { SIGMA * SIGMA });
return new TurnAroundRangeBuilder(random == null ? null : new CorrelatedRandomVectorGenerator(covariance,
1.0e-10,
new GaussianRandomGenerator(random)),
master, slave, SIGMA, 1.0, 0);
}
@Test
public void testForward() {
doTest(0xf50c0ce7c8c1dab2l, 0.0, 1.2, 123, 3.2 * SIGMA);
}
@Test
public void testBackward() {
doTest(0x453a681440d01832l, 0.0, -1.0, 100, 2.6 * SIGMA);
}
private Propagator buildPropagator() {
return EstimationTestUtils.createPropagator(context.initialOrbit, propagatorBuilder);
}
private void doTest(long seed, double startPeriod, double endPeriod, int expectedMeasurements, double tolerance) {
Generator generator = new Generator();
final double step = 60.0;
final Map.Entry<GroundStation, GroundStation> entry = context.TARstations.entrySet().iterator().next();
final GroundStation master = entry.getKey();
final GroundStation slave = entry.getValue();
generator.addScheduler(new EventBasedScheduler<>(getBuilder(new Well19937a(seed), master, slave),
new FixedStepSelector(step, TimeScalesFactory.getUTC()),
buildPropagator(),
BooleanDetector.andCombine(new ElevationDetector(master.getBaseFrame()).
withConstantElevation(FastMath.toRadians(5.0)),
new ElevationDetector(slave.getBaseFrame()).
withConstantElevation(FastMath.toRadians(5.0))),
SignSemantic.FEASIBLE_MEASUREMENT_WHEN_POSITIVE));
final double period = context.initialOrbit.getKeplerianPeriod();
AbsoluteDate t0 = context.initialOrbit.getDate().shiftedBy(startPeriod * period);
AbsoluteDate t1 = context.initialOrbit.getDate().shiftedBy(endPeriod * period);
SortedSet<ObservedMeasurement<?>> measurements = generator.generate(t0, t1);
Assert.assertEquals(expectedMeasurements, measurements.size());
Propagator propagator = buildPropagator();
double maxError = 0;
AbsoluteDate previous = null;
AbsoluteDate tInf = t0.compareTo(t1) < 0 ? t0 : t1;
AbsoluteDate tSup = t0.compareTo(t1) < 0 ? t1 : t0;
for (ObservedMeasurement<?> measurement : measurements) {
AbsoluteDate date = measurement.getDate();
double[] m = measurement.getObservedValue();
Assert.assertTrue(date.compareTo(tInf) >= 0);
Assert.assertTrue(date.compareTo(tSup) <= 0);
if (previous != null) {
// measurements are always chronological, even with backward propagation,
// due to the SortedSet (which is intended for combining several
// measurements types with different builders and schedulers)
Assert.assertTrue(date.durationFrom(previous) >= 0.999999 * step);
}
previous = date;
SpacecraftState state = propagator.propagate(date);
double[] e = measurement.estimate(0, 0, new SpacecraftState[] { state }).getEstimatedValue();
for (int i = 0; i < m.length; ++i) {
maxError = FastMath.max(maxError, FastMath.abs(e[i] - m[i]));
}
}
Assert.assertEquals(0.0, maxError, tolerance);
}
@Before
public void setUp() {
context = EstimationTestUtils.eccentricContext("regular-data:potential:tides");
propagatorBuilder = context.createBuilder(OrbitType.KEPLERIAN, PositionAngle.TRUE, true,
1.0e-6, 60.0, 0.001, Force.POTENTIAL,
Force.THIRD_BODY_SUN, Force.THIRD_BODY_MOON);
}
Context context;
NumericalPropagatorBuilder propagatorBuilder;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment