1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.orekit.frames;
18
19
20 import java.util.SortedSet;
21 import java.util.TreeSet;
22
23 import org.junit.Assert;
24 import org.junit.Test;
25 import org.orekit.data.AbstractFilesLoaderTest;
26 import org.orekit.errors.OrekitException;
27 import org.orekit.errors.OrekitMessages;
28 import org.orekit.time.AbsoluteDate;
29 import org.orekit.time.ChronologicalComparator;
30 import org.orekit.time.DateComponents;
31 import org.orekit.time.TimeScalesFactory;
32 import org.orekit.utils.Constants;
33 import org.orekit.utils.IERSConventions;
34
35
36 public class BulletinAFilesLoaderTest extends AbstractFilesLoaderTest {
37
38 @Test
39 public void testStartDate() {
40 setRoot("bulletinA");
41 SortedSet<EOPEntry> history = new TreeSet<EOPEntry>(new ChronologicalComparator());
42 new BulletinAFilesLoader("bulletina-xxvi-\\d\\d\\d\\.txt", manager, () -> utc).fillHistory(null, history);
43 Assert.assertEquals(new AbsoluteDate(new DateComponents(DateComponents.MODIFIED_JULIAN_EPOCH, 56475),
44 TimeScalesFactory.getUTC()),
45 new EOPHistory(IERSConventions.IERS_2010, history, true).getStartDate());
46 }
47
48 @Test
49 public void testEndDate() {
50 setRoot("bulletinA");
51 SortedSet<EOPEntry> history = new TreeSet<EOPEntry>(new ChronologicalComparator());
52 new BulletinAFilesLoader("bulletina-xxvi-\\d\\d\\d\\.txt", manager, () -> utc).fillHistory(null, history);
53 Assert.assertTrue(getMaxGap(history) < 2);
54 Assert.assertEquals(new AbsoluteDate(new DateComponents(DateComponents.MODIFIED_JULIAN_EPOCH, 56968),
55 TimeScalesFactory.getUTC()),
56 new EOPHistory(IERSConventions.IERS_2010, history, false).getEndDate());
57 }
58
59 @Test
60 public void testSingleFile() {
61 setRoot("bulletinA");
62 SortedSet<EOPEntry> data = new TreeSet<EOPEntry>(new ChronologicalComparator());
63 new BulletinAFilesLoader("bulletina-xxvi-039.txt", manager, () -> utc).fillHistory(null, data);
64 EOPHistory history = new EOPHistory(IERSConventions.IERS_2010, data, true);
65
66
67 Assert.assertEquals(new AbsoluteDate(new DateComponents(DateComponents.MODIFIED_JULIAN_EPOCH, 56546),
68 TimeScalesFactory.getUTC()),
69 history.getStartDate());
70
71
72 Assert.assertEquals(56555 - 56548, getMaxGap(data));
73
74
75 Assert.assertEquals(new AbsoluteDate(new DateComponents(DateComponents.MODIFIED_JULIAN_EPOCH, 56926),
76 TimeScalesFactory.getUTC()),
77 history.getEndDate());
78 }
79
80 @Test
81 public void testRapidDataContent() {
82 setRoot("bulletinA");
83 SortedSet<EOPEntry> data = new TreeSet<EOPEntry>(new ChronologicalComparator());
84 new BulletinAFilesLoader(FramesFactory.BULLETINA_FILENAME, manager, () -> utc).fillHistory(null, data);
85 EOPHistory history = new EOPHistory(IERSConventions.IERS_2010, data, true);
86 AbsoluteDate date = new AbsoluteDate(2013, 10, 14, 12, 0, 0, TimeScalesFactory.getUTC());
87
88 Assert.assertEquals( (-3 * -0.001957 + 27 * -0.003274 + 27 * -0.004706 - 3 * -0.006211) / 48, history.getUT1MinusUTC(date), 1.0e-10);
89 Assert.assertEquals(asToRad((-3 * 0.11518 + 27 * 0.11389 + 27 * 0.11285 - 3 * 0.11171) / 48), history.getPoleCorrection(date).getXp(), 1.0e-10);
90 Assert.assertEquals(asToRad((-3 * 0.28484 + 27 * 0.28449 + 27 * 0.28408 - 3 * 0.28379) / 48), history.getPoleCorrection(date).getYp(), 1.0e-10);
91 }
92
93 @Test
94 public void testFinalValuesContent() {
95 setRoot("bulletinA");
96 SortedSet<EOPEntry> data = new TreeSet<EOPEntry>(new ChronologicalComparator());
97 new BulletinAFilesLoader(FramesFactory.BULLETINA_FILENAME, manager, () -> utc).fillHistory(null, data);
98 EOPHistory history = new EOPHistory(IERSConventions.IERS_2010, data, true);
99 AbsoluteDate date = new AbsoluteDate(2013, 8, 26, 12, 0, 0, TimeScalesFactory.getUTC());
100
101 Assert.assertEquals( (-3 * 0.04058 + 27 * 0.04000 + 27 * 0.03953 - 3 * 0.03917) / 48, history.getUT1MinusUTC(date), 1.0e-10);
102 Assert.assertEquals(asToRad((-3 * 0.1692 + 27 * 0.1689 + 27 * 0.1685 - 3 * 0.1684) / 48), history.getPoleCorrection(date).getXp(), 1.0e-10);
103 Assert.assertEquals(asToRad((-3 * 0.3336 + 27 * 0.3322 + 27 * 0.3307 - 3 * 0.3294) / 48), history.getPoleCorrection(date).getYp(), 1.0e-10);
104 }
105
106 private double asToRad(double mas) {
107 return mas * Constants.ARC_SECONDS_TO_RADIANS;
108 }
109
110 @Test
111 public void testMissingSections() {
112 setRoot("bulletinA");
113 checkTruncated("bulletina-missing-eop-rapid-service.txt", OrekitMessages.NOT_A_SUPPORTED_IERS_DATA_FILE);
114 checkTruncated("bulletina-missing-eop-prediction.txt", OrekitMessages.NOT_A_SUPPORTED_IERS_DATA_FILE);
115 checkTruncated("bulletina-with-1980-without-2000-rapid.txt", OrekitMessages.NOT_A_SUPPORTED_IERS_DATA_FILE);
116 checkTruncated("bulletina-without-1980-with-2000-rapid.txt", OrekitMessages.NOT_A_SUPPORTED_IERS_DATA_FILE);
117 checkTruncated("bulletina-with-1980-without-2000-final.txt", OrekitMessages.NOT_A_SUPPORTED_IERS_DATA_FILE);
118 checkTruncated("bulletina-without-1980-with-2000-final.txt", OrekitMessages.NOT_A_SUPPORTED_IERS_DATA_FILE);
119 }
120
121 @Test
122 public void testMissingData() {
123 setRoot("bulletinA");
124 checkTruncated("bulletina-truncated-in-eop-data.txt", OrekitMessages.UNEXPECTED_END_OF_FILE_AFTER_LINE);
125 checkTruncated("bulletina-truncated-in-pole-data.txt", OrekitMessages.UNEXPECTED_END_OF_FILE_AFTER_LINE);
126 }
127
128 private void checkTruncated(String name, OrekitMessages expected) {
129 SortedSet<EOPEntry> history = new TreeSet<EOPEntry>(new ChronologicalComparator());
130 try {
131 new BulletinAFilesLoader(name, manager, () -> utc).fillHistory(null, history);
132 Assert.fail("an exception should have been thrown");
133 } catch (OrekitException oe) {
134 Assert.assertEquals(expected, oe.getSpecifier());
135 Assert.assertTrue(((String) oe.getParts()[0]).endsWith(name));
136 }
137 }
138
139 @Test
140 public void testInconsistentDate() {
141 setRoot("bulletinA");
142 checkInconsistent("bulletina-inconsistent-year.txt");
143 checkInconsistent("bulletina-inconsistent-month.txt");
144 checkInconsistent("bulletina-inconsistent-day.txt");
145 }
146
147 private void checkInconsistent(String name) {
148 SortedSet<EOPEntry> history = new TreeSet<EOPEntry>(new ChronologicalComparator());
149 try {
150 new BulletinAFilesLoader(name, manager, () -> utc).fillHistory(null, history);
151 Assert.fail("an exception should have been thrown");
152 } catch (OrekitException oe) {
153 Assert.assertEquals(OrekitMessages.INCONSISTENT_DATES_IN_IERS_FILE, oe.getSpecifier());
154 Assert.assertTrue(((String) oe.getParts()[0]).endsWith(name));
155 }
156 }
157
158 }