"""Reproduce a known dip using only the early KIC 10619192 observations. Run from the project root. The public Kepler-17 b ephemeris is a starting point, not a discovery. A fixed-duration coarse/fine search maximizes the project's robust event S/N. Independent early-half fits and cross-half measurements describe sensitivity to the observation window; grid spacing is not an uncertainty estimate. No reserved observations are loaded. """ import argparse import hashlib import json import sys from pathlib import Path sys.dont_write_bytecode = True sys.path.insert(0, str(Path.cwd())) from verify import lightcurve, measure STAR = "KIC 10619192" TRAIN = Path("observations/10619192-train.csv.gz") SEED_PERIOD = 1.4857108 SEED_EPOCH = 352.678035 DURATION = 2.3 def grid_search(rows, pivot): """Use the same two-stage search for the full window and each half.""" evaluations = 0 def search(center_period, center_epoch, period_steps, epoch_steps): nonlocal evaluations options = [] for dp in period_steps: for dt in epoch_steps: # Round before measurement so evidence describes the JSON's # actual prediction, including both independent half fits. period = round(center_period + SEED_PERIOD * dp, 9) epoch = round(center_epoch + dt, 8) measured = measure(rows, period, epoch, DURATION) options.append({"period_days": period, "epoch_bkjd": epoch, "measurement": measured}) evaluations += 1 # Preserve deterministic scan order for equal rounded S/N values. return max(options, key=lambda option: option["measurement"]["snr"]) coarse = search(SEED_PERIOD, pivot, [step * 0.000002 for step in range(-10, 11)], [step * 0.002 for step in range(-8, 9)]) fine = search(coarse["period_days"], coarse["epoch_bkjd"], [step * 0.0000005 for step in range(-4, 5)], [step * 0.0005 for step in range(-4, 5)]) best = max((coarse, fine), key=lambda option: option["measurement"]["snr"]) return {**best, "evaluations": evaluations, "coarse_best": coarse} def describe(rows): return {"samples": len(rows), "min_bkjd": rows[0][0], "max_bkjd": rows[-1][0]} def evaluate(rows, fit): return measure(rows, fit["period_days"], fit["epoch_bkjd"], DURATION) def main(): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("--evidence", type=Path, help="Write deterministic training-only diagnostic JSON") args = parser.parse_args() rows = lightcurve(TRAIN) midpoint = (rows[0][0] + rows[-1][0]) / 2 pivot = SEED_EPOCH + round((midpoint - SEED_EPOCH) / SEED_PERIOD) * SEED_PERIOD first = [row for row in rows if row[0] <= midpoint] second = [row for row in rows if row[0] > midpoint] full_fit = grid_search(rows, pivot) first_fit = grid_search(first, pivot) second_fit = grid_search(second, pivot) result = {"star": STAR, "period_days": full_fit["period_days"], "epoch_bkjd": full_fit["epoch_bkjd"], "duration_hours": DURATION} if args.evidence: evidence = { "star": STAR, "purpose": "Reproduction of a published signal; no discovery claim", "input": {"file": str(TRAIN), "sha256": hashlib.sha256(TRAIN.read_bytes()).hexdigest(), **describe(rows)}, "published_seed": {"period_days": SEED_PERIOD, "epoch_bkjd": SEED_EPOCH, "duration_hours": DURATION}, "search": { "objective": "maximize verify.measure robust event S/N", "duration": "fixed at the published 2.3 hours", "pivot_bkjd": round(pivot, 8), "coarse_period_offsets_ppm": [-20, 20, 2], "coarse_epoch_offsets_days": [-0.016, 0.016, 0.002], "fine_period_offsets_ppm": [-2, 2, 0.5], "fine_epoch_offsets_days": [-0.002, 0.002, 0.0005], "offset_definition": "period offsets use the published seed period; fine offsets center on the coarse optimum", "total_evaluations": sum(fit["evaluations"] for fit in (full_fit, first_fit, second_fit)), "caution": "No period uncertainty inferred from grid steps or split-half fits", }, "submitted_prediction": result, "full_early_fit": full_fit, "split_bkjd": midpoint, "first_half": {**describe(first), "independent_fit": first_fit, "submitted_prediction_measurement": evaluate(first, full_fit), "prediction_from_second_half": evaluate(first, second_fit)}, "second_half": {**describe(second), "independent_fit": second_fit, "submitted_prediction_measurement": evaluate(second, full_fit), "prediction_from_first_half": evaluate(second, first_fit)}, } args.evidence.write_text(json.dumps(evidence, indent=2) + "\n") print(json.dumps(result, indent=2)) if __name__ == "__main__": main()