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 NiellMappingFunctionModelTest {
32  
33      @BeforeClass
34      public static void setUpGlobal() {
35          Utils.setDataRoot("atmosphere");
36      }
37  
38      @Before
39      public void setUp() throws OrekitException {
40          Utils.setDataRoot("regular-data:potential/shm-format");
41      }
42  
43      @Test
44      public void testMappingFactors() {
45          
46          // Site (Le Mans, France):      latitude:  48.0°
47          //                              longitude: 0.20°
48          //                              height:    68 m
49          //
50          // Date: 1st January 1994 at 0h UT
51          //
52          // Ref:    Mercier F., Perosanz F., Mesures GNSS, Résolution des ambiguités.
53          //
54          // Expected mapping factors : hydrostatic -> 10.16 (Ref)
55          //                                    wet -> 10.75 (Ref)
56  
57          final AbsoluteDate date = new AbsoluteDate(1994, 1, 1, TimeScalesFactory.getUTC());
58          
59          final double latitude    = FastMath.toRadians(48.0);
60          final double longitude   = FastMath.toRadians(0.20);
61          final double height      = 68.0;
62          final GeodeticPoint point = new GeodeticPoint(latitude, longitude, height);
63  
64          final double elevation     = FastMath.toRadians(5.0);
65          final double expectedHydro = 10.16;
66          final double expectedWet   = 10.75;
67  
68          final MappingFunction model = new NiellMappingFunctionModel();
69          
70          final double[] computedMapping = model.mappingFactors(elevation, point, date);
71          
72          Assert.assertEquals(expectedHydro, computedMapping[0], 1.0e-2);
73          Assert.assertEquals(expectedWet,   computedMapping[1], 1.0e-2);
74      }
75  
76      @Test
77      public void testFixedHeight() {
78          final AbsoluteDate date = new AbsoluteDate();
79          final GeodeticPoint point = new GeodeticPoint(FastMath.toRadians(45.0), FastMath.toRadians(45.0), 350.0);
80          MappingFunction model = new NiellMappingFunctionModel();
81          double[] lastFactors = new double[] {
82              Double.MAX_VALUE,
83              Double.MAX_VALUE
84          };
85          // mapping functions shall decline with increasing elevation angle
86          for (double elev = 10d; elev < 90d; elev += 8d) {
87              final double[] factors = model.mappingFactors(FastMath.toRadians(elev), point, date);
88              Assert.assertTrue(Precision.compareTo(factors[0], lastFactors[0], 1.0e-6) < 0);
89              Assert.assertTrue(Precision.compareTo(factors[1], lastFactors[1], 1.0e-6) < 0);
90              lastFactors[0] = factors[0];
91              lastFactors[1] = factors[1];
92          }
93      }
94  
95  }