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