1   /* Copyright 2022-2025 Thales Alenia Space
2    * Licensed to CS Communication & Systèmes (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.models.earth.troposphere.iturp834;
18  
19  import org.hipparchus.CalculusFieldElement;
20  import org.orekit.bodies.FieldGeodeticPoint;
21  import org.orekit.bodies.GeodeticPoint;
22  import org.orekit.models.earth.ITURP834AtmosphericRefraction;
23  import org.orekit.models.earth.troposphere.FieldTroposphericDelay;
24  import org.orekit.models.earth.troposphere.TroposphereMappingFunction;
25  import org.orekit.models.earth.troposphere.TroposphericDelay;
26  import org.orekit.models.earth.troposphere.TroposphericModel;
27  import org.orekit.models.earth.weather.FieldPressureTemperatureHumidity;
28  import org.orekit.models.earth.weather.PressureTemperatureHumidity;
29  import org.orekit.models.earth.weather.PressureTemperatureHumidityProvider;
30  import org.orekit.time.AbsoluteDate;
31  import org.orekit.time.FieldAbsoluteDate;
32  import org.orekit.time.TimeScale;
33  import org.orekit.utils.FieldTrackingCoordinates;
34  import org.orekit.utils.ParameterDriver;
35  import org.orekit.utils.TrackingCoordinates;
36  import org.orekit.utils.units.Unit;
37  
38  import java.util.Collections;
39  import java.util.List;
40  
41  /** The ITU-R P.834 tropospheric model.
42   * <p>
43   * This class implements the excess radio path length part of the model,
44   * i.e. section 6 of the recommendation. The ray bending part of the model,
45   * i.e. section 1 of the recommendation, is implemented in the
46   * {@link ITURP834AtmosphericRefraction} class.
47   * </p>
48   * @see ITURP834WeatherParametersProvider
49   * @see ITURP834MappingFunction
50   * @author Luc Maisonobe
51   * @see <a href="https://www.itu.int/rec/R-REC-P.834/en">P.834 : Effects of tropospheric refraction on radiowave propagation</a>
52   * @since 13.0
53   */
54  public class ITURP834PathDelay implements TroposphericModel {
55  
56      /** Molar gas constant (J/mol K). */
57      private static final double R = 8.314;
58  
59      /** Dry air molar mass (kg/mol). */
60      private static final double MD = Unit.GRAM.toSI(28.9644);
61  
62      /** Kelvin per hecto-Pascal. */
63      private static final Unit K_PER_HPA = Unit.parse("hPa⁻¹");
64  
65      /** Hydrostatic factor (K/Pa). */
66      private static final double K1 = K_PER_HPA.toSI(76.604);
67  
68      /** Wet factor (K²/Pa). */
69      private static final double K2 = K_PER_HPA.toSI(373900);
70  
71      /** Provider for pressure, temperature and humidity. */
72      private final PressureTemperatureHumidityProvider pthProvider;
73  
74      /** Mapping function. */
75      private final TroposphereMappingFunction mappingFunction;
76  
77      /** Simple constructor.
78       * @param pthProvider provider for pressure, temperature and humidity
79       * @param utc UTC time scale
80       */
81      public ITURP834PathDelay(final PressureTemperatureHumidityProvider pthProvider,
82                               final TimeScale utc) {
83          this.pthProvider     = pthProvider;
84          this.mappingFunction = new ITURP834MappingFunction(utc);
85      }
86  
87      /** {@inheritDoc} */
88      @Override
89      public TroposphericDelay pathDelay(final TrackingCoordinates trackingCoordinates, final GeodeticPoint point,
90                                         final double[] parameters, final AbsoluteDate date) {
91  
92          // compute weather parameters
93          final PressureTemperatureHumidity weather = pthProvider.getWeatherParameters(point, date);
94  
95          // calculate path delay
96          final double gm       = Gravity.getGravityAtAltitude(point).evaluate();
97          final double deltaLvh = 1.0e-6 * R * K1 * weather.getPressure() / (MD * gm);
98          final double deltaLvw = 1.0e-6 * R * K2 * weather.getWaterVaporPressure() /
99                                  (MD * gm * (1 + weather.getLambda()) * weather.getTm());
100 
101         // apply mapping function
102         final double[] mapping = mappingFunction.mappingFactors(trackingCoordinates, point, date);
103         return new TroposphericDelay(deltaLvh, deltaLvw,
104                                      mapping[0] * deltaLvh, mapping[1] * deltaLvw);
105 
106     }
107 
108     /** {@inheritDoc} */
109     @Override
110     public <T extends CalculusFieldElement<T>> FieldTroposphericDelay<T> pathDelay(final FieldTrackingCoordinates<T> trackingCoordinates,
111                                                                                    final FieldGeodeticPoint<T> point,
112                                                                                    final T[] parameters, final FieldAbsoluteDate<T> date) {
113 
114         // compute weather parameters
115         final FieldPressureTemperatureHumidity<T> weather = pthProvider.getWeatherParameters(point, date);
116 
117         // calculate path delay
118         final T gm       = Gravity.getGravityAtAltitude(point).evaluate();
119         final T deltaLvh = weather.getPressure().multiply(1.0e-6 * R * K1).
120                            divide(gm.multiply(MD));
121         final T deltaLvw = weather.getWaterVaporPressure().multiply(1.0e-6 * R * K2).
122                            divide(weather.getTm().multiply(weather.getLambda().add(1)).multiply(gm).multiply(MD));
123 
124         // apply mapping function
125         final T[] mapping = mappingFunction.mappingFactors(trackingCoordinates, point, date);
126         return new FieldTroposphericDelay<>(deltaLvh, deltaLvw,
127                                             mapping[0].multiply(deltaLvh), mapping[1].multiply(deltaLvw));
128 
129     }
130 
131     /** {@inheritDoc} */
132     @Override
133     public List<ParameterDriver> getParametersDrivers() {
134         return Collections.emptyList();
135     }
136 
137 }