UNPKG

astronomy-bundle

Version:

Bundle for astronomical calculations such as position of moon, sun and planets, sunrise, sunset or solar eclipses. Most of the calculations are based on Jean Meeus 'Astronomical Algorithms' book and the VSOP87 theory.

249 lines (248 loc) 12.9 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const AstronomicalObject_1 = __importDefault(require("../astronomicalObject/AstronomicalObject")); const standardAltitude_1 = require("../constants/standardAltitude"); const apparentCoordinateCalc_1 = require("../coordinates/calculations/apparentCoordinateCalc"); const coordinateCalc_1 = require("../coordinates/calculations/coordinateCalc"); const createEarth_1 = __importDefault(require("../earth/createEarth")); const createSun_1 = __importDefault(require("../sun/createSun")); const time_1 = require("../time"); const utils_1 = require("../utils"); const riseSetTransitCalc_1 = require("../utils/riseSetTransitCalc"); const calculations_1 = require("./calculations"); const librationCalc_1 = require("./calculations/librationCalc"); const magnitudeCalc_1 = require("./calculations/magnitudeCalc"); const diameters_1 = require("./constants/diameters"); const moonPhases_1 = require("./constants/moonPhases"); const GoldenHandle_1 = __importDefault(require("./events/GoldenHandle")); const LunarV_1 = __importDefault(require("./events/LunarV")); const LunarX_1 = __importDefault(require("./events/LunarX")); class Moon extends AstronomicalObject_1.default { constructor(toi) { super(toi, 'moon'); this.sun = (0, createSun_1.default)(toi); this.earth = (0, createEarth_1.default)(toi); } getHeliocentricEclipticRectangularJ2000Coordinates() { return __awaiter(this, void 0, void 0, function* () { return yield this.getHeliocentricEclipticRectangularDateCoordinates(); }); } getHeliocentricEclipticRectangularDateCoordinates() { return __awaiter(this, void 0, void 0, function* () { const geocentricCoords = yield this.getGeocentricEclipticRectangularDateCoordinates(); const heliocentricCoordsEarth = yield this.earth.getHeliocentricEclipticRectangularDateCoordinates(); return (0, coordinateCalc_1.rectangularGeocentric2rectangularHeliocentric)(geocentricCoords, heliocentricCoordsEarth); }); } getHeliocentricEclipticSphericalJ2000Coordinates() { return __awaiter(this, void 0, void 0, function* () { return yield this.getHeliocentricEclipticSphericalDateCoordinates(); }); } getHeliocentricEclipticSphericalDateCoordinates() { return __awaiter(this, void 0, void 0, function* () { const coords = yield this.getHeliocentricEclipticRectangularDateCoordinates(); return (0, coordinateCalc_1.rectangular2spherical)(coords); }); } getGeocentricEclipticRectangularJ2000Coordinates() { return __awaiter(this, void 0, void 0, function* () { return yield this.getGeocentricEclipticRectangularDateCoordinates(); }); } getGeocentricEclipticRectangularDateCoordinates() { return __awaiter(this, void 0, void 0, function* () { const coords = yield this.getGeocentricEclipticSphericalDateCoordinates(); return (0, coordinateCalc_1.spherical2rectangular)(coords); }); } getGeocentricEclipticSphericalJ2000Coordinates() { return __awaiter(this, void 0, void 0, function* () { return yield this.getGeocentricEclipticSphericalDateCoordinates(); }); } getGeocentricEclipticSphericalDateCoordinates() { return __awaiter(this, void 0, void 0, function* () { const lon = calculations_1.moonCalc.getLongitude(this.T); const lat = calculations_1.moonCalc.getLatitude(this.T); const radiusVector = calculations_1.moonCalc.getRadiusVector(this.T); return Promise.resolve({ lon, lat, radiusVector }); }); } getApparentGeocentricEclipticSphericalCoordinates() { return __awaiter(this, void 0, void 0, function* () { const coords = yield this.getGeocentricEclipticSphericalDateCoordinates(); return (0, apparentCoordinateCalc_1.correctEffectOfNutation)(coords, this.T); }); } getTransit(location) { return __awaiter(this, void 0, void 0, function* () { const jd = yield (0, riseSetTransitCalc_1.getTransit)(Moon, location, this.jd0); return time_1.createTimeOfInterest.fromJulianDay(jd); }); } getRise(location_1) { return __awaiter(this, arguments, void 0, function* (location, standardAltitude = standardAltitude_1.STANDARD_ALTITUDE_MOON_CENTER_REFRACTION) { const jd = yield (0, riseSetTransitCalc_1.getRise)(Moon, location, this.jd0, standardAltitude); return time_1.createTimeOfInterest.fromJulianDay(jd); }); } getSet(location_1) { return __awaiter(this, arguments, void 0, function* (location, standardAltitude = standardAltitude_1.STANDARD_ALTITUDE_MOON_CENTER_REFRACTION) { const jd = yield (0, riseSetTransitCalc_1.getSet)(Moon, location, this.jd0, standardAltitude); return time_1.createTimeOfInterest.fromJulianDay(jd); }); } getAngularDiameter() { return __awaiter(this, void 0, void 0, function* () { const distance = yield this.getApparentDistanceToEarth(); return utils_1.observationCalc.getAngularDiameter(distance, diameters_1.DIAMETER_MOON); }); } getTopocentricAngularDiameter(location) { return __awaiter(this, void 0, void 0, function* () { const distance = yield this.getTopocentricDistanceToEarth(location); return utils_1.observationCalc.getAngularDiameter(distance, diameters_1.DIAMETER_MOON); }); } getElongation() { return __awaiter(this, void 0, void 0, function* () { const coordsMoon = yield this.getApparentGeocentricEquatorialSphericalCoordinates(); const coordsSun = yield this.sun.getApparentGeocentricEquatorialSphericalCoordinates(); return utils_1.observationCalc.getElongation(coordsMoon, coordsSun); }); } getTopocentricElongation(location) { return __awaiter(this, void 0, void 0, function* () { const coordsMoon = yield this.getTopocentricEquatorialSphericalCoordinates(location); const coordsSun = yield this.sun.getApparentGeocentricEquatorialSphericalCoordinates(); return utils_1.observationCalc.getElongation(coordsMoon, coordsSun); }); } getPhaseAngle() { return __awaiter(this, void 0, void 0, function* () { const coordsMoon = yield this.getApparentGeocentricEquatorialSphericalCoordinates(); const coordsSun = yield this.sun.getApparentGeocentricEquatorialSphericalCoordinates(); return utils_1.observationCalc.getPhaseAngle(coordsMoon, coordsSun); }); } getTopocentricPhaseAngle(location) { return __awaiter(this, void 0, void 0, function* () { const coordsMoon = yield this.getTopocentricEquatorialSphericalCoordinates(location); const coordsSun = yield this.sun.getApparentGeocentricEquatorialSphericalCoordinates(); return utils_1.observationCalc.getPhaseAngle(coordsMoon, coordsSun); }); } getIlluminatedFraction() { return __awaiter(this, void 0, void 0, function* () { const i = yield this.getPhaseAngle(); return utils_1.observationCalc.getIlluminatedFraction(i); }); } getTopocentricIlluminatedFraction(location) { return __awaiter(this, void 0, void 0, function* () { const i = yield this.getTopocentricPhaseAngle(location); return utils_1.observationCalc.getIlluminatedFraction(i); }); } getPositionAngleOfBrightLimb() { return __awaiter(this, void 0, void 0, function* () { const coordsMoon = yield this.getApparentGeocentricEquatorialSphericalCoordinates(); const coordsSun = yield this.sun.getApparentGeocentricEquatorialSphericalCoordinates(); return utils_1.observationCalc.getPositionAngleOfBrightLimb(coordsMoon, coordsSun); }); } getTopocentricPositionAngleOfBrightLimb(location) { return __awaiter(this, void 0, void 0, function* () { const coordsMoon = yield this.getTopocentricEquatorialSphericalCoordinates(location); const coordsSun = yield this.sun.getApparentGeocentricEquatorialSphericalCoordinates(); return utils_1.observationCalc.getPositionAngleOfBrightLimb(coordsMoon, coordsSun); }); } isWaxing() { return __awaiter(this, void 0, void 0, function* () { const chi = yield this.getPositionAngleOfBrightLimb(); return utils_1.observationCalc.isWaxing(chi); }); } isTopocentricWaxing(location) { return __awaiter(this, void 0, void 0, function* () { const chi = yield this.getTopocentricPositionAngleOfBrightLimb(location); return utils_1.observationCalc.isWaxing(chi); }); } getApparentMagnitude() { return __awaiter(this, void 0, void 0, function* () { const coordsHelio = yield this.getHeliocentricEclipticSphericalDateCoordinates(); const coordsGeo = yield this.getGeocentricEclipticSphericalDateCoordinates(); const i = yield this.getPhaseAngle(); const isWaxing = yield this.isWaxing(); return (0, magnitudeCalc_1.getApparentMagnitudeMoon)(coordsHelio.radiusVector, coordsGeo.radiusVector, i, isWaxing); }); } getTopocentricApparentMagnitude(location) { return __awaiter(this, void 0, void 0, function* () { const coordsHelio = yield this.getHeliocentricEclipticSphericalDateCoordinates(); const coordsGeo = yield this.getTopocentricEquatorialSphericalCoordinates(location); const i = yield this.getTopocentricPhaseAngle(location); const isWaxing = yield this.isTopocentricWaxing(location); return (0, magnitudeCalc_1.getApparentMagnitudeMoon)(coordsHelio.radiusVector, coordsGeo.radiusVector, i, isWaxing); }); } getUpcomingNewMoon() { const decimalYear = this.toi.getDecimalYear(); return calculations_1.moonPhaseCalc.getTimeOfInterestOfUpcomingPhase(decimalYear, moonPhases_1.MOON_PHASE_NEW_MOON); } getUpcomingFirstQuarter() { const decimalYear = this.toi.getDecimalYear(); return calculations_1.moonPhaseCalc.getTimeOfInterestOfUpcomingPhase(decimalYear, moonPhases_1.MOON_PHASE_FIRST_QUARTER); } getUpcomingFullMoon() { const decimalYear = this.toi.getDecimalYear(); return calculations_1.moonPhaseCalc.getTimeOfInterestOfUpcomingPhase(decimalYear, moonPhases_1.MOON_PHASE_FULL_MOON); } getUpcomingLastQuarter() { const decimalYear = this.toi.getDecimalYear(); return calculations_1.moonPhaseCalc.getTimeOfInterestOfUpcomingPhase(decimalYear, moonPhases_1.MOON_PHASE_LAST_QUARTER); } getGeocentricLibration() { return __awaiter(this, void 0, void 0, function* () { return yield this.getSelenographicLocationOfEarth(); }); } getSelenographicLocationOfEarth() { return __awaiter(this, void 0, void 0, function* () { const coords = yield this.getGeocentricEclipticSphericalDateCoordinates(); return (0, librationCalc_1.getSelenographicLocation)(coords, this.T); }); } getSelenographicLocationOfSun() { return __awaiter(this, void 0, void 0, function* () { const coords = yield this.getHeliocentricEclipticSphericalDateCoordinates(); return (0, librationCalc_1.getSelenographicLocation)(coords, this.T); }); } getGoldenHandle() { return new GoldenHandle_1.default(this.toi); } getLunarX() { return new LunarX_1.default(this.toi); } getLunarV() { return new LunarV_1.default(this.toi); } } exports.default = Moon;