1 | /**
|
2 | * @copyright 2013 Sonia Keys
|
3 | * @copyright 2016 commenthol
|
4 | * @license MIT
|
5 | * @module sidereal
|
6 | */
|
7 | /**
|
8 | * Sidereal: Chapter 12, Sidereal Time at Greenwich.
|
9 | */
|
10 |
|
11 | import base from './base';
|
12 | import nutation from './nutation';
|
13 |
|
14 | /**
|
15 | * JDToCFrac returns values for use in computing sidereal time at Greenwich.
|
16 | *
|
17 | * Cen is centuries from J2000 of the JD at 0h UT of argument jd. This is
|
18 | * the value to use for evaluating the IAU sidereal time polynomial.
|
19 | * DayFrac is the fraction of jd after 0h UT. It is used to compute the
|
20 | * final value of sidereal time.
|
21 | *
|
22 | * @param {number} jd - Julian Days
|
23 | * @return {number[]} [century, fraction] century and fraction of jd after 0h UT
|
24 | */
|
25 | export function JDToCFrac(jd) {
|
26 | var _base$modf = base.modf(jd + 0.5),
|
27 | j0 = _base$modf[0],
|
28 | f = _base$modf[1];
|
29 |
|
30 | return [base.J2000Century(j0 - 0.5), f]; // (cen, dayFrac /* float */)
|
31 | }
|
32 |
|
33 | /**
|
34 | * iau82 is a polynomial giving mean sidereal time at Greenwich at 0h UT.
|
35 | *
|
36 | * The polynomial is in centuries from J2000.0, as given by JDToCFrac.
|
37 | * Coefficients are those adopted in 1982 by the International Astronomical
|
38 | * Union and are given in (12.2) p. 87.
|
39 | */
|
40 | export var iau82 = [24110.54841, 8640184.812866, 0.093104, 0.0000062];
|
41 |
|
42 | /**
|
43 | * Mean returns mean sidereal time at Greenwich for a given JD.
|
44 | *
|
45 | * Computation is by IAU 1982 coefficients. The result is in seconds of
|
46 | * time and is in the range [0,86400).
|
47 | *
|
48 | * @param {number} jd - Julian Days
|
49 | * @return {number}
|
50 | */
|
51 | export function mean(jd) {
|
52 | return base.pmod(_mean(jd), 86400);
|
53 | }
|
54 |
|
55 | /**
|
56 | * @private
|
57 | */
|
58 | function _mean(jd) {
|
59 | var _mean0UT2 = _mean0UT(jd),
|
60 | s = _mean0UT2[0],
|
61 | f = _mean0UT2[1];
|
62 |
|
63 | return s + f * 1.00273790935 * 86400;
|
64 | }
|
65 |
|
66 | /**
|
67 | * Mean0UT returns mean sidereal time at Greenwich at 0h UT on the given JD.
|
68 | *
|
69 | * The result is in seconds of time and is in the range [0,86400).
|
70 | *
|
71 | * @param {number} jd - Julian Days
|
72 | * @return {number}
|
73 | */
|
74 | export function mean0UT(jd /* float */) {
|
75 | var _mean0UT3 = _mean0UT(jd),
|
76 | s = _mean0UT3[0],
|
77 | _ = _mean0UT3[1]; // eslint-disable-line
|
78 |
|
79 |
|
80 | return base.pmod(s, 86400);
|
81 | }
|
82 |
|
83 | /**
|
84 | * @private
|
85 | */
|
86 | function _mean0UT(jd /* float */) {
|
87 | var _JDToCFrac = JDToCFrac(jd),
|
88 | cen = _JDToCFrac[0],
|
89 | f = _JDToCFrac[1];
|
90 | // (12.2) p. 87
|
91 |
|
92 |
|
93 | return [base.horner.apply(base, [cen].concat(iau82)), f]; // (sidereal, dayFrac /* float */)
|
94 | }
|
95 |
|
96 | /**
|
97 | * Apparent returns apparent sidereal time at Greenwich for the given JD.
|
98 | *
|
99 | * Apparent is mean plus the nutation in right ascension.
|
100 | *
|
101 | * The result is in seconds of time and is in the range [0,86400).
|
102 | *
|
103 | * @param {number} jd - Julian Days
|
104 | * @return {number}
|
105 | */
|
106 | export function apparent(jd) {
|
107 | var s = _mean(jd); // seconds of time
|
108 | var n = nutation.nutationInRA(jd); // angle (radians) of RA
|
109 | var ns = n * 3600 * 180 / Math.PI / 15; // convert RA to time in seconds
|
110 | return base.pmod(s + ns, 86400);
|
111 | }
|
112 |
|
113 | /**
|
114 | * Apparent0UT returns apparent sidereal time at Greenwich at 0h UT
|
115 | * on the given JD.
|
116 | *
|
117 | * The result is in seconds of time and is in the range [0,86400).
|
118 | *
|
119 | * @param {number} jd - Julian Days
|
120 | * @return {number}
|
121 | */
|
122 | export function apparent0UT(jd) {
|
123 | var _base$modf2 = base.modf(jd + 0.5),
|
124 | j0 = _base$modf2[0],
|
125 | f = _base$modf2[1];
|
126 |
|
127 | var cen = (j0 - 0.5 - base.J2000) / 36525;
|
128 | var s = base.horner.apply(base, [cen].concat(iau82)) + f * 1.00273790935 * 86400;
|
129 | var n = nutation.nutationInRA(j0); // angle (radians) of RA
|
130 | var ns = n * 3600 * 180 / Math.PI / 15; // convert RA to time in seconds
|
131 | return base.pmod(s + ns, 86400);
|
132 | }
|
133 |
|
134 | export default {
|
135 | JDToCFrac: JDToCFrac,
|
136 | iau82: iau82,
|
137 | mean: mean,
|
138 | mean0UT: mean0UT,
|
139 | apparent: apparent,
|
140 | apparent0UT: apparent0UT
|
141 | }; |
\ | No newline at end of file |