1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.orekit.estimation.sequential;
18
19 import java.util.List;
20
21 import org.hipparchus.exception.MathRuntimeException;
22 import org.hipparchus.filtering.kalman.KalmanFilter;
23 import org.hipparchus.filtering.kalman.ProcessEstimate;
24 import org.orekit.errors.OrekitException;
25 import org.orekit.estimation.measurements.ObservedMeasurement;
26 import org.orekit.propagation.SpacecraftState;
27 import org.orekit.propagation.sampling.OrekitStepHandler;
28 import org.orekit.propagation.sampling.OrekitStepInterpolator;
29 import org.orekit.time.AbsoluteDate;
30
31
32
33
34
35
36
37
38
39 public class SemiAnalyticalMeasurementHandler implements OrekitStepHandler {
40
41
42 private int index;
43
44
45 private AbsoluteDate referenceDate;
46
47
48 private final SemiAnalyticalProcess model;
49
50
51 private final KalmanFilter<MeasurementDecorator> filter;
52
53
54 private final List<ObservedMeasurement<?>> observedMeasurements;
55
56
57 private final boolean isUnscented;
58
59
60
61
62
63
64
65
66
67
68
69 public SemiAnalyticalMeasurementHandler(final SemiAnalyticalProcess model,
70 final KalmanFilter<MeasurementDecorator> filter,
71 final List<ObservedMeasurement<?>> observedMeasurements,
72 final AbsoluteDate referenceDate) {
73 this(model, filter, observedMeasurements, referenceDate, false);
74 }
75
76
77
78
79
80
81
82
83
84 public SemiAnalyticalMeasurementHandler(final SemiAnalyticalProcess model,
85 final KalmanFilter<MeasurementDecorator> filter,
86 final List<ObservedMeasurement<?>> observedMeasurements,
87 final AbsoluteDate referenceDate,
88 final boolean isUnscented) {
89 this.model = model;
90 this.filter = filter;
91 this.observedMeasurements = observedMeasurements;
92 this.referenceDate = referenceDate;
93 this.isUnscented = isUnscented;
94 }
95
96
97 @Override
98 public void init(final SpacecraftState s0, final AbsoluteDate t) {
99 this.index = 0;
100
101 model.initializeShortPeriodicTerms(s0);
102 model.updateShortPeriods(s0);
103 }
104
105
106 @Override
107 public void handleStep(final OrekitStepInterpolator interpolator) {
108
109
110 final AbsoluteDate currentDate = interpolator.getCurrentState().getDate();
111
112
113 model.updateShortPeriods(interpolator.getCurrentState());
114
115
116 while (index < observedMeasurements.size() && observedMeasurements.get(index).getDate().compareTo(currentDate) < 0) {
117
118 try {
119
120
121 model.updateNominalSpacecraftState(interpolator.getInterpolatedState(observedMeasurements.get(index).getDate()));
122
123
124 final MeasurementDecorator decorated = isUnscented ?
125 KalmanEstimatorUtil.decorateUnscented(observedMeasurements.get(index), referenceDate) :
126 KalmanEstimatorUtil.decorate(observedMeasurements.get(index), referenceDate);
127 final ProcessEstimate estimate = filter.estimationStep(decorated);
128
129
130 model.finalizeEstimation(observedMeasurements.get(index), estimate);
131
132 } catch (MathRuntimeException mrte) {
133 throw new OrekitException(mrte);
134 }
135
136
137 index += 1;
138
139 }
140
141
142 model.finalizeOperationsObservationGrid();
143
144 }
145
146 }