/rust/registry/src/index.crates.io-1949cf8c6b5b557f/sofars-0.6.1/src/erst/era00.rs
Line | Count | Source |
1 | | use std::ops::Rem; |
2 | | |
3 | | use crate::consts::{D2PI, DJ00}; |
4 | | use crate::vm::anp; |
5 | | |
6 | | /// Earth rotation angle (IAU 2000 model). |
7 | | /// |
8 | | /// This function is part of the International Astronomical Union's |
9 | | /// SOFA (Standards of Fundamental Astronomy) software collection. |
10 | | /// |
11 | | /// Status: canonical model. |
12 | | /// |
13 | | /// Given: |
14 | | /// ``` |
15 | | /// dj1,dj2 double UT1 as a 2-part Julian Date (see note) |
16 | | /// ``` |
17 | | /// Returned (function value): |
18 | | /// ``` |
19 | | /// double Earth rotation angle (radians), range 0-2pi |
20 | | /// ``` |
21 | | /// Notes: |
22 | | /// |
23 | | /// 1) The UT1 date dj1+dj2 is a Julian Date, apportioned in any |
24 | | /// convenient way between the arguments dj1 and dj2. For example, |
25 | | /// JD(UT1)=2450123.7 could be expressed in any of these ways, |
26 | | /// among others: |
27 | | /// ``` |
28 | | /// dj1 dj2 |
29 | | /// |
30 | | /// 2450123.7 0.0 (JD method) |
31 | | /// 2451545.0 -1421.3 (J2000 method) |
32 | | /// 2400000.5 50123.2 (MJD method) |
33 | | /// 2450123.5 0.2 (date & time method) |
34 | | /// ``` |
35 | | /// The JD method is the most natural and convenient to use in |
36 | | /// cases where the loss of several decimal digits of resolution |
37 | | /// is acceptable. The J2000 and MJD methods are good compromises |
38 | | /// between resolution and convenience. The date & time method is |
39 | | /// best matched to the algorithm used: maximum precision is |
40 | | /// delivered when the dj1 argument is for 0hrs UT1 on the day in |
41 | | /// question and the dj2 argument lies in the range 0 to 1, or vice |
42 | | /// versa. |
43 | | /// |
44 | | /// 2) The algorithm is adapted from Expression 22 of Capitaine et al. |
45 | | /// 2000. The time argument has been expressed in days directly, |
46 | | /// and, to retain precision, integer contributions have been |
47 | | /// eliminated. The same formulation is given in IERS Conventions |
48 | | /// (2003), Chap. 5, Eq. 14. |
49 | | /// |
50 | | /// Called: |
51 | | /// ``` |
52 | | /// iauAnp normalize angle into range 0 to 2pi |
53 | | /// ``` |
54 | | /// References: |
55 | | /// |
56 | | /// Capitaine N., Guinot B. and McCarthy D.D, 2000, Astron. |
57 | | /// Astrophys., 355, 398-405. |
58 | | /// |
59 | | /// McCarthy, D. D., Petit, G. (eds.), IERS Conventions (2003), |
60 | | /// IERS Technical Note No. 32, BKG (2004) |
61 | 0 | pub fn era00(dj1: f64, dj2: f64) -> f64 { |
62 | | let d1: f64; |
63 | | let d2: f64; |
64 | | |
65 | | // Days since fundamental epoch. |
66 | 0 | if dj1 < dj2 { |
67 | 0 | d1 = dj1; |
68 | 0 | d2 = dj2; |
69 | 0 | } else { |
70 | 0 | d1 = dj2; |
71 | 0 | d2 = dj1; |
72 | 0 | } |
73 | | |
74 | 0 | let t = d1 + (d2 - DJ00); |
75 | | |
76 | | // Fractional part of T (days). |
77 | 0 | let f = d1.rem(1.0) + d2.rem(1.0); |
78 | | |
79 | | // Earth rotation angle at this UT1. |
80 | 0 | let theta = anp(D2PI * (f + 0.7790572732640 + 0.00273781191135448 * t)); |
81 | | |
82 | 0 | theta |
83 | 0 | } |