# 査読（2026-10-20 07:2x）への応答: ① N=200・Df 2.8 の lmax=1 を7波長にそろえ、次数と波長刻みの効果を分ける
# ② N=1000 は向きを変えて（seed 3, 4）向きによる b* のばらつきを見る。結果は tm_extra.jsonl に (N, Df, lmax, lam, seed) で足す
import json, os, time
from tm_core import cross_sections
from aggregate import make_aggregate
OUT = "tm_extra.jsonl"
done = set()
if os.path.exists(OUT):
    for l in open(OUT): d = json.loads(l); done.add((d["N"], d["Df"], d["lmax"], d["lam"], d["seed"]))
jobs = [(200, 2.8, 1, lam, 2, 2) for lam in (450, 550, 650)]
jobs += [(1000, Df, 1, lam, seed, 1) for seed in (3, 4) for Df in (2.8, 1.8) for lam in (400, 500, 600, 700)]
X = {}
for N, Df, lmax, lam, seed, nd in jobs:
    if (N, Df, lmax, lam, seed) in done: continue
    if (N, Df) not in X: X[(N, Df)] = make_aggregate(N, Df, seed=1) * 15.0
    t = time.time()
    ca, cs, g = cross_sections(X[(N, Df)], 15.0, 1.95 + 0.79j, float(lam), lmax=lmax, ndir=nd, seed=seed)
    with open(OUT, "a") as f:
        f.write(json.dumps(dict(N=N, Df=Df, lam=lam, lmax=lmax, ndir=nd, seed=seed, Cabs=ca, Csca=cs, g=g, sec=round(time.time() - t, 1))) + "\n")
    print(N, Df, lmax, lam, seed, ca, cs, g, round(time.time() - t), "s", flush=True)
