"""The preprint's configuration-selection procedure (section 2.3, p. 6), year by year. Start with the Sun and the four inner planets; while a year gives more than 100 candidate timestamps, add the next body of the nested sequence and repeat. The paper names the Moon (placed after Earth, as in its Table 1) and then Jupiter; it does not say what comes after Jupiter, so we take Saturn, Uranus and Neptune in order of distance (never needed in 2010-2012). Writes /selection--.json and /dates--.json. Usage: python -I select_dates.py [alpha] [method] [order] """ import json, pathlib, sys sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent)) # our own scripts only (run with -I) import config_dates as cd BASE = ["199", "299", "399", "499"] SEQUENCE = [("301", 3), ("599", None), ("699", None), ("799", None), ("899", None)] # (body, insert position) def select(hdir, year, alpha=0.35, method="svd", order="sunfirst", limit=100): bodies, steps = list(BASE), [] for nxt in [None] + SEQUENCE: if nxt is not None: body, pos = nxt bodies = bodies[:pos] + [body] + bodies[pos:] if pos is not None else bodies + [body] stamps, jumps = cd.candidates(hdir, year, bodies, alpha, method, order) steps.append({"bodies": [cd.NAMES[b] for b in bodies], "candidates": len(stamps)}) if len(stamps) <= limit: dates = sorted({s.date().isoformat() for s in stamps}) return {"year": year, "steps": steps, "selected": [cd.NAMES[b] for b in bodies], "stamps": [s.strftime("%Y-%m-%d %H:%M") for s in stamps], "dates": dates, "jump_max_at_stamps_AU": [float(jumps[(s - s.replace(month=1, day=1, hour=0, minute=0)).days * 1440 + s.hour * 60 + s.minute]) for s in stamps]} return {"year": year, "steps": steps, "selected": None, "stamps": [], "dates": [], "excluded": f"no body set through Neptune gave <= {limit} candidates"} def main(): hdir, out = sys.argv[1], pathlib.Path(sys.argv[2]); y0, y1 = int(sys.argv[3]), int(sys.argv[4]) alpha = float(sys.argv[5]) if len(sys.argv) > 5 else 0.35 method = sys.argv[6] if len(sys.argv) > 6 else "svd" order = sys.argv[7] if len(sys.argv) > 7 else "sunfirst" out.mkdir(parents=True, exist_ok=True) tag = f"{y0}-{y1}" + ("" if (alpha, method, order) == (0.35, "svd", "sunfirst") else f"-a{alpha}-{method}-{order}") res = [select(hdir, y, alpha, method, order) for y in range(y0, y1 + 1)] (out / f"selection-{tag}.json").write_text(json.dumps(res, indent=1), encoding="utf-8") (out / f"dates-{tag}.json").write_text(json.dumps({str(r["year"]): r["dates"] for r in res}, indent=1), encoding="utf-8") for r in res: print(r["year"], " -> ".join(f"{'+'.join(s['bodies'])}: {s['candidates']}" for s in r["steps"]), "| dates:", len(r["dates"]), r.get("excluded", "")) if __name__ == "__main__": main()