1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.orekit.frames;
18
19 import org.junit.jupiter.api.Assertions;
20 import org.junit.jupiter.api.Test;
21 import org.orekit.data.AbstractFilesLoaderTest;
22 import org.orekit.errors.OrekitException;
23 import org.orekit.errors.OrekitMessages;
24 import org.orekit.time.AbsoluteDate;
25 import org.orekit.time.ChronologicalComparator;
26 import org.orekit.time.TimeScalesFactory;
27 import org.orekit.utils.Constants;
28 import org.orekit.utils.IERSConventions;
29
30 import java.util.SortedSet;
31 import java.util.TreeSet;
32
33
34 public class BulletinBFilesLoaderTest extends AbstractFilesLoaderTest {
35
36 @Test
37 public void testMissingMonths() {
38 setRoot("missing-months");
39 IERSConventions.NutationCorrectionConverter converter =
40 IERSConventions.IERS_2010.getNutationCorrectionConverter();
41 SortedSet<EOPEntry> history = new TreeSet<EOPEntry>(new ChronologicalComparator());
42 new BulletinBFilesLoader(FramesFactory.BULLETINB_2000_FILENAME, manager, () -> utc).fillHistory(converter, history);
43 Assertions.assertTrue(getMaxGap(history) > 5);
44 }
45
46 @Test
47 public void testStartDate() {
48 setRoot("regular-data");
49 IERSConventions.NutationCorrectionConverter converter =
50 IERSConventions.IERS_2010.getNutationCorrectionConverter();
51 SortedSet<EOPEntry> history = new TreeSet<EOPEntry>(new ChronologicalComparator());
52 new BulletinBFilesLoader(FramesFactory.BULLETINB_2000_FILENAME, manager, () -> utc).fillHistory(converter, history);
53 Assertions.assertEquals(new AbsoluteDate(2005, 12, 5, TimeScalesFactory.getUTC()),
54 new EOPHistory(IERSConventions.IERS_2010, history, true).getStartDate());
55 }
56
57 @Test
58 public void testEndDate() {
59 setRoot("regular-data");
60 IERSConventions.NutationCorrectionConverter converter =
61 IERSConventions.IERS_2010.getNutationCorrectionConverter();
62 SortedSet<EOPEntry> history = new TreeSet<EOPEntry>(new ChronologicalComparator());
63 new BulletinBFilesLoader(FramesFactory.BULLETINB_2000_FILENAME, manager, () -> utc).fillHistory(converter, history);
64 Assertions.assertTrue(getMaxGap(history) < 5);
65 Assertions.assertEquals(new AbsoluteDate(2006, 3, 5, TimeScalesFactory.getUTC()),
66 new EOPHistory(IERSConventions.IERS_2010, history, false).getEndDate());
67 }
68
69 @Test
70 public void testNewFormatNominal() {
71 setRoot("new-bulletinB");
72 IERSConventions.NutationCorrectionConverter converter =
73 IERSConventions.IERS_2010.getNutationCorrectionConverter();
74 SortedSet<EOPEntry> data = new TreeSet<EOPEntry>(new ChronologicalComparator());
75 new BulletinBFilesLoader("^bulletinb\\.270$", manager, () -> utc).fillHistory(converter, data);
76 EOPHistory history = new EOPHistory(IERSConventions.IERS_2010, data, true);
77 Assertions.assertEquals(new AbsoluteDate(2010, 6, 2, TimeScalesFactory.getUTC()),
78 history.getStartDate());
79 Assertions.assertEquals(new AbsoluteDate(2010, 7, 1, TimeScalesFactory.getUTC()),
80 history.getEndDate());
81 }
82
83 @Test
84 public void testOldFormatContent() {
85 setRoot("regular-data");
86 IERSConventions.NutationCorrectionConverter converter =
87 IERSConventions.IERS_2010.getNutationCorrectionConverter();
88 SortedSet<EOPEntry> data = new TreeSet<EOPEntry>(new ChronologicalComparator());
89 new BulletinBFilesLoader(FramesFactory.BULLETINB_2000_FILENAME, manager, () -> utc).fillHistory(converter, data);
90 EOPHistory history = new EOPHistory(IERSConventions.IERS_2010, data, true);
91 AbsoluteDate date = new AbsoluteDate(2006, 1, 11, 12, 0, 0, TimeScalesFactory.getUTC());
92 Assertions.assertEquals(msToS( (-3 * 0.073 + 27 * -0.130 + 27 * -0.244 - 3 * -0.264) / 48), history.getLOD(date), 1.0e-10);
93 Assertions.assertEquals( (-3 * 0.333275 + 27 * 0.333310 + 27 * 0.333506 - 3 * 0.333768) / 48, history.getUT1MinusUTC(date), 1.0e-10);
94 Assertions.assertEquals(asToRad((-3 * 0.04958 + 27 * 0.04927 + 27 * 0.04876 - 3 * 0.04854) / 48), history.getPoleCorrection(date).getXp(), 1.0e-10);
95 Assertions.assertEquals(asToRad((-3 * 0.38117 + 27 * 0.38105 + 27 * 0.38071 - 3 * 0.38036) / 48), history.getPoleCorrection(date).getYp(), 1.0e-10);
96 }
97
98 @Test
99 public void testOldFormat1980() {
100 setRoot("old-bulletinB");
101 IERSConventions.NutationCorrectionConverter converter =
102 IERSConventions.IERS_1996.getNutationCorrectionConverter();
103 SortedSet<EOPEntry> data = new TreeSet<EOPEntry>(new ChronologicalComparator());
104 new BulletinBFilesLoader("^bulletinb_IAU1980-220\\.txt$", manager, () -> utc).fillHistory(converter, data);
105 EOPHistory history = new EOPHistory(IERSConventions.IERS_1996, data, true);
106 Assertions.assertEquals(new AbsoluteDate(2006, 4, 4, TimeScalesFactory.getUTC()),
107 history.getStartDate());
108 Assertions.assertEquals(new AbsoluteDate(2006, 5, 4, TimeScalesFactory.getUTC()),
109 history.getEndDate());
110 }
111
112 @Test
113 public void testOldFormat1980RemovedFirstDates() {
114 setRoot("old-bulletinB");
115 IERSConventions.NutationCorrectionConverter converter =
116 IERSConventions.IERS_1996.getNutationCorrectionConverter();
117 SortedSet<EOPEntry> data = new TreeSet<EOPEntry>(new ChronologicalComparator());
118 new BulletinBFilesLoader("^bulletinb_IAU1980-220-edited\\.txt$", manager, () -> utc).fillHistory(converter, data);
119 EOPHistory history = new EOPHistory(IERSConventions.IERS_1996, data, true);
120 Assertions.assertEquals(new AbsoluteDate(2006, 4, 14, TimeScalesFactory.getUTC()),
121 history.getStartDate());
122 Assertions.assertEquals(new AbsoluteDate(2006, 5, 4, TimeScalesFactory.getUTC()),
123 history.getEndDate());
124 }
125
126 @Test
127 public void testOldFormatTruncated() {
128 setRoot("old-bulletinB");
129 IERSConventions.NutationCorrectionConverter converter =
130 IERSConventions.IERS_2010.getNutationCorrectionConverter();
131 SortedSet<EOPEntry> data = new TreeSet<EOPEntry>(new ChronologicalComparator());
132 try {
133 new BulletinBFilesLoader("^bulletinb_IAU2000-216-truncated\\.txt$", manager, () -> utc).fillHistory(converter, data);
134 } catch (OrekitException oe) {
135 Assertions.assertEquals(OrekitMessages.UNEXPECTED_END_OF_FILE_AFTER_LINE, oe.getSpecifier());
136 Assertions.assertEquals(54, ((Integer) oe.getParts()[1]).intValue());
137 }
138 }
139
140 @Test
141 public void testNewFormatContent() {
142 setRoot("new-bulletinB");
143 IERSConventions.NutationCorrectionConverter converter =
144 IERSConventions.IERS_2010.getNutationCorrectionConverter();
145 SortedSet<EOPEntry> data = new TreeSet<EOPEntry>(new ChronologicalComparator());
146 new BulletinBFilesLoader("^bulletinb\\.270$", manager, () -> utc).fillHistory(converter, data);
147 EOPHistory history = new EOPHistory(IERSConventions.IERS_2010, data, true);
148 AbsoluteDate date = new AbsoluteDate(2010, 6, 12, 12, 0, 0, TimeScalesFactory.getUTC());
149 Assertions.assertEquals(msToS(( -3 * 0.1202 + 27 * 0.0294 + 27 * 0.0682 - 3 * 0.1531) / 48), history.getLOD(date), 1.0e-10);
150 Assertions.assertEquals(msToS(( -3 * -57.1711 + 27 * -57.2523 + 27 * -57.3103 - 3 * -57.4101) / 48), history.getUT1MinusUTC(date), 1.0e-10);
151 Assertions.assertEquals(masToRad((-3 * -1.216 + 27 * 1.658 + 27 * 4.926 - 3 * 7.789) / 48), history.getPoleCorrection(date).getXp(), 1.0e-10);
152 Assertions.assertEquals(masToRad((-3 * 467.780 + 27 * 469.330 + 27 * 470.931 - 3 * 472.388) / 48), history.getPoleCorrection(date).getYp(), 1.0e-10);
153 Assertions.assertEquals(masToRad((-3 * 0.097 + 27 * 0.089 + 27 * 0.050 - 3 * -0.007) / 48), history.getNonRotatinOriginNutationCorrection(date)[0], 1.0e-10);
154 Assertions.assertEquals(masToRad((-3 * 0.071 + 27 * 0.066 + 27 * 0.090 - 3 * 0.111) / 48), history.getNonRotatinOriginNutationCorrection(date)[1], 1.0e-10);
155 }
156
157 @Test
158 public void testNewFormatRemovedFirstDates() {
159 setRoot("new-bulletinB");
160 IERSConventions.NutationCorrectionConverter converter =
161 IERSConventions.IERS_2010.getNutationCorrectionConverter();
162 SortedSet<EOPEntry> data = new TreeSet<EOPEntry>(new ChronologicalComparator());
163 new BulletinBFilesLoader("^bulletinb-edited\\.270$", manager, () -> utc).fillHistory(converter, data);
164 EOPHistory history = new EOPHistory(IERSConventions.IERS_2010, data, true);
165 Assertions.assertEquals(new AbsoluteDate(2010, 6, 11, TimeScalesFactory.getUTC()),
166 history.getStartDate());
167 }
168
169 private double msToS(double ms) {
170 return ms / 1000.0;
171 }
172
173 private double asToRad(double mas) {
174 return mas * Constants.ARC_SECONDS_TO_RADIANS;
175 }
176
177 private double masToRad(double mas) {
178 return mas * Constants.ARC_SECONDS_TO_RADIANS / 1000.0;
179 }
180
181 @Test
182 public void testNewFormatTruncated() {
183 Assertions.assertThrows(OrekitException.class, () -> {
184 setRoot("new-bulletinB");
185 IERSConventions.NutationCorrectionConverter converter =
186 IERSConventions.IERS_2010.getNutationCorrectionConverter();
187 SortedSet<EOPEntry> history = new TreeSet<EOPEntry>(new ChronologicalComparator());
188 new BulletinBFilesLoader("^bulletinb-truncated\\.270$", manager, () -> utc).fillHistory(converter, history);
189 });
190 }
191
192 @Test
193 public void testNewFormatTruncatedEarly() {
194 Assertions.assertThrows(OrekitException.class, () -> {
195 setRoot("new-bulletinB");
196 IERSConventions.NutationCorrectionConverter converter =
197 IERSConventions.IERS_2010.getNutationCorrectionConverter();
198 SortedSet<EOPEntry> history = new TreeSet<EOPEntry>(new ChronologicalComparator());
199 new BulletinBFilesLoader("^bulletinb-truncated-early\\.270$", manager, () -> utc).fillHistory(converter, history);
200 });
201 }
202
203 @Test
204 public void testNewFormatInconsistent() {
205 Assertions.assertThrows(OrekitException.class, () -> {
206 setRoot("new-bulletinB");
207 IERSConventions.NutationCorrectionConverter converter =
208 IERSConventions.IERS_2010.getNutationCorrectionConverter();
209 SortedSet<EOPEntry> history = new TreeSet<EOPEntry>(new ChronologicalComparator());
210 new BulletinBFilesLoader("^bulletinb-inconsistent\\.270$", manager, () -> utc).fillHistory(converter, history);
211 });
212 }
213
214 @Test
215 public void testNewFormatInconsistentDate() {
216 setRoot("new-bulletinB");
217 IERSConventions.NutationCorrectionConverter converter =
218 IERSConventions.IERS_2010.getNutationCorrectionConverter();
219 SortedSet<EOPEntry> history = new TreeSet<EOPEntry>(new ChronologicalComparator());
220 try {
221 new BulletinBFilesLoader("bulletinb-inconsistent-date.270", manager, () -> utc).fillHistory(converter, history);
222 Assertions.fail("an exception should have been thrown");
223 } catch (OrekitException oe) {
224 Assertions.assertEquals(OrekitMessages.INCONSISTENT_DATES_IN_IERS_FILE, oe.getSpecifier());
225 }
226 }
227
228 }