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.

185 lines (184 loc) 10.3 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 calculationCache_1 = require("../cache/calculationCache"); const standardAltitude_1 = require("../constants/standardAltitude"); const apparentCoordinateCalc_1 = require("../coordinates/calculations/apparentCoordinateCalc"); const coordinateCalc_1 = require("../coordinates/calculations/coordinateCalc"); const earth_1 = require("../earth"); const sun_1 = require("../sun"); const time_1 = require("../time"); const utils_1 = require("../utils"); const angleCalc_1 = require("../utils/angleCalc"); const riseSetTransitCalc_1 = require("../utils/riseSetTransitCalc"); const vsop87Calc_1 = require("./calculations/vsop87Calc"); class Planet extends AstronomicalObject_1.default { constructor(toi = time_1.createTimeOfInterest.fromCurrentTime(), name = 'planet', useVsop87Short = false) { super(toi, name); this.toi = toi; this.name = name; this.useVsop87Short = useVsop87Short; this.sun = (0, sun_1.createSun)(toi); this.earth = (0, earth_1.createEarth)(toi); } getHeliocentricEclipticSphericalJ2000Coordinates() { return __awaiter(this, void 0, void 0, function* () { return yield (0, calculationCache_1.getAsyncCachedCalculation)(this.name + '_heliocentric_spherical_j2000', this.t, () => __awaiter(this, void 0, void 0, function* () { const vsop87 = yield this.vsop87J2000; return { lon: (0, angleCalc_1.normalizeAngle)((0, vsop87Calc_1.calculateVSOP87Angle)(vsop87.VSOP87_X, this.t)), lat: (0, vsop87Calc_1.calculateVSOP87Angle)(vsop87.VSOP87_Y, this.t), radiusVector: (0, vsop87Calc_1.calculateVSOP87)(vsop87.VSOP87_Z, this.t), }; })); }); } getHeliocentricEclipticSphericalDateCoordinates() { return __awaiter(this, void 0, void 0, function* () { return yield (0, calculationCache_1.getAsyncCachedCalculation)(this.name + '_heliocentric_spherical_date', this.t, () => __awaiter(this, void 0, void 0, function* () { const vsop87 = this.useVsop87Short ? yield this.vsop87DateShort : yield this.vsop87Date; return { lon: (0, angleCalc_1.normalizeAngle)((0, vsop87Calc_1.calculateVSOP87Angle)(vsop87.VSOP87_X, this.t)), lat: (0, vsop87Calc_1.calculateVSOP87Angle)(vsop87.VSOP87_Y, this.t), radiusVector: (0, vsop87Calc_1.calculateVSOP87)(vsop87.VSOP87_Z, this.t), }; })); }); } getAngularDiameter() { return __awaiter(this, void 0, void 0, function* () { const distance = yield this.getApparentDistanceToEarth(); return utils_1.observationCalc.getAngularDiameter(distance, this.diameter); }); } getApparentMagnitude() { return __awaiter(this, void 0, void 0, function* () { const coordsHelio = yield this.getHeliocentricEclipticSphericalDateCoordinates(); const coordsGeo = yield this.getGeocentricEclipticSphericalDateCoordinates(); const phaseAngle = yield this.getPhaseAngle(); return this.calculateApparentMagnitude(coordsHelio.radiusVector, coordsGeo.radiusVector, phaseAngle); }); } getHeliocentricEclipticRectangularJ2000Coordinates() { return __awaiter(this, void 0, void 0, function* () { const coords = yield this.getHeliocentricEclipticSphericalJ2000Coordinates(); return (0, coordinateCalc_1.spherical2rectangular)(coords); }); } getHeliocentricEclipticRectangularDateCoordinates() { return __awaiter(this, void 0, void 0, function* () { const coords = yield this.getHeliocentricEclipticSphericalDateCoordinates(); return (0, coordinateCalc_1.spherical2rectangular)(coords); }); } getGeocentricEclipticRectangularJ2000Coordinates() { return __awaiter(this, void 0, void 0, function* () { const coordsPlanet = yield this.getHeliocentricEclipticRectangularJ2000Coordinates(); const coordsEarth = yield this.earth.getHeliocentricEclipticRectangularJ2000Coordinates(); return (0, coordinateCalc_1.rectangularHeliocentric2rectangularGeocentric)(coordsPlanet, coordsEarth); }); } getGeocentricEclipticRectangularDateCoordinates() { return __awaiter(this, void 0, void 0, function* () { const coordsPlanet = yield this.getHeliocentricEclipticRectangularDateCoordinates(); const coordsEarth = yield this.earth.getHeliocentricEclipticRectangularDateCoordinates(); return (0, coordinateCalc_1.rectangularHeliocentric2rectangularGeocentric)(coordsPlanet, coordsEarth); }); } getGeocentricEclipticSphericalJ2000Coordinates() { return __awaiter(this, void 0, void 0, function* () { const coords = yield this.getGeocentricEclipticRectangularJ2000Coordinates(); return (0, coordinateCalc_1.rectangular2spherical)(coords); }); } getGeocentricEclipticSphericalDateCoordinates() { return __awaiter(this, void 0, void 0, function* () { const coords = yield this.getGeocentricEclipticRectangularDateCoordinates(); return (0, coordinateCalc_1.rectangular2spherical)(coords); }); } getApparentGeocentricEclipticSphericalCoordinates() { return __awaiter(this, void 0, void 0, function* () { let coords = yield this.getLightTimeCorrectedEclipticSphericalCoordinates(); coords = (0, apparentCoordinateCalc_1.correctEffectOfAberration)(coords, this.T); coords = (0, apparentCoordinateCalc_1.correctEffectOfNutation)(coords, this.T); return coords; }); } getTransit(location) { return __awaiter(this, void 0, void 0, function* () { const jd = yield (0, riseSetTransitCalc_1.getTransit)(this.constructor, location, this.jd0); return time_1.createTimeOfInterest.fromJulianDay(jd); }); } getRise(location) { return __awaiter(this, void 0, void 0, function* () { const jd = yield (0, riseSetTransitCalc_1.getRise)(this.constructor, location, this.jd0, standardAltitude_1.STANDARD_ALTITUDE_PLANET_REFRACTION); return time_1.createTimeOfInterest.fromJulianDay(jd); }); } getSet(location) { return __awaiter(this, void 0, void 0, function* () { const jd = yield (0, riseSetTransitCalc_1.getSet)(this.constructor, location, this.jd0, standardAltitude_1.STANDARD_ALTITUDE_PLANET_REFRACTION); return time_1.createTimeOfInterest.fromJulianDay(jd); }); } getElongation() { return __awaiter(this, void 0, void 0, function* () { const coords = yield this.getApparentGeocentricEquatorialSphericalCoordinates(); const coordsSun = yield this.sun.getApparentGeocentricEquatorialSphericalCoordinates(); return utils_1.observationCalc.getElongation(coords, coordsSun); }); } getPhaseAngle() { return __awaiter(this, void 0, void 0, function* () { const coords = yield this.getApparentGeocentricEquatorialSphericalCoordinates(); const coordsSun = yield this.sun.getApparentGeocentricEquatorialSphericalCoordinates(); return utils_1.observationCalc.getPhaseAngle(coords, coordsSun); }); } getIlluminatedFraction() { return __awaiter(this, void 0, void 0, function* () { const i = yield this.getPhaseAngle(); return utils_1.observationCalc.getIlluminatedFraction(i); }); } getPositionAngleOfBrightLimb() { return __awaiter(this, void 0, void 0, function* () { const coordsPlanet = yield this.getApparentGeocentricEquatorialSphericalCoordinates(); const coordsSun = yield this.sun.getApparentGeocentricEquatorialSphericalCoordinates(); return utils_1.observationCalc.getPositionAngleOfBrightLimb(coordsPlanet, coordsSun); }); } isWaxing() { return __awaiter(this, void 0, void 0, function* () { const chi = yield this.getPositionAngleOfBrightLimb(); return utils_1.observationCalc.isWaxing(chi); }); } getLightTimeCorrectedEclipticSphericalCoordinates() { return __awaiter(this, void 0, void 0, function* () { const { radiusVector } = yield this.getGeocentricEclipticSphericalDateCoordinates(); const jd = (0, apparentCoordinateCalc_1.getLightTimeCorrectedJulianDay)(this.jd, radiusVector); const toi = time_1.createTimeOfInterest.fromJulianDay(jd); const planet = new this.constructor(toi); const helRecEarthCoords = yield this.earth.getHeliocentricEclipticRectangularDateCoordinates(); const helRecPlanetCoords = yield planet.getHeliocentricEclipticRectangularDateCoordinates(); const coords = (0, coordinateCalc_1.rectangularHeliocentric2rectangularGeocentric)(helRecPlanetCoords, helRecEarthCoords); return (0, coordinateCalc_1.rectangular2spherical)(coords); }); } } exports.default = Planet;