1   /* Copyright 2002-2025 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  
19  import org.hipparchus.util.Binary64Field;
20  import org.hipparchus.util.FastMath;
21  import org.junit.jupiter.api.Test;
22  import org.orekit.bodies.GeodeticPoint;
23  import org.orekit.data.DataSource;
24  import org.orekit.models.earth.weather.ConstantPressureTemperatureHumidityProvider;
25  import org.orekit.models.earth.weather.GlobalPressureTemperature3;
26  import org.orekit.models.earth.weather.PressureTemperatureHumidity;
27  import org.orekit.models.earth.weather.PressureTemperatureHumidityProvider;
28  import org.orekit.models.earth.weather.water.CIPM2007;
29  import org.orekit.time.AbsoluteDate;
30  import org.orekit.time.TimeScale;
31  import org.orekit.time.TimeScalesFactory;
32  import org.orekit.utils.TrackingCoordinates;
33  import org.orekit.utils.units.Unit;
34  
35  import java.io.IOException;
36  import java.net.URISyntaxException;
37  import java.net.URL;
38  
39  public class MendesPavlisModelTest extends AbstractPathDelayTest<MendesPavlisModel> {
40  
41      protected MendesPavlisModel buildTroposphericModel(PressureTemperatureHumidityProvider provider) {
42          // the provider for Mendes-Pavlis model is hard-coded
43          final double height      = 2010.344;
44          final double pressure    = TroposphericModelUtils.HECTO_PASCAL.toSI(798.4188);
45          final double temperature = 300.15;
46          final double humidity    = 0.4;
47          final PressureTemperatureHumidity pth =
48              new PressureTemperatureHumidity(height, pressure, temperature,
49                                              new CIPM2007().waterVaporPressure(pressure, temperature, humidity),
50                                              Double.NaN,  Double.NaN);
51          return new MendesPavlisModel(new ConstantPressureTemperatureHumidityProvider(pth),
52                                       0.532, TroposphericModelUtils.MICRO_M);
53      }
54  
55      @Test
56      @Override
57      public void testFixedHeight() {
58          doTestFixedHeight(null);
59      }
60  
61      @Test
62      @Override
63      public void testFieldFixedHeight() {
64          doTestFieldFixedHeight(Binary64Field.getInstance(), null);
65      }
66  
67      @Test
68      @Override
69      public void testFixedElevation() {
70          doTestFixedElevation(null);
71      }
72  
73      @Test
74      @Override
75      public void testFieldFixedElevation() {
76          doTestFieldFixedElevation(Binary64Field.getInstance(), null);
77      }
78  
79      @Test
80      @Override
81      public void testDelay() {
82  
83          // Site:   McDonald Observatory
84          //         latitude:  30.67166667 °
85          //         longitude: -104.0250 °
86          //         height:    2010.344 m
87          //
88          // Meteo:  pressure:            798.4188 hPa
89          //         water vapor presure: 14.322 hPa
90          //         temperature:         300.15 K
91          //         humidity:            40 %
92          //
93          // Ref:    Petit, G. and Luzum, B. (eds.), IERS Conventions (2010),
94          //         IERS Technical Note No. 36, BKG (2010)
95  
96          doTestDelay(new AbsoluteDate(2009, 8, 12, TimeScalesFactory.getUTC()),
97                      new GeodeticPoint(FastMath.toRadians(30.67166667), FastMath.toRadians(-104.0250), 2010.344), new TrackingCoordinates(0, FastMath.toRadians(38.0), 0),
98                      null,
99                      1.932992, 0.223375e-2, 3.1334, 0.00362, 3.136995);
100 
101     }
102 
103     @Test
104     @Override
105     public void testFieldDelay() {
106 
107         // Site:   McDonald Observatory
108         //         latitude:  30.67166667 °
109         //         longitude: -104.0250 °
110         //         height:    2010.344 m
111         //
112         // Meteo:  pressure:            798.4188 hPa
113         //         water vapor presure: 14.322 hPa
114         //         temperature:         300.15 K
115         //         humidity:            40 %
116         //
117         // Ref:    Petit, G. and Luzum, B. (eds.), IERS Conventions (2010),
118         //         IERS Technical Note No. 36, BKG (2010)
119 
120         doTestDelay(Binary64Field.getInstance(),
121                     new AbsoluteDate(2009, 8, 12, TimeScalesFactory.getUTC()),
122                     new GeodeticPoint(FastMath.toRadians(30.67166667),
123                                       FastMath.toRadians(-104.0250),
124                                       2010.344),
125                     new TrackingCoordinates(0, FastMath.toRadians(38.0), 0),
126                     null,
127                     1.932992, 0.223375e-2, 3.1334, 0.00362, 3.136995);
128 
129     }
130 
131     @Test
132     public void testVsMariniMurray() throws IOException, URISyntaxException {
133         final TimeScale utc = TimeScalesFactory.getUTC();
134         final URL url = ModifiedSaastamoinenModelTest.class.getClassLoader().getResource("gpt-grid/gpt3_5.grd");
135         final PressureTemperatureHumidityProvider provider =
136             new GlobalPressureTemperature3(new DataSource(url.toURI()), utc);
137         final double lambda = 0.532;
138         final Unit lambdaUnits = TroposphericModelUtils.MICRO_M;
139         doTestVsOtherModel(new MariniMurray(lambda, lambdaUnits, provider),
140                            new MendesPavlisModel(provider, lambda, lambdaUnits),
141                            1.2e-3, 6.7e-5, 0.18, 3.3e-4);
142     }
143 
144 }