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.ArrayList;
20 import java.util.List;
21 import java.util.Map;
22
23 import org.hipparchus.fitting.PolynomialCurveFitter;
24 import org.hipparchus.fitting.WeightedObservedPoint;
25 import org.hipparchus.util.FastMath;
26 import org.orekit.files.rinex.observation.ObservationDataSet;
27 import org.orekit.gnss.GnssSignal;
28 import org.orekit.gnss.MeasurementType;
29 import org.orekit.gnss.SatelliteSystem;
30 import org.orekit.time.AbsoluteDate;
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51 public class GeometryFreeCycleSlipDetector extends AbstractCycleSlipDetector {
52
53
54 private final double threshold;
55
56
57
58
59
60
61
62 public GeometryFreeCycleSlipDetector(final double dt, final double threshold, final int n) {
63 super(dt, n);
64 this.threshold = threshold;
65 }
66
67
68
69 @Override
70 protected void manageData(final ObservationDataSet observation) {
71
72
73 final int prn = observation.getSatellite().getPRN();
74 final AbsoluteDate date = observation.getDate();
75 final SatelliteSystem system = observation.getSatellite().getSystem();
76
77
78 final GeometryFreeCombination geometryFree = MeasurementCombinationFactory.getGeometryFreeCombination(system);
79 final CombinedObservationDataSet cods = geometryFree.combine(observation);
80
81
82 final List<CombinedObservationData> phasesGF = new ArrayList<>();
83
84
85 for (final CombinedObservationData cod : cods.getObservationData()) {
86 if (!Double.isNaN(cod.getValue()) && cod.getMeasurementType() == MeasurementType.CARRIER_PHASE) {
87 phasesGF.add(cod);
88 }
89 }
90
91
92 for (CombinedObservationData cod : phasesGF) {
93 final String nameSat = setName(prn, observation.getSatellite().getSystem());
94
95 final GnssSignal signal = cod.getUsedObservationData().get(0).getObservationType().getSignal(system);
96 final boolean slip = cycleSlipDetection(nameSat, date, cod.getValue(), signal);
97 if (!slip) {
98
99 cycleSlipDataSet(nameSat, date, cod.getValue(), cod.getUsedObservationData().get(0).getObservationType().getSignal(system));
100 }
101 }
102
103 }
104
105
106
107
108
109
110
111
112
113 private boolean cycleSlipDetection(final String nameSat, final AbsoluteDate currentDate,
114 final double valueGF, final GnssSignal signal) {
115
116
117 final List<CycleSlipDetectorResults> data = getResults();
118 final List<Map<GnssSignal, DataForDetection>> stuff = getStuffReference();
119
120
121 if (data != null) {
122
123
124 for (CycleSlipDetectorResults resultGF : data) {
125
126
127 if (resultGF.getSatelliteName().compareTo(nameSat) == 0 && resultGF.getCycleSlipMap().containsKey(signal)) {
128 final Map<GnssSignal, DataForDetection> values = stuff.get(data.indexOf(resultGF));
129 final DataForDetection dataForDetection = values.get(signal);
130
131
132 final double deltaT = FastMath.abs(currentDate.durationFrom(dataForDetection.getFiguresReference()[dataForDetection.getWrite()].getDate()));
133 if (deltaT > getMaxTimeBeetween2Measurement()) {
134 resultGF.addCycleSlipDate(signal, currentDate);
135 dataForDetection.resetFigures(new SlipComputationData[getMinMeasurementNumber()], valueGF, currentDate);
136 resultGF.setDate(signal, currentDate);
137 return true;
138 }
139
140
141 if (dataForDetection.getCanBeComputed() >= getMinMeasurementNumber()) {
142 final List<WeightedObservedPoint> xy = new ArrayList<>();
143 for (int i = 0; i < getMinMeasurementNumber(); i++) {
144 final SlipComputationData current = dataForDetection.getFiguresReference()[i];
145 xy.add(new WeightedObservedPoint(1.0, current.getDate().durationFrom(currentDate),
146 current.getValue()));
147 }
148
149 final PolynomialCurveFitter fitting = PolynomialCurveFitter.create(2);
150
151 if (FastMath.abs(fitting.fit(xy)[0] - valueGF) > threshold) {
152 resultGF.addCycleSlipDate(signal, currentDate);
153 dataForDetection.resetFigures(new SlipComputationData[getMinMeasurementNumber()], valueGF, currentDate);
154 resultGF.setDate(signal, currentDate);
155 return true;
156 }
157
158 } else {
159 break;
160 }
161
162 }
163
164 }
165
166 }
167
168
169 return false;
170 }
171
172 }