1   /* Copyright 2002-2025 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.ionosphere;
18  
19  import org.hipparchus.CalculusFieldElement;
20  import org.hipparchus.Field;
21  import org.hipparchus.util.Binary64Field;
22  import org.hipparchus.util.FastMath;
23  import org.junit.jupiter.api.Assertions;
24  import org.junit.jupiter.api.BeforeEach;
25  import org.junit.jupiter.api.Test;
26  import org.orekit.Utils;
27  
28  public class SingleLayerModelMappingFunctionTest {
29  
30      @BeforeEach
31      public void setUp() throws Exception {
32          Utils.setDataRoot("regular-data");
33      }
34  
35      @Test
36      public void testMappingFactor() {
37          // Model
38          final IonosphericMappingFunction model = new SingleLayerModelMappingFunction();
39          // z = 70°
40          final double factor70 = model.mappingFactor(FastMath.toRadians(20.0));
41          Assertions.assertEquals(2.09, factor70, 0.01);
42          // z = 75°
43          final double factor75 = model.mappingFactor(FastMath.toRadians(15.0));
44          Assertions.assertEquals(2.32, factor75, 0.01);
45          // z = 80°
46          final double factor80 = model.mappingFactor(FastMath.toRadians(10.0));
47          Assertions.assertEquals(2.55, factor80, 0.01);
48          // z = 85°
49          final double factor85 = model.mappingFactor(FastMath.toRadians(5.0));
50          Assertions.assertEquals(2.73, factor85, 0.01);
51      }
52  
53      @Test
54      public void testFieldMappingFactor() {
55          doTestFieldMappingFactor(Binary64Field.getInstance());
56      }
57  
58      private <T extends CalculusFieldElement<T>> void doTestFieldMappingFactor(final Field<T> field) {
59          final T zero = field.getZero();
60          // Model
61          final IonosphericMappingFunction model = new SingleLayerModelMappingFunction();
62          // z = 70°
63          final T factor70 = model.mappingFactor(zero.add(FastMath.toRadians(20.0)));
64          Assertions.assertEquals(2.09, factor70.getReal(), 0.01);
65          // z = 75°
66          final T factor75 = model.mappingFactor(zero.add(FastMath.toRadians(15.0)));
67          Assertions.assertEquals(2.32, factor75.getReal(), 0.01);
68          // z = 80°
69          final T factor80 = model.mappingFactor(zero.add(FastMath.toRadians(10.0)));
70          Assertions.assertEquals(2.55, factor80.getReal(), 0.01);
71          // z = 85°
72          final T factor85 = model.mappingFactor(zero.add(FastMath.toRadians(5.0)));
73          Assertions.assertEquals(2.73, factor85.getReal(), 0.01);
74      }
75  
76  }