"""Summarize an archival target's measurements, three separated brightness minima, and a repeating-dip ephemeris measured from the early window. The observation is exactly examples/observe_archive.py's summary. The ephemeris constants were measured from the early window by a deterministic grid search (see routes/galaxy-69-15e59343a9/README.md for the commands): match predicted dip times to clustered deep minima, maximising matched depth. """ import argparse import csv import gzip import json from statistics import median def observation(rows): minima = [] for time, flux in sorted(rows, key=lambda row: (row[1], row[0])): if all(abs(time - item["time_bkjd"]) >= 1 for item in minima): minima.append({"time_bkjd": time, "flux_ppm": flux}) if len(minima) == 3: break return {"samples": len(rows), "span_days": round(rows[-1][0] - rows[0][0], 6), "median_flux_ppm": median(row[1] for row in rows), "minima": minima} # Repeating dip in the early window of KIC 8377068: six consecutive minima near # BKJD 121.03, 122.73, 124.42, 126.12, 127.82, 129.52 (about 37,000-49,000 ppm # deep, roughly 5 hours wide) and later phase-locked dips at the same period. EPHEMERIS = { "period_days": 1.697250, "epoch_bkjd": 121.0300, "duration_hours": 5.0, } def main(): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("star") parser.add_argument("early_csv_gz") args = parser.parse_args() with gzip.open(args.early_csv_gz, "rt", newline="") as handle: rows = [(float(row["time_bkjd"]), int(row["relative_flux_ppm"])) for row in csv.DictReader(handle)] answer = {"star": args.star, "observation": observation(rows)} answer.update(EPHEMERIS) print(json.dumps(answer)) if __name__ == "__main__": main()