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 ViennaThreeModelTest {
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 testMappingFactors() {
47          
48          // Site:     latitude:  37.5°
49          //           longitude: 277.5°
50          //           height:    824 m
51          //
52          // Date:     25 November 2018 at 0h UT
53          //
54          // Values: ah  = 0.00123462
55          //         aw  = 0.00047101
56          //         zhd = 2.1993 m
57          //         zwd = 0.0690 m
58          //
59          // Values taken from: http://vmf.geo.tuwien.ac.at/trop_products/GRID/5x5/VMF3/VMF3_OP/2018/VMF3_20181125.H00
60          //
61          // Expected mapping factors : hydrostatic -> 1.621024
62          //                                    wet -> 1.623023
63          //
64          // Expected outputs are obtained by performing the Matlab script vmf3.m provided by TU WIEN:
65          // http://vmf.geo.tuwien.ac.at/codes/
66          //
67  
68          final AbsoluteDate date = new AbsoluteDate(2018, 11, 25, TimeScalesFactory.getUTC());
69          
70          final double latitude     = FastMath.toRadians(37.5);
71          final double longitude    = FastMath.toRadians(277.5);
72          final double height       = 824.0;
73          final GeodeticPoint point = new GeodeticPoint(latitude, longitude, height);
74  
75          final double elevation     = FastMath.toRadians(38.0);
76          final double expectedHydro = 1.621024;
77          final double expectedWet   = 1.623023;
78          
79          final double[] a = {0.00123462, 0.00047101};
80          final double[] z = {2.1993, 0.0690};
81          
82          final ViennaThreeModel model = new ViennaThreeModel(a, z);
83          
84          final double[] computedMapping = model.mappingFactors(elevation, point, date);
85          
86          Assert.assertEquals(expectedHydro, computedMapping[0], epsilon);
87          Assert.assertEquals(expectedWet,   computedMapping[1], epsilon);
88      }
89  
90      @Test
91      public void testLowElevation() {
92          
93          // Site:     latitude:  37.5°
94          //           longitude: 277.5°
95          //           height:    824 m
96          //
97          // Date:     25 November 2018 at 0h UT
98          //
99          // Values: ah  = 0.00123462
100         //         aw  = 0.00047101
101         //         zhd = 2.1993 m
102         //         zwd = 0.0690 m
103         //
104         // Values taken from: http://vmf.geo.tuwien.ac.at/trop_products/GRID/5x5/VMF3/VMF3_OP/2018/VMF3_20181125.H00
105         //
106         // Expected mapping factors : hydrostatic -> 10.132802
107         //                                    wet -> 10.879154
108         //
109         // Expected outputs are obtained by performing the Matlab script vmf3.m provided by TU WIEN:
110         // http://vmf.geo.tuwien.ac.at/codes/
111         //
112 
113         final AbsoluteDate date = new AbsoluteDate(2018, 11, 25, TimeScalesFactory.getUTC());
114         
115         final double latitude     = FastMath.toRadians(37.5);
116         final double longitude    = FastMath.toRadians(277.5);
117         final double height       = 824.0;
118         final GeodeticPoint point = new GeodeticPoint(latitude, longitude, height);
119 
120         final double elevation     = FastMath.toRadians(5.0);
121         final double expectedHydro = 10.132802;
122         final double expectedWet   = 10.879154;
123         
124         final double[] a = {0.00123462, 0.00047101};
125         final double[] z = {2.1993, 0.0690};
126         
127         final ViennaThreeModel model = new ViennaThreeModel(a, z);
128         
129         final double[] computedMapping = model.mappingFactors(elevation, point, date);
130         
131         Assert.assertEquals(expectedHydro, computedMapping[0], epsilon);
132         Assert.assertEquals(expectedWet,   computedMapping[1], epsilon);
133     }
134 
135     @Test
136     public void testHightElevation() {
137         
138         // Site:     latitude:  37.5°
139         //           longitude: 277.5°
140         //           height:    824 m
141         //
142         // Date:     25 November 2018 at 0h UT
143         //
144         // Values: ah  = 0.00123462
145         //         aw  = 0.00047101
146         //         zhd = 2.1993 m
147         //         zwd = 0.0690 m
148         //
149         // Values taken from: http://vmf.geo.tuwien.ac.at/trop_products/GRID/5x5/VMF3/VMF3_OP/2018/VMF3_20181125.H00
150         //
151         // Expected mapping factors : hydrostatic -> 1.003810
152         //                                    wet -> 1.003816
153         //
154         // Expected outputs are obtained by performing the Matlab script vmf3.m provided by TU WIEN:
155         // http://vmf.geo.tuwien.ac.at/codes/
156         //
157 
158         final AbsoluteDate date = new AbsoluteDate(2018, 11, 25, TimeScalesFactory.getUTC());
159         
160         final double latitude     = FastMath.toRadians(37.5);
161         final double longitude    = FastMath.toRadians(277.5);
162         final double height       = 824.0;
163         final GeodeticPoint point = new GeodeticPoint(latitude, longitude, height);
164 
165         final double elevation     = FastMath.toRadians(85.0);
166         final double expectedHydro = 1.003810;
167         final double expectedWet   = 1.003816;
168         
169         final double[] a = {0.00123462, 0.00047101};
170         final double[] z = {2.1993, 0.0690};
171         
172         final ViennaThreeModel model = new ViennaThreeModel(a, z);
173         
174         final double[] computedMapping = model.mappingFactors(elevation, point, date);
175         
176         Assert.assertEquals(expectedHydro, computedMapping[0], epsilon);
177         Assert.assertEquals(expectedWet,   computedMapping[1], epsilon);
178     }
179 
180     @Test
181     public void testDelay() {
182         final double elevation = 10d;
183         final double height = 100d;
184         final AbsoluteDate date = new AbsoluteDate();
185         final double[] a = { 0.00123462, 0.00047101};
186         final double[] z = {2.1993, 0.0690};
187         final GeodeticPoint point = new GeodeticPoint(FastMath.toRadians(37.5), FastMath.toRadians(277.5), height);
188         ViennaThreeModel model = new ViennaThreeModel(a, z);
189         final double path = model.pathDelay(FastMath.toRadians(elevation), point, model.getParameters(), date);
190         Assert.assertTrue(Precision.compareTo(path, 20d, epsilon) < 0);
191         Assert.assertTrue(Precision.compareTo(path, 0d, epsilon) > 0);
192     }
193 
194     @Test
195     public void testFixedHeight() {
196         final AbsoluteDate date = new AbsoluteDate();
197         final double[] a = { 0.00123462, 0.00047101};
198         final double[] z = {2.1993, 0.0690};
199         final GeodeticPoint point = new GeodeticPoint(FastMath.toRadians(37.5), FastMath.toRadians(277.5), 350.0);
200         ViennaThreeModel model = new ViennaThreeModel(a, z);
201         double lastDelay = Double.MAX_VALUE;
202         // delay shall decline with increasing elevation angle
203         for (double elev = 10d; elev < 90d; elev += 8d) {
204             final double delay = model.pathDelay(FastMath.toRadians(elev), point, model.getParameters(), date);
205             Assert.assertTrue(Precision.compareTo(delay, lastDelay, epsilon) < 0);
206             lastDelay = delay;
207         }
208     }
209 
210 }