UNPKG

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