@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.
195 lines (194 loc) • 8.1 kB
JavaScript
import { getObliquityOfTheEcliptic as v, getHourAngle as Q } from "./astrometry.js";
import { AU_IN_METERS as q } from "./constants.js";
import { earth as R } from "./earth.js";
import { g as l } from "./epoch-nmyjNjKp.js";
import { getFOrbitalParameter as p } from "./orbit.js";
import { getSolarMeanAnomaly as g, getSolarEclipticLongitude as h } from "./sun.js";
import { c as s, e as M } from "./utilities-BM-rBPno.js";
// @license Copyright © 2021-2023 observerly
const U = 2.4234366115277777e6, E = 29.530588853, un = /* @__PURE__ */ new Map([
["January", /* @__PURE__ */ new Set(["Wolf Moon", "Spirit Moon"])],
["February", /* @__PURE__ */ new Set(["Snow Moon", "Bear Moon"])],
["March", /* @__PURE__ */ new Set(["Worm Moon", "Snow Crust Moon"])],
["April", /* @__PURE__ */ new Set(["Pink Moon", "Broken Snowshoe Moon"])],
["May", /* @__PURE__ */ new Set(["Flower Moon", "Sucker Moon"])],
["June", /* @__PURE__ */ new Set(["Strawberry Moon", "Blooming Moon"])],
["July", /* @__PURE__ */ new Set(["Buck Moon", "Berry Moon"])],
["August", /* @__PURE__ */ new Set(["Sturgeon Moon", "Grain Moon"])],
["September", /* @__PURE__ */ new Set(["Corn Moon", "Changing Leaves Moon"])],
["October", /* @__PURE__ */ new Set(["Hunter's Moon", "Falling Leaves Moon"])],
["November", /* @__PURE__ */ new Set(["Beaver Moon", "Freezing Moon"])],
["December", /* @__PURE__ */ new Set(["Cold Moon", "Little Spirit Moon"])]
]), u = {
New: "New",
WaxingCrescent: "Waxing Crescent",
FirstQuarter: "First Quarter",
WaxingGibbous: "Waxing Gibbous",
Full: "Full",
WaningGibbous: "Waning Gibbous",
LastQuarter: "Last Quarter",
WaningCrescent: "Waning Crescent",
Invalid: "Invalid"
}, F = (t) => {
const n = s(g(t));
return 0.1858 * Math.sin(n);
}, w = (t) => {
const o = (l(t) - 2451545) / 36525;
let e = (134.9634114 + 477198.8676313 * o + 8997e-6 * o ** 2 + o ** 3 / 69699 - o ** 4 / 14712e3) % 360;
return e < 0 && (e += 360), e;
}, Mn = (t) => {
const o = (l(t) - 2451545) / 36525;
let e = (218.3164477 + 481267.88123421 * o - 15786e-7 * o ** 2 + o ** 3 / 538841 - o ** 4 / 65194e3) % 360;
return e < 0 && (e += 360), e;
}, ln = (t) => {
const o = (l(t) - 2451545) / 36525;
let r = (160.7108 + 390.67050284 * Math.round(o * 1236.85) - 16118e-7 * o ** 2 - 227e-8 * o ** 3 - 11e-9 * o ** 4) % 360;
return r < 0 && (r += 360), r;
}, b = (t) => {
let e = (13.176339686 * (l(t) - 2451545) + 218.31643388) % 360;
return e < 0 && (e += 360), e;
}, C = (t) => {
const n = s(w(t)), o = s(b(t)), e = s(h(t));
return 1.2739 * Math.sin(2 * (o - e) - n);
}, Y = (t) => {
let o = (125.044522 - 0.0529539 * (l(t) - 2451545)) % 360;
o < 0 && (o += 360);
const e = s(g(t));
return o - 0.16 * Math.sin(e);
}, V = (t) => {
const n = F(t), o = C(t), e = w(t), r = s(g(t));
let c = (e + o - n - 0.37 * Math.sin(r)) % 360;
return c < 0 && (c += 360), c;
}, D = (t) => {
const n = V(t);
let o = 6.2886 * Math.sin(s(n)) + 0.214 * Math.sin(s(2 * n)) % 360;
return o < 0 && (o += 360), o;
}, L = (t) => {
let n = b(t);
const o = F(t), e = C(t), r = D(t);
n = (n + e + r - o) % 360, n < 0 && (n += 360);
const c = h(t), a = 0.6583 * Math.sin(2 * s(n - c));
let i = (n + a) % 360;
return i < 0 && (i += 360), i;
}, S = (t) => {
const n = Y(t), o = g(t);
return n - 0.16 * Math.sin(s(o));
}, gn = (t) => {
const n = L(t), o = S(t), e = s(5.1453964);
let r = (o + M(Math.atan2(Math.sin(s(n - o)) * Math.cos(e), Math.cos(s(n - o))))) % 360;
return r < 0 && (r += 360), r;
}, hn = (t) => {
const n = L(t), o = S(t), e = s(5.1453964);
return M(Math.asin(Math.sin(s(n - o)) * Math.sin(e)));
}, I = (t) => {
const n = L(t), o = S(t), e = s(5.1453964);
let r = (o + M(Math.atan2(Math.sin(s(n - o)) * Math.cos(e), Math.cos(s(n - o))))) % 360;
r < 0 && (r += 360);
const c = M(Math.asin(Math.sin(s(n - o)) * Math.sin(e)));
return { λ: r, β: c };
}, z = (t) => {
const { λ: n, β: o } = I(t), e = s(v(t)), r = M(Math.atan2(Math.sin(s(n)) * Math.cos(e) - Math.tan(s(o)) * Math.sin(e), Math.cos(s(n)))), c = M(Math.asin(Math.sin(s(o)) * Math.cos(e) + Math.cos(s(o)) * Math.sin(e) * Math.sin(s(n))));
return {
ra: r,
dec: c
};
}, j = (t) => {
const { λ: n, β: o } = I(t), e = h(t);
let r = M(Math.acos(Math.cos(s(n - e)) * Math.cos(s(o)))) % 360;
return r < 0 && (r += 360), r;
}, Ln = (t, n) => {
if (!n) {
const H = D(t);
return 0.5181 * p(H, 0.0549);
}
const o = 2 * 0.272481, e = K(t) / q, { ra: r, dec: c } = z(t), a = Q(t, n.longitude, r), i = 8.794 / e, f = Math.sin(s(i / 3600)), N = R.r, { sin: d, cos: T } = { sin: Math.sin(s(c)), cos: Math.cos(s(c)) }, { sin: y, cos: O } = { sin: Math.sin(s(a)), cos: Math.cos(s(a)) }, m = Math.atan(0.99664719 * Math.tan(s(n.latitude))), x = 0.99664719 * Math.sin(m) + n.elevation * Math.sin(s(n.latitude)) / N, B = Math.cos(m) + n.elevation * Math.cos(s(n.latitude)) / N, k = T * y, G = T * O - B * f, P = d - x * f, _ = Math.sqrt(k ** 2 + G ** 2 + P ** 2);
return M(o / _ * f);
}, K = (t) => {
const n = D(t);
return 3844e5 / p(n, 0.0549);
}, X = (t) => {
const n = L(t), o = h(t);
let e = (n - o) % 360;
e < 0 && (e += 360);
const r = e * (29.5306 / 360);
return {
A: e,
age: r
};
}, Z = (t) => {
const n = s(w(t)), o = j(t);
return 180 - o - 0.1468 * ((1 - 0.0549 * Math.sin(n)) / (1 - 0.0167 * Math.sin(n))) * Math.sin(s(o));
}, A = (t) => {
const n = Z(t);
return 50 * (1 + Math.cos(s(n)));
}, J = (t) => {
const { age: n } = X(t), o = A(t);
return n < 5.53699 ? u.WaxingCrescent : n < 9.22831 ? u.FirstQuarter : n < 14.71963 ? u.WaxingGibbous : n < 15.02096 && Math.abs(o - 100) < 1 ? u.Full : n < 20.30228 ? u.WaningGibbous : n < 23.99361 ? u.LastQuarter : n < 29.08493 ? u.WaningCrescent : u.New;
}, fn = (t) => {
const n = l(t);
return Math.round((n - U) / E) + 1;
}, $ = (t) => J(t) === "New", wn = (t) => {
let n = new Date(new Date(t).setHours(0, 0, 0, 0));
for (; !$(n); )
n = new Date(n.getTime() + 60 * 60 * 1e3);
let o = n.getTime() - 12 * 60 * 60 * 1e3;
const e = n.getTime() + 12 * 60 * 60 * 1e3;
let r = Number.POSITIVE_INFINITY, c = n, a = 0;
for (; o <= e; ) {
const i = A(new Date(o));
if (i < r ? (r = i, c = new Date(o), a = 0) : a++, o += 1e4, a > 100)
break;
}
return c;
}, W = (t) => J(t) === "Full", Dn = (t) => {
let n = new Date(new Date(t).setHours(0, 0, 0, 0));
for (; !W(n); )
n = new Date(n.getTime() + 60 * 60 * 1e3);
let o = n.getTime() - 12 * 60 * 60 * 1e3;
const e = n.getTime() + 12 * 60 * 60 * 1e3;
let r = Number.NEGATIVE_INFINITY, c = n, a = 0;
for (; o <= e; ) {
const i = A(new Date(o));
if (i > r ? (r = i, c = new Date(o), a = 0) : a++, o += 1e4, a > 100)
break;
}
return c;
}, Sn = (t) => {
const n = t.getDate(), o = (E - 29) * 24 * 60 * 60 * 1e3, e = t.getHours() * 60 * 60 * 1e3 + t.getMinutes() * 60 * 1e3 + t.getSeconds() * 1e3 + t.getMilliseconds();
return n !== 29 && n !== 30 && n !== 31 || n === 29 && e < o ? !1 : W(t);
};
export {
E as LUNAR_SYNODIC_MONTH,
U as LUNATION_BASE_JULIAN_DAY,
u as Phases,
X as getLunarAge,
Ln as getLunarAngularDiameter,
F as getLunarAnnualEquationCorrection,
ln as getLunarArgumentOfLatitude,
fn as getLunarBrownLunationNumber,
S as getLunarCorrectedEclipticLongitudeOfTheAscendingNode,
K as getLunarDistance,
I as getLunarEclipticCoordinate,
hn as getLunarEclipticLatitude,
gn as getLunarEclipticLongitude,
j as getLunarElongation,
z as getLunarEquatorialCoordinate,
C as getLunarEvectionCorrection,
A as getLunarIllumination,
w as getLunarMeanAnomaly,
V as getLunarMeanAnomalyCorrection,
b as getLunarMeanEclipticLongitude,
Y as getLunarMeanEclipticLongitudeOfTheAscendingNode,
Mn as getLunarMeanGeometricLongitude,
J as getLunarPhase,
Z as getLunarPhaseAngle,
D as getLunarTrueAnomaly,
L as getLunarTrueEclipticLongitude,
Dn as getNextFullMoon,
wn as getNextNewMoon,
Sn as isBlueMoon,
W as isFullMoon,
$ as isNewMoon,
un as names
};
//# sourceMappingURL=moon.js.map