UNPKG

@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.

82 lines (81 loc) 3.03 kB
var d = Object.defineProperty; var I = (r, i, t) => i in r ? d(r, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[i] = t; var e = (r, i, t) => I(r, typeof i != "symbol" ? i + "" : i, t); import { getCorrectionToEquatorialForAnnualAberration as l } from "./aberration.js"; import { getHourAngle as h } from "./astrometry.js"; import { convertEquatorialToHorizontal as N } from "./coordinates.js"; import { getCorrectionToEquatorialForNutation as T } from "./nutation.js"; import { getCorrectionToEquatorialForPrecessionOfEquinoxes as m } from "./precession.js"; import { g as c, d as E } from "./utilities-BM-rBPno.js"; // @license Copyright © 2021-2023 observerly class V extends Object { constructor({ ra: t = Number.NEGATIVE_INFINITY, dec: o = Number.NEGATIVE_INFINITY }, s) { super(); // The initial target coordinate in epoch J2000 (ICRS) reference frame: e(this, "target", { ra: Number.NEGATIVE_INFINITY, dec: Number.NEGATIVE_INFINITY }); // The Right Ascension in the current epoch: e(this, "ra", Number.NEGATIVE_INFINITY); // The Declination in the current epoch: e(this, "dec", Number.NEGATIVE_INFINITY); e(this, "az", Number.NEGATIVE_INFINITY); e(this, "alt", Number.NEGATIVE_INFINITY); e(this, "ha", Number.NEGATIVE_INFINITY); e(this, "datetime", /* @__PURE__ */ new Date()); e(this, "longitude", Number.NEGATIVE_INFINITY); e(this, "latitude", Number.NEGATIVE_INFINITY); const { datetime: a, longitude: n, latitude: u } = s || { datetime: /* @__PURE__ */ new Date(), longitude: 0, latitude: 0 }; this.setDatetime(a), this.setLongitude(n), this.setLatitude(u), this.target = { ra: t, dec: o }, this.setEquatorialCoordinates({ ra: t, dec: o }), this.setHourAngle(), this.setHorizontalCoordinates(N(a, { longitude: this.longitude, latitude: this.latitude }, { ra: this.ra, dec: this.dec })); } at({ datetime: t }) { t && this.setDatetime(t), this.setEquatorialCoordinates(this.target), this.setHorizontalCoordinates(N(this.datetime, { longitude: this.longitude, latitude: this.latitude }, { ra: this.ra, dec: this.dec })); } setDatetime(t) { this.datetime = new Date(Date.UTC(t.getUTCFullYear(), t.getUTCMonth(), t.getUTCDate(), t.getUTCHours(), t.getUTCMinutes(), t.getUTCSeconds(), t.getUTCMilliseconds())); } setEquatorialCoordinates(t) { const o = l(this.datetime, t), s = T(this.datetime, t), a = m(this.datetime, t), n = t.ra + o.ra + s.ra + a.ra, u = t.dec + o.dec + s.dec + a.dec; this.ra = c(n), this.dec = E(u); } setHourAngle() { this.ha = h(this.datetime, this.longitude, this.ra); } setHorizontalCoordinates(t) { const { az: o, alt: s } = t; this.az = o, this.alt = s; } setLongitude(t) { this.longitude = t; } setLatitude(t) { this.latitude = t; } } export { V as Observation }; //# sourceMappingURL=observation.js.map