@observerly/astrometry
Version:
observerly's lightweight, zero-dependency, type safe astrometry library written in Typescript for calculating the position of celestial objects in the sky.
88 lines (87 loc) • 6.13 kB
JavaScript
import { convertEquatorialToHorizontal as y } from "./coordinates.js";
import { getCoefficientOfEccentricity as U } from "./earth.js";
import { g as k } from "./epoch-nmyjNjKp.js";
import { getLunarEquatorialCoordinate as x, getLunarTrueEclipticLongitude as z, getLunarCorrectedEclipticLongitudeOfTheAscendingNode as q } from "./moon.js";
import { convertJulianDateToUTC as O } from "./temporal.js";
import { c as t } from "./utilities-BM-rBPno.js";
var M;
(function(o) {
o.Penumbral = "penumbral", o.Partial = "partial", o.Annular = "annular", o.Total = "total", o.AnnularTotal = "annular-total";
})(M || (M = {}));
function Q(o, u) {
const n = (o.getUTCFullYear() + o.getUTCMonth() / 12 + o.getUTCDate() / 365.25 - 2e3) * 12.3685;
return Math.floor(n - u + 0.5) + u;
}
const H = (o, u) => {
const n = (k(o) - 2451545) / 36525, c = Q(o, 0.5), r = 245155009766e-5 + 29.530588861 * c + 15437e-8 * n ** 2 - 15e-8 * n ** 3 + 73e-11 * n ** 4;
let l = (160.7108 + 390.67050284 * c - 16118e-7 * n ** 2 - 227e-8 * n ** 3 + 11e-9 * n ** 4) % 360;
if (l < 0 && (l += 360), Math.abs(Math.sin(t(l))) > 0.36)
return !1;
const T = (124.7746 - 1.56375588 * c + 20672e-7 * n ** 2 + 215e-8 * n ** 3) % 360, h = l - 0.02665 * Math.sin(t(T)), P = 299.77 + 0.107408 * c - 9173e-6 * n ** 2, e = U(o), s = (2.5534 + 29.1053567 * c - 14e-7 * n ** 2 - 11e-8 * n ** 3) % 360, a = (201.5643 + 385.81693528 * c + 0.0107582 * n ** 2 + 1238e-8 * n ** 3 - 58e-9 * n ** 4) % 360, E = -0.4065 * Math.sin(t(a)) + 0.1727 * e * Math.sin(t(s)) + 0.0161 * Math.sin(t(2 * a)) - 97e-4 * Math.sin(t(2 * h)) + 73e-4 * e * Math.sin(t(a - s)) - 5e-3 * e * Math.sin(t(a + s)) - 23e-4 * Math.sin(t(a - 2 * h)) + 21e-4 * e * Math.sin(t(2 * s)) + 12e-4 * Math.sin(t(a + 2 * h)) + 6e-4 * e * Math.sin(t(2 * a + s)) - 4e-4 * Math.sin(t(3 * a)) - 3e-4 * e * Math.sin(t(s + 2 * h)) + 3e-4 * Math.sin(t(P)) - 2e-4 * e * Math.sin(t(s - 2 * h)) - 2e-4 * e * Math.sin(t(2 * a - s)) - 2e-4 * Math.sin(t(T)), p = O(r + E), L = Math.abs(Math.cos(t(h))), v = 0.207 * e * Math.sin(t(s)) + 24e-4 * e * Math.sin(t(2 * s)) - 0.0392 * Math.sin(t(a)) + 0.0116 * Math.sin(t(2 * a)) - 73e-4 * e * Math.sin(t(a + s)) + 67e-4 * e * Math.sin(t(a - s)) + 0.0118 * Math.sin(t(2 * h)), F = 5.2207 - 48e-4 * e * Math.cos(t(s)) + 2e-3 * e * Math.cos(t(2 * s)) - 0.3299 * Math.cos(t(a)) - 6e-3 * e * Math.cos(t(a + s)) - 41e-4 * e * Math.cos(t(a - s)), i = 59e-4 + 46e-4 * e * Math.cos(t(s)) - 0.0182 * Math.cos(t(a)) + 4e-4 * Math.cos(t(2 * a)) - 5e-4 * Math.cos(t(s + a)), f = (v * Math.cos(t(h)) + F * Math.sin(t(h))) * (1 - 48e-4 * L), b = Math.abs(f) < 0.9972, D = 1.2848 + i, J = 0.7403 - i;
let g = (1.0128 - i - Math.abs(f)) / 0.545, A = M.Penumbral;
if (g > 1 && (A = M.Total), g > 0 && g < 1 && (A = M.Partial), g < 0 && (g = (1.5573 + i - Math.abs(f)) / 0.545, g < 0))
return !1;
const { ra: C, dec: d } = x(p), { alt: S, az: W } = y(p, u, { ra: C, dec: d });
return {
k: c,
JD: r + E,
type: A,
isCentral: b,
maximum: p,
magnitude: g,
alt: S,
az: W,
ra: C,
dec: d,
F: l,
Ω: T,
γ: f,
u: i,
ρ: D,
σ: J
};
}, N = (o, u) => {
const n = (k(o) - 2451545) / 36525, c = Q(o, 0), r = 245155009766e-5 + 29.530588861 * c + 15437e-8 * n ** 2 - 15e-8 * n ** 3 + 73e-11 * n ** 4;
let l = (160.7108 + 390.67050284 * c - 16118e-7 * n ** 2 - 227e-8 * n ** 3 + 11e-9 * n ** 4) % 360;
if (l < 0 && (l += 360), Math.abs(Math.sin(t(l))) > 0.36)
return !1;
const T = (124.7746 - 1.56375588 * c + 20672e-7 * n ** 2 + 215e-8 * n ** 3) % 360, h = l - 0.02665 * Math.sin(t(T)), P = 299.77 + 0.107408 * c - 9173e-6 * n ** 2, e = U(o), s = (2.5534 + 29.1053567 * c - 14e-7 * n ** 2 - 11e-8 * n ** 3) % 360, a = (201.5643 + 385.81693528 * c + 0.0107582 * n ** 2 + 1238e-8 * n ** 3 - 58e-9 * n ** 4) % 360, E = -0.4075 * Math.sin(t(a)) + 0.1721 * e * Math.sin(t(s)) + 0.0161 * Math.sin(t(2 * a)) - 97e-4 * Math.sin(t(2 * h)) + 73e-4 * e * Math.sin(t(a - s)) - 5e-3 * e * Math.sin(t(a + s)) - 23e-4 * Math.sin(t(a - 2 * h)) + 21e-4 * e * Math.sin(t(2 * s)) + 12e-4 * Math.sin(t(a + 2 * h)) + 6e-4 * e * Math.sin(t(2 * a + s)) - 4e-4 * Math.sin(t(3 * a)) - 3e-4 * e * Math.sin(t(s + 2 * h)) + 3e-4 * Math.sin(t(P)) - 2e-4 * e * Math.sin(t(s - 2 * h)) - 2e-4 * e * Math.sin(t(2 * a - s)) - 2e-4 * Math.sin(t(T)), p = O(r + E), L = Math.abs(Math.cos(t(h))), v = 0.207 * e * Math.sin(t(s)) + 24e-4 * e * Math.sin(t(2 * s)) - 0.0392 * Math.sin(t(a)) + 0.0116 * Math.sin(t(2 * a)) - 73e-4 * e * Math.sin(t(a + s)) + 67e-4 * e * Math.sin(t(a - s)) + 0.0118 * Math.sin(t(2 * h)), F = 5.2207 - 48e-4 * e * Math.cos(t(s)) + 2e-3 * e * Math.cos(t(2 * s)) - 0.3299 * Math.cos(t(a)) - 6e-3 * e * Math.cos(t(a + s)) - 41e-4 * e * Math.cos(t(a - s)), i = 59e-4 + 46e-4 * e * Math.cos(t(s)) - 0.0182 * Math.cos(t(a)) + 4e-4 * Math.cos(t(2 * a)) - 5e-4 * Math.cos(t(s + a)), f = (v * Math.cos(t(h)) + F * Math.sin(t(h))) * (1 - 48e-4 * L);
if (Math.abs(f) > 1.5433 + i)
return !1;
let b = M.Total;
const D = Math.abs(f) < 0.9972;
D || (b = M.Partial), D && i > 47e-4 && (b = M.Annular), D && i > 0 && i < 47e-4 && (b = i < 464e-5 * Math.sqrt(1 - f ** 2) ? M.AnnularTotal : M.Annular);
let J;
b === M.Partial && (J = (1.5433 + i - Math.abs(f)) / (0.5461 + 2 * i)), (b === M.Total || b === M.Annular || b === M.AnnularTotal) && (J = 1 - i / (0.27305 + i));
const { ra: g, dec: A } = x(p), { alt: C, az: d } = y(p, u, { ra: g, dec: A });
return C < 0 ? !1 : {
k: c,
JD: r + E,
type: b,
isCentral: D,
maximum: p,
magnitude: J,
alt: C,
az: d,
ra: g,
dec: A,
F: l,
Ω: T,
γ: f,
u: i
};
}, I = (o, u) => {
const n = z(o), c = q(o), r = n - c;
return Math.abs(r) % 360 > 18.25 && Math.abs(r - 180) % 360 > 18.25 ? !1 : H(o, u);
}, K = (o, u) => {
const m = 18.5166666666667, n = z(o), c = q(o), r = n - c;
return Math.abs(r % 360) > m && Math.abs(r - 180) % 360 > m ? !1 : N(o, u);
};
export {
M as EclipseType,
H as getLunarEclipse,
N as getSolarEclipse,
I as isLunarEclipse,
K as isSolarEclipse
};
//# sourceMappingURL=eclipse.js.map