P2 diagnosis on dev, P3 dev experiments, lock protocol_p3

- P2: SMC tie posterior (numpy + torch), RML/soft-DTW losses, bank training,
  D2 synthetic generator, scripts 09-13, protocol_p2 (locked) and its outcome
  (G-B failed; H1 not rejected, H3 rejected, H4 not rejected).
- Diagnosis on dev realizations 900/901 only (scripts 14-17, run_p3_dev.sh):
  posterior screen, SMC stability (P = 1024, K = 1), sigma_a misspecification
  stress and training, H3 with the SMC posterior, F3 placement on sigma_post.
- protocol_p3: H2 split into H2a (posterior-mean labels vs point ties) and
  H2b (RML vs posterior mean as a function of sigma_post); H3 descriptive only;
  sigma_a arm; new D2 config d2_synth_p3.yaml; main grid on realizations 8-15.
  Locked by configs/protocol_p3.sha256 and tag protocol-p3.
- runlog: per-run logs and runtime index (logs/index.csv).
- Docs: plan §12 items 10-11, theory, technical overview, report; wording
  aligned with Gunning & Glinsky (2006): the tie posterior is not claimed as new.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-27 06:03:33 +00:00
parent a76e61398a
commit cee2ff0859
84 changed files with 8793 additions and 460 deletions

View File

@@ -1,14 +1,14 @@
"""Dựng bộ dữ liệu giếng F3 trong miền thời gian seismic.
"""Build the F3 well dataset in the seismic time domain.
python scripts/01_build_wells.py [--config configs/d1_f3.yaml]
Đầu ra (trong outputs/):
f3_wells.npz khóa phẳng "<giếng>/<mục>", không cần allow_pickle. Mọi chuỗi theo thời gian
nằm trên cửa sổ mở rộng `ext_window_ms`; `main_mask` đánh dấu cửa sổ chính:
Outputs (in outputs/):
f3_wells.npz flat keys "<well>/<item>", no allow_pickle needed. All time series lie on
the extended window `ext_window_ms`; `main_mask` marks the main window:
seismic_patch (C, L), times_ms (L,), main_mask (L,), il, xl, x, y,
anchors_md, anchors_twt_ms, tdr/<tên>/md, tdr/<tên>/twt_ms,
<tên TDR>/<curve> (L,), horizon/<tên> (TWT ms tại giếng)
f3_wells_summary.json vị trí giếng (thật và của luận văn), số anchor, độ phủ nhãn.
anchors_md, anchors_twt_ms, tdr/<name>/md, tdr/<name>/twt_ms,
<TDR name>/<curve> (L,), horizon/<name> (TWT ms at the well)
f3_wells_summary.json well locations (true and as used in the thesis), anchor counts, label coverage.
"""
from __future__ import annotations
@@ -43,7 +43,7 @@ def build_tdrs(well: Well, names: list[str]) -> dict[str, TDR]:
elif name == "wlt":
out[name] = TDR.from_pairs(load_td_source(well.name, "wlt"), "wlt", drop_flat=True)
else:
raise ValueError(f"TDR không hỗ trợ: {name}")
raise ValueError(f"unsupported TDR: {name}")
return out
@@ -64,7 +64,7 @@ def main() -> None:
main = (t_win >= t0) & (t_win <= t1)
for name in cfg["wells"]:
w = load_well(name)
# Nhãn hài hoà theo plan mục 1.2d / D-1: PHIE_DT = −0.2018 + 0.0011·DT cho cả 4 giếng.
# Harmonized label per plan §1.2d / D-1: PHIE_DT = −0.2018 + 0.0011·DT for all 4 wells.
w.logs["PHIE_DT"] = -0.2018 + 0.0011 * w.logs["DT"]
il, xl = geom.nearest_bin(w.x, w.y)
patch = cube.patch(il, xl, cfg["patch_radius"])[:, win]
@@ -101,10 +101,10 @@ def main() -> None:
info["legacy_offset_km"] = round(float(np.hypot(lx - w.x, ly - w.y)) / 1000, 2)
summary["wells"][name] = info
print(f"{name}: IL/XL {il}/{xl}"
+ (f" (luận văn {info['legacy_il_xl'][0]}/{info['legacy_il_xl'][1]}, lệch {info['legacy_offset_km']} km)"
+ (f" (thesis {info['legacy_il_xl'][0]}/{info['legacy_il_xl'][1]}, offset {info['legacy_offset_km']} km)"
if "legacy_il_xl" in info else "")
+ f", {info['n_anchors_in_window']} anchor trong cửa sổ, "
+ f"phủ PHIE (calibrated) {coverage.get('calibrated/PHIE', float('nan')):.0%}")
+ f", {info['n_anchors_in_window']} anchors in window, "
+ f"PHIE coverage (calibrated) {coverage.get('calibrated/PHIE', float('nan')):.0%}")
out = outputs_dir()
np.savez_compressed(out / "f3_wells.npz", **arrays)