1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.orekit.estimation.measurements.gnss;
18
19 import java.util.Arrays;
20
21 import org.hipparchus.analysis.differentiation.Gradient;
22 import org.orekit.estimation.measurements.EstimatedMeasurement;
23 import org.orekit.estimation.measurements.EstimatedMeasurementBase;
24 import org.orekit.estimation.measurements.GroundReceiverCommonParametersWithDerivatives;
25 import org.orekit.estimation.measurements.GroundReceiverCommonParametersWithoutDerivatives;
26 import org.orekit.estimation.measurements.GroundReceiverMeasurement;
27 import org.orekit.estimation.measurements.GroundStation;
28 import org.orekit.estimation.measurements.ObservableSatellite;
29 import org.orekit.propagation.SpacecraftState;
30 import org.orekit.time.AbsoluteDate;
31 import org.orekit.utils.Constants;
32 import org.orekit.utils.ParameterDriver;
33 import org.orekit.utils.TimeSpanMap.Span;
34 import org.orekit.utils.TimeStampedPVCoordinates;
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51 public class Phase extends GroundReceiverMeasurement<Phase> {
52
53
54 public static final String MEASUREMENT_TYPE = "Phase";
55
56
57
58
59 @Deprecated
60 public static final String AMBIGUITY_NAME = "ambiguity";
61
62
63 private final AmbiguityDriver ambiguityDriver;
64
65
66 private final double wavelength;
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81 @Deprecated
82 public Phase(final GroundStation station, final AbsoluteDate date,
83 final double phase, final double wavelength, final double sigma,
84 final double baseWeight, final ObservableSatellite satellite) {
85 this(station, date, phase, wavelength, sigma, baseWeight, satellite,
86 AmbiguityCache.DEFAULT_CACHE);
87 }
88
89
90
91
92
93
94
95
96
97
98
99
100 public Phase(final GroundStation station, final AbsoluteDate date,
101 final double phase, final double wavelength, final double sigma,
102 final double baseWeight, final ObservableSatellite satellite,
103 final AmbiguityCache cache) {
104 super(station, false, date, phase, sigma, baseWeight, satellite);
105 ambiguityDriver = cache.getAmbiguity(satellite.getName(),
106 station.getBaseFrame().getName(),
107 wavelength);
108 addParameterDriver(ambiguityDriver);
109 this.wavelength = wavelength;
110 }
111
112
113
114
115 public double getWavelength() {
116 return wavelength;
117 }
118
119
120
121
122
123 public AmbiguityDriver getAmbiguityDriver() {
124 return ambiguityDriver;
125 }
126
127
128 @Override
129 protected EstimatedMeasurementBase<Phase> theoreticalEvaluationWithoutDerivatives(final int iteration,
130 final int evaluation,
131 final SpacecraftState[] states) {
132
133 final GroundReceiverCommonParametersWithoutDerivatives common = computeCommonParametersWithout(states[0]);
134
135
136 final EstimatedMeasurementBase<Phase> estimated =
137 new EstimatedMeasurementBase<>(this, iteration, evaluation,
138 new SpacecraftState[] {
139 common.getTransitState()
140 }, new TimeStampedPVCoordinates[] {
141 common.getTransitPV(),
142 common.getStationDownlink()
143 });
144
145
146 final ObservableSatellite satellite = getSatellites().get(0);
147 final double dts = satellite.getClockOffsetDriver().getValue(common.getState().getDate());
148 final double dtg = getStation().getClockOffsetDriver().getValue(getDate());
149
150
151 final double cOverLambda = Constants.SPEED_OF_LIGHT / wavelength;
152 final double ambiguity = ambiguityDriver.getValue(common.getState().getDate());
153 final double phase = (common.getTauD() + dtg - dts) * cOverLambda + ambiguity;
154
155 estimated.setEstimatedValue(phase);
156
157 return estimated;
158
159 }
160
161
162 @Override
163 protected EstimatedMeasurement<Phase> theoreticalEvaluation(final int iteration,
164 final int evaluation,
165 final SpacecraftState[] states) {
166
167 final SpacecraftState state = states[0];
168
169
170
171
172
173
174
175
176
177 final GroundReceiverCommonParametersWithDerivatives common = computeCommonParametersWithDerivatives(state);
178 final int nbParams = common.getTauD().getFreeParameters();
179
180
181 final EstimatedMeasurement<Phase> estimated =
182 new EstimatedMeasurement<>(this, iteration, evaluation,
183 new SpacecraftState[] {
184 common.getTransitState()
185 }, new TimeStampedPVCoordinates[] {
186 common.getTransitPV().toTimeStampedPVCoordinates(),
187 common.getStationDownlink().toTimeStampedPVCoordinates()
188 });
189
190
191 final ObservableSatellite satellite = getSatellites().get(0);
192 final Gradient dts = satellite.getClockOffsetDriver().getValue(nbParams, common.getIndices(), state.getDate());
193 final Gradient dtg = getStation().getClockOffsetDriver().getValue(nbParams, common.getIndices(), getDate());
194
195
196 final double cOverLambda = Constants.SPEED_OF_LIGHT / wavelength;
197 final Gradient ambiguity = ambiguityDriver.getValue(nbParams, common.getIndices(), state.getDate());
198 final Gradient phase = common.getTauD().add(dtg).subtract(dts).multiply(cOverLambda).add(ambiguity);
199
200 estimated.setEstimatedValue(phase.getValue());
201
202
203 final double[] derivatives = phase.getGradient();
204 estimated.setStateDerivatives(0, Arrays.copyOfRange(derivatives, 0, 6));
205
206
207 for (final ParameterDriver driver : getParametersDrivers()) {
208 for (Span<String> span = driver.getNamesSpanMap().getFirstSpan(); span != null; span = span.next()) {
209
210 final Integer index = common.getIndices().get(span.getData());
211 if (index != null) {
212 estimated.setParameterDerivatives(driver, span.getStart(), derivatives[index]);
213 }
214 }
215 }
216
217 return estimated;
218
219 }
220
221 }