1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.orekit.models.earth.ionosphere;
19
20 import org.junit.jupiter.api.Assertions;
21 import org.junit.jupiter.api.Test;
22 import org.orekit.Utils;
23 import org.orekit.errors.OrekitException;
24 import org.orekit.errors.OrekitMessages;
25 import org.orekit.time.DateComponents;
26
27 public class KlobucharIonoCoefficientsLoaderTest {
28
29 @Test
30
31
32
33 public void testRegularFile() {
34
35 Utils.setDataRoot("klobuchar-ionospheric-coefficients");
36
37 KlobucharIonoCoefficientsLoader ionoLoader = new KlobucharIonoCoefficientsLoader();
38 DateComponents dateComponents = new DateComponents(2017, 1);
39 ionoLoader.loadKlobucharIonosphericCoefficients(dateComponents);
40
41 final double alpha[] = ionoLoader.getAlpha();
42 final double beta[] = ionoLoader.getBeta();
43
44 Assertions.assertEquals(1.2821e-08 , alpha[0], 1e-16);
45 Assertions.assertEquals(-9.6222e-09, alpha[1], 1e-16);
46 Assertions.assertEquals(-3.5982e-07, alpha[2], 1e-16);
47 Assertions.assertEquals(-6.0901e-07, alpha[3], 1e-16);
48
49 Assertions.assertEquals(1.0840e+05 , beta[0], 1e-16);
50 Assertions.assertEquals(-1.3197e+05, beta[1], 1e-16);
51 Assertions.assertEquals(-2.6331e+05, beta[2], 1e-16);
52 Assertions.assertEquals(4.0570e+05 , beta[3], 1e-16);
53 }
54
55 @Test
56
57
58
59 public void testCorruptedFileBadKeyword() {
60
61 Utils.setDataRoot("klobuchar-ionospheric-coefficients");
62 final String fileName = "corrupted-bad-keyword-CGIM0020.17N";
63 KlobucharIonoCoefficientsLoader ionoLoader =
64 new KlobucharIonoCoefficientsLoader(fileName);
65
66 try {
67 ionoLoader.loadKlobucharIonosphericCoefficients();
68 Assertions.fail("An exception should have been thrown");
69
70 } catch (OrekitException oe) {
71 Assertions.assertEquals(OrekitMessages.NO_KLOBUCHAR_ALPHA_BETA_IN_FILE, oe.getSpecifier());
72 Assertions.assertTrue(((String) oe.getParts()[0]).endsWith(fileName));
73 }
74 }
75
76 @Test
77
78
79
80 public void testCorruptedFileBadData() {
81
82 Utils.setDataRoot("klobuchar-ionospheric-coefficients");
83 final String fileName = "corrupted-bad-data-CGIM0020.17N";
84 KlobucharIonoCoefficientsLoader ionoLoader =
85 new KlobucharIonoCoefficientsLoader(fileName);
86
87 try {
88 ionoLoader.loadKlobucharIonosphericCoefficients();
89 Assertions.fail("An exception should have been thrown");
90
91 } catch (OrekitException oe) {
92 Assertions.assertEquals(OrekitMessages.UNABLE_TO_PARSE_LINE_IN_FILE, oe.getSpecifier());
93 }
94 }
95
96 @Test
97
98
99
100 public void testAbsentFile() {
101
102 Utils.setDataRoot("klobuchar-ionospheric-coefficients");
103 KlobucharIonoCoefficientsLoader ionoLoader = new KlobucharIonoCoefficientsLoader();
104 DateComponents dateComponents = new DateComponents(2017, 3);
105
106 try {
107 ionoLoader.loadKlobucharIonosphericCoefficients(dateComponents);
108 Assertions.fail("An exception should have been thrown");
109
110 } catch (OrekitException oe) {
111 Assertions.assertEquals(OrekitMessages.KLOBUCHAR_ALPHA_BETA_NOT_AVAILABLE_FOR_DATE,
112 oe.getSpecifier());
113 Assertions.assertEquals(dateComponents.toString(),
114 (String) oe.getParts()[0]);
115 }
116 }
117 }