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 ViennaOneModelTest {
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 (NRAO, Green Bank, WV): latitude:  38°
49          //                              longitude: 280°
50          //                              height:    824.17 m
51          //
52          // Date: MJD 55055 -> 12 August 2009 at 0h UT
53          //
54          // Ref for the inputs:    Petit, G. and Luzum, B. (eds.), IERS Conventions (2010),
55          //                        IERS Technical Note No. 36, BKG (2010)
56          //
57          // Values: ah  = 0.00127683
58          //         aw  = 0.00060955
59          //         zhd = 2.0966 m
60          //         zwd = 0.2140 m
61          //
62          // Values taken from: http://vmf.geo.tuwien.ac.at/trop_products/GRID/2.5x2/VMF1/VMF1_OP/2009/VMFG_20090812.H00
63          //
64          // Expected mapping factors : hydrostatic -> 3.425088
65          //                                    wet -> 3.448300
66          //
67          // Expected outputs are obtained by performing the Matlab script vmf1_ht.m provided by TU WIEN:
68          // http://vmf.geo.tuwien.ac.at/codes/
69          //
70  
71          final AbsoluteDate date = AbsoluteDate.createMJDDate(55055, 0, TimeScalesFactory.getUTC());
72          
73          final double latitude     = FastMath.toRadians(38.0);
74          final double longitude    = FastMath.toRadians(280.0);
75          final double height       = 824.17;
76          final GeodeticPoint point = new GeodeticPoint(latitude, longitude, height);
77  
78          final double elevation     = 0.5 * FastMath.PI - 1.278564131;
79          final double expectedHydro = 3.425088;
80          final double expectedWet   = 3.448300;
81          
82          final double[] a = { 0.00127683, 0.00060955 };
83          final double[] z = {2.0966, 0.2140};
84          
85          final ViennaOneModel model = new ViennaOneModel(a, z);
86          
87          final double[] computedMapping = model.mappingFactors(elevation, point, date);
88          
89          Assert.assertEquals(expectedHydro, computedMapping[0], 4.1e-6);
90          Assert.assertEquals(expectedWet,   computedMapping[1], 1.0e-6);
91      }
92  
93      @Test
94      public void testDelay() {
95          final double elevation = 10d;
96          final double height = 100d;
97          final AbsoluteDate date = new AbsoluteDate();
98          final double[] a = { 0.00127683, 0.00060955 };
99          final double[] z = {2.0966, 0.2140};
100         final GeodeticPoint point = new GeodeticPoint(FastMath.toRadians(45.0), FastMath.toRadians(45.0), height);
101         ViennaOneModel model = new ViennaOneModel(a, z);
102         final double path = model.pathDelay(FastMath.toRadians(elevation), point, model.getParameters(), date);
103         Assert.assertTrue(Precision.compareTo(path, 20d, epsilon) < 0);
104         Assert.assertTrue(Precision.compareTo(path, 0d, epsilon) > 0);
105     }
106 
107     @Test
108     public void testFixedHeight() {
109         final AbsoluteDate date = new AbsoluteDate();
110         final double[] a = { 0.00127683, 0.00060955 };
111         final double[] z = {2.0966, 0.2140};
112         final GeodeticPoint point = new GeodeticPoint(FastMath.toRadians(45.0), FastMath.toRadians(45.0), 350.0);
113         ViennaOneModel model = new ViennaOneModel(a, z);
114         double lastDelay = Double.MAX_VALUE;
115         // delay shall decline with increasing elevation angle
116         for (double elev = 10d; elev < 90d; elev += 8d) {
117             final double delay = model.pathDelay(FastMath.toRadians(elev), point, model.getParameters(), date);
118             Assert.assertTrue(Precision.compareTo(delay, lastDelay, epsilon) < 0);
119             lastDelay = delay;
120         }
121     }
122 
123 }