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.

67 lines (66 loc) 3.14 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.circumstancesToJulianDay = exports.getTimeLocationCircumstances = exports.getTimeCircumstances = void 0; const coordinateCalc_1 = require("../../coordinates/calculations/coordinateCalc"); const angleCalc_1 = require("../../utils/angleCalc"); const besselianElementsCalc_1 = require("./besselianElementsCalc"); function getTimeCircumstances(besselianElements, t) { const { x, y, d, mu, l1, l2 } = besselianElements; return { x: (0, besselianElementsCalc_1.populate)(x, t), dX: (0, besselianElementsCalc_1.populateD)(x, t), y: (0, besselianElementsCalc_1.populate)(y, t), dY: (0, besselianElementsCalc_1.populateD)(y, t), d: (0, besselianElementsCalc_1.populate)(d, t), dD: (0, besselianElementsCalc_1.populateD)(d, t), mu: (0, besselianElementsCalc_1.populate)(mu, t), dMu: (0, besselianElementsCalc_1.populateD)(mu, t), l1: (0, besselianElementsCalc_1.populate)(l1, t), dL1: (0, besselianElementsCalc_1.populateD)(l1, t), l2: (0, besselianElementsCalc_1.populate)(l2, t), dL2: (0, besselianElementsCalc_1.populateD)(l2, t), }; } exports.getTimeCircumstances = getTimeCircumstances; function getTimeLocationCircumstances(besselianElements, location, t) { const { dT, tanF1, tanF2 } = besselianElements; const { lat, lon, elevation } = location; const { x, dX, y, dY, mu, dMu, d, dD, l1, l2 } = getTimeCircumstances(besselianElements, t); const rhoSinLat = (0, coordinateCalc_1.getRhoSinLat)(lat, elevation); const rhoCosLat = (0, coordinateCalc_1.getRhoCosLat)(lat, elevation); const muRad = (0, angleCalc_1.deg2rad)(mu); const dMuRad = (0, angleCalc_1.deg2rad)(dMu); const dRad = (0, angleCalc_1.deg2rad)(d); const dDRad = (0, angleCalc_1.deg2rad)(dD); const lonRad = (0, angleCalc_1.deg2rad)(lon); const hRad = muRad + lonRad - dT / 13713.440924999626077; const h = (0, angleCalc_1.rad2deg)(hRad); const xi = rhoCosLat * Math.sin(hRad); const eta = rhoSinLat * Math.cos(dRad) - rhoCosLat * Math.cos(hRad) * Math.sin(dRad); const zeta = rhoSinLat * Math.sin(dRad) + rhoCosLat * Math.cos(hRad) * Math.cos(dRad); const dXi = dMuRad * rhoCosLat * Math.cos(hRad); const dEta = dMuRad * xi * Math.sin(dRad) - zeta * dDRad; const u = x - xi; const v = y - eta; const a = dX - dXi; const b = dY - dEta; const l1Derived = l1 - zeta * tanF1; const l2Derived = l2 - zeta * tanF2; const n2 = Math.pow(a, 2) + Math.pow(b, 2); return { t, h, u, v, a, b, l1Derived, l2Derived, n2 }; } exports.getTimeLocationCircumstances = getTimeLocationCircumstances; function circumstancesToJulianDay(besselianElements, circumstances) { const { tMax, t0, dT } = besselianElements; let { t } = circumstances; let jd = Math.floor(tMax - t0 / 24.0); t = t + t0 - (dT - 0.05) / 3600.0; if (t < 0.0) { jd--; } else if (t >= 24.0) { jd++; } return jd + (t + 12) / 24; } exports.circumstancesToJulianDay = circumstancesToJulianDay;