AbstractVienna.java

  1. /* Copyright 2002-2024 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.models.earth.troposphere;

  18. import java.util.Collections;
  19. import java.util.List;

  20. import org.hipparchus.CalculusFieldElement;
  21. import org.hipparchus.util.FastMath;
  22. import org.hipparchus.util.FieldSinCos;
  23. import org.hipparchus.util.SinCos;
  24. import org.orekit.bodies.FieldGeodeticPoint;
  25. import org.orekit.bodies.GeodeticPoint;
  26. import org.orekit.models.earth.weather.FieldPressureTemperatureHumidity;
  27. import org.orekit.models.earth.weather.PressureTemperatureHumidity;
  28. import org.orekit.time.AbsoluteDate;
  29. import org.orekit.time.FieldAbsoluteDate;
  30. import org.orekit.time.TimeScale;
  31. import org.orekit.utils.FieldTrackingCoordinates;
  32. import org.orekit.utils.ParameterDriver;
  33. import org.orekit.utils.TrackingCoordinates;

  34. /** The Vienna tropospheric delay model for radio techniques.
  35.  * @since 12.1
  36.  * @author Bryan Cazabonne
  37.  * @author Luc Maisonobe
  38.  */
  39. public abstract class AbstractVienna implements TroposphericModel, TroposphereMappingFunction {

  40.     /** C coefficient from Chen and Herring gradient mapping function.
  41.      * @see Modeling tropospheric delays for space geodetic techniques, Daniel Landskron, 2017, section 2.2
  42.      */
  43.     private static final double C = 0.0032;

  44.     /** Provider for a<sub>h</sub> and a<sub>w</sub> coefficients. */
  45.     private final ViennaAProvider aProvider;

  46.     /** Provider for {@link AzimuthalGradientCoefficients} and {@link FieldAzimuthalGradientCoefficients}. */
  47.     private final AzimuthalGradientProvider gProvider;

  48.     /** Provider for zenith delays. */
  49.     private final TroposphericModel zenithDelayProvider;

  50.     /** UTC time scale. */
  51.     private final TimeScale utc;

  52.     /** Build a new instance.
  53.      * @param aProvider provider for a<sub>h</sub> and a<sub>w</sub> coefficients
  54.      * @param gProvider provider for {@link AzimuthalGradientCoefficients} and {@link FieldAzimuthalGradientCoefficients}
  55.      * @param zenithDelayProvider provider for zenith delays
  56.      * @param utc                 UTC time scale
  57.      */
  58.     protected AbstractVienna(final ViennaAProvider aProvider,
  59.                              final AzimuthalGradientProvider gProvider,
  60.                              final TroposphericModel zenithDelayProvider,
  61.                              final TimeScale utc) {
  62.         this.aProvider           = aProvider;
  63.         this.gProvider           = gProvider;
  64.         this.zenithDelayProvider = zenithDelayProvider;
  65.         this.utc                 = utc;
  66.     }

  67.     /** {@inheritDoc} */
  68.     @Override
  69.     public TroposphericDelay pathDelay(final TrackingCoordinates trackingCoordinates,
  70.                                        final GeodeticPoint point,
  71.                                        final PressureTemperatureHumidity weather,
  72.                                        final double[] parameters, final AbsoluteDate date) {
  73.         // zenith delay
  74.         final TroposphericDelay delays =
  75.                         zenithDelayProvider.pathDelay(trackingCoordinates, point, weather, parameters, date);

  76.         // mapping function
  77.         final double[] mappingFunction =
  78.                         mappingFactors(trackingCoordinates, point, weather, date);

  79.         // horizontal gradient
  80.         final AzimuthalGradientCoefficients agc = gProvider.getGradientCoefficients(point, date);
  81.         final double gh;
  82.         final double gw;
  83.         if (agc != null) {

  84.             // Chen and Herring gradient mapping function
  85.             final double sinE = FastMath.sin(trackingCoordinates.getElevation());
  86.             final double tanE = FastMath.tan(trackingCoordinates.getElevation());
  87.             final double mfh  = 1.0 / (sinE * tanE + C);

  88.             final SinCos sc = FastMath.sinCos(trackingCoordinates.getAzimuth());
  89.             gh = mfh * (agc.getGnh() * sc.cos() + agc.getGeh() * sc.sin());
  90.             gw = mfh * (agc.getGnw() * sc.cos() + agc.getGew() * sc.sin());

  91.         } else {
  92.             gh = 0;
  93.             gw = 0;
  94.         }

  95.         // Tropospheric path delay
  96.         return new TroposphericDelay(delays.getZh(),
  97.                                      delays.getZw(),
  98.                                      delays.getZh() * mappingFunction[0] + gh,
  99.                                      delays.getZw() * mappingFunction[1] + gw);

  100.     }

  101.     /** {@inheritDoc} */
  102.     @Override
  103.     public <T extends CalculusFieldElement<T>> FieldTroposphericDelay<T> pathDelay(final FieldTrackingCoordinates<T> trackingCoordinates,
  104.                                                                                    final FieldGeodeticPoint<T> point,
  105.                                                                                    final FieldPressureTemperatureHumidity<T> weather,
  106.                                                                                    final T[] parameters, final FieldAbsoluteDate<T> date) {
  107.         // zenith delay
  108.         final FieldTroposphericDelay<T> delays =
  109.                         zenithDelayProvider.pathDelay(trackingCoordinates, point, weather, parameters, date);

  110.         // mapping function
  111.         final T[] mappingFunction =
  112.                         mappingFactors(trackingCoordinates, point, weather, date);

  113.         // horizontal gradient
  114.         final FieldAzimuthalGradientCoefficients<T> agc = gProvider.getGradientCoefficients(point, date);
  115.         final T gh;
  116.         final T gw;
  117.         if (agc != null) {

  118.             // Chen and Herring gradient mapping function
  119.             final T sinE = FastMath.sin(trackingCoordinates.getElevation());
  120.             final T tanE = FastMath.tan(trackingCoordinates.getElevation());
  121.             final T mfh  = sinE.multiply(tanE).add(C).reciprocal();

  122.             final FieldSinCos<T> sc = FastMath.sinCos(trackingCoordinates.getAzimuth());
  123.             gh = mfh.multiply(agc.getGnh().multiply(sc.cos()).add(agc.getGeh().multiply(sc.sin())));
  124.             gw = mfh.multiply(agc.getGnw().multiply(sc.cos()).add(agc.getGew().multiply(sc.sin())));

  125.         } else {
  126.             gh = date.getField().getZero();
  127.             gw = date.getField().getZero();
  128.         }

  129.         // Tropospheric path delay
  130.         return new FieldTroposphericDelay<>(delays.getZh(),
  131.                                             delays.getZw(),
  132.                                             delays.getZh().multiply(mappingFunction[0]).add(gh),
  133.                                             delays.getZw().multiply(mappingFunction[1]).add(gw));

  134.     }

  135.     /** {@inheritDoc} */
  136.     @Override
  137.     public List<ParameterDriver> getParametersDrivers() {
  138.         return Collections.emptyList();
  139.     }

  140.     /** Get provider for Vienna a<sub>h</sub> and a<sub>w</sub> coefficients.
  141.      * @return provider for Vienna a<sub>h</sub> and a<sub>w</sub> coefficients
  142.      */
  143.     protected ViennaAProvider getAProvider() {
  144.         return aProvider;
  145.     }

  146.     /** Get day of year.
  147.      * @param date date
  148.      * @return day of year
  149.      */
  150.     protected int getDayOfYear(final AbsoluteDate date) {
  151.         return date.getComponents(utc).getDate().getDayOfYear();
  152.     }

  153. }