/rust/registry/src/index.crates.io-1949cf8c6b5b557f/sofars-0.6.1/src/erst/gmst82.rs
Line | Count | Source |
1 | | use crate::consts::{DAYSEC, DJ00, DJC, DS2R}; |
2 | | use crate::vm::anp; |
3 | | use std::ops::Rem; |
4 | | |
5 | | /// Greenwich mean sidereal time, IAU 1982 |
6 | 0 | pub fn gmst82(dj1: f64, dj2: f64) -> f64 { |
7 | | // Coefficients of IAU 1982 GMST-UT1 model |
8 | 0 | let a = 24110.54841 - DAYSEC / 2.0; |
9 | 0 | let b = 8640184.812866; |
10 | 0 | let c = 0.093104; |
11 | 0 | let d = -6.2e-6; |
12 | | |
13 | | // The first constant, A, has to be adjusted by 12 hours because the |
14 | | // UT1 is supplied as a Julian date, which begins at noon. |
15 | | |
16 | 0 | let (d1, d2) = if dj1 < dj2 { (dj1, dj2) } else { (dj2, dj1) }; |
17 | | |
18 | | // Julian centuries since fundamental epoch. |
19 | 0 | let t = (d1 + (d2 - DJ00)) / DJC; |
20 | | |
21 | | // Fractional part of JD(UT1), in seconds. |
22 | 0 | let f = DAYSEC * (d1.rem(1.0) + d2.rem(1.0)); |
23 | | |
24 | | // GMST at this UT1. |
25 | 0 | let gmst = anp(DS2R * ((a + (b + (c + d * t) * t) * t) + f)); |
26 | | |
27 | 0 | gmst |
28 | 0 | } |