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  
19  import org.orekit.annotation.DefaultDataContext;
20  import org.orekit.bodies.GeodeticPoint;
21  import org.orekit.data.DataContext;
22  import org.orekit.data.DataProvidersManager;
23  import org.orekit.models.earth.Geoid;
24  import org.orekit.models.earth.troposphere.TroposphericModelUtils;
25  import org.orekit.models.earth.troposphere.ViennaACoefficients;
26  import org.orekit.time.AbsoluteDate;
27  import org.orekit.time.TimeScale;
28  
29  /** The Global Pressure and Temperature 2 (GPT2) model.
30   * This model is an empirical model that provides the temperature, the pressure and the water vapor pressure
31   * of a site depending its latitude and  longitude. This model also provides the a<sub>h</sub>
32   * and a<sub>w</sub> coefficients used for the {@link
33   * org.orekit.models.earth.troposphere.ViennaOneModel Vienna 1} model.
34   * <p>
35   * The requisite coefficients for the computation of the weather parameters are provided by the
36   * Department of Geodesy and Geoinformation of the Vienna University. They are based on an
37   * external grid file like "gpt2_1.grd" (1° x 1°) or "gpt2_5.grd" (5° x 5°) available at:
38   * <a href="http://vmf.geo.tuwien.ac.at/codes/"> link</a>
39   * </p>
40   * <p>
41   * A bilinear interpolation is performed in order to obtained the correct values of the weather parameters.
42   * </p>
43   * <p>
44   * The format is always the same, with and example shown below for the pressure and the temperature.
45   * <p>
46   * Example:
47   * </p>
48   * <pre>
49   * %  lat    lon   p:a0    A1   B1   A2   B2  T:a0    A1   B1   A2   B2
50   *   87.5    2.5 101421    21  409 -217 -122 259.2 -13.2 -6.1  2.6  0.3
51   *   87.5    7.5 101416    21  411 -213 -120 259.3 -13.1 -6.1  2.6  0.3
52   *   87.5   12.5 101411    22  413 -209 -118 259.3 -13.1 -6.1  2.6  0.3
53   *   87.5   17.5 101407    23  415 -205 -116 259.4 -13.0 -6.1  2.6  0.3
54   *   ...
55   * </pre>
56   *
57   * @see "K. Lagler, M. Schindelegger, J. Böhm, H. Krasna, T. Nilsson (2013),
58   * GPT2: empirical slant delay model for radio space geodetic techniques. Geophys
59   * Res Lett 40(6):1069–1073. doi:10.1002/grl.50288"
60   *
61   * @author Bryan Cazabonne
62   * as of 12.1, replaced by {@link GlobalPressureTemperature2}
63   */
64  @Deprecated
65  public class GlobalPressureTemperature2Model extends GlobalPressureTemperature2 implements WeatherModel {
66  
67      /** Default supported files name pattern. */
68      public static final String DEFAULT_SUPPORTED_NAMES = "gpt2_\\d+.grd";
69  
70      /** The hydrostatic and wet a coefficients loaded. */
71      private double[] coefficientsA;
72  
73      /** Geodetic site latitude, radians.*/
74      private final double latitude;
75  
76      /** Geodetic site longitude, radians.*/
77      private final double longitude;
78  
79      /** Temperature site, in kelvins. */
80      private double temperature;
81  
82      /** Pressure site, in hPa. */
83      private double pressure;
84  
85      /** water vapour pressure, in hPa. */
86      private double e0;
87  
88      /**
89       * Constructor with supported names given by user. This constructor uses the {@link
90       * DataContext#getDefault() default data context}.
91       *
92       * @param supportedNames supported names (files with extra columns like GPT2w or GPT3 can be used here)
93       * @param latitude geodetic latitude of the station, in radians
94       * @param longitude longitude geodetic longitude of the station, in radians
95       * @param geoid level surface of the gravity potential of a body (ignored since 12.1)
96       * @see #GlobalPressureTemperature2Model(String, double, double, Geoid,
97       * DataProvidersManager, TimeScale)
98       */
99      @DefaultDataContext
100     public GlobalPressureTemperature2Model(final String supportedNames, final double latitude,
101                                            final double longitude, final Geoid geoid) {
102         this(supportedNames, latitude, longitude, geoid,
103              DataContext.getDefault().getDataProvidersManager(),
104              DataContext.getDefault().getTimeScales().getUTC());
105     }
106 
107     /**
108      * Constructor with supported names and source of GPT2 auxiliary data given by user.
109      *
110      * @param supportedNames supported names (files with extra columns like GPT2w or GPT3 can be used here)
111      * @param latitude geodetic latitude of the station, in radians
112      * @param longitude longitude geodetic longitude of the station, in radians
113      * @param ignoredGeoid level surface of the gravity potential of a body (ignored since 12.1)
114      * @param dataProvidersManager provides access to auxiliary data.
115      * @param utc UTC time scale.
116      * @since 10.1
117      */
118     public GlobalPressureTemperature2Model(final String supportedNames,
119                                            final double latitude,
120                                            final double longitude,
121                                            final Geoid ignoredGeoid,
122                                            final DataProvidersManager dataProvidersManager,
123                                            final TimeScale utc) {
124         super(supportedNames, dataProvidersManager, utc);
125         this.coefficientsA = null;
126         this.temperature   = Double.NaN;
127         this.pressure      = Double.NaN;
128         this.e0            = Double.NaN;
129         this.latitude      = latitude;
130         this.longitude     = longitude;
131     }
132 
133     /**
134      * Constructor with default supported names. This constructor uses the {@link
135      * DataContext#getDefault() default data context}.
136      *
137      * @param latitude geodetic latitude of the station, in radians
138      * @param longitude geodetic latitude of the station, in radians
139      * @param geoid level surface of the gravity potential of a body (ignored since 12.1)
140      * @see #GlobalPressureTemperature2Model(String, double, double, Geoid,
141      * DataProvidersManager, TimeScale)
142      */
143     @DefaultDataContext
144     public GlobalPressureTemperature2Model(final double latitude, final double longitude, final Geoid geoid) {
145         this(DEFAULT_SUPPORTED_NAMES, latitude, longitude, geoid);
146     }
147 
148     /** Returns the a coefficients array.
149      * <ul>
150      * <li>double[0] = a<sub>h</sub>
151      * <li>double[1] = a<sub>w</sub>
152      * </ul>
153      * @return the a coefficients array
154      */
155     public double[] getA() {
156         return coefficientsA.clone();
157     }
158 
159     /** Returns the temperature at the station [K].
160      * @return the temperature at the station [K]
161      */
162     public double getTemperature() {
163         return temperature;
164     }
165 
166     /** Returns the pressure at the station [hPa].
167      * @return the pressure at the station [hPa]
168      */
169     public double getPressure() {
170         return pressure;
171     }
172 
173     /** Returns the water vapor pressure at the station [hPa].
174      * @return the water vapor pressure at the station [hPa]
175      */
176     public double getWaterVaporPressure() {
177         return e0;
178     }
179 
180     @Override
181     public void weatherParameters(final double stationHeight, final AbsoluteDate currentDate) {
182 
183         final GeodeticPoint location = new GeodeticPoint(latitude, longitude, stationHeight);
184 
185         // ah and aw coefficients
186         final ViennaACoefficients aC = getA(location, currentDate);
187         coefficientsA = new double[] {
188             aC.getAh(), aC.getAw()
189         };
190 
191         // Pressure, temperature, humidity
192         final PressureTemperatureHumidity pth = getWeatherParamerers(location, currentDate);
193         this.temperature = pth.getTemperature();
194         this.pressure    = TroposphericModelUtils.HECTO_PASCAL.fromSI(pth.getPressure());
195         this.e0          = TroposphericModelUtils.HECTO_PASCAL.fromSI(pth.getWaterVaporPressure());
196 
197     }
198 
199 }