update at 2026-10-12 16:53:40

网站v8修复(时序竞态+M3表格) + exp06 SNR×窗口扫描 + README里程碑更新
This commit is contained in:
douboer
2026-10-12 16:53:41 +08:00
parent 4a734e6299
commit 42cb251061
47 changed files with 29891 additions and 12 deletions

View File

@@ -40,11 +40,13 @@ def git_hash():
return "unversioned"
def save_run(runs_dir, name, records, figures=None, notes="", seed=None, extra_meta=None):
def save_run(runs_dir, name, records, figures=None, notes="", seed=None, extra_meta=None,
data_csvs=None):
"""落盘一个记录包。
records: dict 或 list[dict],每个含 meta/data 字段(pipeline 输出);
figures: list[(filename, matplotlib.figure)]。
figures: list[(filename, matplotlib.figure)];
data_csvs: list[(filename, list[dict])]——任意键值表写入 data/(扫描数据等)。
返回记录包目录。
"""
ts = datetime.datetime.now().strftime("%Y%m%d-%H%M%S")
@@ -79,7 +81,8 @@ def save_run(runs_dir, name, records, figures=None, notes="", seed=None, extra_m
if k in ("fit", "tau_hat", "tau_true", "rel_error", "n_samples",
"sigma", "mean", "std", "rel_std", "bias", "tau_hats",
"uniformity", "sorted_phases_ns", "channels", "construction",
"target_phases_ns", "is_uniform_grid", "recommended")}
"target_phases_ns", "is_uniform_grid", "recommended",
"scan", "single_rel_std", "fiber_rel_std", "ratio")}
results.append(r)
# 采样点 CSV
if "t_samples" in rec:
@@ -99,6 +102,15 @@ def save_run(runs_dir, name, records, figures=None, notes="", seed=None, extra_m
fig.savefig(os.path.join(run_dir, "figures", f"{fname}.svg"))
fig.savefig(os.path.join(run_dir, "figures", f"{fname}.png"), dpi=150)
for fname, rows in (data_csvs or []):
if not rows:
continue
path = os.path.join(run_dir, "data", f"{fname}.csv")
with open(path, "w", newline="") as f:
w = csv.DictWriter(f, fieldnames=list(rows[0].keys()))
w.writeheader()
w.writerows(rows)
with open(os.path.join(run_dir, "README.md"), "w") as f:
f.write(f"# 记录包:{name}\n\n{notes}\n\n"
f"- 运行时间:{meta['created']}\n"