// astronomy-engine at the study's moments. // // Horospire ephemeris accuracy study, version 1.0. MIT licence (LICENSE-CODE.txt). // astronomy-engine is Don Cross's, MIT; this script calls it. // // Usage: node astronomy_engine.mjs PATH_TO_ASTRONOMY_ENGINE_PACKAGE MOMENTS_JSON OUT_JSON // // Pinned: astronomy-engine 2.1.19 (npm). // Calls: the Sun from SunPosition(time).elon (apparent ecliptic longitude of // date); the Moon and the planets from Ecliptic(GeoVector(body, time, true)).elon, // geocentric with aberration, on the true ecliptic and equinox of date. // Time: MakeTime(new Date(civil time)), read as UT; the library applies its own // Delta T. import { readFileSync, writeFileSync } from 'node:fs'; import { createRequire } from 'node:module'; const [pkg, momentsPath, outPath] = process.argv.slice(2); const require = createRequire(import.meta.url); const Astronomy = require(pkg); const version = JSON.parse(readFileSync(`${pkg}/package.json`, 'utf8')).version; const B = Astronomy.Body; const bodies = [B.Sun, B.Moon, B.Mercury, B.Venus, B.Mars, B.Jupiter, B.Saturn, B.Uranus, B.Neptune, B.Pluto]; const lon = JSON.parse(readFileSync(momentsPath, 'utf8')).map((civil) => { const t = Astronomy.MakeTime(new Date(civil)); return bodies.map((b) => (b === B.Sun ? Astronomy.SunPosition(t).elon : Astronomy.Ecliptic(Astronomy.GeoVector(b, t, true)).elon)); }); writeFileSync(outPath, JSON.stringify({ engine: `astronomy-engine ${version}`, lon })); console.log(`${lon.length} moments, astronomy-engine ${version}`);