protostar-climate-2026 / code /run_v2_eval.py
Tonic's picture
Protostar Climate submission: v2 forecast + v3/DCPP amendment audit (29 gated candidates)
49f3de8 verified
Raw History Blame Contribute Delete
1.74 kB
"""Phase 0/1/4(generic): evaluate pre-declared candidates per metric."""
from __future__ import annotations
import sys
from functools import partial
from pathlib import Path
import pandas as pd
sys.path.insert(0, str(Path(__file__).parent))
from candidates import (CDD_LINEAR_CANDIDATES, GENERIC_CANDIDATES,
TEMP_CANDIDATES, level_trend)
from harness import evaluate, skill_table
from panel import Panel
CLIP = {"cdd", "total_precip_in"}
def wrap(metric: str, cfg: dict):
return lambda p, origin: level_trend(p, metric, origin,
clip_zero=metric in CLIP, **cfg)
def main() -> None:
root = Path(__file__).resolve().parent.parent
panel = Panel(root)
out = root / "outputs" / "v2"
out.mkdir(parents=True, exist_ok=True)
jobs = {
"annual_avg_temp": TEMP_CANDIDATES,
"cdd": CDD_LINEAR_CANDIDATES,
"total_precip_in": GENERIC_CANDIDATES,
"hottest_day_temp": GENERIC_CANDIDATES,
}
all_detail = []
for metric, registry in jobs.items():
cands = {name: wrap(metric, cfg) for name, cfg in registry.items()}
detail = evaluate(panel, metric, cands)
detail.to_csv(out / f"detail_{metric}.csv", index=False)
all_detail.append(detail)
tab = skill_table(detail)
piv = tab.pivot_table(index="candidate", columns="era", values="skill")
print(f"\n== {metric} (skill by era) ==")
print(piv.sort_values("tune", ascending=False).round(4).to_string())
pd.concat(all_detail).to_csv(out / "detail_all.csv", index=False)
print("\nwrote outputs/v2/detail_*.csv")
if __name__ == "__main__":
main()