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
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//! Precession and nutation code.
pub use nut00a;
use crate*;
/// Mean obliquity of the ecliptic, IAU 2006 precession model. (`eraObl06`)
///
/// Given:
/// * `date1`,`date2`: TT as a 2-part Julian Date (Note 1)
///
/// Returned:
/// * obliquity of the ecliptic (radians, Note 2)
///
/// # Notes:
///
/// 1) The TT date `date1+date2` is a Julian Date, apportioned in any convenient
/// way between the two arguments. For example, `JD(TT)=2450123.7` could be
/// expressed in any of these ways, among others:
///
/// | `date1` | `date2` | |
/// |-----------|---------|--------------------|
/// | 2450123.7 | 0.0 | JD method |
/// | 2451545.0 | -1421.3 | J2000 method |
/// | 2400000.5 | 50123.2 | MJD method |
/// | 2450123.5 | 0.2 | date & time method |
///
/// The JD method is the most natural and convenient to use in cases where
/// the loss of several decimal digits of resolution is acceptable. The
/// J2000 method is best matched to the way the argument is handled
/// internally and will deliver the optimum resolution. The MJD method and
/// the date & time methods are both good compromises between resolution and
/// convenience.
///
/// 2) The result is the angle between the ecliptic and mean equator of date
/// `date1+date2`.
///
/// # References:
///
/// * Hilton, J. et al., 2006, Celest.Mech.Dyn.Astron. 94, 351
///
/// Precession angles, IAU 2006, equinox based. (`eraP06e`)
///
/// Given:
/// * `date1`,`date2`: TT as a 2-part Julian Date (Note 1)
///
/// Returned (see Note 2):
/// * `eps0`: epsilon_0
/// * `psia`: psi_A
/// * `oma`: omega_A
/// * `bpa`: P_A
/// * `bqa`: Q_A
/// * `pia`: pi_A
/// * `bpia`: Pi_A
/// * `epsa`: obliquity epsilon_A
/// * `chia`: chi_A
/// * `za`: z_A
/// * `zetaa`: zeta_A
/// * `thetaa`: theta_A
/// * `pa`: p_A
/// * `gam`: F-W angle gamma_J2000
/// * `phi`: F-W angle phi_J2000
/// * `psi`: F-W angle psi_J2000
///
/// Notes:
///
/// 1) The TT date `date1+date2` is a Julian Date, apportioned in any convenient
/// way between the two arguments. For example, `JD(TT)=2450123.7` could be
/// expressed in any of these ways, among others:
///
/// | `date1` | `date2` | |
/// |-----------|---------|--------------------|
/// | 2450123.7 | 0.0 | JD method |
/// | 2451545.0 | -1421.3 | J2000 method |
/// | 2400000.5 | 50123.2 | MJD method |
/// | 2450123.5 | 0.2 | date & time method |
///
/// The JD method is the most natural and convenient to use in cases where
/// the loss of several decimal digits of resolution is acceptable. The
/// J2000 method is best matched to the way the argument is handled
/// internally and will deliver the optimum resolution. The MJD method and
/// the date & time methods are both good compromises between resolution and
/// convenience.
///
/// 2) This function returns the set of equinox based angles for the Capitaine
/// et al. "P03" precession theory, adopted by the IAU in
/// 2006. The angles are set out in Table 1 of Hilton et al. (2006):
///
/// * `eps0` `epsilon_0` obliquity at J2000.0
/// * `psia` `psi_A` luni-solar precession
/// * `oma` `omega_A` inclination of equator wrt J2000.0 ecliptic
/// * `bpa` `P_A` ecliptic pole x, J2000.0 ecliptic triad
/// * `bqa` `Q_A` ecliptic pole -y, J2000.0 ecliptic triad
/// * `pia` `pi_A` angle between moving and J2000.0 ecliptics
/// * `bpia` `Pi_A` longitude of ascending node of the ecliptic
/// * `epsa` `epsilon_A` obliquity of the ecliptic
/// * `chia` `chi_A` planetary precession
/// * `za` `z_A` equatorial precession: -3rd 323 Euler angle
/// * `zetaa` `zeta_A` equatorial precession: -1st 323 Euler angle
/// * `thetaa` `theta_A` equatorial precession: 2nd 323 Euler angle
/// * `pa` `p_A` general precession (n.b. see below)
/// * `gam` `gamma_J2000` J2000.0 RA difference of ecliptic poles
/// * `phi` `phi_J2000` J2000.0 codeclination of ecliptic pole
/// * `psi` `psi_J2000` longitude difference of equator poles, J2000.0
///
/// The returned values are all radians.
///
/// Note that the `t^5` coefficient in the series for `p_A` from Capitaine et
/// al. (2003) is incorrectly signed in Hilton et al. (2006).
///
/// 3) Hilton et al. (2006) Table 1 also contains angles that depend on models
/// distinct from the P03 precession theory itself, namely the IAU 2000A
/// frame bias and nutation. The quoted polynomials are used in other ERFA
/// functions:
///
/// * `eraXy06` contains the polynomial parts of the `X` and `Y` series.
///
/// * `eraS06` contains the polynomial part of the `s+XY/2` series.
///
/// * `eraPfw06`: implements the series for the Fukushima-Williams angles
/// that are with respect to the GCRS pole (i.e. the variants that include
/// frame bias).
///
/// 4) The IAU resolution stipulated that the choice of parameterization was
/// left to the user, and so an IAU compliant precession implementation can
/// be constructed using various combinations of the angles returned by the
/// present function.
///
/// 5) The parameterization used by ERFA is the version of the Fukushima-
/// Williams angles that refers directly to the GCRS pole. These angles may
/// be calculated by calling the function
/// [`eraPfw06`](precession_angles_fw06). ERFA also supports the direct
/// computation of the CIP GCRS `X`,`Y` by series, available by calling
/// `eraXy06`.
///
/// 6) The agreement between the different parameterizations is at the 1
/// microarcsecond level in the present era.
///
/// 7) When constructing a precession formulation that refers to the GCRS pole
/// rather than the dynamical pole, it may (depending on the choice of
/// angles) be necessary to introduce the frame bias explicitly.
///
/// 8) It is permissible to re-use the same variable in the returned arguments.
/// The quantities are stored in the stated order.
///
/// References:
///
/// * Capitaine, N., Wallace, P.T. & Chapront, J., 2003, Astron.Astrophys., 412,
/// 567
///
/// * Hilton, J. et al., 2006, Celest.Mech.Dyn.Astron. 94, 351
///
/// Precession angles, IAU 2006 (Fukushima-Williams 4-angle formulation).
/// (`eraPfw06`)
///
/// Given:
/// * `date1`,`date2`: TT as a 2-part Julian Date (Note 1)
///
/// Returned:
/// * `gamb`: F-W angle gamma_bar (radians)
/// * `phib`: F-W angle phi_bar (radians)
/// * `psib`: F-W angle psi_bar (radians)
/// * `epsa`: F-W angle epsilon_A (radians)
///
/// # Notes:
///
/// 1) The TT date `date1+date2` is a Julian Date, apportioned in any convenient
/// way between the two arguments. For example, `JD(TT)=2450123.7` could be
/// expressed in any of these ways, among others:
///
/// | `date1` | `date2` | |
/// |-----------|---------|--------------------|
/// | 2450123.7 | 0.0 | JD method |
/// | 2451545.0 | -1421.3 | J2000 method |
/// | 2400000.5 | 50123.2 | MJD method |
/// | 2450123.5 | 0.2 | date & time method |
///
/// The JD method is the most natural and convenient to use in cases where
/// the loss of several decimal digits of resolution is acceptable. The
/// J2000 method is best matched to the way the argument is handled
/// internally and will deliver the optimum resolution. The MJD method and
/// the date & time methods are both good compromises between resolution and
/// convenience.
///
/// 2) Naming the following points:
///
/// * `e` = J2000.0 ecliptic pole,
/// * `p` = GCRS pole,
/// * `E` = mean ecliptic pole of date,
/// * `P` = mean pole of date,
///
/// the four Fukushima-Williams angles are as follows:
///
/// * `gamb` = gamma_bar = epE
/// * `phib` = phi_bar = pE
/// * `psib` = psi_bar = pEP
/// * `epsa` = epsilon_A = EP
///
/// 3) The matrix representing the combined effects of frame bias and precession
/// is:
///
/// `PxB = R_1(-epsa).R_3(-psib).R_1(phib).R_3(gamb)``
///
/// 4) The matrix representing the combined effects of frame bias, precession
/// and nutation is simply:
///
/// `NxPxB = R_1(-epsa-dE).R_3(-psib-dP).R_1(phib).R_3(gamb)``
///
/// where `dP` and `dE` are the nutation components with respect to the
/// ecliptic of date.
///
/// References:
///
/// * Hilton, J. et al., 2006, Celest.Mech.Dyn.Astron. 94, 351
///
/// IAU 2000A nutation with adjustments to match the IAU 2006 precession.
/// (`eraNut06a`)
///
/// Given:
/// * `date1`,`date2`: TT as a 2-part Julian Date (Note 1)
///
/// Returned:
/// * `dpsi`,`deps`: nutation, luni-solar + planetary (Note 2)
///
/// # Notes:
///
/// 1) The TT date `date1+date2` is a Julian Date, apportioned in any convenient
/// way between the two arguments. For example, `JD(TT)=2450123.7` could be
/// expressed in any of these ways, among others:
///
/// | `date1` | `date2` | |
/// |-----------|---------|--------------------|
/// | 2450123.7 | 0.0 | JD method |
/// | 2451545.0 | -1421.3 | J2000 method |
/// | 2400000.5 | 50123.2 | MJD method |
/// | 2450123.5 | 0.2 | date & time method |
///
/// The JD method is the most natural and convenient to use in cases where
/// the loss of several decimal digits of resolution is acceptable. The
/// J2000 method is best matched to the way the argument is handled
/// internally and will deliver the optimum resolution. The MJD method and
/// the date & time methods are both good compromises between resolution and
/// convenience.
///
/// 2) The nutation components in longitude and obliquity are in radians and
/// with respect to the mean equinox and ecliptic of date, IAU 2006
/// precession model (Hilton et al. 2006, Capitaine et al. 2005).
///
/// 3) The function first computes the IAU 2000A nutation, then applies
/// adjustments for (i) the consequences of the change in obliquity from the
/// IAU 1980 ecliptic to the IAU 2006 ecliptic and (ii) the secular variation
/// in the Earth's dynamical form factor J2.
///
/// 4) The present function provides classical nutation, complementing the IAU
/// 2000 frame bias and IAU 2006 precession. It delivers a pole which is at
/// current epochs accurate to a few tens of microarcseconds, apart from the
/// free core nutation.
///
/// # References:
///
/// * Chapront, J., Chapront-Touze, M. & Francou, G. 2002, Astron.Astrophys.
/// 387, 700
/// * Lieske, J.H., Lederle, T., Fricke, W. & Morando, B. 1977,
/// Astron.Astrophys. 58, 1-16
/// * Mathews, P.M., Herring, T.A., Buffet, B.A. 2002, J.Geophys.Res. 107, B4.
/// The MHB_2000 code itself was obtained on 9th September 2002 from
/// <ftp://maia.usno.navy.mil/conv2000/chapter5/IAU2000A>.
/// * Simon, J.-L., Bretagnon, P., Chapront, J., Chapront-Touze, M., Francou,
/// G., Laskar, J. 1994, Astron.Astrophys. 282, 663-683
/// * Souchay, J., Loysel, B., Kinoshita, H., Folgueira, M. 1999,
/// Astron.Astrophys.Supp.Ser. 135, 111
/// * Wallace, P.T., "Software for Implementing the IAU 2000 Resolutions", in
/// IERS Workshop 5.1 (2002)
///
/// Form rotation matrix given the Fukushima-Williams angles. (`eraFw2m`)
///
/// Given:
/// * `gamb`: F-W angle gamma_bar (radians)
/// * `phib`: F-W angle phi_bar (radians)
/// * `psi`: F-W angle psi (radians)
/// * `eps`: F-W angle epsilon (radians)
///
/// Returned:
/// * `r`: rotation matrix
///
/// # Notes:
///
/// 1) Naming the following points:
///
/// * `e` = J2000.0 ecliptic pole,
/// * `p` = GCRS pole,
/// * `E` = ecliptic pole of date,
/// * `P` = CIP,
///
/// the four Fukushima-Williams angles are as follows:
///
/// * `gamb = gamma = epE`,
/// * `phib = phi = pE`,
/// * `psi = psi = pEP`,
/// * `eps = epsilon = EP`
///
/// 2) The matrix representing the combined effects of frame bias, precession
/// and nutation is:
///
/// `NxPxB = R_1(-eps).R_3(-psi).R_1(phib).R_3(gamb)`
///
/// 3) The present function can construct three different matrices, depending on
/// which angles are supplied as the arguments `gamb`, `phib`, `psi` and
/// `eps`:
///
/// - To obtain the nutation x precession x frame bias matrix, first
/// generate the four precession angles known conventionally as
/// `gamma_bar`, `phi_bar`, `psi_bar` and `epsilon_A`, then generate the
/// nutation components `Dpsi` and `Depsilon` and add them to `psi_bar`
/// and `epsilon_A`, and finally call the present function using those
/// four angles as arguments.
///
/// - To obtain the precession x frame bias matrix, generate the four
/// precession angles and call the present function.
///
/// - To obtain the frame bias matrix, generate the four precession angles
/// for date J2000.0 and call the present function.
///
/// The nutation-only and precession-only matrices can if necessary be
/// obtained by combining these three appropriately.
///
/// # References:
///
/// * Capitaine, N. & Wallace, P.T., 2006, Astron.Astrophys. 450, 855
/// * Hilton, J. et al., 2006, Celest.Mech.Dyn.Astron. 94, 351
///
/// Form the matrix of precession-nutation for a given date (including frame
/// bias), equinox based, IAU 2006 precession and IAU 2000A nutation models.
/// (`eraPnm06a`)
///
/// Given:
/// * `date1`,`date2`: TT as a 2-part Julian Date (Note 1)
///
/// Returned:
/// * `rbpn`: bias-precession-nutation matrix (Note 2)
///
/// # Notes:
///
/// 1) The TT date `date1+date2` is a Julian Date, apportioned in any convenient
/// way between the two arguments. For example, `JD(TT)=2450123.7` could be
/// expressed in any of these ways, among others:
///
/// | `date1` | `date2` | |
/// |-----------|---------|--------------------|
/// | 2450123.7 | 0.0 | JD method |
/// | 2451545.0 | -1421.3 | J2000 method |
/// | 2400000.5 | 50123.2 | MJD method |
/// | 2450123.5 | 0.2 | date & time method |
///
/// The JD method is the most natural and convenient to use in cases where
/// the loss of several decimal digits of resolution is acceptable. The
/// J2000 method is best matched to the way the argument is handled
/// internally and will deliver the optimum resolution. The MJD method and
/// the date & time methods are both good compromises between resolution and
/// convenience.
///
/// 2) The matrix operates in the sense `V(date) = rbpn * V(GCRS)`, where the
/// p-vector `V(date)` is with respect to the true equatorial triad of date
/// `date1+date2` and the p-vector `V(GCRS)` is with respect to the
/// Geocentric Celestial Reference System (IAU, 2000).
///
/// # References:
///
/// * Capitaine, N. & Wallace, P.T., 2006, Astron.Astrophys. 450, 855.
///
/// Extract from the bias-precession-nutation matrix the X,Y coordinates of the
/// Celestial Intermediate Pole. (`eraBpn2xy`)
///
/// Given:
/// * `rbpn`: celestial-to-true matrix (Note 1)
///
/// Returned:
/// * `x`,`y`: Celestial Intermediate Pole (Note 2)
///
/// # Notes:
///
/// 1) The matrix `rbpn` transforms vectors from GCRS to true equator (and CIO
/// or equinox) of date, and therefore the Celestial Intermediate Pole unit
/// vector is the bottom row of the matrix.
///
/// 2) `x` and `y` are components of the Celestial Intermediate Pole unit vector
/// in the Geocentric Celestial Reference System.
///
/// # Reference:
///
/// * "Expressions for the Celestial Intermediate Pole and Celestial Ephemeris
/// Origin consistent with the IAU 2000A precession- nutation model",
/// Astron.Astrophys. 400, 1145-1154 (2003)
///
/// n.b. The celestial ephemeris origin (CEO) was renamed "celestial
/// intermediate origin" (CIO) by IAU 2006 Resolution 2.
///
/// Equation of the origins, given the classical NPB matrix and the quantity
/// `s`. (`eraEors`)
///
/// Given:
/// * `rnpb` classical nutation x precession x bias matrix
/// * `s`: the quantity s (the CIO locator) in radians
///
/// Returned:
/// * the equation of the origins in radians
///
/// # Notes:
///
/// 1) The equation of the origins is the distance between the true equinox and
/// the celestial intermediate origin and, equivalently, the difference
/// between Earth rotation angle and Greenwich apparent sidereal time
/// (ERA-GST). It comprises the precession (since J2000.0) in right
/// ascension plus the equation of the equinoxes (including the small
/// correction terms).
///
/// 2) The algorithm is from Wallace & Capitaine (2006).
///
/// # References:
///
/// * Capitaine, N. & Wallace, P.T., 2006, Astron.Astrophys. 450, 855
/// * Wallace, P. & Capitaine, N., 2006, Astron.Astrophys. 459, 981
///
/// Precession matrix (including frame bias) from GCRS to a specified date, IAU
/// 2006 model. (`eraPmat06`)
///
/// Given:
/// * `date1`,`date2`: TT as a 2-part Julian Date (Note 1)
///
/// Returned:
/// * `rbp`: bias-precession matrix (Note 2)
///
/// # Notes:
///
/// 1) The TT date `date1+date2` is a Julian Date, apportioned in any
/// convenient way between the two arguments. For example,
/// `JD(TT)=2450123.7` could be expressed in any of these ways, among others:
///
/// | `date1` | `date2` | |
/// |-----------|---------|--------------------|
/// | 2450123.7 | 0.0 | JD method |
/// | 2451545.0 | -1421.3 | J2000 method |
/// | 2400000.5 | 50123.2 | MJD method |
/// | 2450123.5 | 0.2 | date & time method |
///
/// The JD method is the most natural and convenient to use in cases where
/// the loss of several decimal digits of resolution is acceptable. The
/// J2000 method is best matched to the way the argument is handled
/// internally and will deliver the optimum resolution. The MJD method and
/// the date & time methods are both good compromises between resolution and
/// convenience.
///
/// 2) The matrix operates in the sense `V(date) = rbp * V(GCRS)`, where the
/// p-vector `V(GCRS)` is with respect to the Geocentric Celestial Reference
/// System (IAU, 2000) and the p-vector `V(date)` is with respect to the mean
/// equatorial triad of the given date.
///
/// # References:
///
/// * Capitaine, N. & Wallace, P.T., 2006, Astron.Astrophys. 450, 855
///
/// * IAU: Trans. International Astronomical Union, Vol. XXIVB; Proc. 24th
/// General Assembly, Manchester, UK. Resolutions B1.3, B1.6. (2000)
///
/// * Wallace, P.T. & Capitaine, N., 2006, Astron.Astrophys. 459, 981
///