UNPKG

16.5 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6
7var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); /**
8 * @copyright 2013 Sonia Keys
9 * @copyright 2016 commenthol
10 * @license MIT
11 * @module planetary
12 */
13/**
14 * Planetary: Chapter 36, The Calculation of some Planetary Phenomena.
15 *
16 * Incomplete: Some functions unimplemented for lack of test data.
17 */
18
19exports.mean = mean;
20exports.sum = sum;
21exports.ms = ms;
22exports.mercuryInfConj = mercuryInfConj;
23exports.mercurySupConj = mercurySupConj;
24exports.venusInfConj = venusInfConj;
25exports.marsOpp = marsOpp;
26exports.sumA = sumA;
27exports.msa = msa;
28exports.jupiterOpp = jupiterOpp;
29exports.saturnOpp = saturnOpp;
30exports.saturnConj = saturnConj;
31exports.uranusOpp = uranusOpp;
32exports.neptuneOpp = neptuneOpp;
33exports.el = el;
34exports.mercuryEastElongation = mercuryEastElongation;
35exports.mercuryWestElongation = mercuryWestElongation;
36exports.marsStation2 = marsStation2;
37
38var _base = require('./base');
39
40var _base2 = _interopRequireDefault(_base);
41
42function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
43
44/**
45 * Mean computes some intermediate values for a mean planetary configuration
46 * given a year and a row of coefficients from Table 36.A, p. 250.0
47 */
48function mean(y, a) {
49 // (y float64, a *ca) (J, M, T float64)
50 // (36.1) p. 250
51 var k = Math.floor((365.2425 * y + 1721060 - a.A) / a.B + 0.5);
52 var J = a.A + k * a.B;
53 var M = _base2.default.pmod(a.M0 + k * a.M1, 360) * Math.PI / 180;
54 var T = _base2.default.J2000Century(J);
55 return [J, M, T];
56}
57
58/**
59 * Sum computes a sum of periodic terms.
60 */
61function sum(T, M, c) {
62 // (T, M float64, c [][]float64) float64
63 var j = _base2.default.horner(T, c[0]);
64 var mm = 0.0;
65 for (var i = 1; i < c.length; i++) {
66 mm += M;
67
68 var _base$sincos = _base2.default.sincos(mm),
69 _base$sincos2 = _slicedToArray(_base$sincos, 2),
70 smm = _base$sincos2[0],
71 cmm = _base$sincos2[1];
72
73 j += smm * _base2.default.horner(T, c[i]);
74 i++;
75 j += cmm * _base2.default.horner(T, c[i]);
76 }
77 return j;
78}
79
80/**
81 * ms returns a mean time corrected by a sum.
82 */
83function ms(y, a, c) {
84 // (y float64, a *ca, c [][]float64) float64
85 var _mean = mean(y, a),
86 _mean2 = _slicedToArray(_mean, 3),
87 J = _mean2[0],
88 M = _mean2[1],
89 T = _mean2[2];
90
91 return J + sum(T, M, c);
92}
93
94/**
95 * MercuryInfConj returns the time of an inferior conjunction of Mercury.
96 *
97 * Result is time (as a jde) of the event nearest the given time (as a
98 * decimal year.)
99 */
100function mercuryInfConj(y) {
101 // (y float64) (jde float64)
102 return ms(y, micA, micB);
103}
104
105/**
106 * MercurySupConj returns the time of a superior conjunction of Mercury.
107 *
108 * Result is time (as a jde) of the event nearest the given time (as a
109 * decimal year.)
110 */
111function mercurySupConj(y) {
112 // (y float64) (jde float64)
113 return ms(y, mscA, mscB);
114}
115
116/**
117 * VenusInfConj returns the time of an inferior conjunction of Venus.
118 *
119 * Result is time (as a jde) of the event nearest the given time (as a
120 * decimal year.)
121 */
122function venusInfConj(y) {
123 // (y float64) (jde float64)
124 return ms(y, vicA, vicB);
125}
126
127/**
128 * MarsOpp returns the time of an opposition of Mars.
129 *
130 * Result is time (as a jde) of the event nearest the given time (as a
131 * decimal year.)
132 */
133function marsOpp(y) {
134 // (y float64) (jde float64)
135 return ms(y, moA, moB);
136}
137
138/**
139 * SumA computes the sum of periodic terms with "additional angles"
140 */
141function sumA(T, M, c, aa) {
142 // (T, M float64, c [][]float64, aa []caa) float64
143 var i = c.length - 2 * aa.length;
144 var j = sum(T, M, c.slice(0, i));
145 for (var k = 0; k < aa.length; k++) {
146 var _base$sincos3 = _base2.default.sincos((aa[k].c + aa[k].f * T) * Math.PI / 180),
147 _base$sincos4 = _slicedToArray(_base$sincos3, 2),
148 _saa = _base$sincos4[0],
149 caa = _base$sincos4[1];
150
151 j += _saa * _base2.default.horner(T, c[i]);
152 i++;
153 j += caa * _base2.default.horner(T, c[i]);
154 i++;
155 }
156 return j;
157}
158
159/**
160 * Msa returns a mean time corrected by a sum.
161 */
162function msa(y, a, c, aa) {
163 // (y float64, a *ca, c [][]float64, aa []caa) float64
164 var _mean3 = mean(y, a),
165 _mean4 = _slicedToArray(_mean3, 3),
166 J = _mean4[0],
167 M = _mean4[1],
168 T = _mean4[2];
169
170 return J + sumA(T, M, c, aa);
171}
172
173/**
174 * JupiterOpp returns the time of an opposition of Jupiter.
175 *
176 * Result is time (as a jde) of the event nearest the given time (as a
177 * decimal year.)
178 */
179function jupiterOpp(y) {
180 // (y float64) (jde float64)
181 return msa(y, joA, joB, jaa);
182}
183
184/**
185 * SaturnOpp returns the time of an opposition of Saturn.
186 *
187 * Result is time (as a jde) of the event nearest the given time (as a
188 * decimal year.)
189 */
190function saturnOpp(y) {
191 // (y float64) (jde float64)
192 return msa(y, soA, soB, saa);
193}
194
195/**
196 * SaturnConj returns the time of a conjunction of Saturn.
197 *
198 * Result is time (as a jde) of the event nearest the given time (as a
199 * decimal year.)
200 */
201function saturnConj(y) {
202 // (y float64) (jde float64)
203 return msa(y, scA, scB, saa);
204}
205
206/**
207 * UranusOpp returns the time of an opposition of Uranus.
208 *
209 * Result is time (as a jde) of the event nearest the given time (as a
210 * decimal year.)
211 */
212function uranusOpp(y) {
213 // (y float64) (jde float64)
214 return msa(y, uoA, uoB, uaa);
215}
216
217/**
218 * NeptuneOpp returns the time of an opposition of Neptune.
219 *
220 * Result is time (as a jde) of the event nearest the given time (as a
221 * decimal year.)
222 */
223function neptuneOpp(y) {
224 // (y float64) (jde float64)
225 return msa(y, noA, noB, naa);
226}
227
228/**
229 * El computes time and elongation of a greatest elongation event.
230 */
231function el(y, a, t, e) {
232 // (y float64, a *ca, t, e [][]float64) (jde, elongation float64)
233 var _mean5 = mean(y, micA),
234 _mean6 = _slicedToArray(_mean5, 3),
235 J = _mean6[0],
236 M = _mean6[1],
237 T = _mean6[2];
238
239 return [J + sum(T, M, t), sum(T, M, e) * Math.PI / 180];
240}
241
242/**
243 * MercuryEastElongation returns the time and elongation of a greatest eastern elongation of Mercury.
244 *
245 * Result is time (as a jde) of the event nearest the given time (as a
246 * decimal year.)
247 */
248function mercuryEastElongation(y) {
249 // (y float64) (jde, elongation float64)
250 return el(y, micA, met, mee);
251}
252
253/**
254 * MercuryWestElongation returns the time and elongation of a greatest western elongation of Mercury.
255 *
256 * Result is time (as a jde) of the event nearest the given time (as a
257 * decimal year.)
258 */
259function mercuryWestElongation(y) {
260 // (y float64) (jde, elongation float64)
261 return el(y, micA, mwt, mwe);
262}
263
264function marsStation2(y) {
265 // (y float64) (jde float64)
266 var _mean7 = mean(y, moA),
267 _mean8 = _slicedToArray(_mean7, 3),
268 J = _mean8[0],
269 M = _mean8[1],
270 T = _mean8[2];
271
272 return J + sum(T, M, ms2);
273}
274
275/**
276 * ca holds coefficients from one line of table 36.A, p. 250
277 */
278function Ca(A, B, M0, M1) {
279 this.A = A;
280 this.B = B;
281 this.M0 = M0;
282 this.M1 = M1;
283}
284
285/**
286 * Table 36.A, p. 250
287 */
288var micA = new Ca(2451612.023, 115.8774771, 63.5867, 114.2088742);
289var mscA = new Ca(2451554.084, 115.8774771, 6.4822, 114.2088742);
290var vicA = new Ca(2451996.706, 583.921361, 82.7311, 215.513058);
291var moA = new Ca(2452097.382, 779.936104, 181.9573, 48.705244);
292var joA = new Ca(2451870.628, 398.884046, 318.4681, 33.140229);
293var soA = new Ca(2451870.17, 378.091904, 318.0172, 12.647487);
294var scA = new Ca(2451681.124, 378.091904, 131.6934, 12.647487);
295var uoA = new Ca(2451764.317, 369.656035, 213.6884, 4.333093);
296var noA = new Ca(2451753.122, 367.486703, 202.6544, 2.194998);
297
298/**
299 * caa holds coefficients for "additional angles" for outer planets
300 * as given on p. 251
301 */
302function Caa(c, f) {
303 this.c = c;
304 this.f = f;
305}
306
307var jaa = [new Caa(82.74, 40.76)];
308
309var saa = [new Caa(82.74, 40.76), new Caa(29.86, 1181.36), new Caa(14.13, 590.68), new Caa(220.02, 1262.87)];
310
311var uaa = [new Caa(207.83, 8.51), new Caa(108.84, 419.96)];
312
313var naa = [new Caa(207.83, 8.51), new Caa(276.74, 209.98)];
314
315/**
316 * Table 33.B, p. 256
317 */
318
319/**
320 * Mercury inferior conjunction
321 */
322var micB = [[0.0545, 0.0002], [-6.2008, 0.0074, 0.00003], [-3.275, -0.0197, 0.00001], [0.4737, -0.0052, -0.00001], [0.8111, 0.0033, -0.00002], [0.0037, 0.0018], [-0.1768, 0, 0.00001], [-0.0211, -0.0004], [0.0326, -0.0003], [0.0083, 0.0001], [-0.004, 0.0001]];
323
324/**
325 * Mercury superior conjunction
326 */
327var mscB = [[-0.0548, -0.0002], [7.3894, -0.01, -0.00003], [3.22, 0.0197, -0.00001], [0.8383, -0.0064, -0.00001], [0.9666, 0.0039, -0.00003], [0.077, -0.0026], [0.2758, 0.0002, -0.00002], [-0.0128, -0.0008], [0.0734, -0.0004, -0.00001], [-0.0122, -0.0002], [0.0173, -0.0002]];
328
329/**
330 * Venus inferior conjunction
331 */
332var vicB = [[-0.0096, 0.0002, -0.00001], [2.0009, -0.0033, -0.00001], [0.598, -0.0104, 0.00001], [0.0967, -0.0018, -0.00003], [0.0913, 0.0009, -0.00002], [0.0046, -0.0002], [0.0079, 0.0001]];
333
334/**
335 * Mars opposition
336 */
337var moB = [[-0.3088, 0, 0.00002], [-17.6965, 0.0363, 0.00005], [18.3131, 0.0467, -0.00006], [-0.2162, -0.0198, -0.00001], [-4.5028, -0.0019, 0.00007], [0.8987, 0.0058, -0.00002], [0.7666, -0.005, -0.00003], [-0.3636, -0.0001, 0.00002], [0.0402, 0.0032], [0.0737, -0.0008], [-0.098, -0.0011]];
338
339/**
340 * Jupiter opposition
341 */
342var joB = [[-0.1029, 0, -0.00009], [-1.9658, -0.0056, 0.00007], [6.1537, 0.021, -0.00006], [-0.2081, -0.0013], [-0.1116, -0.001], [0.0074, 0.0001], [-0.0097, -0.0001], [0, 0.0144, -0.00008], [0.3642, -0.0019, -0.00029]];
343
344/**
345 * Saturn opposition
346 */
347var soB = [[-0.0209, 0.0006, 0.00023], [4.5795, -0.0312, -0.00017], [1.1462, -0.0351, 0.00011], [0.0985, -0.0015], [0.0733, -0.0031, 0.00001], [0.0025, -0.0001], [0.005, -0.0002], [0, -0.0337, 0.00018], [-0.851, 0.0044, 0.00068], [0, -0.0064, 0.00004], [0.2397, -0.0012, -0.00008], [0, -0.001], [0.1245, 0.0006], [0, 0.0024, -0.00003], [0.0477, -0.0005, -0.00006]];
348
349/**
350 * Saturn conjunction
351 */
352var scB = [[0.0172, -0.0006, 0.00023], [-8.5885, 0.0411, 0.00020], [-1.147, 0.0352, -0.00011], [0.3331, -0.0034, -0.00001], [0.1145, -0.0045, 0.00002], [-0.0169, 0.0002], [-0.0109, 0.0004], [0, -0.0337, 0.00018], [-0.851, 0.0044, 0.00068], [0, -0.0064, 0.00004], [0.2397, -0.0012, -0.00008], [0, -0.001], [0.1245, 0.0006], [0, 0.0024, -0.00003], [0.0477, -0.0005, -0.00006]];
353
354/**
355 * Uranus opposition
356 */
357var uoB = [[0.0844, -0.0006], [-0.1048, 0.0246], [-5.1221, 0.0104, 0.00003], [-0.1428, 0.0005], [-0.0148, -0.0013], [0], [0.0055], [0], [0.885], [0], [0.2153]];
358
359/**
360 * Neptune opposition [
361 */
362var noB = [[-0.014, 0, 0.00001], [-1.3486, 0.001, 0.00001], [0.8597, 0.0037], [-0.0082, -0.0002, 0.00001], [0.0037, -0.0003], [0], [-0.5964], [0], [0.0728]];
363
364/**
365 * Table 36.C, p. 259
366 */
367
368/**
369 * Mercury east time correction
370 */
371var met = [[-21.6106, 0.0002], [-1.9803, -0.006, 0.00001], [1.4151, -0.0072, -0.00001], [0.5528, -0.0005, -0.00001], [0.2905, 0.0034, 0.00001], [-0.1121, -0.0001, 0.00001], [-0.0098, -0.0015], [0.0192], [0.0111, 0.0004], [-0.0061], [-0.0032, -0.0001]];
372
373/**
374 * Mercury east elongation
375 */
376var mee = [[22.4697], [-4.2666, 0.0054, 0.00002], [-1.8537, -0.0137], [0.3598, 0.0008, -0.00001], [-0.068, 0.0026], [-0.0524, -0.0003], [0.0052, -0.0006], [0.0107, 0.0001], [-0.0013, 0.0001], [-0.0021], [0.0003]];
377
378/**
379 * Mercury west time correction
380 */
381var mwt = [[21.6249, -0.0002], [0.1306, 0.0065], [-2.7661, -0.0011, 0.00001], [0.2438, -0.0024, -0.00001], [0.5767, 0.0023], [0.1041], [-0.0184, 0.0007], [-0.0051, -0.0001], [0.0048, 0.0001], [0.0026], [0.0037]];
382
383/**
384 * Mercury west elongation
385 */
386var mwe = [[22.4143, -0.0001], [4.3651, -0.0048, -0.00002], [2.3787, 0.0121, -0.00001], [0.2674, 0.0022], [-0.3873, 0.0008, 0.00001], [-0.0369, -0.0001], [0.0017, -0.0001], [0.0059], [0.0061, 0.0001], [0.0007], [-0.0011]];
387
388/**
389 * Table 36.D, p. 261
390 */
391
392/**
393 * Mars Station 2
394 */
395var ms2 = [[36.7191, 0.0016, 0.00003], [-12.6163, 0.0417, -0.00001], [20.1218, 0.0379, -0.00006], [-1.636, -0.019], [-3.9657, 0.0045, 0.00007], [1.1546, 0.0029, -0.00003], [0.2888, -0.0073, -0.00002], [-0.3128, 0.0017, 0.00002], [0.2513, 0.0026, -0.00002], [-0.0021, -0.0016], [-0.1497, -0.0006]];
396
397exports.default = {
398 mean: mean,
399 sum: sum,
400 ms: ms,
401 mercuryInfConj: mercuryInfConj,
402 mercurySupConj: mercurySupConj,
403 venusInfConj: venusInfConj,
404 marsOpp: marsOpp,
405 sumA: sumA,
406 msa: msa,
407 jupiterOpp: jupiterOpp,
408 saturnOpp: saturnOpp,
409 saturnConj: saturnConj,
410 uranusOpp: uranusOpp,
411 neptuneOpp: neptuneOpp,
412 el: el,
413 mercuryEastElongation: mercuryEastElongation,
414 mercuryWestElongation: mercuryWestElongation,
415 marsStation2: marsStation2
416};
\No newline at end of file