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