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.io.File;
20 import java.io.IOException;
21 import java.util.List;
22 import java.util.function.Supplier;
23
24 import org.hipparchus.geometry.euclidean.threed.Vector3D;
25 import org.hipparchus.util.FastMath;
26 import org.junit.Assert;
27 import org.junit.Before;
28 import org.junit.Test;
29 import org.orekit.data.DirectoryCrawler;
30 import org.orekit.data.LazyLoadedDataContext;
31 import org.orekit.frames.ITRFVersionLoader.ITRFVersionConfiguration;
32 import org.orekit.time.AbsoluteDate;
33 import org.orekit.time.OffsetModel;
34 import org.orekit.time.TAIUTCDatFilesLoader.Parser;
35 import org.orekit.time.TimeScales;
36 import org.orekit.utils.Constants;
37 import org.orekit.utils.IERSConventions;
38
39
40
41
42
43
44 public class FramesTest {
45
46
47 private TimeScales timeScales;
48
49
50
51
52
53
54 @Before
55 public void setUp() throws IOException {
56 final String leapPath = "/USNO/tai-utc.dat";
57 final String eopPath = "/rapid-data-columns/finals2000A.daily";
58 final ITRFVersionConfiguration configuration = new ITRFVersionConfiguration(
59 "", ITRFVersion.ITRF_2014, Integer.MIN_VALUE, Integer.MAX_VALUE);
60 final ItrfVersionProvider itrfVersionProvider = (name, mjd) -> configuration;
61 final List<OffsetModel> leapSeconds = new Parser().parse(
62 this.getClass().getResourceAsStream(leapPath),
63 leapPath);
64 this.timeScales = TimeScales.of(
65 leapSeconds,
66 (conventions, timeScales) -> {
67 try {
68 return EOPHistoryLoader.Parser
69 .newFinalsColumnsParser(
70 conventions,
71 itrfVersionProvider,
72 timeScales,
73 true)
74 .parse(
75 this.getClass().getResourceAsStream(eopPath),
76 eopPath);
77 } catch (IOException e) {
78 throw new RuntimeException(e);
79 }
80 });
81 }
82
83
84 @Test
85 public void testOf() {
86
87 Frames frames = Frames.of(timeScales, () -> null);
88 Frame itrf = frames.getITRF(IERSConventions.IERS_2010, true);
89 EOPHistory eopHistory = ((ITRFProvider) itrf.getTransformProvider()).getEOPHistory();
90 Frame itrfEquinox = frames.getITRFEquinox(IERSConventions.IERS_2010, true);
91 Frame itrfFull = frames.getITRF(IERSConventions.IERS_2010, false);
92 EOPHistory eopFull = ((ITRFProvider) itrfFull.getTransformProvider()).getEOPHistory();
93
94
95 Assert.assertEquals(eopHistory.getConventions(), IERSConventions.IERS_2010);
96 Assert.assertEquals(eopFull.getConventions(), IERSConventions.IERS_2010);
97 Assert.assertEquals(eopHistory.getTimeScales(), timeScales);
98 Assert.assertEquals(eopFull.getTimeScales(), timeScales);
99
100 Assert.assertSame(
101 timeScales.getUT1(IERSConventions.IERS_2010, true).getEOPHistory(),
102 eopHistory);
103 Assert.assertSame(
104 eopHistory,
105 ((ITRFProvider) itrfEquinox.getTransformProvider()).getEOPHistory());
106
107 Assert.assertNotEquals(eopFull, eopHistory);
108 final int n = 181;
109 List<EOPEntry> entries = eopHistory.getEntries();
110 List<EOPEntry> entriesFull = eopFull.getEntries();
111 Assert.assertEquals(n, entries.size());
112 Assert.assertEquals(n, entriesFull.size());
113 for (int i = 0; i < n; i++) {
114 Assert.assertSame(entries.get(i), entriesFull.get(i));
115 }
116
117 Assert.assertEquals(null, frames.getICRF());
118 }
119
120
121 @Test
122 public void testComparison() {
123
124 Frames frames = Frames.of(timeScales, () -> null);
125 LazyLoadedDataContext dataContext = new LazyLoadedDataContext();
126 dataContext.getDataProvidersManager().addProvider(
127 new DirectoryCrawler(new File("src/test/resources/regular-data")));
128 LazyLoadedFrames other = dataContext.getFrames();
129 AbsoluteDate date = new AbsoluteDate(2011, 5, 1, timeScales.getUTC());
130
131
132 Assert.assertSame(frames.getGCRF(), other.getGCRF());
133 Frame itrf = frames.getITRF(IERSConventions.IERS_2010, true);
134 Frame otherItrf = other.getITRF(IERSConventions.IERS_2010, true);
135 Transform transform = itrf.getTransformTo(otherItrf, date);
136 final double angle = transform.getRotation().getAngle();
137
138 final double expected = new Vector3D(
139 0.2449186 / Constants.JULIAN_DAY * 2 * FastMath.PI,
140 0.341136 * Constants.ARC_SECONDS_TO_RADIANS,
141 0.3e-3 * Constants.ARC_SECONDS_TO_RADIANS).getNorm();
142 Assert.assertEquals(expected, angle, 1e-2 * expected);
143 }
144
145 }