1   /* Copyright 2002-2024 Thales Alenia Space
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.models.earth.troposphere;
18  
19  import org.hipparchus.CalculusFieldElement;
20  import org.hipparchus.util.FastMath;
21  import org.hipparchus.util.MathArrays;
22  import org.orekit.bodies.FieldGeodeticPoint;
23  import org.orekit.bodies.GeodeticPoint;
24  import org.orekit.models.earth.weather.FieldPressureTemperatureHumidity;
25  import org.orekit.models.earth.weather.PressureTemperatureHumidity;
26  import org.orekit.time.AbsoluteDate;
27  import org.orekit.time.FieldAbsoluteDate;
28  import org.orekit.utils.FieldTrackingCoordinates;
29  import org.orekit.utils.TrackingCoordinates;
30  
31  /** Chao mapping function for radio wavelengths.
32   *
33   * @see "C. C. Chao, A model for tropospheric calibration from delay surface and radiosonde ballon measurements, 1972"
34   *
35   * @author Luc Maisonobe
36   * @since 12.1
37   */
38  public class AbstractChaoMappingFunction implements TroposphereMappingFunction {
39  
40      /** First coefficient for hydrostatic (dry) component. */
41      private final double ad;
42  
43      /** Second coefficient for hydrostatic (dry) component. */
44      private final double bd;
45  
46      /** First coefficient for wet component. */
47      private final double aw;
48  
49      /** Second coefficient for wet component. */
50      private final double bw;
51  
52      /** Builds a new instance.
53       * @param ad first coefficient for hydrostatic (dry) component
54       * @param bd second coefficient for hydrostatic (dry) component
55       * @param aw first coefficient for wet component
56       * @param bw second coefficient for wet component
57       */
58      protected AbstractChaoMappingFunction(final double ad, final double bd, final double aw, final double bw) {
59          this.ad = ad;
60          this.bd = bd;
61          this.aw = aw;
62          this.bw = bw;
63      }
64  
65      /** {@inheritDoc} */
66      @Override
67      public double[] mappingFactors(final TrackingCoordinates trackingCoordinates, final GeodeticPoint point,
68                                     final PressureTemperatureHumidity weather,
69                                     final AbsoluteDate date) {
70          final double sinE = FastMath.sin(trackingCoordinates.getElevation());
71          final double tanE = FastMath.tan(trackingCoordinates.getElevation());
72          return new double[] {
73              1 / (sinE + ad / (tanE + bd)),
74              1 / (sinE + aw / (tanE + bw))
75          };
76      }
77  
78      /** {@inheritDoc} */
79      @Override
80      public <T extends CalculusFieldElement<T>> T[] mappingFactors(final FieldTrackingCoordinates<T> trackingCoordinates,
81                                                                    final FieldGeodeticPoint<T> point,
82                                                                    final FieldPressureTemperatureHumidity<T> weather,
83                                                                    final FieldAbsoluteDate<T> date) {
84          final T sinE = FastMath.sin(trackingCoordinates.getElevation());
85          final T tanE = FastMath.tan(trackingCoordinates.getElevation());
86          final T[] mapping = MathArrays.buildArray(date.getField(), 2);
87          mapping[0] = sinE.add(tanE.add(bd).reciprocal().multiply(ad)).reciprocal();
88          mapping[1] = sinE.add(tanE.add(bw).reciprocal().multiply(aw)).reciprocal();
89          return mapping;
90      }
91  
92  }