You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
3.0 KiB
Python
69 lines
3.0 KiB
Python
"""Summarize qualified telephoto pulses from episode JSONL into review candidates."""
|
|
import argparse
|
|
from collections import defaultdict
|
|
import json
|
|
import math
|
|
from pathlib import Path
|
|
from statistics import median
|
|
|
|
|
|
def focal(fov):
|
|
return -math.log(math.tan(math.radians(fov / 2)))
|
|
|
|
|
|
def summarize(files):
|
|
grouped = defaultdict(dict)
|
|
for file in files:
|
|
with file.open(encoding="utf-8") as rows:
|
|
for line in rows:
|
|
item = json.loads(line)
|
|
if item.get("event") != "native10_pulse_calibration":
|
|
continue
|
|
key = (item["track_start_utc"], item["generation"], item["request"])
|
|
grouped[item["cam"]][key] = item
|
|
result = {}
|
|
for camera, records in sorted(grouped.items()):
|
|
accepted = []
|
|
for item in records.values():
|
|
rate = item.get("effective_tele_log_rate_s")
|
|
if (item.get("outcome") != "settled" or not isinstance(rate, (float, int))
|
|
or not math.isfinite(rate) or rate <= 0):
|
|
continue
|
|
before, after = item["HFOV_before"], item["HFOV_after"]
|
|
if not 0 < after < before < 15:
|
|
continue
|
|
if item.get("put_rtt_ms") is None or item.get("stop_rtt_ms") is None:
|
|
continue
|
|
accepted.append(item)
|
|
result[str(camera)] = {"qualified": len(accepted), "seen": len(records),
|
|
"candidate_for_review": None}
|
|
# A single track may have a common framing or status-timing bias.
|
|
if len(accepted) < 3 or len({x["track_start_utc"] for x in accepted}) < 2:
|
|
continue
|
|
rates = [x["effective_tele_log_rate_s"] for x in accepted]
|
|
bracket = [
|
|
max(0., focal(x["HFOV_after"]) - focal(x["HFOV_stop_sample"]))
|
|
for x in accepted if x.get("stop_status_at") is not None
|
|
and x["put_at"] <= x["stop_status_at"] <= x["stop_issued_at"]
|
|
and 0 <= x["stop_issued_at"] - x["stop_status_at"] <= .18
|
|
]
|
|
full_sweep_rate = math.log(252 / 6) / 5.5
|
|
result[str(camera)]["candidate_for_review"] = {
|
|
"observed_hfov_before_deg": [min(x["HFOV_before"] for x in accepted),
|
|
max(x["HFOV_before"] for x in accepted)],
|
|
"median_effective_tele_log_rate_s": median(rates),
|
|
"stress_upper_gain": max(rates) * 1.25 / full_sweep_rate,
|
|
"qualified_stop_brackets": len(bracket),
|
|
"max_stop_bracket_log_narrowing": max(bracket, default=None),
|
|
"max_put_rtt_ms": max(x["put_rtt_ms"] for x in accepted),
|
|
"max_stop_rtt_ms": max(x["stop_rtt_ms"] for x in accepted),
|
|
}
|
|
return {"scope": "observed_telephoto_windows_only", "production_enable": False, "cameras": result}
|
|
|
|
|
|
if __name__ == "__main__":
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument("files", nargs="+", type=Path)
|
|
args = parser.parse_args()
|
|
print(json.dumps(summarize(args.files), indent=2, allow_nan=False))
|