/
fk5.jl
757 lines (611 loc) · 28.1 KB
/
fk5.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
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
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
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
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
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
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
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
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
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
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
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
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# Description
# ==============================================================================
#
# Functions related with the model IAU-76/FK5.
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# References
# ==============================================================================
#
# [1] Vallado, D. A (2013). Fundamentals of Astrodynamics and Applications.
# Microcosm Press, Hawthorn, CA, USA.
#
# [2] Gontier, A. M., Capitaine, N (1991). High-Accuracy Equation of Equinoxes
# and VLBI Astrometric Modelling. Radio Interferometry: Theory, Techniques
# and Applications, IAU Coll. 131, ASP Conference Series, Vol. 19.
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
export r_itrf_to_pef_fk5, r_pef_to_itrf_fk5
export r_pef_to_tod_fk5, r_tod_to_pef_fk5
export r_tod_to_mod_fk5, r_mod_to_tod_fk5
export r_mod_to_gcrf_fk5, r_gcrf_to_mod_fk5
export r_itrf_to_gcrf_fk5, r_gcrf_to_itrf_fk5
export r_pef_to_mod_fk5, r_mod_to_pef_fk5
################################################################################
# IAU-76/FK5 Reductions
################################################################################
#
# The conversion between the Geocentric Celestial Reference Frame (GCRF) to the
# International Terrestrial Reference Frame (ITRF) is done by means of:
#
# GCRF <=> MOD <=> TOD <=> PEF <=> ITRF
#
# in which:
# - MOD: Mean of Date frame.
# - TOD: True of Date frame.
# - PEF: Pseudo-Earth fixed frame.
#
# Every rotation will be coded as a function using the IAU-76/FK5 theory.
# Additionally, composed rotations will also available. In general, the API is:
#
# function r_<Origin Frame>_to_<Destination Frame>_fk5
#
# The arguments vary depending on the origin and destination frame and should be
# verified using the function documentation.
#
################################################################################
################################################################################
# Single Rotations
################################################################################
# ITRF <=> PEF
# ==============================================================================
"""
r_itrf_to_pef_fk5([T,] x_p::Number, y_p::Number)
Compute the rotation that aligns the International Terrestrial Reference Frame
(ITRF) with the Pseudo-Earth Fixed (PEF) frame considering the polar motion
represented by the angles `x_p` [rad] and `y_p` [rad] that are obtained from
IERS EOP Data (see [`get_iers_eop`](@ref)).
`x_p` is the polar motion displacement about X-axis, which is the IERS Reference
Meridian direction (positive south along the 0˚ longitude meridian). `y_p` is
the polar motion displacement about Y-axis (90˚W or 270˚E meridian).
The rotation type is described by the optional variable `T`. If it is `DCM`,
then a DCM will be returned. Otherwise, if it is `Quaternion`, then a Quaternion
will be returned. In case this parameter is omitted, then it falls back to
`DCM`.
# Returns
The rotation that aligns the ITRF frame with the PEF frame. The rotation
representation is selected by the optional parameter `T`.
# Remarks
The ITRF is defined based on the International Reference Pole (IRP), which is
the location of the terrestrial pole agreed by international committees **[1]**.
The Pseudo-Earth Fixed, on the other hand, is defined based on the Earth axis of
rotation, or the Celestial Intermediate Pole (CIP). Hence, PEF XY-plane contains
the True Equator. Furthermore, since the recovered latitude and longitude are
sensitive to the CIP, then it should be computed considering the PEF frame.
# References
- **[1]**: Vallado, D. A (2013). Fundamentals of Astrodynamics and Applications.
Microcosm Press, Hawthorn, CA, USA.
"""
r_itrf_to_pef_fk5(x_p::Number, y_p::Number) = r_itrf_to_pef_fk5(DCM, x_p, y_p)
function r_itrf_to_pef_fk5(
T::Type,
x_p::Number,
y_p::Number
)
# Notice that `x_p` and `y_p` are displacements in X and Y directions and
# **not** rotation angles. Hence, a displacement in X is a rotation in Y and
# a displacement in Y is a rotation in X.
return smallangle_to_rot(T, +y_p, +x_p, 0)
end
"""
r_pef_to_itrf_fk5([T,] x_p::Number, y_p::Number)
Compute the rotation that aligns the Pseudo-Earth Fixed (PEF) with the
International Terrestrial Reference Frame (ITRF) considering the polar motion
represented by the angles `x_p` [rad] and `y_p` [rad] that are obtained from
IERS EOP Data (see [`get_iers_eop`](@ref)).
`x_p` is the polar motion displacement about X-axis, which is the IERS Reference
Meridian direction (positive south along the 0˚ longitude meridian). `y_p` is
the polar motion displacement about Y-axis (90˚W or 270˚E meridian).
The rotation type is described by the optional variable `T`. If it is `DCM`,
then a DCM will be returned. Otherwise, if it is `Quaternion`, then a Quaternion
will be returned. In case this parameter is omitted, then it falls back to
`DCM`.
# Returns
The rotation that aligns the PEF frame with the ITRF. The rotation
representation is selected by the optional parameter `T`.
# Remarks
The ITRF is defined based on the International Reference Pole (IRP), which is
the location of the terrestrial pole agreed by international committees **[1]**.
The Pseudo-Earth Fixed, on the other hand, is defined based on the Earth axis of
rotation, or the Celestial Intermediate Pole (CIP). Hence, PEF XY-plane contains
the True Equator. Furthermore, since the recovered latitude and longitude are
sensitive to the CIP, then it should be computed considering the PEF frame.
# References
- **[1]**: Vallado, D. A (2013). Fundamentals of Astrodynamics and Applications.
Microcosm Press, Hawthorn, CA, USA.
"""
r_pef_to_itrf_fk5(x_p::Number, y_p::Number) = r_pef_to_itrf_fk5(DCM, x_p, y_p)
function r_pef_to_itrf_fk5(T::Type, x_p::Number, y_p::Number)
# Notice that `x_p` and `y_p` are displacements in X and Y directions and
# **not** rotation angles. Hence, a displacement in X is a rotation in Y and
# a displacement in Y is a rotation in X.
return smallangle_to_rot(T, -y_p, -x_p, 0)
end
# PEF <=> TOD
# ==============================================================================
"""
r_pef_to_tod_fk5([T,] JD_UT1::Number, JD_TT::Number [, δΔψ_1980::Number])
Compute the rotation that aligns the Pseudo-Earth Fixed (PEF) frame with the
True of Date (TOD) frame at the Julian Day `JD_UT1` [UT1] and `JD_TT`
[Terrestrial Time]. This algorithm uses the IAU-76/FK5 theory. Notice that one
can provide correction for the nutation in longitude (`δΔψ_1980`) [rad] that
is usually obtained from IERS EOP Data (see [`get_iers_eop`](@ref)).
The Julian Day in UT1 is used to compute the Greenwich Mean Sidereal Time (GMST)
(see [`jd_to_gmst`](@ref)), whereas the Julian Day in Terrestrial Time is used
to compute the nutation in the longitude. Notice that the Julian Day in UT1 and
in Terrestrial Time must be equivalent, i.e. must be related to the same
instant. This function **does not** check this.
The rotation type is described by the optional variable `T`. If it is `DCM`,
then a DCM will be returned. Otherwise, if it is `Quaternion`, then a Quaternion
will be returned. In case this parameter is omitted, then it falls back to
`DCM`.
# Returns
The rotation that aligns the PEF frame with the TOD frame. The rotation
representation is selected by the optional parameter `T`.
# Remarks
The Pseudo-Earth Fixed (PEF) frame is rotated into the True of Date (TOD) frame
considering the 1980 IAU Theory of Nutation. The IERS EOP corrections must be
added if one wants to make the rotation consistent with the Geocentric Celestial
Reference Systems (GCRS).
"""
function r_pef_to_tod_fk5(
JD_UT1::Number,
JD_TT::Number,
δΔψ_1980::Number = 0
)
return r_pef_to_tod_fk5(DCM, JD_UT1, JD_TT, δΔψ_1980)
end
function r_pef_to_tod_fk5(
T::Type,
JD_UT1::Number,
JD_TT::Number,
δΔψ_1980::Number = 0
)
# Compute the nutation in the Julian Day (Terrestrial Time) `JD_TT`.
mϵ_1980, Δϵ_1980, Δψ_1980 = nutation_fk5(JD_TT)
# Add the corrections to the nutation in obliquity and longitude.
Δψ_1980 += δΔψ_1980
# Evaluate the Delaunay parameters associated with the Moon in the interval
# [0,2π]°.
#
# The parameters here were updated as stated in the errata [2].
T_TT = (JD_TT - JD_J2000) / 36525
r = 360
Ω_m = @evalpoly(
T_TT,
+ 125.04452222,
- (5r + 134.1362608),
+ 0.0020708,
+ 2.2e-6
)
Ω_m = mod(Ω_m, 360) * π / 180
# Compute the equation of Equinoxes.
#
# According to [2], the constant unit before `sin(2Ω_m)` is also in [rad].
Eq_equinox1982 = Δψ_1980 * cos(mϵ_1980) +
(0.002640sin(1Ω_m) + 0.000063sin(2Ω_m) ) * π / 648000
# Compute the Mean Greenwich Sidereal Time.
θ_gmst = jd_to_gmst(JD_UT1)
# Compute the Greenwich Apparent Sidereal Time (GAST).
#
# TODO: Should GAST be moved to a new function as the GMST?
θ_gast = θ_gmst + Eq_equinox1982
# Compute the rotation matrix.
return angle_to_rot(T, -θ_gast, 0, 0, :ZYX)
end
"""
r_tod_to_pef_fk5([T,] JD_UT1::Number, JD_TT::Number [, δΔψ_1980::Number])
Compute the rotation that aligns the True of Date (TOD) frame with the
Pseudo-Earth Fixed (PEF) frame at the Julian Day `JD_UT1` [UT1] and `JD_TT`
[Terrestrial Time]. This algorithm uses the IAU-76/FK5 theory. Notice that one
can provide correction for the nutation in longitude (`δΔψ_1980`) [rad] that
is usually obtained from IERS EOP Data (see [`get_iers_eop`](@ref)).
The Julian Day in UT1 is used to compute the Greenwich Mean Sidereal Time (GMST)
(see [`jd_to_gmst`](@ref)), whereas the Julian Day in Terrestrial Time is used
to compute the nutation in the longitude. Notice that the Julian Day in UT1 and
in Terrestrial Time must be equivalent, i.e. must be related to the same
instant. This function **does not** check this.
The rotation type is described by the optional variable `T`. If it is `DCM`,
then a DCM will be returned. Otherwise, if it is `Quaternion`, then a Quaternion
will be returned. In case this parameter is omitted, then it falls back to
`DCM`.
# Returns
The rotation that aligns the TOD frame with the PEF frame. The rotation
representation is selected by the optional parameter `T`.
# Remarks
The True of Date (TOD) frame is rotated into the Pseudo-Earth Fixed (PEF) frame
considering the 1980 IAU Theory of Nutation. The IERS EOP corrections must be
added if one wants to make the rotation consistent with the Geocentric Celestial
Reference Systems (GCRS).
"""
function r_tod_to_pef_fk5(
JD_UT1::Number,
JD_TT::Number,
δΔψ_1980::Number = 0
)
return r_tod_to_pef_fk5(DCM, JD_UT1, JD_TT, δΔψ_1980)
end
function r_tod_to_pef_fk5(
T::T_ROT,
JD_UT1::Number,
JD_TT::Number,
δΔψ_1980::Number = 0
)
return inv_rotation(r_pef_to_tod_fk5(T, JD_UT1, JD_TT, δΔψ_1980))
end
# TOD <=> MOD
# ==============================================================================
"""
r_tod_to_mod_fk5([T,] JD_TT::Number [, δΔϵ_1980::Number, δΔψ_1980::Number])
Compute the rotation that aligns the True of Date (TOD) frame with the Mean of
Date (MOD) frame at the Julian Day `JD_TT` [Terrestrial Time]. This algorithm
uses the IAU-76/FK5 theory. Notice that one can provide corrections for the
nutation in obliquity (`δΔϵ_1980`) [rad] and in longitude (`δΔψ_1980`) [rad]
that are usually obtained from IERS EOP Data (see [`get_iers_eop`](@ref)).
The rotation type is described by the optional variable `T`. If it is `DCM`,
then a DCM will be returned. Otherwise, if it is `Quaternion`, then a Quaternion
will be returned. In case this parameter is omitted, then it falls back to
`DCM`.
# Returns
The rotation that aligns the TOD frame with the MOD frame. The rotation
representation is selected by the optional parameter `T`.
# Remarks
The True of Date (TOD) frame is rotated into the Mean of Date (MOD) frame
considering the 1980 IAU Theory of Nutation. The IERS EOP corrections must be
added if one wants to make the rotation consistent with the Geocentric Celestial
Reference Systems (GCRS).
"""
function r_tod_to_mod_fk5(
JD_TT::Number,
δΔϵ_1980::Number = 0,
δΔψ_1980::Number = 0
)
return r_tod_to_mod_fk5(DCM, JD_TT, δΔϵ_1980, δΔψ_1980)
end
function r_tod_to_mod_fk5(
T::Type,
JD_TT::Number,
δΔϵ_1980::Number = 0,
δΔψ_1980::Number = 0
)
# Compute the nutation in the Julian Day (Terrestrial Time) `JD_TT`.
mϵ_1980, Δϵ_1980, Δψ_1980 = nutation_fk5(JD_TT)
# Add the corrections to the nutation in obliquity and longitude.
Δϵ_1980 += δΔϵ_1980
Δψ_1980 += δΔψ_1980
# Compute the obliquity.
ϵ_1980 = mϵ_1980 + Δϵ_1980
# Compute and return the Direction Cosine DCM.
return angle_to_rot(T, ϵ_1980, Δψ_1980, -mϵ_1980, :XZX)
end
"""
r_mod_to_tod_fk5([T,] JD_TT::Number [, δΔϵ_1980::Number, δΔψ_1980::Number])
Compute the rotation that aligns the Mean of Date (MOD) frame with the True of
Date (TOD) frame at the Julian Day `JD_TT` [Terrestrial Time]. This algorithm
uses the IAU-76/FK5 theory. Notice that one can provide corrections for the
nutation in obliquity (`δΔϵ_1980`) [rad] and in longitude (`δΔψ_1980`) [rad]
that are usually obtained from IERS EOP Data (see [`get_iers_eop`](@ref)).
The rotation type is described by the optional variable `T`. If it is `DCM`,
then a DCM will be returned. Otherwise, if it is `Quaternion`, then a Quaternion
will be returned. In case this parameter is omitted, then it falls back to
`DCM`.
# Returns
The rotation that aligns the MOD frame with the TOD frame. The rotation
representation is selected by the optional parameter `T`.
# Remarks
The Mean of Date (MOD) frame is rotated into the True of Date (TOD) frame
considering the 1980 IAU Theory of Nutation. The IERS EOP corrections must be
added if one wants to make the rotation consistent with the Geocentric Celestial
Reference Systems (GCRS).
"""
function r_mod_to_tod_fk5(
JD_TT::Number,
δΔϵ_1980::Number = 0,
δΔψ_1980::Number = 0
)
return r_mod_to_tod_fk5(DCM, JD_TT, δΔϵ_1980, δΔψ_1980)
end
function r_mod_to_tod_fk5(
T::T_ROT,
JD_TT::Number,
δΔϵ_1980::Number = 0,
δΔψ_1980::Number = 0
)
return inv_rotation(r_tod_to_mod_fk5(T, JD_TT, δΔϵ_1980, δΔψ_1980))
end
# MOD <=> GCRF
# ==============================================================================
"""
r_mod_to_gcrf_fk5([T,] JD_TT::Number)
Compute the rotation that aligns the Mean of Date (MOD) frame with the
Geocentric Celestial Reference Frame (GCRF) at the Julian Day [Terrestrial Time]
`JD_TT`. This algorithm uses the IAU-76/FK5 theory.
The rotation type is described by the optional variable `T`. If it is `DCM`,
then a DCM will be returned. Otherwise, if it is `Quaternion`, then a Quaternion
will be returned. In case this parameter is omitted, then it falls back to
`DCM`.
# Returns
The rotation that aligns the MOD frame with the GCRF frame. The rotation
representation is selected by the optional parameter `T`.
# Remarks
The Mean of Date (MOD) frame is rotated into the Geocentric Celestial Reference
Frame (GCRF) considering the IAU 1976 Precession model.
Notice that if the conversion `TOD => MOD` is performed **without** considering
the EOP corrections, then the GCRF obtained by this rotation is what is usually
called the J2000 reference frame.
"""
r_mod_to_gcrf_fk5(JD_TT::Number) = r_mod_to_gcrf_fk5(DCM,JD_TT)
function r_mod_to_gcrf_fk5(T::Type, JD_TT::Number)
ζ, Θ, z = precession_fk5(JD_TT)
return angle_to_rot(T, z, -Θ, ζ, :ZYZ)
end
"""
r_gcrf_to_mod_fk5([T,] JD_TT::Number)
Compute the rotation that aligns the Geocentric Celestial Reference Frame (GCRF)
with the Mean of Date (MOD) frame at the Julian Day [Terrestrial Time] `JD_TT`.
This algorithm uses the IAU-76/FK5 theory.
The rotation type is described by the optional variable `T`. If it is `DCM`,
then a DCM will be returned. Otherwise, if it is `Quaternion`, then a Quaternion
will be returned. In case this parameter is omitted, then it falls back to
`DCM`.
# Returns
The rotation that aligns the GCRF frame with the MOD frame. The rotation
representation is selected by the optional parameter `T`.
# Remarks
The Geocentric Celestial Reference Frame (GCRF) is rotated into the Mean of Date
(MOD) frame considering the IAU 1976 Precession model.
Notice that if the conversion `MOD => TOD` is performed **without** considering
the EOP corrections, then the GCRF in this rotation is what is usually called
the J2000 reference frame.
"""
r_gcrf_to_mod_fk5(JD_TT::Number) = r_gcrf_to_mod_fk5(DCM,JD_TT)
r_gcrf_to_mod_fk5(T::T_ROT, JD_TT::Number) = inv_rotation(r_mod_to_gcrf_fk5(T, JD_TT))
################################################################################
# Multiple Rotations
################################################################################
# The functions with multiple rotations must be added only in two cases:
#
# * ITRF <=> GCRF (Full rotation between ECI and ECEF).
# * When the it will decrease the computational burden compared to
# calling the functions with the single rotations.
#
# ITRF <=> GCRF
# ==============================================================================
"""
r_itrf_to_gcrf_fk5([T,] JD_UT1::Number, JD_TT::Number, x_p::Number, y_p::Number [, δΔϵ_1980::Number, δΔψ_1980::Number])
Compute the rotation that aligns the International Terrestrial Reference Frame
(ITRF) with the Geocentric Celestial Reference Frame (GCRF) at the Julian Day
`JD_UT1` [UT1] and `JD_TT` [Terrestrial Time], and considering the IERS EOP Data
`x_p` [rad], `y_p` [rad], `δΔϵ_1980` [rad], and `δΔψ_1980` [rad] \\(see
[`get_iers_eop`](@ref)). This algorithm uses the IAU-76/FK5 theory.
`x_p` is the polar motion displacement about X-axis, which is the IERS Reference
Meridian direction (positive south along the 0˚ longitude meridian). `y_p` is
the polar motion displacement about Y-axis (90˚W or 270˚E meridian). `δΔϵ_1980`
is the nutation in obliquity. `δΔψ_1980` is the nutation in longitude.
The Julian Day in UT1 is used to compute the Greenwich Mean Sidereal Time (GMST)
(see [`jd_to_gmst`](@ref)), whereas the Julian Day in Terrestrial Time is used
to compute the nutation in the longitude. Notice that the Julian Day in UT1 and
in Terrestrial Time must be equivalent, i.e. must be related to the same
instant. This function **does not** check this.
The rotation type is described by the optional variable `T`. If it is `DCM`,
then a DCM will be returned. Otherwise, if it is `Quaternion`, then a Quaternion
will be returned. In case this parameter is omitted, then it falls back to
`DCM`.
# Returns
The rotation that aligns the ITRF frame with the GCRF frame. The rotation
representation is selected by the optional parameter `T`.
# Remarks
The EOP data related to the polar motion (`x_p` and `y_p`) is required, since
this is the only way available to compute the conversion ITRF <=> PEF (the
models are highly imprecise since the motion is still not very well understood
- **[1]**). However, the EOP data related to the nutation of the obliquity
(`δΔϵ_1980`) and the nutation of the longitude (`δΔψ_1980`) can be omitted. In
this case, the GCRF frame is what is usually called J2000 reference frame.
# References
- **[1]**: Vallado, D. A (2013). Fundamentals of Astrodynamics and Applications.
Microcosm Press, Hawthorn, CA, USA.
"""
function r_itrf_to_gcrf_fk5(
JD_UT1::Number,
JD_TT::Number,
x_p::Number,
y_p::Number,
δΔϵ_1980::Number = 0,
δΔψ_1980::Number = 0
)
return r_itrf_to_gcrf_fk5(DCM, JD_UT1, JD_TT, x_p, y_p, δΔϵ_1980, δΔψ_1980)
end
function r_itrf_to_gcrf_fk5(
T::Type,
JD_UT1::Number,
JD_TT::Number,
x_p::Number,
y_p::Number,
δΔϵ_1980::Number = 0,
δΔψ_1980::Number = 0
)
# Compute the rotation ITRF => PEF.
r_PEF_ITRF = r_itrf_to_pef_fk5(T, x_p, y_p)
# Compute the rotation PEF => MOD.
r_MOD_PEF = r_pef_to_mod_fk5(T, JD_UT1, JD_TT, δΔϵ_1980, δΔψ_1980)
# Compute the rotation MOD => GCRF.
r_GCRF_MOD = r_mod_to_gcrf_fk5(T, JD_TT)
# Return the full rotation.
return compose_rotation(r_PEF_ITRF, r_MOD_PEF, r_GCRF_MOD)
end
"""
r_gcrf_to_itrf_fk5([T,] JD_UT1::Number, JD_TT::Number, x_p::Number, y_p::Number [, δΔϵ_1980::Number, δΔψ_1980::Number])
Compute the rotation that aligns the Geocentric Celestial Reference Frame (GCRF)
with the International Terrestrial Reference Frame (ITRF) at the Julian Day
`JD_UT1` [UT1] and `JD_TT` [Terrestrial Time], and considering the IERS EOP Data
`x_p` [rad], `y_p` [rad], `δΔϵ_1980` [rad], and `δΔψ_1980` [rad] \\(see
[`get_iers_eop`](@ref)). This algorithm uses the IAU-76/FK5 theory.
`x_p` is the polar motion displacement about X-axis, which is the IERS Reference
Meridian direction (positive south along the 0˚ longitude meridian). `y_p` is
the polar motion displacement about Y-axis (90˚W or 270˚E meridian). `δΔϵ_1980`
is the nutation in obliquity. `δΔψ_1980` is the nutation in longitude.
The Julian Day in UT1 is used to compute the Greenwich Mean Sidereal Time (GMST)
(see [`jd_to_gmst`](@ref)), whereas the Julian Day in Terrestrial Time is used
to compute the nutation in the longitude. Notice that the Julian Day in UT1 and
in Terrestrial Time must be equivalent, i.e. must be related to the same
instant. This function **does not** check this.
The rotation type is described by the optional variable `T`. If it is `DCM`,
then a DCM will be returned. Otherwise, if it is `Quaternion`, then a Quaternion
will be returned. In case this parameter is omitted, then it falls back to
`DCM`.
# Returns
The rotation that aligns the GCRF frame with the ITRF frame. The rotation
representation is selected by the optional parameter `T`.
# Remarks
The EOP data related to the polar motion (`x_p` and `y_p`) is required, since
this is the only way available to compute the conversion ITRF <=> PEF (the
models are highly imprecise since the motion is still not very well understood
- **[1]**). However, the EOP data related to the nutation of the obliquity
(`δΔϵ_1980`) and the nutation of the longitude (`δΔψ_1980`) can be omitted. In
this case, the GCRF frame is what is usually called J2000 reference frame.
# References
- **[1]**: Vallado, D. A (2013). Fundamentals of Astrodynamics and Applications.
Microcosm Press, Hawthorn, CA, USA.
"""
function r_gcrf_to_itrf_fk5(
JD_UT1::Number,
JD_TT::Number,
x_p::Number,
y_p::Number,
δΔϵ_1980::Number = 0,
δΔψ_1980::Number = 0
)
return r_gcrf_to_itrf_fk5(DCM, JD_UT1, JD_TT, x_p, y_p, δΔϵ_1980, δΔψ_1980)
end
function r_gcrf_to_itrf_fk5(
T::T_ROT,
JD_UT1::Number,
JD_TT::Number,
x_p::Number,
y_p::Number,
δΔϵ_1980::Number = 0,
δΔψ_1980::Number = 0
)
return inv_rotation(r_itrf_to_gcrf_fk5(T, JD_UT1, JD_TT, x_p, y_p, δΔϵ_1980, δΔψ_1980))
end
# PEF <=> MOD
# ==============================================================================
"""
r_pef_to_mod_fk5([T,] JD_UT1::Number, JD_TT::Number [, δΔϵ_1980::Number, δΔψ_1980::Number])
Compute the rotation that aligns the Pseudo-Earth Fixed (PEF) frame with the
Mean of Date (MOD) at the Julian Day `JD_UT1` [UT1] and `JD_TT` [Terrestrial
Time]. This algorithm uses the IAU-76/FK5 theory. Notice that one can provide
corrections for the nutation in obliquity (`δΔϵ_1980`) [rad] and in longitude
(`δΔψ_1980`) [rad] that are usually obtained from IERS EOP Data (see
[`get_iers_eop`](@ref)).
The Julian Day in UT1 is used to compute the Greenwich Mean Sidereal Time (GMST)
(see [`jd_to_gmst`](@ref)), whereas the Julian Day in Terrestrial Time is used
to compute the nutation in the longitude. Notice that the Julian Day in UT1 and
in Terrestrial Time must be equivalent, i.e. must be related to the same
instant. This function **does not** check this.
The rotation type is described by the optional variable `T`. If it is `DCM`,
then a DCM will be returned. Otherwise, if it is `Quaternion`, then a Quaternion
will be returned. In case this parameter is omitted, then it falls back to
`DCM`.
# Returns
The rotation that aligns the PEF frame with the TOD frame. The rotation
representation is selected by the optional parameter `T`.
"""
function r_pef_to_mod_fk5(
JD_UT1::Number,
JD_TT::Number,
δΔϵ_1980::Number = 0,
δΔψ_1980::Number = 0
)
return r_pef_to_mod_fk5(DCM, JD_UT1, JD_TT, δΔϵ_1980, δΔψ_1980)
end
function r_pef_to_mod_fk5(
T::Type,
JD_UT1::Number,
JD_TT::Number,
δΔϵ_1980::Number = 0,
δΔψ_1980::Number = 0
)
# Notice that, in this case, we will not use `rPEFtoTOD` and `rTODtoMOD`
# because this would call the function `nutation` twice, leading to a huge
# performance drop. Hence, the code of those two functions is almost
# entirely rewritten here.
# Compute the nutation in the Julian Day (Terrestrial Time) `JD_TT`.
mϵ_1980, Δϵ_1980, Δψ_1980 = nutation_fk5(JD_TT)
# Add the corrections to the nutation in obliquity and longitude.
Δϵ_1980 += δΔϵ_1980
Δψ_1980 += δΔψ_1980
# Compute the obliquity.
ϵ_1980 = mϵ_1980 + Δϵ_1980
# Evaluate the Delaunay parameters associated with the Moon in the interval
# [0,2π]°.
#
# The parameters here were updated as stated in the errata [2].
T_TT = (JD_TT - JD_J2000) / 36525
r = 360
Ω_m = @evalpoly(
T_TT,
+ 125.04452222,
- (5r + 134.1362608),
+ 0.0020708,
+ 2.2e-6
)
Ω_m = mod(Ω_m, 360) * π / 180
# Compute the equation of Equinoxes.
#
# According to [2], the constant unit before `sin(2Ω_m)` is also in [rad].
Eq_equinox1982 = Δψ_1980*cos(mϵ_1980) +
(0.002640sin(1Ω_m) + 0.000063sin(2Ω_m)) * π / 648000
# Compute the Mean Greenwich Sidereal Time.
θ_gmst = jd_to_gmst(JD_UT1)
# Compute the Greenwich Apparent Sidereal Time (GAST).
#
# TODO: Should GAST be moved to a new function as the GMST?
θ_gast = θ_gmst + Eq_equinox1982
# Compute the rotation PEF => TOD.
r_TOD_PEF = angle_to_rot(T, -θ_gast, 0, 0, :ZYX)
# Compute the rotation TOD => MOD.
r_MOD_TOD = angle_to_rot(T, ϵ_1980, Δψ_1980, -mϵ_1980, :XZX)
return compose_rotation(r_TOD_PEF, r_MOD_TOD)
end
"""
r_mod_to_pef_fk5([T,] JD_UT1::Number, JD_TT::Number [, δΔϵ_1980::Number, δΔψ_1980::Number])
Compute the rotation that aligns the Mean of Date (MOD) reference frame with the
Pseudo-Earth Fixed (PEF) frame at the Julian Day `JD_UT1` [UT1] and `JD_TT`
[Terrestrial Time]. This algorithm uses the IAU-76/FK5 theory. Notice that one
can provide corrections for the nutation in obliquity (`δΔϵ_1980`) [rad] and in
longitude (`δΔψ_1980`) [rad] that are usually obtained from IERS EOP Data (see
[`get_iers_eop`](@ref)).
The Julian Day in UT1 is used to compute the Greenwich Mean Sidereal Time (GMST)
(see [`jd_to_gmst`](@ref)), whereas the Julian Day in Terrestrial Time is used
to compute the nutation in the longitude. Notice that the Julian Day in UT1 and
in Terrestrial Time must be equivalent, i.e. must be related to the same
instant. This function **does not** check this.
The rotation type is described by the optional variable `T`. If it is `DCM`,
then a DCM will be returned. Otherwise, if it is `Quaternion`, then a Quaternion
will be returned. In case this parameter is omitted, then it falls back to
`DCM`.
# Returns
The rotation that aligns the MOD frame with the PEF frame. The rotation
representation is selected by the optional parameter `T`.
"""
function r_mod_to_pef_fk5(
JD_UT1::Number,
JD_TT::Number,
δΔϵ_1980::Number = 0,
δΔψ_1980::Number = 0
)
return r_mod_to_pef_fk5(DCM, JD_UT1, JD_TT, δΔϵ_1980, δΔψ_1980)
end
function r_mod_to_pef_fk5(
T::T_ROT,
JD_UT1::Number,
JD_TT::Number,
δΔϵ_1980::Number = 0,
δΔψ_1980::Number = 0
)
return inv_rotation(r_pef_to_mod_fk5(T, JD_UT1, JD_TT, δΔϵ_1980, δΔψ_1980))
end