1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.orekit.time;
18
19 import org.junit.jupiter.api.AfterEach;
20 import org.junit.jupiter.api.Assertions;
21 import org.junit.jupiter.api.BeforeEach;
22 import org.junit.jupiter.api.Test;
23 import org.orekit.Utils;
24 import org.orekit.utils.Constants;
25 import org.orekit.utils.IERSConventions;
26
27
28 public class GMSTScaleTest {
29
30 @Test
31
32 public void testReference() {
33 Assertions.assertEquals("GMST", gmst.toString());
34 AbsoluteDate date = new AbsoluteDate(2001, 10, 3, 6, 30, 0.0,
35 TimeScalesFactory.getUT1(IERSConventions.IERS_2010, true));
36 DateTimeComponents gmstComponents = date.getComponents(gmst);
37 Assertions.assertEquals(2001, gmstComponents.getDate().getYear());
38 Assertions.assertEquals( 10, gmstComponents.getDate().getMonth());
39 Assertions.assertEquals( 3, gmstComponents.getDate().getDay());
40 Assertions.assertEquals( 7, gmstComponents.getTime().getHour());
41 Assertions.assertEquals( 18, gmstComponents.getTime().getMinute());
42 Assertions.assertEquals(8.329, gmstComponents.getTime().getSecond(), 4.0e-4);
43 }
44
45 @Test
46 public void testSymmetry() {
47 for (double dt = -10000; dt < 10000; dt += 123.456789) {
48 AbsoluteDate date = AbsoluteDate.J2000_EPOCH.shiftedBy(dt * Constants.JULIAN_DAY);
49 double dt1 = gmst.offsetFromTAI(date).toDouble();
50 DateTimeComponents components = date.getComponents(gmst);
51 double dt2 = gmst.offsetToTAI(components.getDate(), components.getTime()).toDouble();
52 Assertions.assertEquals( 0.0, dt1 + dt2, 1.0e-10);
53 }
54 }
55
56 @Test
57 public void testDuringLeap() {
58 final TimeScale utc = TimeScalesFactory.getUTC();
59 final TimeScale scale = gmst;
60 final AbsoluteDate before = new AbsoluteDate(new DateComponents(1983, 6, 30),
61 new TimeComponents(23, 59, 59),
62 utc);
63 final AbsoluteDate during = before.shiftedBy(1.25);
64 Assertions.assertEquals(61, utc.minuteDuration(during));
65 Assertions.assertEquals(1.0, utc.getLeap(during).toDouble(), 1.0e-10);
66 Assertions.assertEquals(60, scale.minuteDuration(during));
67 Assertions.assertEquals(0.0, scale.getLeap(during).toDouble(), 1.0e-10);
68 }
69
70 @BeforeEach
71 public void setUp() {
72 Utils.setDataRoot("regular-data");
73 gmst = TimeScalesFactory.getGMST(IERSConventions.IERS_2010, false);
74 }
75
76 @AfterEach
77 public void tearDown() {
78 gmst = null;
79 }
80
81 private TimeScale gmst;
82
83 }