1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.orekit.time;
18
19
20 import org.junit.Assert;
21 import org.junit.Before;
22 import org.junit.Test;
23 import org.orekit.Utils;
24 import org.orekit.frames.ITRFVersion;
25 import org.orekit.utils.Constants;
26 import org.orekit.utils.IERSConventions;
27
28
29 public class TAIScaleTest {
30
31 @Test
32 public void testZero() {
33 TimeScale scale = TimeScalesFactory.getTAI();
34 Assert.assertEquals("TAI", scale.toString());
35 for (double dt = -10000; dt < 10000; dt += 123.456789) {
36 AbsoluteDate date = AbsoluteDate.J2000_EPOCH.shiftedBy(dt * Constants.JULIAN_DAY);
37 Assert.assertEquals(0, scale.offsetFromTAI(date), 0);
38 DateTimeComponents components = date.getComponents(scale);
39 Assert.assertEquals(0, scale.offsetToTAI(components.getDate(), components.getTime()), 0);
40 }
41 }
42
43 @Test
44 public void testAAS06134() {
45
46
47
48
49
50
51 Utils.setLoaders(IERSConventions.IERS_1996,
52 Utils.buildEOPList(IERSConventions.IERS_1996, ITRFVersion.ITRF_2008, new double[][] {
53 { 53098, -0.439962, 0.0015563, -0.140682, 0.333309, -0.052195, -0.003875, Double.NaN, Double.NaN },
54 { 53099, -0.439962, 0.0015563, -0.140682, 0.333309, -0.052195, -0.003875, Double.NaN, Double.NaN },
55 { 53100, -0.439962, 0.0015563, -0.140682, 0.333309, -0.052195, -0.003875, Double.NaN, Double.NaN },
56 { 53101, -0.439962, 0.0015563, -0.140682, 0.333309, -0.052195, -0.003875, Double.NaN, Double.NaN },
57 { 53102, -0.439962, 0.0015563, -0.140682, 0.333309, -0.052195, -0.003875, Double.NaN, Double.NaN },
58 { 53103, -0.439962, 0.0015563, -0.140682, 0.333309, -0.052195, -0.003875, Double.NaN, Double.NaN },
59 { 53104, -0.439962, 0.0015563, -0.140682, 0.333309, -0.052195, -0.003875, Double.NaN, Double.NaN },
60 { 53105, -0.439962, 0.0015563, -0.140682, 0.333309, -0.052195, -0.003875, Double.NaN, Double.NaN }
61 }));
62 AbsoluteDate date =
63 new AbsoluteDate(2004, 4, 6, 7, 51, 28.386009, TimeScalesFactory.getUTC());
64 DateTimeComponents components = date.getComponents(TimeScalesFactory.getTAI());
65 Assert.assertEquals(2004, components.getDate().getYear());
66 Assert.assertEquals( 4, components.getDate().getMonth());
67 Assert.assertEquals( 6, components.getDate().getDay());
68 Assert.assertEquals( 7, components.getTime().getHour());
69 Assert.assertEquals( 52, components.getTime().getMinute());
70 Assert.assertEquals( 0.386009, components.getTime().getSecond(), 1.0e-10);
71 }
72
73 @Test
74 public void testDuringLeap() {
75 final TimeScale utc = TimeScalesFactory.getUTC();
76 final TimeScale scale = TimeScalesFactory.getTAI();
77 final AbsoluteDate before = new AbsoluteDate(new DateComponents(1983, 06, 30),
78 new TimeComponents(23, 59, 59),
79 utc);
80 final AbsoluteDate during = before.shiftedBy(1.25);
81 Assert.assertEquals(61, utc.minuteDuration(during));
82 Assert.assertEquals(1.0, utc.getLeap(during), 1.0e-10);
83 Assert.assertEquals(60, scale.minuteDuration(during));
84 Assert.assertEquals(0.0, scale.getLeap(during), 1.0e-10);
85 }
86
87 @Before
88 public void setUp() {
89 Utils.setDataRoot("regular-data");
90 }
91
92 }