1   /* Copyright 2002-2022 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.FastMath;
20  import org.hipparchus.util.Precision;
21  import org.junit.Assert;
22  import org.junit.Before;
23  import org.junit.BeforeClass;
24  import org.junit.Test;
25  import org.orekit.Utils;
26  import org.orekit.bodies.GeodeticPoint;
27  import org.orekit.errors.OrekitException;
28  import org.orekit.time.AbsoluteDate;
29  import org.orekit.time.TimeScalesFactory;;
30  
31  public class MendesPavlisModelTest {
32      
33      private static double epsilon = 1e-6;
34  
35      @BeforeClass
36      public static void setUpGlobal() {
37          Utils.setDataRoot("atmosphere");
38      }
39  
40      @Before
41      public void setUp() throws OrekitException {
42          Utils.setDataRoot("regular-data:potential/shm-format");
43      }
44  
45      @Test
46      public void testZenithDelay() {
47          
48          // Site:   McDonald Observatory
49          //         latitude:  30.67166667 °
50          //         longitude: -104.0250 °
51          //         height:    2010.344 m
52          //
53          // Meteo:  pressure:            798.4188 hPa
54          //         water vapor presure: 14.322 hPa
55          //         temperature:         300.15 K
56          //         humidity:            40 %
57          //
58          // Ref:    Petit, G. and Luzum, B. (eds.), IERS Conventions (2010),
59          //         IERS Technical Note No. 36, BKG (2010)
60          
61          final double latitude     = FastMath.toRadians(30.67166667);
62          final double longitude    = FastMath.toRadians(-104.0250);
63          final double height       = 2010.344;
64          final double pressure     = 798.4188;
65          final double temperature  = 300.15;
66          final double humidity     = 0.4;
67          final double lambda       = 0.532;
68          final GeodeticPoint point = new GeodeticPoint(latitude, longitude, height);
69          
70          // Expected zenith hydrostatic delay: 1.932992 m (Ref)
71          final double expectedHydroDelay = 1.932992;
72          // Expected zenith wet delay: 0.223375*10-2 m (Ref)
73          final double expectedWetDelay   = 0.223375e-2;
74          // Expected total zenith delay: 1.935226 m (Ref)
75          final double expectedDelay      = 1.935226;
76          
77          final double precision = 4.0e-6;
78          
79          final AbsoluteDate date = new AbsoluteDate(2009, 8, 12, TimeScalesFactory.getUTC());
80  
81          final MendesPavlisModel model = new MendesPavlisModel(temperature, pressure,
82                                                                 humidity, lambda);
83          
84          final double[] computedDelay = model.computeZenithDelay(point, model.getParameters(), date);
85          
86          Assert.assertEquals(expectedHydroDelay, computedDelay[0],                    precision);
87          Assert.assertEquals(expectedWetDelay,                      computedDelay[1], precision);
88          Assert.assertEquals(expectedDelay,      computedDelay[0] + computedDelay[1], precision);
89  
90      }
91     
92      @Test
93      public void testMappingFactors() {
94          
95          // Site:   McDonald Observatory
96          //         latitude:  30.67166667 °
97          //         longitude: -104.0250 °
98          //         height:    2075 m
99          //
100         // Meteo:  pressure:            798.4188 hPa
101         //         water vapor presure: 14.322 hPa
102         //         temperature:         300.15 K
103         //         humidity:            40 %
104         //
105         // Ref:    Petit, G. and Luzum, B. (eds.), IERS Conventions (2010),
106         //         IERS Technical Note No. 36, BKG (2010)
107 
108         final AbsoluteDate date = new AbsoluteDate(2009, 8, 12, TimeScalesFactory.getUTC());
109         
110         final double latitude     = FastMath.toRadians(30.67166667);
111         final double longitude    = FastMath.toRadians(-104.0250);
112         final double height       = 2075;
113         final double pressure     = 798.4188;
114         final double temperature  = 300.15;
115         final double humidity     = 0.4;
116         final double lambda       = 0.532;
117         final GeodeticPoint point = new GeodeticPoint(latitude, longitude, height);
118         
119         final double elevation        = FastMath.toRadians(15.0);
120         // Expected mapping factor: 3.80024367 (Ref)
121         final double expectedMapping    = 3.80024367;
122         
123         // Test for the second constructor
124         final MendesPavlisModel model = new MendesPavlisModel(temperature, pressure,
125                                                                humidity, lambda);
126         
127         final double[] computedMapping = model.mappingFactors(elevation, point, date);
128 
129         Assert.assertEquals(expectedMapping, computedMapping[0], 5.0e-8);
130         Assert.assertEquals(expectedMapping, computedMapping[1], 5.0e-8);
131     }
132 
133     @Test
134     public void testDelay() {
135         final double elevation = 10d;
136         final double height = 100d;
137         final AbsoluteDate date = new AbsoluteDate();
138         final GeodeticPoint point = new GeodeticPoint(FastMath.toRadians(45.0), FastMath.toRadians(45.0), height);
139         MendesPavlisModel model = MendesPavlisModel.getStandardModel( 0.6943);
140         final double path = model.pathDelay(FastMath.toRadians(elevation), point, model.getParameters(), date);
141         Assert.assertTrue(Precision.compareTo(path, 20d, epsilon) < 0);
142         Assert.assertTrue(Precision.compareTo(path, 0d, epsilon) > 0);
143     }
144 
145     @Test
146     public void testFixedHeight() {
147         final AbsoluteDate date = new AbsoluteDate();
148         final GeodeticPoint point = new GeodeticPoint(FastMath.toRadians(45.0), FastMath.toRadians(45.0), 350.0);
149         MendesPavlisModel model = MendesPavlisModel.getStandardModel(0.6943);
150         double lastDelay = Double.MAX_VALUE;
151         // delay shall decline with increasing elevation angle
152         for (double elev = 10d; elev < 90d; elev += 8d) {
153             final double delay = model.pathDelay(FastMath.toRadians(elev), point, model.getParameters(), date);
154             Assert.assertTrue(Precision.compareTo(delay, lastDelay, epsilon) < 0);
155             lastDelay = delay;
156         }
157     }
158 
159 }