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,11 +1,11 @@
"""QC dữ liệu minh giải Volve (Geophysical_Interpretations) trước khi có cube.
"""QC of the Volve interpretation data (Geophysical_Interpretations) before the cube is available.
python scripts/07_volve_interp_qc.py
Kiểm tra: lưới các horizon, số anchor TWT của well picks tại 10 giếng D3 (9 giếng PHIF và F-15 A), độ lệch pick − horizon
tại toạ độ pick, độ lệch pick − checkshot (F-11 T2, F-15 A), ROI theo IL/XL của lưới ST10010; nếu đã có cube:
toạ độ header so với lưới horizon, và lag của cực trị biên độ trung bình dọc mỗi horizon (≈ 0 nếu trục thời gian đúng).
Đầu ra: outputs/volve/{horizons,anchors,pick_vs_horizon,pick_vs_checkshot,horizon_lag}.csv, summary.json
Checks: horizon grids, number of TWT anchors from the well picks at the 10 D3 wells (9 PHIF wells and F-15 A), pick − horizon
offset at the pick coordinates, pick − checkshot offset (F-11 T2, F-15 A), ROI in IL/XL of the ST10010 grid; if the cube is present:
header coordinates vs the horizon grid, and the lag of the mean-amplitude extremum along each horizon (≈ 0 if the time axis is correct).
Outputs: outputs/volve/{horizons,anchors,pick_vs_horizon,pick_vs_checkshot,horizon_lag}.csv, summary.json
"""
from __future__ import annotations
@@ -28,7 +28,7 @@ def main() -> None:
hdir = root / cfg["horizons_twt"]
summary = {}
# lưới horizon
# horizon grids
rows, hors = [], {}
for f in sorted(hdir.parent.rglob("*.dat")):
h = read_horizon(f)
@@ -46,7 +46,7 @@ def main() -> None:
summary["grid"] = {"x_coef": geom.x_coef, "y_coef": geom.y_coef, "bin_m": geom.bin_spacing(),
"max_affine_residual_m_all_horizons": float(H.affine_res_m.max())}
# anchor TWT tại giếng chính
# TWT anchors at the main wells
P = read_well_picks(root / cfg["picks"])
P["il"], P["xl"] = geom.xy_to_bin(P.x, P.y)
ok = (P.twt_ms.notna() & ~P.qlf.isin(cfg["anchor_exclude_qlf"])
@@ -60,12 +60,12 @@ def main() -> None:
"n_faulted": int((a.qlf == "FP").sum())}
summary["anchors"] = per_well
# TWT nông: cùng MD, khác nhánh khoan
# shallow TWT: same MD, different well branches
sh = P[P.surface.isin(["Utsira Fm. Top", "HORDALAND GP. Top"]) & P.twt_ms.notna()]
summary["shallow_twt_spread_ms"] = {s: [float(g.twt_ms.min()), float(g.twt_ms.max())]
for s, g in sh.groupby("surface")}
# pick − horizon tại toạ độ pick
# pick − horizon at the pick coordinates
C = []
for s, f in cfg["pick_horizons"].items():
h = hors[f"{hdir.name}/{f}"]
@@ -81,7 +81,7 @@ def main() -> None:
s: {"n": len(g), "median": round(float(g.d_ms.median()), 1), "mad": round(float((g.d_ms - g.d_ms.median()).abs().median()), 1),
"max_abs": round(float(g.d_ms.abs().max()), 1)} for s, g in clean.groupby("surface")}
# pick − checkshot (theo TVDSS để không phụ thuộc mốc MD)
# pick − checkshot (in TVDSS, independent of the MD datum)
D = []
for w, files in cfg["checkshots"].items():
p = P[(P.well == w) & P.twt_ms.notna()]
@@ -98,14 +98,14 @@ def main() -> None:
summary["pick_minus_checkshot_ms"] = {f"{w} {k}": [round(float(g.d_tvd_ms.min()), 1), round(float(g.d_tvd_ms.max()), 1)]
for (w, k), g in deep.groupby(["well", "checkshot"])}
# ROI theo IL/XL
# ROI in IL/XL
x0, x1, y0, y1 = cfg["roi_xy"]
il, xl = geom.xy_to_bin([x0, x1, x1, x0], [y0, y0, y1, y1])
summary["roi_ilxl"] = {"il": [int(np.floor(il.min())), int(np.ceil(il.max()))],
"xl": [int(np.floor(xl.min())), int(np.ceil(xl.max()))]}
summary["anchor_twt_range_ms"] = [float(A.twt_ms.min()), float(A.twt_ms.max())]
# cube: header so với lưới horizon; horizon pick trên peak/trough nên cực trị phải ở lag ≈ 0
# cube: header vs horizon grid; horizons are picked on peaks/troughs, so the extremum should be at lag ≈ 0
cube_path = root / cfg["cube"]
if cube_path.exists():
(i0, i1), (j0, j1) = summary["roi_ilxl"]["il"], summary["roi_ilxl"]["xl"]