UNPKG

2.52 kBJavaScriptView Raw
1/**
2 * @copyright 2013 Sonia Keys
3 * @copyright 2016 commenthol
4 * @license MIT
5 * @module eqtime
6 */
7/**
8 * Eqtime: Chapter 28, Equation of time.
9 */
10
11import base from './base';
12import coord from './coord';
13import nutation from './nutation';
14import solar from './solar';
15var cos = Math.cos,
16 sin = Math.sin,
17 tan = Math.tan;
18
19/**
20 * e computes the "equation of time" for the given JDE.
21 *
22 * Parameter planet must be a planetposition.Planet object for Earth obtained
23 * with `new planetposition.Planet('earth')`.
24 *
25 * @param {Number} jde - Julian ephemeris day
26 * @param {planetposition.Planet} earth - VSOP87 planet
27 * @returns {Number} equation of time as an hour angle in radians.
28 */
29
30export function e(jde, earth) {
31 var τ = base.J2000Century(jde) * 0.1;
32 var L0 = l0(τ);
33 // code duplicated from solar.ApparentEquatorialVSOP87 so that
34 // we can keep Δψ and cε
35
36 var _solar$trueVSOP = solar.trueVSOP87(earth, jde),
37 lon = _solar$trueVSOP.lon,
38 lat = _solar$trueVSOP.lat,
39 range = _solar$trueVSOP.range;
40
41 var _nutation$nutation = nutation.nutation(jde),
42 Δψ = _nutation$nutation[0],
43 Δε = _nutation$nutation[1];
44
45 var a = -20.4898 / 3600 * Math.PI / 180 / range;
46 var λ = lon + Δψ + a;
47 var ε = nutation.meanObliquity(jde) + Δε;
48 var eq = new coord.Ecliptic(λ, lat).toEquatorial(ε);
49 // (28.1) p. 183
50 var E = L0 - 0.0057183 * Math.PI / 180 - eq.ra + Δψ * cos(ε);
51 return base.pmod(E + Math.PI, 2 * Math.PI) - Math.PI;
52}
53
54/**
55 * (28.2) p. 183
56 */
57var l0 = function l0(τ) {
58 return base.horner(τ, 280.4664567, 360007.6982779, 0.03032028, 1.0 / 49931, -1.0 / 15300, -1.0 / 2000000) * Math.PI / 180;
59};
60
61/**
62 * eSmart computes the "equation of time" for the given JDE.
63 *
64 * Result is less accurate that e() but the function has the advantage
65 * of not requiring the V87Planet object.
66 *
67 * @param {Number} jde - Julian ephemeris day
68 * @returns {Number} equation of time as an hour angle in radians.
69 */
70export function eSmart(jde) {
71 var ε = nutation.meanObliquity(jde);
72 var t = tan(ε * 0.5);
73 var y = t * t;
74 var T = base.J2000Century(jde);
75 var L0 = l0(T * 0.1);
76 var e = solar.eccentricity(T);
77 var M = solar.meanAnomaly(T);
78
79 var _base$sincos = base.sincos(2 * L0),
80 sin2L0 = _base$sincos[0],
81 cos2L0 = _base$sincos[1];
82
83 var sinM = sin(M);
84 // (28.3) p. 185
85 return y * sin2L0 - 2 * e * sinM + 4 * e * y * sinM * cos2L0 - y * y * sin2L0 * cos2L0 - 1.25 * e * e * sin(2 * M);
86}
87
88export default {
89 e: e,
90 eSmart: eSmart
91};
\No newline at end of file