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.List;
20  
21  import org.hipparchus.CalculusFieldElement;
22  import org.hipparchus.Field;
23  import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
24  import org.hipparchus.geometry.euclidean.threed.Vector3D;
25  import org.orekit.estimation.measurements.GroundStation;
26  import org.orekit.models.earth.troposphere.TroposphericModel;
27  import org.orekit.propagation.FieldSpacecraftState;
28  import org.orekit.propagation.SpacecraftState;
29  import org.orekit.utils.FieldTrackingCoordinates;
30  import org.orekit.utils.ParameterDriver;
31  import org.orekit.utils.TrackingCoordinates;
32  
33  /** Base class modifying theoretical range measurements with tropospheric delay.
34   * The effect of tropospheric correction on the range is directly computed
35   * through the computation of the tropospheric delay.
36   *
37   * In general, for GNSS, VLBI, ... there is hardly any frequency dependence in the delay.
38   * For SLR techniques however, the frequency dependence is sensitive.
39   *
40   * @author Joris Olympio
41   * @since 11.2
42   */
43  public abstract class BaseRangeTroposphericDelayModifier {
44  
45      /** Tropospheric delay model. */
46      private final TroposphericModel tropoModel;
47  
48      /** Constructor.
49       *
50       * @param model  Tropospheric delay model appropriate for the current range measurement method.
51       * @since 12.1
52       */
53      protected BaseRangeTroposphericDelayModifier(final TroposphericModel model) {
54          tropoModel = model;
55      }
56  
57      /** Get the name of the effect modifying the measurement.
58       * @return name of the effect modifying the measurement
59       * @since 13.0
60       */
61      public String getEffectName() {
62          return "troposphere";
63      }
64  
65      /** Get the tropospheric delay model.
66       * @return tropospheric delay model
67       */
68      protected TroposphericModel getTropoModel() {
69          return tropoModel;
70      }
71  
72      /** Compute the measurement error due to Troposphere.
73       * @param station station
74       * @param state spacecraft state
75       * @return the measurement error due to Troposphere
76       */
77      public double rangeErrorTroposphericModel(final GroundStation station,
78                                                final SpacecraftState state) {
79  
80          // spacecraft position and elevation as seen from the ground station
81          final Vector3D position = state.getPosition();
82          final TrackingCoordinates trackingCoordinates =
83                          station.getBaseFrame().getTrackingCoordinates(position, state.getFrame(), state.getDate());
84  
85          // only consider measures above the horizon
86          if (trackingCoordinates.getElevation() > 0) {
87              // tropospheric delay in meters
88              return tropoModel.
89                      pathDelay(trackingCoordinates,
90                                station.getOffsetGeodeticPoint(state.getDate()),
91                                tropoModel.getParameters(), state.getDate()).
92                      getDelay();
93          }
94  
95          return 0;
96      }
97  
98  
99      /** Compute the measurement error due to Troposphere.
100      * @param <T> type of the element
101      * @param station station
102      * @param state spacecraft state
103      * @param parameters tropospheric model parameters
104      * @return the measurement error due to Troposphere
105      */
106     public <T extends CalculusFieldElement<T>> T rangeErrorTroposphericModel(final GroundStation station,
107                                                                              final FieldSpacecraftState<T> state,
108                                                                              final T[] parameters) {
109         // Field
110         final Field<T> field = state.getDate().getField();
111         final T zero         = field.getZero();
112 
113         // spacecraft position and elevation as seen from the ground station
114         final FieldVector3D<T> position = state.getPosition();
115         final FieldTrackingCoordinates<T> trackingCoordinates =
116                         station.getBaseFrame().getTrackingCoordinates(position, state.getFrame(), state.getDate());
117 
118         // only consider measures above the horizon
119         if (trackingCoordinates.getElevation() .getReal() > 0) {
120             // tropospheric delay in meters
121             return tropoModel.
122                     pathDelay(trackingCoordinates,
123                               station.getOffsetGeodeticPoint(state.getDate()),
124                               parameters, state.getDate()).
125                     getDelay();
126         }
127 
128         return zero;
129     }
130 
131     /** Get the drivers for this modifier parameters.
132      * @return drivers for this modifier parameters
133      */
134     public List<ParameterDriver> getParametersDrivers() {
135         return tropoModel.getParametersDrivers();
136     }
137 
138 }