1   /* Copyright 2022-2026 Romain Serra
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.ArrayList;
20  import java.util.List;
21  
22  import org.junit.jupiter.api.BeforeEach;
23  import org.junit.jupiter.api.Test;
24  import org.orekit.TestUtils;
25  import org.orekit.Utils;
26  import org.orekit.bodies.GeodeticPoint;
27  import org.orekit.bodies.OneAxisEllipsoid;
28  import org.orekit.estimation.measurements.AngularAzEl;
29  import org.orekit.estimation.measurements.EstimatedMeasurementBase;
30  import org.orekit.estimation.measurements.GroundStation;
31  import org.orekit.estimation.measurements.ObservableSatellite;
32  import org.orekit.frames.FramesFactory;
33  import org.orekit.frames.TopocentricFrame;
34  import org.orekit.models.earth.ionosphere.IonosphericModel;
35  import org.orekit.propagation.SpacecraftState;
36  import org.orekit.time.AbsoluteDate;
37  import org.orekit.utils.Constants;
38  import org.orekit.utils.ParameterDriver;
39  import org.orekit.utils.TimeStampedPVCoordinates;
40  import static org.junit.jupiter.api.Assertions.assertEquals;
41  import static org.mockito.ArgumentMatchers.any;
42  import static org.mockito.Mockito.mock;
43  import static org.mockito.Mockito.when;
44  
45  class AngularIonosphericDelayModifierTest {
46  
47      @BeforeEach
48      void setUp() {
49          Utils.setDataRoot("regular-data");
50      }
51  
52      @Test
53      void testGetParameters() {
54          // GIVEN
55          final IonosphericModel model = mock();
56          final List<ParameterDriver> expectedDrivers = new ArrayList<>();
57          expectedDrivers.add(mock(ParameterDriver.class));
58          when(model.getParametersDrivers()).thenReturn(expectedDrivers);
59          final AngularIonosphericDelayModifier modifier = new AngularIonosphericDelayModifier(model, 1.);
60          // WHEN
61          final List<ParameterDriver> drivers = modifier.getParametersDrivers();
62          // THEN
63          assertEquals(expectedDrivers, drivers);
64      }
65  
66      @Test
67      void testNoDelayModifyWithoutDerivatives() {
68          // GIVEN
69          final SpacecraftState state = new SpacecraftState(TestUtils.getDefaultOrbit(AbsoluteDate.ARBITRARY_EPOCH));
70          final OneAxisEllipsoid ellipsoid = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, 0.,
71                  FramesFactory.getGTOD(true));
72          final GeodeticPoint point = new GeodeticPoint(0., 0., 100.);
73          final GroundStation station = mock();
74          when(station.getBaseFrame()).thenReturn(new TopocentricFrame(ellipsoid, point, ""));
75          when(station.getOffsetGeodeticPoint(any(AbsoluteDate.class))).thenReturn(point);
76          final AngularAzEl angularAzEl = new AngularAzEl(station, AbsoluteDate.ARBITRARY_EPOCH, new double[2], new double[2], new double[2], new ObservableSatellite(0));
77          final EstimatedMeasurementBase<AngularAzEl> estimated = new EstimatedMeasurementBase<>(angularAzEl, 0, 0,
78                  new SpacecraftState[] {state}, new TimeStampedPVCoordinates[]{state.getPVCoordinates()});
79          final double azimuth = 2.;
80          final double elevation = 1.;
81          estimated.setEstimatedValue(azimuth, elevation);
82          final IonosphericModel model = mock();
83          when(model.pathDelay(any(SpacecraftState.class), any(TopocentricFrame.class), any(Double.class), any())).thenReturn(0.);
84          final AngularIonosphericDelayModifier modifier = new AngularIonosphericDelayModifier(model, 1.);
85          // WHEN
86          modifier.modifyWithoutDerivatives(estimated);
87          // THEN
88          assertEquals(azimuth, estimated.getEstimatedValue()[0]);
89          assertEquals(elevation, estimated.getEstimatedValue()[1]);
90      }
91  }