1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.orekit.utils;
18
19 import org.hipparchus.analysis.UnivariateFunction;
20 import org.hipparchus.analysis.UnivariateVectorFunction;
21 import org.hipparchus.analysis.differentiation.DSFactory;
22 import org.hipparchus.analysis.differentiation.DerivativeStructure;
23 import org.hipparchus.analysis.differentiation.FiniteDifferencesDifferentiator;
24 import org.hipparchus.analysis.differentiation.UnivariateDifferentiableFunction;
25 import org.hipparchus.analysis.differentiation.UnivariateDifferentiableVectorFunction;
26 import org.hipparchus.util.Binary64;
27 import org.hipparchus.util.FastMath;
28 import org.hipparchus.util.MathUtils;
29 import org.junit.jupiter.api.Assertions;
30 import org.junit.jupiter.api.BeforeEach;
31 import org.junit.jupiter.api.Test;
32 import org.orekit.Utils;
33 import org.orekit.frames.EOPHistory;
34 import org.orekit.frames.FramesFactory;
35 import org.orekit.frames.ITRFVersion;
36 import org.orekit.time.AbsoluteDate;
37 import org.orekit.time.DateComponents;
38 import org.orekit.time.FieldAbsoluteDate;
39 import org.orekit.time.TimeScalarFunction;
40 import org.orekit.time.TimeScale;
41 import org.orekit.time.TimeScalesFactory;
42 import org.orekit.time.TimeVectorFunction;
43 import org.orekit.time.UT1Scale;
44
45
46 public class IERSConventionsTest {
47
48 @Test
49 public void testConventionsNumber() {
50 Assertions.assertEquals(3, IERSConventions.values().length);
51 }
52
53 @Test
54 public void testIERS1996NutationAngles() {
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107 AbsoluteDate date = new AbsoluteDate(2004, 2, 14, TimeScalesFactory.getUTC());
108 double[] angles= IERSConventions.IERS_1996.getNutationFunction().value(date);
109 Assertions.assertEquals(-5.3059154211478291722e-05, angles[0], 4.8e-11);
110 Assertions.assertEquals(3.2051803135750973851e-05, angles[1], 1.3e-11);
111
112 double epsilonA = IERSConventions.IERS_1996.getMeanObliquityFunction().value(date);
113 Assertions.assertEquals(0.40908345528446415917, epsilonA, 1.0e-16);
114
115 }
116
117 @Test
118 public void testGMST82FieldConsistency() {
119 final TimeScale ut1 = TimeScalesFactory.getUT1(IERSConventions.IERS_1996, true);
120 checkScalarFunctionConsistency(IERSConventions.IERS_1996.getGMSTFunction(ut1),
121 AbsoluteDate.J2000_EPOCH.shiftedBy(-0.4 * Constants.JULIAN_DAY),
122 0.8 * Constants.JULIAN_DAY, 600.0, 10.0, 1.8e-15, 8.0e-13);
123 }
124
125 @Test
126 public void testGMST82Sofa() {
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153 final TimeScale ut1 = TimeScalesFactory.getUT1(IERSConventions.IERS_1996, true);
154 final TimeScalarFunction gmst82 = IERSConventions.IERS_1996.getGMSTFunction(ut1);
155 AbsoluteDate date = new AbsoluteDate(2004, 2, 14, TimeScalesFactory.getUTC());
156 double gmst = MathUtils.normalizeAngle(gmst82.value(date), 0.0);
157 Assertions.assertEquals(2.5021977627453466653, gmst, 2.0e-13);
158 date = new AbsoluteDate(2004, 2, 29, TimeScalesFactory.getUTC());
159 gmst = MathUtils.normalizeAngle(gmst82.value(date), 0.0);
160 Assertions.assertEquals(2.7602390405411441066, gmst, 4.0e-13);
161
162 }
163
164 @Test
165 public void testGMST00FieldConsistency() {
166 final TimeScale ut1 = TimeScalesFactory.getUT1(IERSConventions.IERS_2003, true);
167 checkScalarFunctionConsistency(IERSConventions.IERS_2003.getGMSTFunction(ut1),
168 AbsoluteDate.J2000_EPOCH.shiftedBy(-0.4 * Constants.JULIAN_DAY),
169 0.8 * Constants.JULIAN_DAY, 600.0, 10.0, 2.0e-15, 8.0e-13);
170 }
171
172 @Test
173 public void testGMST00Sofa() {
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206 final TimeScale ut1 = TimeScalesFactory.getUT1(IERSConventions.IERS_2003, true);
207 final TimeScalarFunction gmst00 = IERSConventions.IERS_2003.getGMSTFunction(ut1);
208 AbsoluteDate date = new AbsoluteDate(2004, 2, 14, TimeScalesFactory.getUTC());
209 double gmst = MathUtils.normalizeAngle(gmst00.value(date), 0.0);
210 Assertions.assertEquals(2.5021977786243789765, gmst, 1.0e-15);
211 date = new AbsoluteDate(2004, 2, 29, TimeScalesFactory.getUTC());
212 gmst = MathUtils.normalizeAngle(gmst00.value(date), 0.0);
213 Assertions.assertEquals(2.7602390558728311376, gmst, 1.0e-15);
214
215 }
216
217 @Test
218 public void testGMST06FieldConsistency() {
219 final TimeScale ut1 = TimeScalesFactory.getUT1(IERSConventions.IERS_2010, true);
220 checkScalarFunctionConsistency(IERSConventions.IERS_2010.getGMSTFunction(ut1),
221 AbsoluteDate.J2000_EPOCH.shiftedBy(-0.4 * Constants.JULIAN_DAY),
222 0.8 * Constants.JULIAN_DAY, 600.0, 10.0, 2.0e-15, 8.0e-13);
223 }
224
225 @Test
226 public void testGMST06Sofa() {
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259 final TimeScale ut1 = TimeScalesFactory.getUT1(IERSConventions.IERS_2010, true);
260 final TimeScalarFunction gmst06 = IERSConventions.IERS_2010.getGMSTFunction(ut1);
261 AbsoluteDate date = new AbsoluteDate(2004, 2, 14, TimeScalesFactory.getUTC());
262 double gmst = MathUtils.normalizeAngle(gmst06.value(date), 0.0);
263 Assertions.assertEquals(2.5021977784096232078, gmst, 1.0e-15);
264 date = new AbsoluteDate(2004, 2, 29, TimeScalesFactory.getUTC());
265 gmst = MathUtils.normalizeAngle(gmst06.value(date), 0.0);
266 Assertions.assertEquals(2.7602390556555129741, gmst, 3.0e-15);
267
268 }
269
270 @Test
271 public void testERA1996FieldConsistency() {
272 final TimeScale ut1 = TimeScalesFactory.getUT1(IERSConventions.IERS_1996, true);
273 checkScalarFunctionConsistency(IERSConventions.IERS_1996.getEarthOrientationAngleFunction(ut1),
274 AbsoluteDate.J2000_EPOCH.shiftedBy(-0.4 * Constants.JULIAN_DAY),
275 0.8 * Constants.JULIAN_DAY, 1800.0, 10.0, 2.0e-15, 8.0e-13);
276 }
277
278 @Test
279 public void testERA2003FieldConsistency() {
280 final TimeScale ut1 = TimeScalesFactory.getUT1(IERSConventions.IERS_2003, true);
281 checkScalarFunctionConsistency(IERSConventions.IERS_2003.getEarthOrientationAngleFunction(ut1),
282 AbsoluteDate.J2000_EPOCH.shiftedBy(-0.4 * Constants.JULIAN_DAY),
283 0.8 * Constants.JULIAN_DAY, 1800.0, 10.0, 2.0e-15, 8.0e-13);
284 }
285
286 @Test
287 public void testERA2010FieldConsistency() {
288 final TimeScale ut1 = TimeScalesFactory.getUT1(IERSConventions.IERS_2010, true);
289 checkScalarFunctionConsistency(IERSConventions.IERS_2010.getEarthOrientationAngleFunction(ut1),
290 AbsoluteDate.J2000_EPOCH.shiftedBy(-0.4 * Constants.JULIAN_DAY),
291 0.8 * Constants.JULIAN_DAY, 1800.0, 10.0, 2.0e-15, 8.0e-13);
292 }
293
294 @Test
295 public void testERASofa() {
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323 final TimeScale ut1 = TimeScalesFactory.getUT1(IERSConventions.IERS_2003, true);
324 final TimeScalarFunction era00 =
325 IERSConventions.IERS_2003.getEarthOrientationAngleFunction(ut1);
326 AbsoluteDate date = new AbsoluteDate(2004, 2, 14, TimeScalesFactory.getUTC());
327 double era = MathUtils.normalizeAngle(era00.value(date), 0.0);
328 Assertions.assertEquals(2.5012766511308228701, era, 1.0e-15);
329 date = new AbsoluteDate(2004, 2, 29, TimeScalesFactory.getUTC());
330 era = MathUtils.normalizeAngle(era00.value(date), 0.0);
331 Assertions.assertEquals(2.7593087452455264952, era, 1.0e-15);
332
333 }
334
335 @Test
336 public void testGST94FieldConsistency() {
337 EOPHistory eopHistory = FramesFactory.getEOPHistory(IERSConventions.IERS_1996, true);
338 checkScalarFunctionConsistency(IERSConventions.IERS_1996.getGASTFunction(TimeScalesFactory.getUT1(eopHistory),
339 eopHistory),
340 AbsoluteDate.J2000_EPOCH.shiftedBy(-0.4 * Constants.JULIAN_DAY),
341 0.8 * Constants.JULIAN_DAY, 1800.0, 10.0, 9.0e-16, 8.0e-13);
342 }
343
344 @Test
345 public void testGST94FieldConsistencyNoEOP() {
346 checkScalarFunctionConsistency(IERSConventions.IERS_1996.getGASTFunction(TimeScalesFactory.getUT1(null), null),
347 AbsoluteDate.J2000_EPOCH.shiftedBy(-0.4 * Constants.JULIAN_DAY),
348 0.8 * Constants.JULIAN_DAY, 1800.0, 10.0, 9.0e-16, 2.0e-16);
349 }
350
351 @Test
352 public void testGST94Sofa() {
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431 Utils.setLoaders(IERSConventions.IERS_1996,
432 Utils.buildEOPList(IERSConventions.IERS_1996, ITRFVersion.ITRF_2008, new double[][] {
433 { 53047, -0.4093509, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00 },
434 { 53048, -0.4093509, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00 },
435 { 53049, -0.4093509, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00 },
436 { 53050, -0.4093509, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00 },
437 { 53051, -0.4093509, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00 },
438 { 53052, -0.4093509, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00 },
439 { 53053, -0.4093509, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00 },
440 { 53054, -0.4093509, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00 },
441
442 { 53059, -0.4175723, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00 },
443 { 53060, -0.4175723, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00 },
444 { 53061, -0.4175723, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00 },
445 { 53062, -0.4175723, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00 },
446 { 53063, -0.4175723, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00 },
447 { 53064, -0.4175723, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00 },
448 { 53065, -0.4175723, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00 },
449 { 53066, -0.4175723, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00 }
450 }));
451 EOPHistory eopHistory = FramesFactory.getEOPHistory(IERSConventions.IERS_1996, true);
452 final TimeScalarFunction gst94 =
453 IERSConventions.IERS_1996.getGASTFunction(TimeScalesFactory.getUT1(eopHistory),
454 eopHistory);
455 AbsoluteDate date = new AbsoluteDate(2004, 2, 14, TimeScalesFactory.getUTC());
456 double gst = MathUtils.normalizeAngle(gst94.value(date), 0.0);
457 Assertions.assertEquals(2.5021490911406645274, gst, 4.4e-11);
458 date = new AbsoluteDate(2004, 2, 29, TimeScalesFactory.getUTC());
459 gst = MathUtils.normalizeAngle(gst94.value(date), 0.0);
460 Assertions.assertEquals(2.7601901474864534158, gst, 9.0e-11);
461
462 }
463
464 @Test
465 public void testGST00AFieldConsistency() {
466 EOPHistory eopHistory = FramesFactory.getEOPHistory(IERSConventions.IERS_2003, true);
467 checkScalarFunctionConsistency(IERSConventions.IERS_2003.getGASTFunction(TimeScalesFactory.getUT1(eopHistory), eopHistory),
468 AbsoluteDate.J2000_EPOCH.shiftedBy(-0.4 * Constants.JULIAN_DAY),
469 0.8 * Constants.JULIAN_DAY, 1800.0, 10.0, 2.0e-15, 8.0e-13);
470 }
471
472 @Test
473 public void testGST00AFieldConsistencyNoEOP() {
474 checkScalarFunctionConsistency(IERSConventions.IERS_2003.getGASTFunction(TimeScalesFactory.getUT1(null), null),
475 AbsoluteDate.J2000_EPOCH.shiftedBy(-0.4 * Constants.JULIAN_DAY),
476 0.8 * Constants.JULIAN_DAY, 1800.0, 10.0, 2.0e-15, 2.0e-16);
477 }
478
479 @Test
480 public void testGST00ASofa() {
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513 Utils.setLoaders(IERSConventions.IERS_2003,
514 Utils.buildEOPList(IERSConventions.IERS_2003, ITRFVersion.ITRF_2008, new double[][] {
515 { 53047, -0.4093509, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00 },
516 { 53048, -0.4093509, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00 },
517 { 53049, -0.4093509, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00 },
518 { 53050, -0.4093509, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00 },
519 { 53051, -0.4093509, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00 },
520 { 53052, -0.4093509, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00 },
521 { 53053, -0.4093509, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00 },
522 { 53054, -0.4093509, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00 },
523
524 { 53059, -0.4175723, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00 },
525 { 53060, -0.4175723, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00 },
526 { 53061, -0.4175723, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00 },
527 { 53062, -0.4175723, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00 },
528 { 53063, -0.4175723, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00 },
529 { 53064, -0.4175723, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00 },
530 { 53065, -0.4175723, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00 },
531 { 53066, -0.4175723, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00 }
532 }));
533 EOPHistory eopHistory = FramesFactory.getEOPHistory(IERSConventions.IERS_2003, true);
534 final TimeScalarFunction gst00a =
535 IERSConventions.IERS_2003.getGASTFunction(TimeScalesFactory.getUT1(eopHistory), eopHistory);
536 AbsoluteDate date = new AbsoluteDate(2004, 2, 14, TimeScalesFactory.getUTC());
537 double gst = MathUtils.normalizeAngle(gst00a.value(date), 0.0);
538 Assertions.assertEquals(2.5021491024360624778, gst, 2.0e-13);
539 date = new AbsoluteDate(2004, 2, 29, TimeScalesFactory.getUTC());
540 gst = MathUtils.normalizeAngle(gst00a.value(date), 0.0);
541 Assertions.assertEquals(2.7601901615614221619, gst, 3.0e-13);
542
543 }
544
545 @Test
546 public void testGST06FieldConsistency() {
547 EOPHistory eopHistory = FramesFactory.getEOPHistory(IERSConventions.IERS_2010, true);
548 checkScalarFunctionConsistency(IERSConventions.IERS_2010.getGASTFunction(TimeScalesFactory.getUT1(eopHistory), eopHistory),
549 AbsoluteDate.J2000_EPOCH.shiftedBy(-0.4 * Constants.JULIAN_DAY),
550 0.8 * Constants.JULIAN_DAY, 1800.0, 10.0, 2.0e-15, 8.0e-13);
551 }
552
553 @Test
554 public void testGST06FieldConsistencyNoEOP() {
555 checkScalarFunctionConsistency(IERSConventions.IERS_2010.getGASTFunction(TimeScalesFactory.getUT1(null), null),
556 AbsoluteDate.J2000_EPOCH.shiftedBy(-0.4 * Constants.JULIAN_DAY),
557 0.8 * Constants.JULIAN_DAY, 1800.0, 10.0, 2.0e-15, 2.0e-16);
558 }
559
560 @Test
561 public void testGST06Sofa() {
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594 Utils.setLoaders(IERSConventions.IERS_2010,
595 Utils.buildEOPList(IERSConventions.IERS_2010, ITRFVersion.ITRF_2008, new double[][] {
596 { 53047, -0.4093509, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00 },
597 { 53048, -0.4093509, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00 },
598 { 53049, -0.4093509, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00 },
599 { 53050, -0.4093509, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00 },
600 { 53051, -0.4093509, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00 },
601 { 53052, -0.4093509, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00 },
602 { 53053, -0.4093509, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00 },
603 { 53054, -0.4093509, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00 },
604
605 { 53059, -0.4175723, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00 },
606 { 53060, -0.4175723, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00 },
607 { 53061, -0.4175723, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00 },
608 { 53062, -0.4175723, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00 },
609 { 53063, -0.4175723, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00 },
610 { 53064, -0.4175723, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00 },
611 { 53065, -0.4175723, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00 },
612 { 53066, -0.4175723, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00 }
613 }));
614 EOPHistory eopHistory = FramesFactory.getEOPHistory(IERSConventions.IERS_2010, true);
615 final TimeScalarFunction gst06 =
616 IERSConventions.IERS_2010.getGASTFunction(TimeScalesFactory.getUT1(eopHistory), eopHistory);
617 AbsoluteDate date = new AbsoluteDate(2004, 2, 14, TimeScalesFactory.getUTC());
618 double gst = MathUtils.normalizeAngle(gst06.value(date), 0.0);
619 Assertions.assertEquals(2.5021491022006503435, gst, 1.3e-12);
620 date = new AbsoluteDate(2004, 2, 29, TimeScalesFactory.getUTC());
621 gst = MathUtils.normalizeAngle(gst06.value(date), 0.0);
622 Assertions.assertEquals(2.7601901613234058885, gst, 1.2e-12);
623
624 }
625
626 @Test
627 public void testGMST2000vs82() {
628
629 final TimeScalarFunction gmst82 =
630 IERSConventions.IERS_1996.getGMSTFunction(TimeScalesFactory.getUT1(IERSConventions.IERS_1996, true));
631 final TimeScalarFunction gmst00 =
632 IERSConventions.IERS_2003.getGMSTFunction(TimeScalesFactory.getUT1(IERSConventions.IERS_2003, true));
633 final DSFactory factory = new DSFactory(1, 1);
634 final FieldAbsoluteDate<DerivativeStructure> ds2000 =
635 FieldAbsoluteDate.getJ2000Epoch(factory.getDerivativeField());
636 for (double dt = 0; dt < 10 * Constants.JULIAN_YEAR; dt += 10 * Constants.JULIAN_DAY) {
637 FieldAbsoluteDate<DerivativeStructure> date = ds2000.shiftedBy(factory.variable(0, dt));
638 DerivativeStructure delta = gmst00.value(date).subtract(gmst82.value(date));
639
640 Assertions.assertEquals(0.0, MathUtils.normalizeAngle(delta.getValue(), 0.0), 7.1e-8);
641 Assertions.assertEquals(0.0, delta.getPartialDerivative(1), 1.0e-15);
642 }
643 }
644
645 @Test
646 public void testGMST2000vs2006() {
647
648 final UT1Scale ut1 = TimeScalesFactory.getUT1(IERSConventions.IERS_2010, true);
649 final TimeScalarFunction gmst00 = IERSConventions.IERS_2003.getGMSTFunction(ut1);
650 final TimeScalarFunction gmst06 = IERSConventions.IERS_2010.getGMSTFunction(ut1);
651 final DSFactory factory = new DSFactory(1, 1);
652 final FieldAbsoluteDate<DerivativeStructure> ds2000 =
653 FieldAbsoluteDate.getJ2000Epoch(factory.getDerivativeField());
654 for (double dt = 0; dt < 10 * Constants.JULIAN_YEAR; dt += 10 * Constants.JULIAN_DAY) {
655 FieldAbsoluteDate<DerivativeStructure> date = ds2000.shiftedBy(factory.variable(0, dt));
656 DerivativeStructure delta = gmst06.value(date).subtract(gmst00.value(date));
657
658 Assertions.assertEquals(0.0, MathUtils.normalizeAngle(delta.getValue(), 0.0), 7e-10);
659 Assertions.assertEquals(0.0, delta.getPartialDerivative(1), 3.0e-18);
660 }
661 }
662
663 @Test
664 public void testIAU1994ResolutionC7Discontinuity() {
665 TimeVectorFunction nutation = IERSConventions.IERS_1996.getNutationFunction();
666 AbsoluteDate switchDate = new AbsoluteDate(1997, 2, 27, TimeScalesFactory.getUTC());
667 double h = 0.01;
668 for (double dt = -1.0 - h / 2; dt <= 1.0 + h /2; dt += h) {
669 AbsoluteDate d = switchDate.shiftedBy(dt);
670 final double currentCorr = nutation.value(d)[2];
671 if (dt < 0) {
672 Assertions.assertEquals(0.0, currentCorr, 1.0e-20);
673 } else {
674 Assertions.assertEquals(-7.87098e-12, currentCorr, 1.0e-15);
675 }
676 }
677 }
678
679 @Test
680 public void testTidalCorrection1996() {
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724 Utils.setLoaders(IERSConventions.IERS_1996,
725 Utils.buildEOPList(IERSConventions.IERS_1996, ITRFVersion.ITRF_2008, new double[][] {
726 { 52653, -0.2979055, 0.0005744, -0.120344, 0.217095, 0.0, 0.0, 0.0, 0.0 },
727 { 52654, -0.2984238, 0.0004224, -0.121680, 0.219400, 0.0, 0.0, 0.0, 0.0 },
728 { 52655, -0.2987682, 0.0002878, -0.122915, 0.221760, 0.0, 0.0, 0.0, 0.0 },
729 { 52656, -0.2989957, 0.0001778, -0.124248, 0.224294, 0.0, 0.0, 0.0, 0.0 }
730 }));
731 EOPHistory eopHistory = FramesFactory.getEOPHistory(IERSConventions.IERS_1996, false);
732
733 final AbsoluteDate t0 = new AbsoluteDate(new DateComponents(DateComponents.MODIFIED_JULIAN_EPOCH, 52654),
734 TimeScalesFactory.getUTC());
735 for (double[] row : new double[][] {
736 { 0.0, -0.29839889612705234, -0.12191552977388567, 0.21921143351558756 },
737 { 3600.0, -0.29841696994736727, -0.12208276003864491, 0.21925416583607277 },
738 { 7200.0, -0.29843402412052122, -0.12218102086455683, 0.21930263880545320 },
739 { 43200.0, -0.29866785146390035, -0.12250027826538630, 0.22103779809979979 },
740 { 86400.0, -0.29874248853173840, -0.12308592577174847, 0.22161565557764881 }
741 }) {
742 AbsoluteDate date = t0.shiftedBy(row[0]);
743 Assertions.assertEquals(row[1], eopHistory.getUT1MinusUTC(date), 8.8e-11);
744 Assertions.assertEquals(row[2] * Constants.ARC_SECONDS_TO_RADIANS,
745 eopHistory.getPoleCorrection(date).getXp(),
746 3.2e-14);
747 Assertions.assertEquals(row[3] * Constants.ARC_SECONDS_TO_RADIANS,
748 eopHistory.getPoleCorrection(date).getYp(),
749 8.2e-15);
750 }
751
752 }
753
754 @Test
755 public void testTidalCorrection2003() {
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802 Utils.setLoaders(IERSConventions.IERS_2003,
803 Utils.buildEOPList(IERSConventions.IERS_2003, ITRFVersion.ITRF_2008, new double[][] {
804 { 52653, -0.2979055, 0.0005744, -0.120344, 0.217095, 0.0, 0.0, 0.0, 0.0 },
805 { 52654, -0.2984238, 0.0004224, -0.121680, 0.219400, 0.0, 0.0, 0.0, 0.0 },
806 { 52655, -0.2987682, 0.0002878, -0.122915, 0.221760, 0.0, 0.0, 0.0, 0.0 },
807 { 52656, -0.2989957, 0.0001778, -0.124248, 0.224294, 0.0, 0.0, 0.0, 0.0 }
808 }));
809 EOPHistory eopHistory = FramesFactory.getEOPHistory(IERSConventions.IERS_2003, false);
810
811 final AbsoluteDate t0 = new AbsoluteDate(new DateComponents(DateComponents.MODIFIED_JULIAN_EPOCH, 52654),
812 TimeScalesFactory.getUTC());
813
814 for (double[] row : new double[][] {
815 { 0.0, -0.29840026968370659, 0.00045312852893139, -0.12196223480123573, 0.21922730818562719 },
816 { 3600.0, -0.29841834564816189, 0.00041710864863793, -0.12213345007640604, 0.21927433626001305 },
817 { 7200.0, -0.29843503870494986, 0.00039207574457087, -0.12222881007999241, 0.21932415788122142 },
818 { 43200.0, -0.29866930257052676, 0.00042895046506082, -0.12247697694276605, 0.22105450666130921 },
819 { 86400.0, -0.29874235341010519, 0.00035460263868306, -0.12312252389660779, 0.22161364352515728 }
820 }) {
821 AbsoluteDate date = t0.shiftedBy(row[0]);
822 Assertions.assertEquals(row[1], eopHistory.getUT1MinusUTC(date), 4.3e-8);
823 Assertions.assertEquals(row[2], eopHistory.getLOD(date), 1.4e-7);
824 Assertions.assertEquals(row[3] * Constants.ARC_SECONDS_TO_RADIANS,
825 eopHistory.getPoleCorrection(date).getXp(),
826 1.6e-10);
827 Assertions.assertEquals(row[4] * Constants.ARC_SECONDS_TO_RADIANS,
828 eopHistory.getPoleCorrection(date).getYp(),
829 0.7e-10);
830 }
831
832 }
833
834 @Test
835 public void testTidalCorrection2010() {
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882 Utils.setLoaders(IERSConventions.IERS_2010,
883 Utils.buildEOPList(IERSConventions.IERS_2010, ITRFVersion.ITRF_2008, new double[][] {
884 { 52653, -0.2979055, 0.0005744, -0.120344, 0.217095, 0.0, 0.0, 0.0, 0.0 },
885 { 52654, -0.2984238, 0.0004224, -0.121680, 0.219400, 0.0, 0.0, 0.0, 0.0 },
886 { 52655, -0.2987682, 0.0002878, -0.122915, 0.221760, 0.0, 0.0, 0.0, 0.0 },
887 { 52656, -0.2989957, 0.0001778, -0.124248, 0.224294, 0.0, 0.0, 0.0, 0.0 }
888 }));
889 EOPHistory eopHistory = FramesFactory.getEOPHistory(IERSConventions.IERS_2010, false);
890
891 final AbsoluteDate t0 = new AbsoluteDate(new DateComponents(DateComponents.MODIFIED_JULIAN_EPOCH, 52654),
892 TimeScalesFactory.getUTC());
893
894 for (double[] row : new double[][] {
895 { 0.0, -0.29840026968370659, 0.00045312852893139, -0.12196223480123573, 0.21922730818562719 },
896 { 3600.0, -0.29841834564816189, 0.00041710864863793, -0.12213345007640604, 0.21927433626001305 },
897 { 7200.0, -0.29843503870494986, 0.00039207574457087, -0.12222881007999241, 0.21932415788122142 },
898 { 43200.0, -0.29866930257052676, 0.00042895046506082, -0.12247697694276605, 0.22105450666130921 },
899 { 86400.0, -0.29874235341010519, 0.00035460263868306, -0.12312252389660779, 0.22161364352515728 }
900 }) {
901 AbsoluteDate date = t0.shiftedBy(row[0]);
902 Assertions.assertEquals(row[1], eopHistory.getUT1MinusUTC(date), 2.5e-12);
903 Assertions.assertEquals(row[2], eopHistory.getLOD(date), 4.3e-11);
904 Assertions.assertEquals(row[3] * Constants.ARC_SECONDS_TO_RADIANS,
905 eopHistory.getPoleCorrection(date).getXp(),
906 1.6e-10);
907 Assertions.assertEquals(row[4] * Constants.ARC_SECONDS_TO_RADIANS,
908 eopHistory.getPoleCorrection(date).getYp(),
909 0.7e-10);
910 }
911
912 }
913
914 @Test
915 public void testGMSTRate1996() {
916 final UT1Scale ut1 = TimeScalesFactory.getUT1(IERSConventions.IERS_1996, true);
917 checkGMSTRate(IERSConventions.IERS_1996.getGMSTFunction(ut1),
918 IERSConventions.IERS_1996.getGMSTRateFunction(ut1),
919 AbsoluteDate.J2000_EPOCH.shiftedBy(-0.4 * Constants.JULIAN_DAY),
920 0.8 * Constants.JULIAN_DAY, 600.0, 10.0, 8.0e-13);
921 }
922
923 @Test
924 public void testGMSTRate2003() {
925 final UT1Scale ut1 = TimeScalesFactory.getUT1(IERSConventions.IERS_2003, true);
926 checkGMSTRate(IERSConventions.IERS_2003.getGMSTFunction(ut1),
927 IERSConventions.IERS_2003.getGMSTRateFunction(ut1),
928 AbsoluteDate.J2000_EPOCH.shiftedBy(-0.4 * Constants.JULIAN_DAY),
929 0.8 * Constants.JULIAN_DAY, 600.0, 10.0, 8.0e-13);
930 }
931
932 @Test
933 public void testGMSTRate2010() {
934 final UT1Scale ut1 = TimeScalesFactory.getUT1(IERSConventions.IERS_2010, true);
935 checkGMSTRate(IERSConventions.IERS_2010.getGMSTFunction(ut1),
936 IERSConventions.IERS_2010.getGMSTRateFunction(ut1),
937 AbsoluteDate.J2000_EPOCH.shiftedBy(-0.4 * Constants.JULIAN_DAY),
938 0.8 * Constants.JULIAN_DAY, 600.0, 10.0, 8.0e-13);
939 }
940
941 private void checkGMSTRate(final TimeScalarFunction gmst, final TimeScalarFunction gmstRate,
942 final AbsoluteDate date, final double span, final double sampleStep,
943 final double h, final double tolerance)
944 {
945 UnivariateDifferentiableFunction differentiated =
946 new FiniteDifferencesDifferentiator(4, h).differentiate(new UnivariateFunction() {
947 @Override
948 public double value(final double dt) {
949 return gmst.value(date.shiftedBy(dt));
950 }
951 });
952 DSFactory factory = new DSFactory(1, 1);
953 double maxRateError = 0;
954 for (double dt = 0; dt < span; dt += sampleStep) {
955 double rateRef = differentiated.value(factory.variable(0, dt)).getPartialDerivative(1);
956 double rate = gmstRate.value(date.shiftedBy(dt));
957 maxRateError = FastMath.max(maxRateError, FastMath.abs(rateRef - rate));
958 }
959 Assertions.assertEquals(0, maxRateError, tolerance);
960 }
961
962 @Test
963 public void testFieldGMSTRate1996() {
964 final UT1Scale ut1 = TimeScalesFactory.getUT1(IERSConventions.IERS_1996, true);
965 checkFieldGMSTRate(IERSConventions.IERS_1996.getGMSTFunction(ut1),
966 IERSConventions.IERS_1996.getGMSTRateFunction(ut1),
967 AbsoluteDate.J2000_EPOCH.shiftedBy(-0.4 * Constants.JULIAN_DAY),
968 0.8 * Constants.JULIAN_DAY, 600.0, 10.0, Double.MIN_VALUE);
969 }
970
971 @Test
972 public void testFieldGMSTRate2003() {
973 final UT1Scale ut1 = TimeScalesFactory.getUT1(IERSConventions.IERS_2003, true);
974 checkFieldGMSTRate(IERSConventions.IERS_2003.getGMSTFunction(ut1),
975 IERSConventions.IERS_2003.getGMSTRateFunction(ut1),
976 AbsoluteDate.J2000_EPOCH.shiftedBy(-0.4 * Constants.JULIAN_DAY),
977 0.8 * Constants.JULIAN_DAY, 600.0, 10.0, Double.MIN_VALUE);
978 }
979
980 @Test
981 public void testFieldGMSTRate2010() {
982 final UT1Scale ut1 = TimeScalesFactory.getUT1(IERSConventions.IERS_2010, true);
983 checkFieldGMSTRate(IERSConventions.IERS_2010.getGMSTFunction(ut1),
984 IERSConventions.IERS_2010.getGMSTRateFunction(ut1),
985 AbsoluteDate.J2000_EPOCH.shiftedBy(-0.4 * Constants.JULIAN_DAY),
986 0.8 * Constants.JULIAN_DAY, 600.0, 10.0, Double.MIN_VALUE);
987 }
988
989 private void checkFieldGMSTRate(final TimeScalarFunction gmst, final TimeScalarFunction gmstRate,
990 final AbsoluteDate date, final double span, final double sampleStep,
991 final double h, final double tolerance)
992 {
993 double maxError = 0;
994 for (double dt = 0; dt < span; dt += sampleStep) {
995 double rateDouble = gmstRate.value(date.shiftedBy(dt));
996 double rateBinary64 = gmstRate.value(new FieldAbsoluteDate<>(date, new Binary64(dt))).doubleValue();
997 maxError = FastMath.max(maxError, FastMath.abs(rateDouble - rateBinary64));
998 }
999 Assertions.assertEquals(0, maxError, tolerance);
1000 }
1001
1002 @Test
1003 public void testPrecessionFunction1996FieldConsistency() {
1004 checkVectorFunctionConsistency(IERSConventions.IERS_1996.getPrecessionFunction(), 3,
1005 AbsoluteDate.J2000_EPOCH.shiftedBy(-0.4 * Constants.JULIAN_DAY),
1006 0.8 * Constants.JULIAN_DAY, 600.0, 10.0, 2.0e-22, 3.0e-19);
1007 }
1008
1009 @Test
1010 public void testPrecessionFunction2003FieldConsistency() {
1011 checkVectorFunctionConsistency(IERSConventions.IERS_2003.getPrecessionFunction(), 3,
1012 AbsoluteDate.J2000_EPOCH.shiftedBy(-0.4 * Constants.JULIAN_DAY),
1013 0.8 * Constants.JULIAN_DAY, 600.0, 10.0, 6.0e-17, 6.0e-18);
1014 }
1015
1016 @Test
1017 public void testPrecessionFunction2010FieldConsistency() {
1018 checkVectorFunctionConsistency(IERSConventions.IERS_2010.getPrecessionFunction(), 3,
1019 AbsoluteDate.J2000_EPOCH.shiftedBy(-0.4 * Constants.JULIAN_DAY),
1020 0.8 * Constants.JULIAN_DAY, 600.0, 10.0, 6.0e-17, 6.0e-18);
1021 }
1022
1023 @Test
1024 public void testNutationFunction1996FieldConsistency() {
1025 checkVectorFunctionConsistency(IERSConventions.IERS_1996.getNutationFunction(), 3,
1026 AbsoluteDate.J2000_EPOCH.shiftedBy(-0.4 * Constants.JULIAN_DAY),
1027 0.8 * Constants.JULIAN_DAY, 600.0, 10.0, 2.0e-19, 4.0e-21);
1028 }
1029
1030 @Test
1031 public void testNutationFunction2003FieldConsistency() {
1032 checkVectorFunctionConsistency(IERSConventions.IERS_2003.getNutationFunction(), 3,
1033 AbsoluteDate.J2000_EPOCH.shiftedBy(-0.4 * Constants.JULIAN_DAY),
1034 0.8 * Constants.JULIAN_DAY, 600.0, 10.0, 3.0e-19, 6.0e-21);
1035 }
1036
1037 @Test
1038 public void testNutationFunction2010FieldConsistency() {
1039 checkVectorFunctionConsistency(IERSConventions.IERS_2010.getNutationFunction(), 3,
1040 AbsoluteDate.J2000_EPOCH.shiftedBy(-0.4 * Constants.JULIAN_DAY),
1041 0.8 * Constants.JULIAN_DAY, 600.0, 10.0, 5.0e-19, 6.0e-21);
1042 }
1043
1044 @Test
1045 public void testXYSpXY2Function1996FieldConsistency() {
1046 checkVectorFunctionConsistency(IERSConventions.IERS_1996.getXYSpXY2Function(), 3,
1047 AbsoluteDate.J2000_EPOCH.shiftedBy(-0.4 * Constants.JULIAN_DAY),
1048 0.8 * Constants.JULIAN_DAY, 600.0, 10.0, 6.0e-20, 2.0e-21);
1049 }
1050
1051 @Test
1052 public void testXYSpXY2Function2003FieldConsistency() {
1053 checkVectorFunctionConsistency(IERSConventions.IERS_2003.getXYSpXY2Function(), 3,
1054 AbsoluteDate.J2000_EPOCH.shiftedBy(-0.4 * Constants.JULIAN_DAY),
1055 0.8 * Constants.JULIAN_DAY, 600.0, 10.0, 2.0e-19, 3.0e-21);
1056 }
1057
1058 @Test
1059 public void testXYSpXY2Function2010FieldConsistency() {
1060 checkVectorFunctionConsistency(IERSConventions.IERS_2010.getXYSpXY2Function(), 3,
1061 AbsoluteDate.J2000_EPOCH.shiftedBy(-0.4 * Constants.JULIAN_DAY),
1062 0.8 * Constants.JULIAN_DAY, 600.0, 10.0, 2.0e-19, 3.0e-21);
1063 }
1064
1065 @Test
1066 public void testMeanObliquityFunction1996FieldConsistency() {
1067 checkScalarFunctionConsistency(IERSConventions.IERS_1996.getMeanObliquityFunction(),
1068 AbsoluteDate.J2000_EPOCH.shiftedBy(-0.4 * Constants.JULIAN_DAY),
1069 0.8 * Constants.JULIAN_DAY, 600.0, 10.0, 6.0e-17, 6.0e-18);
1070 }
1071
1072 @Test
1073 public void testMeanObliquityFunction2003FieldConsistency() {
1074 checkScalarFunctionConsistency(IERSConventions.IERS_2003.getMeanObliquityFunction(),
1075 AbsoluteDate.J2000_EPOCH.shiftedBy(-0.4 * Constants.JULIAN_DAY),
1076 0.8 * Constants.JULIAN_DAY, 600.0, 10.0, 6.0e-17, 6.0e-18);
1077 }
1078
1079 @Test
1080 public void testMeanObliquityFunction2010FieldConsistency() {
1081 checkScalarFunctionConsistency(IERSConventions.IERS_2010.getMeanObliquityFunction(),
1082 AbsoluteDate.J2000_EPOCH.shiftedBy(-0.4 * Constants.JULIAN_DAY),
1083 0.8 * Constants.JULIAN_DAY, 600.0, 10.0, 6.0e-17, 6.0e-18);
1084 }
1085
1086 @Test
1087 public void testEOPTidalCorrection1996FieldConsistency() {
1088 checkVectorFunctionConsistency(IERSConventions.IERS_1996.getEOPTidalCorrection(), 4,
1089 AbsoluteDate.J2000_EPOCH.shiftedBy(-0.4 * Constants.JULIAN_DAY),
1090 0.8 * Constants.JULIAN_DAY, 600.0, 10.0, 2.0e-17, 6.0e-20);
1091 }
1092
1093 @Test
1094 public void testEOPTidalCorrection2003FieldConsistency() {
1095 checkVectorFunctionConsistency(IERSConventions.IERS_2003.getEOPTidalCorrection(), 4,
1096 AbsoluteDate.J2000_EPOCH.shiftedBy(-0.4 * Constants.JULIAN_DAY),
1097 0.8 * Constants.JULIAN_DAY, 600.0, 10.0, 2.0e-17, 2.0e-19);
1098 }
1099
1100 @Test
1101 public void testEOPTidalCorrection2010FieldConsistency() {
1102 checkVectorFunctionConsistency(IERSConventions.IERS_2010.getEOPTidalCorrection(), 4,
1103 AbsoluteDate.J2000_EPOCH.shiftedBy(-0.4 * Constants.JULIAN_DAY),
1104 0.8 * Constants.JULIAN_DAY, 600.0, 10.0, 2.0e-17, 2.0e-19);
1105 }
1106
1107 @Test
1108 public void testTideFrequencyDependenceFunction1996FieldConsistency() {
1109 final UT1Scale ut1 = TimeScalesFactory.getUT1(IERSConventions.IERS_1996, true);
1110 checkVectorFunctionConsistency(IERSConventions.IERS_1996.getTideFrequencyDependenceFunction(ut1), 5,
1111 AbsoluteDate.J2000_EPOCH.shiftedBy(-0.4 * Constants.JULIAN_DAY),
1112 0.8 * Constants.JULIAN_DAY, 600.0, 10.0, 4.0e-24, 4.0e-22);
1113 }
1114
1115 @Test
1116 public void testTideFrequencyDependenceFunction2003FieldConsistency() {
1117 final UT1Scale ut1 = TimeScalesFactory.getUT1(IERSConventions.IERS_2003, true);
1118 checkVectorFunctionConsistency(IERSConventions.IERS_2003.getTideFrequencyDependenceFunction(ut1), 5,
1119 AbsoluteDate.J2000_EPOCH.shiftedBy(-0.4 * Constants.JULIAN_DAY),
1120 0.8 * Constants.JULIAN_DAY, 600.0, 10.0, 4.0e-24, 4.0e-22);
1121 }
1122
1123 @Test
1124 public void testTideFrequencyDependenceFunction2010FieldConsistency() {
1125 final UT1Scale ut1 = TimeScalesFactory.getUT1(IERSConventions.IERS_2010, true);
1126 checkVectorFunctionConsistency(IERSConventions.IERS_2010.getTideFrequencyDependenceFunction(ut1), 5,
1127 AbsoluteDate.J2000_EPOCH.shiftedBy(-0.4 * Constants.JULIAN_DAY),
1128 0.8 * Constants.JULIAN_DAY, 600.0, 10.0, 4.0e-24, 4.0e-22);
1129 }
1130
1131 @Test
1132 public void testSolidPoleTide1996FieldConsistency() {
1133 EOPHistory eopHistory = FramesFactory.getEOPHistory(IERSConventions.IERS_1996, false);
1134 checkVectorFunctionConsistency(IERSConventions.IERS_1996.getSolidPoleTide(eopHistory), 2,
1135 AbsoluteDate.J2000_EPOCH.shiftedBy(-0.4 * Constants.JULIAN_DAY),
1136 0.8 * Constants.JULIAN_DAY, 600.0, 10.0, 3.0e-25, 4.0e-26);
1137 }
1138
1139 @Test
1140 public void testSolidPoleTide2003FieldConsistency() {
1141 EOPHistory eopHistory = FramesFactory.getEOPHistory(IERSConventions.IERS_2003, false);
1142 checkVectorFunctionConsistency(IERSConventions.IERS_2003.getSolidPoleTide(eopHistory), 2,
1143 AbsoluteDate.J2000_EPOCH.shiftedBy(-0.4 * Constants.JULIAN_DAY),
1144 0.8 * Constants.JULIAN_DAY, 600.0, 10.0, 1.5e-14, 6.9e-19);
1145 }
1146
1147 @Test
1148 public void testSolidPoleTide2010FieldConsistency() {
1149 EOPHistory eopHistory = FramesFactory.getEOPHistory(IERSConventions.IERS_2010, false);
1150 checkVectorFunctionConsistency(IERSConventions.IERS_2010.getSolidPoleTide(eopHistory), 2,
1151 AbsoluteDate.J2000_EPOCH.shiftedBy(-0.4 * Constants.JULIAN_DAY),
1152 0.8 * Constants.JULIAN_DAY, 600.0, 10.0, 1.5e-14, 6.9e-19);
1153 }
1154
1155 @Test
1156 public void testOceanPoleTide1996FieldConsistency() {
1157 EOPHistory eopHistory = FramesFactory.getEOPHistory(IERSConventions.IERS_1996, false);
1158 checkVectorFunctionConsistency(IERSConventions.IERS_1996.getOceanPoleTide(eopHistory), 2,
1159 AbsoluteDate.J2000_EPOCH.shiftedBy(-0.4 * Constants.JULIAN_DAY),
1160 0.8 * Constants.JULIAN_DAY, 600.0, 10.0, Double.MIN_VALUE, Double.MIN_VALUE);
1161 }
1162
1163 @Test
1164 public void testOceanPoleTide2003FieldConsistency() {
1165 EOPHistory eopHistory = FramesFactory.getEOPHistory(IERSConventions.IERS_2003, false);
1166 checkVectorFunctionConsistency(IERSConventions.IERS_2003.getOceanPoleTide(eopHistory), 2,
1167 AbsoluteDate.J2000_EPOCH.shiftedBy(-0.4 * Constants.JULIAN_DAY),
1168 0.8 * Constants.JULIAN_DAY, 600.0, 10.0, Double.MIN_VALUE, Double.MIN_VALUE);
1169 }
1170
1171 @Test
1172 public void testOceanPoleTide2010FieldConsistency() {
1173 EOPHistory eopHistory = FramesFactory.getEOPHistory(IERSConventions.IERS_2010, false);
1174 checkVectorFunctionConsistency(IERSConventions.IERS_2010.getOceanPoleTide(eopHistory), 2,
1175 AbsoluteDate.J2000_EPOCH.shiftedBy(-0.4 * Constants.JULIAN_DAY),
1176 0.8 * Constants.JULIAN_DAY, 600.0, 10.0, 1.9e-15, 8.9e-20);
1177 }
1178
1179 private void checkScalarFunctionConsistency(final TimeScalarFunction function,
1180 final AbsoluteDate date, final double span, final double sampleStep,
1181 final double h, final double valueTolerance, final double derivativeTolerance) {
1182
1183 UnivariateDifferentiableFunction differentiated =
1184 new FiniteDifferencesDifferentiator(4, h).differentiate(new UnivariateFunction() {
1185 @Override
1186 public double value(final double dt) {
1187 return function.value(date.shiftedBy(dt));
1188 }
1189 });
1190
1191 DSFactory factory = new DSFactory(1, 1);
1192 FieldAbsoluteDate<DerivativeStructure> dsDate = new FieldAbsoluteDate<>(date, factory.constant(0.0));
1193 double maxValueError = 0;
1194 double maxDerivativeError = 0;
1195 for (double dt = 0; dt < span; dt += sampleStep) {
1196 DerivativeStructure dsdt = factory.variable(0, dt);
1197 DerivativeStructure yRef = differentiated.value(dsdt);
1198 DerivativeStructure y = function.value(dsDate.shiftedBy(dsdt));
1199 maxValueError = FastMath.max(maxValueError,
1200 FastMath.abs(yRef.getValue() - y.getValue()));
1201 maxDerivativeError = FastMath.max(maxDerivativeError,
1202 FastMath.abs(yRef.getPartialDerivative(1) - y.getPartialDerivative(1)));
1203 }
1204 Assertions.assertEquals(0, maxValueError, valueTolerance);
1205 Assertions.assertEquals(0, maxDerivativeError, derivativeTolerance);
1206
1207 }
1208
1209 private void checkVectorFunctionConsistency(final TimeVectorFunction function, final int dimension,
1210 final AbsoluteDate date, final double span, final double sampleStep,
1211 final double h, final double valueTolerance, final double derivativeTolerance) {
1212
1213 UnivariateDifferentiableVectorFunction differentiated =
1214 new FiniteDifferencesDifferentiator(4, h).differentiate(new UnivariateVectorFunction() {
1215 @Override
1216 public double[] value(final double dt) {
1217 return function.value(date.shiftedBy(dt));
1218 }
1219 });
1220
1221 DSFactory factory = new DSFactory(1, 1);
1222 FieldAbsoluteDate<DerivativeStructure> dsDate = new FieldAbsoluteDate<>(date, factory.constant(0.0));
1223 double maxValueError = 0;
1224 double maxDerivativeError = 0;
1225 for (double dt = 0; dt < span; dt += sampleStep) {
1226 DerivativeStructure dsdt = factory.variable(0, dt);
1227 DerivativeStructure[] yRef = differentiated.value(dsdt);
1228 DerivativeStructure[] y = function.value(dsDate.shiftedBy(dsdt));
1229 Assertions.assertEquals(dimension, yRef.length);
1230 Assertions.assertEquals(dimension, y.length);
1231 for (int i = 0; i < dimension; ++i) {
1232 maxValueError = FastMath.max(maxValueError,
1233 FastMath.abs(yRef[i].getValue() - y[i].getValue()));
1234 maxDerivativeError = FastMath.max(maxDerivativeError,
1235 FastMath.abs(yRef[i].getPartialDerivative(1) - y[i].getPartialDerivative(1)));
1236 }
1237 }
1238 Assertions.assertEquals(0, maxValueError, valueTolerance);
1239 Assertions.assertEquals(0, maxDerivativeError, derivativeTolerance);
1240
1241 }
1242
1243 @BeforeEach
1244 public void setUp() {
1245 Utils.setDataRoot("compressed-data");
1246 }
1247
1248 }