1   /* Copyright 2002-2024 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.Collections;
20  import java.util.List;
21  
22  import org.hipparchus.geometry.euclidean.threed.Vector3D;
23  import org.orekit.estimation.measurements.AngularAzEl;
24  import org.orekit.estimation.measurements.EstimatedMeasurementBase;
25  import org.orekit.estimation.measurements.EstimationModifier;
26  import org.orekit.estimation.measurements.GroundStation;
27  import org.orekit.models.AtmosphericRefractionModel;
28  import org.orekit.propagation.SpacecraftState;
29  import org.orekit.utils.ParameterDriver;
30  
31  /** Class modifying theoretical angular measurement with ionospheric radio refractive index.
32   * A radio ray passing through the lower (non-ionized) layer of the atmosphere undergoes bending
33   * caused by the gradient of the relative index. Since the refractive index varies mainly with
34   * altitude, only the vertical gradient of the refractive index is considered here.
35   * The effect of ionospheric correction on the angular measurement is computed directly
36   * through the computation of the apparent elevation angle.
37   * Recommendation ITU-R P.453-11 (07/2015) and Recommendation ITU-R P.834-7 (10/2015)
38   *
39   *
40   * @author Thierry Ceolin
41   * @since 8.0
42   */
43  public class AngularRadioRefractionModifier implements EstimationModifier<AngularAzEl> {
44  
45      /** Tropospheric refraction model. */
46      private final AtmosphericRefractionModel atmosModel;
47  
48      /** Constructor.
49      *
50      * @param model  tropospheric refraction model appropriate for the current angular measurement method.
51      */
52      public AngularRadioRefractionModifier(final AtmosphericRefractionModel model) {
53          atmosModel = model;
54      }
55  
56      /** Compute the measurement error due to troposphere refraction.
57      * @param station station
58      * @param state spacecraft state
59      * @return the measurement error due to ionosphere
60      */
61      private double angularErrorRadioRefractionModel(final GroundStation station,
62                                                      final SpacecraftState state) {
63  
64          final Vector3D position = state.getPosition();
65  
66          // elevation in radians
67          final double elevation =
68                          station.getBaseFrame().getTrackingCoordinates(position, state.getFrame(), state.getDate()).
69                          getElevation();
70  
71          // angle correction (rad)
72          return atmosModel.getRefraction(elevation);
73      }
74  
75      /** {@inheritDoc} */
76      @Override
77      public List<ParameterDriver> getParametersDrivers() {
78          return Collections.emptyList();
79      }
80  
81      @Override
82      public void modifyWithoutDerivatives(final EstimatedMeasurementBase<AngularAzEl> estimated) {
83          final AngularAzEl     measure = estimated.getObservedMeasurement();
84          final GroundStation   station = measure.getStation();
85          final SpacecraftState state   = estimated.getStates()[0];
86          final double correction = angularErrorRadioRefractionModel(station, state);
87  
88          // update estimated value taking into account the tropospheric elevation corection.
89          // The tropospheric elevation correction is directly added to the elevation.
90          final double[] oldValue = estimated.getEstimatedValue();
91          final double[] newValue = oldValue.clone();
92  
93          // consider only effect on elevation
94          newValue[1] = newValue[1] + correction;
95          estimated.modifyEstimatedValue(this, newValue[0], newValue[1]);
96      }
97  
98  }