UNPKG

2.24 kBJavaScriptView Raw
1/**
2 * @copyright 2013 Sonia Keys
3 * @copyright 2016 commenthol
4 * @license MIT
5 * @module solardisk
6 */
7/**
8 * Solardisk: Chapter 29, Ephemeris for Physical Observations of the Sun.
9 */
10
11import base from './base';
12import nutation from './nutation';
13import solar from './solar';
14
15/**
16 * Ephemeris returns the apparent orientation of the sun at the given jd.
17 *
18 * Results:
19 * P: Position angle of the solar north pole.
20 * B0: Heliographic latitude of the center of the solar disk.
21 * L0: Heliographic longitude of the center of the solar disk.
22 *
23 * All results in radians.
24 */
25export function ephemeris(jd, earth) {
26 // (jd float64, e *pp.V87Planet) (P, B0, L0 float64)
27 var θ = (jd - 2398220) * 2 * Math.PI / 25.38;
28 var I = 7.25 * Math.PI / 180;
29 var K = 73.6667 * Math.PI / 180 + 1.3958333 * Math.PI / 180 * (jd - 2396758) / base.JulianCentury;
30
31 var solarPos = solar.trueVSOP87(earth, jd);
32 var L = solarPos.lon;
33 var R = solarPos.range;
34
35 var _nutation$nutation = nutation.nutation(jd),
36 Δψ = _nutation$nutation[0],
37 Δε = _nutation$nutation[1];
38
39 var ε0 = nutation.meanObliquity(jd);
40 var ε = ε0 + Δε;
41 var λ = L - 20.4898 / 3600 * Math.PI / 180 / R;
42 var λp = λ + Δψ;
43
44 var _base$sincos = base.sincos(λ - K),
45 sλK = _base$sincos[0],
46 cλK = _base$sincos[1];
47
48 var _base$sincos2 = base.sincos(I),
49 sI = _base$sincos2[0],
50 cI = _base$sincos2[1];
51
52 var tx = -Math.cos(λp) * Math.tan(ε);
53 var ty = -cλK * Math.tan(I);
54 var P = Math.atan(tx) + Math.atan(ty);
55 var B0 = Math.asin(sλK * sI);
56 var η = Math.atan2(-sλK * cI, -cλK);
57 var L0 = base.pmod(η - θ, 2 * Math.PI);
58 return [P, B0, L0];
59}
60
61/**
62 * Cycle returns the jd of the start of the given synodic rotation.
63 *
64 * Argument c is the "Carrington" cycle number.
65 *
66 * Result is a dynamical time (not UT).
67 */
68export function cycle(c) {
69 // (c int) (jde float64)
70 var jde = 2398140.227 + 27.2752316 * c;
71 var m = 281.96 * Math.PI / 180 + 26.882476 * Math.PI / 180 * c;
72
73 var _base$sincos3 = base.sincos(2 * m),
74 s2m = _base$sincos3[0],
75 c2m = _base$sincos3[1];
76
77 return jde + 0.1454 * Math.sin(m) - 0.0085 * s2m - 0.0141 * c2m;
78}
79
80export default {
81 ephemeris: ephemeris,
82 cycle: cycle
83};
\No newline at end of file