1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.orekit.estimation.measurements.generation;
18
19 import org.hipparchus.util.FastMath;
20 import org.junit.jupiter.api.Assertions;
21 import org.junit.jupiter.api.BeforeEach;
22 import org.junit.jupiter.api.Test;
23 import org.orekit.estimation.Context;
24 import org.orekit.estimation.EstimationTestUtils;
25 import org.orekit.estimation.Force;
26 import org.orekit.estimation.measurements.AngularAzEl;
27 import org.orekit.estimation.measurements.EstimatedMeasurementBase;
28 import org.orekit.estimation.measurements.ObservableSatellite;
29 import org.orekit.estimation.measurements.Range;
30 import org.orekit.orbits.OrbitType;
31 import org.orekit.orbits.PositionAngleType;
32 import org.orekit.propagation.Propagator;
33 import org.orekit.propagation.conversion.NumericalPropagatorBuilder;
34 import org.orekit.propagation.events.ElevationDetector;
35 import org.orekit.propagation.events.EventDetector;
36 import org.orekit.time.AbsoluteDate;
37 import org.orekit.time.FixedStepSelector;
38 import org.orekit.time.TimeScalesFactory;
39 import org.orekit.utils.Constants;
40
41 import java.util.SortedSet;
42
43 public class GeneratorTest {
44
45 @Test
46 public void testIssue557() {
47
48 final EventDetector detector = EstimationTestUtils.getElevationDetector(context.stations.get(0).getBaseFrame(),
49 FastMath.toRadians(0.0));
50
51 double[] azElError = new double[] {
52 FastMath.toRadians(0.015),
53 FastMath.toRadians(0.015)
54 };
55 double[] baseweight = new double[] {
56 1.0,
57 1.0
58 };
59
60 double rangeSigma = 40.0;
61 double rangeBW = 1;
62 ObservableSatellite obs = new ObservableSatellite(0);
63 RangeBuilder rB = new RangeBuilder(null, context.stations.get(0), false, rangeSigma, rangeBW,obs);
64 AngularAzElBuilder aAEB = new AngularAzElBuilder(null, context.stations.get(0), azElError, baseweight, obs);
65 double timeToEnd = Constants.JULIAN_DAY;
66
67 AbsoluteDate initialDate = context.initialOrbit.getDate();
68 AbsoluteDate finalDate = initialDate.shiftedBy(timeToEnd);
69 Propagator numProp = EstimationTestUtils.createPropagator(context.initialOrbit, propagatorBuilder);
70 FixedStepSelector fssAE = new FixedStepSelector(10., TimeScalesFactory.getUTC());
71 EventBasedScheduler<Range> eBS = new EventBasedScheduler<>(rB, fssAE, numProp, detector, SignSemantic.FEASIBLE_MEASUREMENT_WHEN_NEGATIVE);
72 FixedStepSelector fssR = new FixedStepSelector(10., TimeScalesFactory.getUTC());
73 EventBasedScheduler<AngularAzEl> aeBS = new EventBasedScheduler<>(aAEB, fssR, numProp, detector, SignSemantic.FEASIBLE_MEASUREMENT_WHEN_NEGATIVE);
74 Generator genR = new Generator();
75 genR.addPropagator(numProp);
76 genR.addScheduler(aeBS);
77 genR.addScheduler(eBS);
78 final GatheringSubscriber gatherer = new GatheringSubscriber();
79 genR.addSubscriber(gatherer);
80
81 genR.generate(initialDate, finalDate);
82 SortedSet<EstimatedMeasurementBase<?>> generated = gatherer.getGeneratedMeasurements();
83
84 int nbAzEl = 0;
85 int nbRange = 0;
86 for (final EstimatedMeasurementBase<?> m : generated) {
87 if (m.getObservedMeasurement().getMeasurementType().equals(AngularAzEl.MEASUREMENT_TYPE)) {
88 ++nbAzEl;
89 } else if (m.getObservedMeasurement().getMeasurementType().equals(Range.MEASUREMENT_TYPE)) {
90 ++nbRange;
91 } else {
92 Assertions.fail("unexpected measurement type: " + m.getClass().getSimpleName());
93 }
94 }
95 Assertions.assertEquals(740, nbAzEl);
96 Assertions.assertEquals(740, nbRange);
97
98 }
99
100 @BeforeEach
101 public void setUp() {
102 context = EstimationTestUtils.eccentricContext("regular-data:potential:tides");
103
104 propagatorBuilder = context.createBuilder(OrbitType.KEPLERIAN, PositionAngleType.TRUE, true,
105 1.0e-6, 300.0, 0.001, Force.POTENTIAL,
106 Force.THIRD_BODY_SUN, Force.THIRD_BODY_MOON);
107 }
108
109 Context context;
110 NumericalPropagatorBuilder propagatorBuilder;
111
112 }