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.frames.Frame;
23  import org.orekit.models.earth.Geoid;
24  import org.orekit.models.earth.ReferenceEllipsoid;
25  import org.orekit.models.earth.troposphere.TroposphericModelUtils;
26  import org.orekit.time.AbsoluteDate;
27  
28  /** The Global Pressure and Temperature model.
29   * This model is an empirical model that provides the temperature and the pressure depending
30   * the latitude and the longitude of the station.
31   * <p>
32   * The Global Pressure and Temperature model is based on spherical harmonics up
33   * to degree and order of 9. The residual values ​​of this model can reach 20 hPa
34   * for pressure and 10 ° C for temperature. They are significant for higher latitudes and
35   * small near the equator (Böhm, 2007)
36   * </p>
37   *
38   * @see "J. Böhm, R. Heinkelmann, and H. Schuh (2007),
39   * Short Note: A global model of pressure and temperature for geodetic applications. J Geod,
40   * doi:10.1007/s00190-007-0135-3."
41   *
42   * @author Bryan Cazabonne
43   * @deprecated as of 12.1, replaced by {@link GlobalPressureTemperature}
44   */
45  @Deprecated
46  public class GlobalPressureTemperatureModel extends GlobalPressureTemperature implements WeatherModel {
47  
48      /** Spherical harmonics degree. */
49      private static final int DEGREE = 9;
50  
51      /** Spherical harmonics order. */
52      private static final int ORDER = 9;
53  
54      /** Geodetic latitude, in radians. */
55      private final double latitude;
56  
57      /** Geodetic longitude, in radians. */
58      private final double longitude;
59  
60      /** Temperature site, in kelvins. */
61      private double temperature;
62  
63      /** Pressure site, in hPa. */
64      private double pressure;
65  
66      /** Build a new instance.
67       * <p>
68       * At the initialization the values of the pressure and the temperature are set to NaN.
69       * The user has to call {@link #weatherParameters(double, AbsoluteDate)} method before using
70       * the values of the pressure and the temperature.
71       * </p>
72       *
73       * <p>This method uses the {@link DataContext#getDefault() default data context}.
74       *
75       * @param latitude geodetic latitude, in radians
76       * @param longitude geodetic longitude, in radians
77       * @param bodyFrame the frame to attach to the ellipsoid. The origin is at
78       *                  the center of mass, the z axis is the minor axis.
79       * @see #GlobalPressureTemperatureModel(double, double, Frame, DataContext)
80       */
81      @DefaultDataContext
82      public GlobalPressureTemperatureModel(final double latitude, final double longitude, final Frame bodyFrame) {
83          this(latitude, longitude, bodyFrame, DataContext.getDefault());
84      }
85  
86      /** Build a new instance.
87       * <p>
88       * At the initialization the values of the pressure and the temperature are set to NaN.
89       * The user has to call {@link #weatherParameters(double, AbsoluteDate)} method before using
90       * the values of the pressure and the temperature.
91       * </p>
92       * @param latitude geodetic latitude, in radians
93       * @param longitude geodetic longitude, in radians
94       * @param bodyFrame the frame to attach to the ellipsoid. The origin is at
95       * @param dataContext to use for time and gravity.
96       * @since 10.1
97       */
98      public GlobalPressureTemperatureModel(final double latitude,
99                                            final double longitude,
100                                           final Frame bodyFrame,
101                                           final DataContext dataContext) {
102         super(new Geoid(dataContext.getGravityFields().getNormalizedProvider(DEGREE, ORDER),
103                         ReferenceEllipsoid.getWgs84(bodyFrame)),
104               dataContext.getTimeScales().getUTC());
105         this.latitude    = latitude;
106         this.longitude   = longitude;
107         this.temperature = Double.NaN;
108         this.pressure    = Double.NaN;
109     }
110 
111     /** Get the atmospheric temperature of the station depending its position.
112      * @return the temperature in kelvins
113      */
114     public double getTemperature() {
115         return temperature;
116     }
117 
118     /** Get the atmospheric pressure of the station depending its position.
119      * @return the pressure in hPa
120      */
121     public double getPressure() {
122         return pressure;
123     }
124 
125     @Override
126     public void weatherParameters(final double height, final AbsoluteDate date) {
127 
128         final GeodeticPoint location = new GeodeticPoint(latitude, longitude, height);
129 
130         // Pressure and temperature
131         final PressureTemperature pt = getWeatherParameters(location, date);
132         this.temperature = pt.getTemperature();
133         this.pressure    = TroposphericModelUtils.HECTO_PASCAL.fromSI(pt.getPressure());
134 
135     }
136 
137 }