1   /* Copyright 2002-2022 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 java.util.Arrays;
20  
21  import org.hipparchus.geometry.euclidean.threed.Vector3D;
22  import org.hipparchus.util.FastMath;
23  import org.junit.Assert;
24  import org.junit.Before;
25  import org.junit.Test;
26  import org.orekit.Utils;
27  import org.orekit.bodies.GeodeticPoint;
28  import org.orekit.bodies.OneAxisEllipsoid;
29  import org.orekit.estimation.measurements.EstimatedMeasurement;
30  import org.orekit.estimation.measurements.GroundStation;
31  import org.orekit.estimation.measurements.ObservableSatellite;
32  import org.orekit.estimation.measurements.gnss.Phase;
33  import org.orekit.frames.FramesFactory;
34  import org.orekit.frames.TopocentricFrame;
35  import org.orekit.gnss.Frequency;
36  import org.orekit.orbits.CartesianOrbit;
37  import org.orekit.propagation.SpacecraftState;
38  import org.orekit.propagation.analytical.tle.TLE;
39  import org.orekit.propagation.analytical.tle.TLEPropagator;
40  import org.orekit.utils.Constants;
41  import org.orekit.utils.IERSConventions;
42  import org.orekit.utils.ParameterDriver;
43  import org.orekit.utils.TimeStampedPVCoordinates;
44  
45  public class RelativisticClockPhaseModifierTest {
46  
47      @Test
48      public void testRelativisticClockCorrection() {
49  
50          // Station
51          final OneAxisEllipsoid earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS,
52                                                              Constants.WGS84_EARTH_FLATTENING,
53                                                              FramesFactory.getITRF(IERSConventions.IERS_2010, true));
54          final GeodeticPoint point    = new GeodeticPoint(FastMath.toRadians(42.0), FastMath.toRadians(1.0), 100.0);
55          final TopocentricFrame topo  = new TopocentricFrame(earth, point, "");
56          final GroundStation station  = new GroundStation(topo);
57  
58          // Satellite (GPS orbit from TLE)
59          final TLE tle = new TLE("1 28474U 04045A   20252.59334296 -.00000043  00000-0  00000-0 0  9998",
60                                  "2 28474  55.0265  49.5108 0200271 267.9106 149.0797  2.00552216116165");
61          final TimeStampedPVCoordinates satPV = TLEPropagator.selectExtrapolator(tle).getPVCoordinates(tle.getDate(), FramesFactory.getEME2000());
62          final SpacecraftState state = new SpacecraftState(new CartesianOrbit(satPV, FramesFactory.getEME2000(), Constants.WGS84_EARTH_MU));
63  
64          // Set reference date to station drivers
65          for (ParameterDriver driver : Arrays.asList(station.getClockOffsetDriver(),
66                                                      station.getEastOffsetDriver(),
67                                                      station.getNorthOffsetDriver(),
68                                                      station.getZenithOffsetDriver(),
69                                                      station.getPrimeMeridianOffsetDriver(),
70                                                      station.getPrimeMeridianDriftDriver(),
71                                                      station.getPolarOffsetXDriver(),
72                                                      station.getPolarDriftXDriver(),
73                                                      station.getPolarOffsetYDriver(),
74                                                      station.getPolarDriftYDriver())) {
75              if (driver.getReferenceDate() == null) {
76                  driver.setReferenceDate(state.getDate());
77              }
78          }
79  
80          // Station PV
81          final Vector3D zero = Vector3D.ZERO;
82          final TimeStampedPVCoordinates stationPV = station.getOffsetToInertial(state.getFrame(), state.getDate()).transformPVCoordinates(new TimeStampedPVCoordinates(state.getDate(), zero, zero, zero));
83  
84          // Range measurement
85          final Phase phase = new Phase(station, state.getDate(), 26584264.45, Frequency.G01.getWavelength(), 1.0, 1.0, new ObservableSatellite(0));
86          final EstimatedMeasurement<Phase> estimated = new EstimatedMeasurement<Phase>(phase, 0, 0,
87                          new SpacecraftState[] {state},
88                          new TimeStampedPVCoordinates[] {state.getPVCoordinates(), stationPV});
89          estimated.setEstimatedValue(phase.getObservedValue()[0]);
90          Assert.assertEquals(0.0, estimated.getObservedValue()[0] - estimated.getEstimatedValue()[0], 1.0e-3);
91  
92          // Measurement modifier
93          final RelativisticClockPhaseModifier modifier = new RelativisticClockPhaseModifier();
94          modifier.modify(estimated);
95          Assert.assertEquals(0, modifier.getParametersDrivers().size());
96  
97          // Verify
98          Assert.assertEquals(-6.87 / Frequency.G01.getWavelength(), estimated.getObservedValue()[0] - estimated.getEstimatedValue()[0], 1.0e-2);
99  
100     }
101 
102     @Before
103     public void setUp() {
104         Utils.setDataRoot("regular-data");
105     }
106 
107 }