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 GlobalMappingFunctionModelTest {
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 (NRAO, Green Bank, WV): latitude:  0.6708665767 radians
47          //                              longitude: -1.393397187 radians
48          //                              height:    844.715 m
49          //
50          // Date: MJD 55055 -> 12 August 2009 at 0h UT
51          //
52          // Ref:    Petit, G. and Luzum, B. (eds.), IERS Conventions (2010),
53          //         IERS Technical Note No. 36, BKG (2010)
54          //
55          // Expected mapping factors : hydrostatic -> 3.425246 (Ref)
56          //                                    wet -> 3.449589 (Ref)
57  
58          final AbsoluteDate date = AbsoluteDate.createMJDDate(55055, 0, TimeScalesFactory.getUTC());
59          
60          final double latitude    = 0.6708665767;
61          final double longitude   = -1.393397187;
62          final double height      = 844.715;
63          final GeodeticPoint point = new GeodeticPoint(latitude, longitude, height);
64  
65          final double elevation     = 0.5 * FastMath.PI - 1.278564131;
66          final double expectedHydro = 3.425246;
67          final double expectedWet   = 3.449589;
68  
69          final MappingFunction model = new GlobalMappingFunctionModel();
70          
71          final double[] computedMapping = model.mappingFactors(elevation, point, date);
72          
73          Assert.assertEquals(expectedHydro, computedMapping[0], 1.0e-6);
74          Assert.assertEquals(expectedWet,   computedMapping[1], 1.0e-6);
75      }
76  
77      @Test
78      public void testFixedHeight() {
79          final AbsoluteDate date = new AbsoluteDate();
80          MappingFunction model = new GlobalMappingFunctionModel();
81          double[] lastFactors = new double[] {
82              Double.MAX_VALUE,
83              Double.MAX_VALUE
84          };
85          GeodeticPoint point = new GeodeticPoint(FastMath.toRadians(45.0), FastMath.toRadians(45.0), 350.0);
86          // mapping functions shall decline with increasing elevation angle
87          for (double elev = 10d; elev < 90d; elev += 8d) {
88              final double[] factors = model.mappingFactors(FastMath.toRadians(elev), point, date);
89              Assert.assertTrue(Precision.compareTo(factors[0], lastFactors[0], 1.0e-6) < 0);
90              Assert.assertTrue(Precision.compareTo(factors[1], lastFactors[1], 1.0e-6) < 0);
91              lastFactors[0] = factors[0];
92              lastFactors[1] = factors[1];
93          }
94      }
95  
96  }