1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.orekit.frames;
18
19 import java.util.List;
20 import java.util.SortedSet;
21 import java.util.TreeSet;
22
23 import org.hipparchus.stat.descriptive.rank.Percentile;
24 import org.junit.jupiter.api.Assertions;
25 import org.junit.jupiter.api.BeforeEach;
26 import org.junit.jupiter.api.Test;
27 import org.orekit.data.AbstractFilesLoaderTest;
28 import org.orekit.time.AbsoluteDate;
29 import org.orekit.time.ChronologicalComparator;
30 import org.orekit.utils.IERSConventions;
31
32
33 public class EopCsvFilesLoaderTest extends AbstractFilesLoaderTest {
34
35 @Test
36 public void testEopc04Rates() {
37 EOPHistory history = load("eopc04_20.2022-now.csv");
38 Assertions.assertEquals(IERSConventions.IERS_2010, history.getConventions());
39 Assertions.assertEquals(new AbsoluteDate(2022, 1, 1, utc), history.getStartDate());
40 Assertions.assertEquals(new AbsoluteDate(2023, 8, 28, utc), history.getEndDate());
41 checkRatesConsistency(history, 0.049, 0.072, 0.063, 0.046);
42 }
43
44 @Test
45 public void testBulletinAWithoutRates() {
46 EOPHistory history = load("bulletina-xxxvi-037.csv");
47 Assertions.assertEquals(IERSConventions.IERS_2010, history.getConventions());
48 Assertions.assertEquals(new AbsoluteDate(2023, 8, 24, utc), history.getStartDate());
49 Assertions.assertEquals(new AbsoluteDate(2024, 9, 13, utc), history.getEndDate());
50 }
51
52 @Test
53 public void testBulletinAWithRatesOnlyInHeader() {
54 EOPHistory history = load("bulletina-xxxvi-038.csv");
55 Assertions.assertEquals(IERSConventions.IERS_2010, history.getConventions());
56 Assertions.assertEquals(new AbsoluteDate(2023, 8, 30, utc), history.getStartDate());
57 Assertions.assertEquals(new AbsoluteDate(2024, 9, 20, utc), history.getEndDate());
58 }
59
60 @Test
61 public void testBulletinBWithoutRates() {
62 EOPHistory history = load("bulletinb-423.csv");
63 Assertions.assertEquals(IERSConventions.IERS_2010, history.getConventions());
64 Assertions.assertEquals(new AbsoluteDate(2023, 3, 2, utc), history.getStartDate());
65 Assertions.assertEquals(new AbsoluteDate(2023, 5, 1, utc), history.getEndDate());
66 }
67
68 @Test
69 public void testBulletinBWithRatesOnlyInHeader() {
70 EOPHistory history = load("bulletinb-427.csv");
71 Assertions.assertEquals(IERSConventions.IERS_2010, history.getConventions());
72 Assertions.assertEquals(new AbsoluteDate(2023, 7, 2, utc), history.getStartDate());
73 Assertions.assertEquals(new AbsoluteDate(2023, 9, 1, utc), history.getEndDate());
74 }
75
76 @Test
77 public void testIssue1728() {
78 EOPHistory csvHistory = load("eopc04_14_IAU2000.24.csv");
79 final AbsoluteDate date = new AbsoluteDate(2024, 7, 25, 23, 35, 4, utc);
80
81 Assertions.assertEquals(0.021170741929032552, csvHistory.getUT1MinusUTC(date), 1.0e-25);
82 Assertions.assertEquals(-8.342402414219897E-5, csvHistory.getLOD(date), 1.0e-25);
83 Assertions.assertEquals(7.316737126610988E-7, csvHistory.getPoleCorrection(date).getXp(), 1.0e-25);
84 Assertions.assertEquals(2.325298397135211E-6, csvHistory.getPoleCorrection(date).getYp(), 1.0e-25);
85 Assertions.assertEquals(3.82064825755344E-9, csvHistory.getEquinoxNutationCorrection(date)[0], 1.0e-25);
86 Assertions.assertEquals(-1.1033150064768268E-9, csvHistory.getEquinoxNutationCorrection(date)[1], 1.0e-25);
87 Assertions.assertEquals(1.5135095005872742E-9, csvHistory.getNonRotatinOriginNutationCorrection(date)[0], 1.0e-25);
88 Assertions.assertEquals(-1.111662473262389E-9, csvHistory.getNonRotatinOriginNutationCorrection(date)[1], 1.0e-25);
89 }
90
91 private EOPHistory load(final String name) {
92 IERSConventions.NutationCorrectionConverter converter =
93 IERSConventions.IERS_2010.getNutationCorrectionConverter();
94 SortedSet<EOPEntry> data = new TreeSet<>(new ChronologicalComparator());
95 new EopCsvFilesLoader("^" + name + "$", manager, () -> utc).
96 fillHistory(converter, data);
97 return new EOPHistory(IERSConventions.IERS_2010, EOPHistory.DEFAULT_INTERPOLATION_DEGREE, data, true);
98 }
99
100 private final void checkRatesConsistency(final EOPHistory history,
101 final double tol10X, final double tol90X,
102 final double tol10Y, final double tol90Y) {
103
104 final List<EOPEntry> entries = history.getEntries();
105 double[] sampleX = new double[entries.size() - 2];
106 double[] sampleY = new double[entries.size() - 2];
107 for (int i = 1; i < entries.size() - 1; ++i) {
108 final EOPEntry previous = entries.get(i - 1);
109 final EOPEntry current = entries.get(i);
110 final EOPEntry next = entries.get(i + 1);
111 final double xRate = (next.getX() - previous.getX()) / next.durationFrom(previous);
112 final double yRate = (next.getY() - previous.getY()) / next.durationFrom(previous);
113 sampleX[i - 1] = (xRate - current.getXRate()) / xRate;
114 sampleY[i - 1] = (yRate - current.getYRate()) / yRate;
115 }
116
117 Assertions.assertEquals(0.0, new Percentile(10.0).evaluate(sampleX), tol10X);
118 Assertions.assertEquals(0.0, new Percentile(90.0).evaluate(sampleX), tol90X);
119 Assertions.assertEquals(0.0, new Percentile(10.0).evaluate(sampleY), tol10Y);
120 Assertions.assertEquals(0.0, new Percentile(90.0).evaluate(sampleY), tol90Y);
121
122 }
123
124 @BeforeEach
125 public void setUp() {
126 setRoot("eop-csv");
127 }
128
129 }