@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.
139 lines (138 loc) • 3.53 kB
JavaScript
import { getAngularSeparation as S } from "./astrometry.js";
import { convertEclipticToEquatorial as T, convertEquatorialToHorizontal as m } from "./coordinates.js";
import { getPlanetaryGeocentricEclipticCoordinate as j, getPlanetaryPositions as M } from "./planets.js";
// @license Copyright © 2021-2023 observerly
const p = 3, P = (a, s, h, o = {
horizon: 6,
angularSeparationThreshold: p
}) => {
const [t, e] = h, { horizon: r = 6, angularSeparationThreshold: u = p } = o, l = T(a, j(a, t)), n = T(a, j(a, e)), i = m(a, s, l), c = m(a, s, n);
if (i.alt < r || c.alt < r)
return !1;
const f = S({
θ: i.alt,
φ: i.az
}, {
θ: c.alt,
φ: c.az
});
if (f > u)
return !1;
const g = [
{
name: t.name,
...i,
...l
},
{
name: e.name,
...c,
...n
}
];
return {
datetime: a,
targets: g,
angularSeparation: f,
ra: (l.ra + n.ra) / 2,
dec: (l.dec + n.dec) / 2
};
}, y = (a, s, h = {
horizon: 6,
angularSeparationThreshold: p
}) => {
const { horizon: o = 6, angularSeparationThreshold: t = p } = h, [e, r] = s;
if (e.alt < o || r.alt < o)
return !1;
const u = S({
θ: e.alt,
φ: e.az
}, {
θ: r.alt,
φ: r.az
});
return u > t ? !1 : {
datetime: a,
targets: s,
angularSeparation: u,
ra: (e.ra + r.ra) / 2,
dec: (e.dec + r.dec) / 2
};
}, D = (a, s, h, o = {
horizon: 6,
angularSeparationThreshold: 3,
stepMinutes: 20
}) => {
let { from: t, to: e } = a;
const { horizon: r = 6, angularSeparationThreshold: u = p, stepMinutes: l = 20 } = o;
for (; t <= e; ) {
const n = P(t, s, h, {
horizon: r,
angularSeparationThreshold: u
});
if (n)
return n;
t = new Date(t.getTime() + l * 6e4);
}
}, H = (a, s, h = {
horizon: 6,
angularSeparationThreshold: p,
stepMinutes: 20
}) => {
let { from: o, to: t } = a;
const { horizon: e = 6, angularSeparationThreshold: r = p, stepMinutes: u = 20 } = h;
for (; o <= t; ) {
const l = y(o, s, {
horizon: e,
angularSeparationThreshold: r
});
if (l)
return l;
o = new Date(o.getTime() + u * 6e4);
}
return !1;
}, R = (a, s, h = {
horizon: 6,
angularSeparationThreshold: p,
stepMinutes: 20
}) => {
const o = /* @__PURE__ */ new Map();
let { from: t, to: e } = a;
const { horizon: r = 6, angularSeparationThreshold: u = p, stepMinutes: l = 20 } = h;
for (; t <= e; ) {
const n = M(t, s);
for (let i = 0; i < n.length; i++)
for (let c = i + 1; c < n.length; c++) {
if (n[i].alt < r || n[c].alt < r)
continue;
const f = n[i], g = n[c], d = [f.name, g.name].sort().join("-"), z = S({
θ: n[i].alt,
φ: n[i].az
}, {
θ: n[c].alt,
φ: n[c].az
});
if (z <= u && // biome-ignore lint/style/noNonNullAssertion: This is a false positive. The conjunctions map is initialized above.
(!o.has(d) || o.get(d).angularSeparation > z)) {
const w = {
datetime: t,
targets: [f, g],
angularSeparation: z,
ra: (f.ra + g.ra) / 2,
dec: (f.dec + g.dec) / 2
};
o.set(d, w);
}
}
t = new Date(t.getTime() + l * 6e4);
}
return o;
};
export {
H as findConjunction,
D as findPlanetaryConjunction,
R as findPlanetaryConjunctions,
y as isConjunction,
P as isPlanetaryConjunction
};
//# sourceMappingURL=conjunction.js.map