1   /* Copyright 2002-2025 CS GROUP
2    * Licensed to CS GROUP (CS) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * CS licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *   http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.orekit.estimation.measurements.modifiers;
18  
19  import org.hipparchus.geometry.euclidean.threed.Vector3D;
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.Utils;
24  import org.orekit.estimation.measurements.EstimatedMeasurement;
25  import org.orekit.estimation.measurements.EstimatedMeasurementBase;
26  import org.orekit.estimation.measurements.EstimationModifier;
27  import org.orekit.estimation.measurements.ObservableSatellite;
28  import org.orekit.estimation.measurements.gnss.AmbiguityCache;
29  import org.orekit.estimation.measurements.gnss.InterSatellitesPhase;
30  import org.orekit.gnss.PredefinedGnssSignal;
31  import org.orekit.propagation.SpacecraftState;
32  import org.orekit.propagation.analytical.tle.TLE;
33  import org.orekit.propagation.analytical.tle.TLEPropagator;
34  import org.orekit.time.AbsoluteDate;
35  import org.orekit.time.TimeScalesFactory;
36  
37  public class RelativisticClockInterSatellitesPhaseModifierTest {
38  
39      /** Date. */
40      private static AbsoluteDate date;
41  
42      /** Spacecraft states. */
43      private static SpacecraftState[] states;
44  
45      @Deprecated
46      @Test
47      public void testRelativisticClockCorrectionDeprecated() {
48  
49          // Measurement
50          final double wavelength = PredefinedGnssSignal.G01.getWavelength();
51          final InterSatellitesPhase phase = new InterSatellitesPhase(new ObservableSatellite(0), new ObservableSatellite(1),
52                                                                      date,
53                                                                      Vector3D.distance(states[0].getPosition(),
54                                                                                        states[1].getPosition()) / wavelength,
55                                                                      wavelength, 1.0, 1.0,
56                                                                      new AmbiguityCache());
57  
58          // Inter-satellites phase before applying the modifier
59          final EstimatedMeasurementBase<InterSatellitesPhase> estimatedBefore = phase.estimateWithoutDerivatives(states);
60  
61          // Inter-satellites phase after applying the modifier
62          final EstimationModifier<InterSatellitesPhase> modifier = new RelativisticClockInterSatellitesPhaseModifier();
63          phase.addModifier(modifier);
64          final EstimatedMeasurement<InterSatellitesPhase> estimatedAfter = phase.estimate(0, 0, states);
65  
66          // Verify
67          Assertions.assertEquals(-10.57, (estimatedBefore.getEstimatedValue()[0] - estimatedAfter.getEstimatedValue()[0]) * wavelength, 1.0e-2);
68          Assertions.assertEquals(0, modifier.getParametersDrivers().size());
69          Assertions.assertEquals(1,
70                                  estimatedAfter.getAppliedEffects().entrySet().stream().
71                                  filter(e -> e.getKey().getEffectName().equals("clock relativity")).count());
72  
73      }
74  
75      @Test
76      public void testRelativisticClockCorrection() {
77  
78          // Measurement
79          final double wavelength = PredefinedGnssSignal.G01.getWavelength();
80          final InterSatellitesPhase phase = new InterSatellitesPhase(new ObservableSatellite(0), new ObservableSatellite(1),
81                                                                      date,
82                                                                      Vector3D.distance(states[0].getPosition(),
83                                                                                        states[1].getPosition()) / wavelength,
84                                                                      wavelength, 1.0, 1.0,
85                                                                      new AmbiguityCache());
86  
87          // Inter-satellites phase before applying the modifier
88          final EstimatedMeasurementBase<InterSatellitesPhase> estimatedBefore = phase.estimateWithoutDerivatives(states);
89  
90          // Inter-satellites phase after applying the modifier
91          final EstimationModifier<InterSatellitesPhase> modifier = new RelativisticClockInterSatellitesPhaseModifier();
92          phase.addModifier(modifier);
93          final EstimatedMeasurement<InterSatellitesPhase> estimatedAfter = phase.estimate(0, 0, states);
94  
95          // Verify
96          Assertions.assertEquals(-10.57, (estimatedBefore.getEstimatedValue()[0] - estimatedAfter.getEstimatedValue()[0]) * wavelength, 1.0e-2);
97          Assertions.assertEquals(0, modifier.getParametersDrivers().size());
98  
99      }
100 
101     @BeforeEach
102     public void setUp() {
103         // Data root
104         Utils.setDataRoot("regular-data");
105 
106         // Date
107         date = new AbsoluteDate("2004-01-13T00:00:00.000", TimeScalesFactory.getUTC());
108 
109         // Spacecraft states
110         states = new SpacecraftState[2];
111         final TLE local = new TLE("1 27642U 03002A   04013.91734903  .00000108  00000-0  12227-4 0  3621",
112                                   "2 27642  93.9970   6.8623 0003169  80.1383 280.0205 14.90871424 54508");
113         final TLE remote = new TLE("1 20061U 89044A   04013.44391333  .00000095  00000-0  10000-3 0  3242",
114                                    "2 20061  53.4233 172.2072 0234017 261.4179  95.8975  2.00577231106949");
115         states[0] = TLEPropagator.selectExtrapolator(local).propagate(date);
116         states[1] = TLEPropagator.selectExtrapolator(remote).propagate(date);
117     }
118 
119 }