GlobalPressureTemperature2Model.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.weather;

  18. import org.orekit.annotation.DefaultDataContext;
  19. import org.orekit.bodies.GeodeticPoint;
  20. import org.orekit.data.DataContext;
  21. import org.orekit.data.DataProvidersManager;
  22. import org.orekit.models.earth.Geoid;
  23. import org.orekit.models.earth.troposphere.TroposphericModelUtils;
  24. import org.orekit.models.earth.troposphere.ViennaACoefficients;
  25. import org.orekit.time.AbsoluteDate;
  26. import org.orekit.time.TimeScale;

  27. /** The Global Pressure and Temperature 2 (GPT2) model.
  28.  * This model is an empirical model that provides the temperature, the pressure and the water vapor pressure
  29.  * of a site depending its latitude and  longitude. This model also provides the a<sub>h</sub>
  30.  * and a<sub>w</sub> coefficients used for the {@link
  31.  * org.orekit.models.earth.troposphere.ViennaOneModel Vienna 1} model.
  32.  * <p>
  33.  * The requisite coefficients for the computation of the weather parameters are provided by the
  34.  * Department of Geodesy and Geoinformation of the Vienna University. They are based on an
  35.  * external grid file like "gpt2_1.grd" (1° x 1°) or "gpt2_5.grd" (5° x 5°) available at:
  36.  * <a href="http://vmf.geo.tuwien.ac.at/codes/"> link</a>
  37.  * </p>
  38.  * <p>
  39.  * A bilinear interpolation is performed in order to obtained the correct values of the weather parameters.
  40.  * </p>
  41.  * <p>
  42.  * The format is always the same, with and example shown below for the pressure and the temperature.
  43.  * <p>
  44.  * Example:
  45.  * </p>
  46.  * <pre>
  47.  * %  lat    lon   p:a0    A1   B1   A2   B2  T:a0    A1   B1   A2   B2
  48.  *   87.5    2.5 101421    21  409 -217 -122 259.2 -13.2 -6.1  2.6  0.3
  49.  *   87.5    7.5 101416    21  411 -213 -120 259.3 -13.1 -6.1  2.6  0.3
  50.  *   87.5   12.5 101411    22  413 -209 -118 259.3 -13.1 -6.1  2.6  0.3
  51.  *   87.5   17.5 101407    23  415 -205 -116 259.4 -13.0 -6.1  2.6  0.3
  52.  *   ...
  53.  * </pre>
  54.  *
  55.  * @see "K. Lagler, M. Schindelegger, J. Böhm, H. Krasna, T. Nilsson (2013),
  56.  * GPT2: empirical slant delay model for radio space geodetic techniques. Geophys
  57.  * Res Lett 40(6):1069–1073. doi:10.1002/grl.50288"
  58.  *
  59.  * @author Bryan Cazabonne
  60.  * as of 12.1, replaced by {@link GlobalPressureTemperature2}
  61.  */
  62. @Deprecated
  63. public class GlobalPressureTemperature2Model extends GlobalPressureTemperature2 implements WeatherModel {

  64.     /** Default supported files name pattern. */
  65.     public static final String DEFAULT_SUPPORTED_NAMES = "gpt2_\\d+.grd";

  66.     /** The hydrostatic and wet a coefficients loaded. */
  67.     private double[] coefficientsA;

  68.     /** Geodetic site latitude, radians.*/
  69.     private final double latitude;

  70.     /** Geodetic site longitude, radians.*/
  71.     private final double longitude;

  72.     /** Temperature site, in kelvins. */
  73.     private double temperature;

  74.     /** Pressure site, in hPa. */
  75.     private double pressure;

  76.     /** water vapour pressure, in hPa. */
  77.     private double e0;

  78.     /**
  79.      * Constructor with supported names given by user. This constructor uses the {@link
  80.      * DataContext#getDefault() default data context}.
  81.      *
  82.      * @param supportedNames supported names (files with extra columns like GPT2w or GPT3 can be used here)
  83.      * @param latitude geodetic latitude of the station, in radians
  84.      * @param longitude longitude geodetic longitude of the station, in radians
  85.      * @param geoid level surface of the gravity potential of a body (ignored since 12.1)
  86.      * @see #GlobalPressureTemperature2Model(String, double, double, Geoid,
  87.      * DataProvidersManager, TimeScale)
  88.      */
  89.     @DefaultDataContext
  90.     public GlobalPressureTemperature2Model(final String supportedNames, final double latitude,
  91.                                            final double longitude, final Geoid geoid) {
  92.         this(supportedNames, latitude, longitude, geoid,
  93.              DataContext.getDefault().getDataProvidersManager(),
  94.              DataContext.getDefault().getTimeScales().getUTC());
  95.     }

  96.     /**
  97.      * Constructor with supported names and source of GPT2 auxiliary data given by user.
  98.      *
  99.      * @param supportedNames supported names (files with extra columns like GPT2w or GPT3 can be used here)
  100.      * @param latitude geodetic latitude of the station, in radians
  101.      * @param longitude longitude geodetic longitude of the station, in radians
  102.      * @param ignoredGeoid level surface of the gravity potential of a body (ignored since 12.1)
  103.      * @param dataProvidersManager provides access to auxiliary data.
  104.      * @param utc UTC time scale.
  105.      * @since 10.1
  106.      */
  107.     public GlobalPressureTemperature2Model(final String supportedNames,
  108.                                            final double latitude,
  109.                                            final double longitude,
  110.                                            final Geoid ignoredGeoid,
  111.                                            final DataProvidersManager dataProvidersManager,
  112.                                            final TimeScale utc) {
  113.         super(supportedNames, dataProvidersManager, utc);
  114.         this.coefficientsA = null;
  115.         this.temperature   = Double.NaN;
  116.         this.pressure      = Double.NaN;
  117.         this.e0            = Double.NaN;
  118.         this.latitude      = latitude;
  119.         this.longitude     = longitude;
  120.     }

  121.     /**
  122.      * Constructor with default supported names. This constructor uses the {@link
  123.      * DataContext#getDefault() default data context}.
  124.      *
  125.      * @param latitude geodetic latitude of the station, in radians
  126.      * @param longitude geodetic latitude of the station, in radians
  127.      * @param geoid level surface of the gravity potential of a body (ignored since 12.1)
  128.      * @see #GlobalPressureTemperature2Model(String, double, double, Geoid,
  129.      * DataProvidersManager, TimeScale)
  130.      */
  131.     @DefaultDataContext
  132.     public GlobalPressureTemperature2Model(final double latitude, final double longitude, final Geoid geoid) {
  133.         this(DEFAULT_SUPPORTED_NAMES, latitude, longitude, geoid);
  134.     }

  135.     /** Returns the a coefficients array.
  136.      * <ul>
  137.      * <li>double[0] = a<sub>h</sub>
  138.      * <li>double[1] = a<sub>w</sub>
  139.      * </ul>
  140.      * @return the a coefficients array
  141.      */
  142.     public double[] getA() {
  143.         return coefficientsA.clone();
  144.     }

  145.     /** Returns the temperature at the station [K].
  146.      * @return the temperature at the station [K]
  147.      */
  148.     public double getTemperature() {
  149.         return temperature;
  150.     }

  151.     /** Returns the pressure at the station [hPa].
  152.      * @return the pressure at the station [hPa]
  153.      */
  154.     public double getPressure() {
  155.         return pressure;
  156.     }

  157.     /** Returns the water vapor pressure at the station [hPa].
  158.      * @return the water vapor pressure at the station [hPa]
  159.      */
  160.     public double getWaterVaporPressure() {
  161.         return e0;
  162.     }

  163.     @Override
  164.     public void weatherParameters(final double stationHeight, final AbsoluteDate currentDate) {

  165.         final GeodeticPoint location = new GeodeticPoint(latitude, longitude, stationHeight);

  166.         // ah and aw coefficients
  167.         final ViennaACoefficients aC = getA(location, currentDate);
  168.         coefficientsA = new double[] {
  169.             aC.getAh(), aC.getAw()
  170.         };

  171.         // Pressure, temperature, humidity
  172.         final PressureTemperatureHumidity pth = getWeatherParamerers(location, currentDate);
  173.         this.temperature = pth.getTemperature();
  174.         this.pressure    = TroposphericModelUtils.HECTO_PASCAL.fromSI(pth.getPressure());
  175.         this.e0          = TroposphericModelUtils.HECTO_PASCAL.fromSI(pth.getWaterVaporPressure());

  176.     }

  177. }