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.hipparchus.util.Binary64;
20 import org.hipparchus.util.Binary64Field;
21 import org.hipparchus.util.FastMath;
22 import org.junit.jupiter.api.Assertions;
23 import org.junit.jupiter.api.BeforeEach;
24 import org.junit.jupiter.api.Test;
25 import org.orekit.Utils;
26 import org.orekit.estimation.measurements.QuadraticClockModel;
27 import org.orekit.gnss.TimeSystem;
28
29 public class ClockTimeScaleTest {
30
31 @Test
32 public void testGalileo() {
33 final String name = "Galileo+offset";
34 final AbsoluteDate t0 = new AbsoluteDate(2020, 4, 1,
35 TimeScalesFactory.getUTC());
36 final QuadraticClockModel clock = new QuadraticClockModel(t0,
37 FastMath.scalb(1.0, -10),
38 FastMath.scalb(1.0, -11),
39 FastMath.scalb(1.0, -12));
40 final ClockTimeScale positive = new ClockTimeScale(name,
41 TimeSystem.GALILEO.getTimeScale(TimeScalesFactory.getTimeScales()),
42 clock);
43 Assertions.assertEquals(name, positive.getName());
44 Assertions.assertEquals(1.00 / 1024.0 - 19.0, positive.offsetFromTAI(t0).toDouble(), 1.0e-15);
45 Assertions.assertEquals(1.75 / 1024.0 - 19.0, positive.offsetFromTAI(t0.shiftedBy(1.0)).toDouble(), 1.0e-15);
46 Assertions.assertEquals(3.00 / 1024.0 - 19.0, positive.offsetFromTAI(t0.shiftedBy(2.0)).toDouble(), 1.0e-15);
47
48 FieldAbsoluteDate<Binary64> t064 = new FieldAbsoluteDate<>(Binary64Field.getInstance(), t0);
49 Assertions.assertEquals(1.00 / 1024.0 - 19.0, positive.offsetFromTAI(t064).getReal(), 1.0e-15);
50 Assertions.assertEquals(1.75 / 1024.0 - 19.0, positive.offsetFromTAI(t064.shiftedBy(1.0)).getReal(), 1.0e-15);
51 Assertions.assertEquals(3.00 / 1024.0 - 19.0, positive.offsetFromTAI(t064.shiftedBy(2.0)).getReal(), 1.0e-15);
52
53 }
54
55 @Test
56 public void testUTC() {
57 final String name = "UTC+offset";
58 final AbsoluteDate t0 = new AbsoluteDate(2020, 4, 1,
59 TimeScalesFactory.getUTC());
60 final QuadraticClockModel clock = new QuadraticClockModel(t0,
61 FastMath.scalb(1.0, -10),
62 FastMath.scalb(1.0, -11),
63 FastMath.scalb(1.0, -12));
64 final ClockTimeScale positive = new ClockTimeScale(name,
65 TimeScalesFactory.getUTC(),
66 clock);
67 Assertions.assertEquals(name, positive.getName());
68 Assertions.assertEquals(1.00 / 1024.0 - 37.0, positive.offsetFromTAI(t0).toDouble(), 1.0e-15);
69 Assertions.assertEquals(1.75 / 1024.0 - 37.0, positive.offsetFromTAI(t0.shiftedBy(1.0)).toDouble(), 1.0e-15);
70 Assertions.assertEquals(3.00 / 1024.0 - 37.0, positive.offsetFromTAI(t0.shiftedBy(2.0)).toDouble(), 1.0e-15);
71
72 FieldAbsoluteDate<Binary64> t064 = new FieldAbsoluteDate<>(Binary64Field.getInstance(), t0);
73 Assertions.assertEquals(1.00 / 1024.0 - 37.0, positive.offsetFromTAI(t064).getReal(), 1.0e-15);
74 Assertions.assertEquals(1.75 / 1024.0 - 37.0, positive.offsetFromTAI(t064.shiftedBy(1.0)).getReal(), 1.0e-15);
75 Assertions.assertEquals(3.00 / 1024.0 - 37.0, positive.offsetFromTAI(t064.shiftedBy(2.0)).getReal(), 1.0e-15);
76
77 }
78
79 @BeforeEach
80 public void setUp() throws Exception {
81 Utils.setDataRoot("regular-data");
82 }
83
84 }