"""The Swiss Ephemeris in Moshier mode at the study's moments. Horospire ephemeris accuracy study, version 1.0. MIT licence (LICENSE-CODE.txt). The Swiss Ephemeris itself is Astrodienst's, under its own licence (AGPL or its professional licence); this script calls it and distributes none of it. Usage: python swiss_ephemeris.py MOMENTS_JSON OUT_JSON Pinned: pyswisseph 2.10.3.2, which wraps Swiss Ephemeris 2.10.03. Call: swe.calc_ut(julian day of the civil time, body, FLG_MOSEPH | FLG_SPEED). No ephemeris files are read, so this is Moshier mode, the library's built-in analytical ephemeris, not its compressed JPL files. No other flag is set, so the position is the library's default: apparent, geocentric, on the true ecliptic and equinox of date (light time, aberration, deflection and nutation applied), with Delta T by the library's own model. """ import json import sys from datetime import datetime import swisseph as swe BODIES = [swe.SUN, swe.MOON, swe.MERCURY, swe.VENUS, swe.MARS, swe.JUPITER, swe.SATURN, swe.URANUS, swe.NEPTUNE, swe.PLUTO] FLAGS = swe.FLG_MOSEPH | swe.FLG_SPEED def main(): moments_path, out_path = sys.argv[1:3] rows = [] for civil in json.load(open(moments_path)): d = datetime.strptime(civil, "%Y-%m-%dT%H:%M:%SZ") jd = swe.julday(d.year, d.month, d.day, d.hour + d.minute / 60.0 + d.second / 3600.0, swe.GREG_CAL) rows.append([swe.calc_ut(jd, body, FLAGS)[0][0] for body in BODIES]) json.dump({"engine": f"Swiss Ephemeris {swe.version}, Moshier mode", "flags": "FLG_MOSEPH|FLG_SPEED", "lon": rows}, open(out_path, "w")) print(f"{len(rows)} moments, Swiss Ephemeris {swe.version}") if __name__ == "__main__": main()