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 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 tropospheric 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 tropospheric 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   * @author Thierry Ceolin
40   * @since 8.0
41   */
42  public class AngularRadioRefractionModifier implements EstimationModifier<AngularAzEl> {
43  
44      /** Tropospheric refraction model. */
45      private final AtmosphericRefractionModel atmosModel;
46  
47      /** Constructor.
48      *
49      * @param model  tropospheric refraction model appropriate for the current angular measurement method.
50      */
51      public AngularRadioRefractionModifier(final AtmosphericRefractionModel model) {
52          atmosModel = model;
53      }
54  
55      /** {@inheritDoc} */
56      @Override
57      public String getEffectName() {
58          return "refraction";
59      }
60  
61      /** Compute the measurement error due to troposphere refraction.
62      * @param station station
63      * @param state spacecraft state
64      * @return the measurement error due to troposphere
65      */
66      private double angularErrorRadioRefractionModel(final GroundStation station,
67                                                      final SpacecraftState state) {
68  
69          final Vector3D position = state.getPosition();
70  
71          // elevation in radians
72          final double elevation =
73                          station.getBaseFrame().getTrackingCoordinates(position, state.getFrame(), state.getDate()).
74                          getElevation();
75  
76          // angle correction (rad)
77          return atmosModel.getRefraction(elevation);
78      }
79  
80      /** {@inheritDoc} */
81      @Override
82      public List<ParameterDriver> getParametersDrivers() {
83          return Collections.emptyList();
84      }
85  
86      @Override
87      public void modifyWithoutDerivatives(final EstimatedMeasurementBase<AngularAzEl> estimated) {
88          final AngularAzEl     measure = estimated.getObservedMeasurement();
89          final GroundStation   station = measure.getStation();
90          final SpacecraftState state   = estimated.getStates()[0];
91          final double correction = angularErrorRadioRefractionModel(station, state);
92  
93          // update estimated value taking into account the tropospheric elevation correction.
94          // The tropospheric elevation correction is directly added to the elevation.
95          final double[] oldValue = estimated.getEstimatedValue();
96          final double[] newValue = oldValue.clone();
97  
98          // consider only effect on elevation
99          newValue[1] = newValue[1] + correction;
100         estimated.modifyEstimatedValue(this, newValue[0], newValue[1]);
101     }
102 
103 }