1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.orekit.forces.gravity.potential;
18
19 import org.hipparchus.util.FastMath;
20 import org.junit.jupiter.api.Assertions;
21 import org.junit.jupiter.api.BeforeEach;
22 import org.junit.jupiter.api.Test;
23 import org.orekit.Utils;
24 import org.orekit.data.DataContext;
25 import org.orekit.errors.OrekitException;
26 import org.orekit.errors.OrekitMessages;
27
28 import java.lang.reflect.Field;
29 import java.util.List;
30 import java.util.Map;
31
32 public class FESCHatEpsilonReaderTest {
33
34 @Test
35 void testTooLargeDegree()
36 {
37
38 try {
39 AstronomicalAmplitudeReader aaReader =
40 new AstronomicalAmplitudeReader("hf-fes2004.dat", 5, 2, 3, 1.0);
41 DataContext.getDefault().getDataProvidersManager().feed(aaReader.getSupportedNames(), aaReader);
42 Map<Integer, Double> map = aaReader.getAstronomicalAmplitudesMap();
43 OceanTidesReader reader2 = new FESCHatEpsilonReader("fes2004-7x7.dat",
44 0.01, FastMath.toRadians(1.0),
45 OceanLoadDeformationCoefficients.IERS_2010,
46 map);
47 reader2.setMaxParseDegree(8);
48 reader2.setMaxParseOrder(8);
49 DataContext.getDefault().getDataProvidersManager().feed(reader2.getSupportedNames(), reader2);
50 } catch (OrekitException oe) {
51 Assertions.assertEquals(OrekitMessages.OCEAN_TIDE_LOAD_DEFORMATION_LIMITS, oe.getSpecifier());
52 Assertions.assertEquals(6, ((Integer) oe.getParts()[0]).intValue());
53 Assertions.assertEquals(7, ((Integer) oe.getParts()[1]).intValue());
54 }
55 }
56
57 @Test
58 void testCoefficientsConversion2010()
59 throws SecurityException, NoSuchFieldException,
60 IllegalArgumentException, IllegalAccessException {
61 checkConversion(OceanLoadDeformationCoefficients.IERS_2010, 1.0e-14);
62 }
63
64 @Test
65 void testCoefficientsConversionGegout()
66 throws SecurityException, NoSuchFieldException,
67 IllegalArgumentException, IllegalAccessException {
68 checkConversion(OceanLoadDeformationCoefficients.GEGOUT, 1.7e-12);
69 }
70
71 private void checkConversion(OceanLoadDeformationCoefficients oldc,
72 double threshold)
73 throws SecurityException, NoSuchFieldException,
74 IllegalArgumentException, IllegalAccessException {
75
76 Field cGammaField = OceanTidesWave.class.getDeclaredField("cGamma");
77 cGammaField.setAccessible(true);
78 Field cPlusField = OceanTidesWave.class.getDeclaredField("cPlus");
79 cPlusField.setAccessible(true);
80 Field sPlusField = OceanTidesWave.class.getDeclaredField("sPlus");
81 sPlusField.setAccessible(true);
82 Field cMinusField = OceanTidesWave.class.getDeclaredField("cMinus");
83 cMinusField.setAccessible(true);
84 Field sMinusField = OceanTidesWave.class.getDeclaredField("sMinus");
85 sMinusField.setAccessible(true);
86
87 OceanTidesReader reader1 = new FESCnmSnmReader("fes2004_Cnm-Snm-8x8.dat", 1.0e-11);
88 reader1.setMaxParseDegree(6);
89 reader1.setMaxParseOrder(6);
90 DataContext.getDefault().getDataProvidersManager().feed(reader1.getSupportedNames(), reader1);
91 List<OceanTidesWave> waves1 = reader1.getWaves();
92
93 AstronomicalAmplitudeReader aaReader =
94 new AstronomicalAmplitudeReader("hf-fes2004.dat", 5, 2, 3, 1.0);
95 DataContext.getDefault().getDataProvidersManager().feed(aaReader.getSupportedNames(), aaReader);
96 Map<Integer, Double> map = aaReader.getAstronomicalAmplitudesMap();
97 OceanTidesReader reader2 = new FESCHatEpsilonReader("fes2004-7x7.dat",
98 0.01, FastMath.toRadians(1.0),
99 oldc,
100 map);
101 reader2.setMaxParseDegree(6);
102 reader2.setMaxParseOrder(6);
103 DataContext.getDefault().getDataProvidersManager().feed(reader2.getSupportedNames(), reader2);
104 List<OceanTidesWave> waves2 = reader2.getWaves();
105
106 for (OceanTidesWave wave1 : waves1) {
107
108 boolean found = false;
109 for (OceanTidesWave wave2 : waves2) {
110 if (wave1.getDoodson() == wave2.getDoodson()) {
111 found = true;
112
113 Assertions.assertEquals(wave1.getMaxDegree(), wave2.getMaxDegree());
114 Assertions.assertEquals(wave1.getMaxOrder(), wave2.getMaxOrder());
115 double[][] cP1 = (double[][]) cPlusField.get(wave1);
116 double[][] sP1 = (double[][]) sPlusField.get(wave1);
117 double[][] cM1 = (double[][]) cMinusField.get(wave1);
118 double[][] sM1 = (double[][]) sMinusField.get(wave1);
119 double[][] cP2 = (double[][]) cPlusField.get(wave2);
120 double[][] sP2 = (double[][]) sPlusField.get(wave2);
121 double[][] cM2 = (double[][]) cMinusField.get(wave2);
122 double[][] sM2 = (double[][]) sMinusField.get(wave2);
123
124 for (int n = 2; n <= wave1.getMaxDegree(); ++n) {
125 for (int m = 0; m <= FastMath.min(wave1.getMaxOrder(), n); ++m) {
126 Assertions.assertEquals(cP1[n][m], cP2[n][m], threshold);
127 Assertions.assertEquals(sP1[n][m], sP2[n][m], threshold);
128 Assertions.assertEquals(cM1[n][m], cM2[n][m], threshold);
129 Assertions.assertEquals(sM1[n][m], sM2[n][m], threshold);
130 }
131 }
132
133 }
134 }
135 Assertions.assertTrue(found);
136 }
137
138 }
139
140 @BeforeEach
141 public void setUp() {
142 Utils.setDataRoot("regular-data:tides");
143 }
144
145 }