P0 + P1: ml_porosity package, audited F3 data, LOWO baselines, protocol v2

P0
- ml_porosity/: survey geometry, LAS/TDR/SEG-Y readers (4 ms delay fix,
  invalid time scalar, header LUT for incomplete cubes), anti-aliased
  log-to-time resampling, CNN-GRU v2 with the thesis loss, 41+ unit tests.
- Full F3 Demo 2023 under data/ (text well/fault files tracked, bulk data
  ignored); the filtered copy and its cleanup notes are removed.
- SHA-256 manifests for F3, Volve, NLOG and the thesis outputs.

P1
- configs/protocol.yaml v2, locked by SHA-256 at 2026-10-26T04:28:09Z,
  before the first LOWO run (04:30:50Z); 05_lowo.py refuses to run on a
  hash mismatch. This commit postdates the runs.
- Wavelet/synthetic tie QC, residual misregistration, LOWO 5 seeds for
  B0a, B0b, B1, B2, B3a, B3b (scripts 04-06); gate G-A: no pivot.
- Volve D3: horizons, well picks, checkshots and the ST10010 cube read
  from data/Volve (scripts/07).
- D-1 label check against measured NLOG density (scripts/08): PHIE_DT
  stays the primary label.
- docs/plan.md, Volve and NLOG inventories, report.html.

Full-text reference PDFs in refs/ stay local (ignored).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-26 08:41:11 +00:00
parent d11b7b1bb5
commit a76e61398a
163 changed files with 120177 additions and 2742 deletions

70
scripts/02_td_qc.py Normal file
View File

@@ -0,0 +1,70 @@
"""QC các nguồn TD so với marker TD (bản nháp hình F2 và bảng mục 1.2b–c).
python scripts/02_td_qc.py
Đầu ra: outputs/figures/td_drift.png, outputs/td_qc.csv
"""
from __future__ import annotations
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from ml_porosity.data.las_io import F3_WELLS, load_td_source, load_well
from ml_porosity.data.tdr import TDR, legacy_sonic_tdr, misfit_at_anchors
from ml_porosity.paths import outputs_dir
WINDOW_MS = (600.0, 1100.0)
SOURCES = {
"legacy": "Tích phân DT (luận văn)",
"wlt": "OpendTect .wlt",
"dt_model": "DT_model",
}
COLORS = {"legacy": "#c0392b", "wlt": "#1f5fbf", "dt_model": "#7a7a7a"}
def main() -> None:
rows = []
fig, axes = plt.subplots(1, len(F3_WELLS), figsize=(13, 4.8), sharey=True, constrained_layout=True)
for ax, name in zip(axes, F3_WELLS):
w = load_well(name)
cs = w.checkshot
tdrs = {
"legacy": legacy_sonic_tdr(w.md, w.curve("DT")),
"wlt": TDR.from_pairs(load_td_source(name, "wlt"), drop_flat=True),
"dt_model": TDR.from_pairs(load_td_source(name, "dt_model")),
}
inwin = cs.twt_ms.between(*WINDOW_MS).to_numpy()
for key, tdr in tdrs.items():
d = misfit_at_anchors(tdr, cs.md, cs.twt_ms)
ax.plot(d, cs.twt_ms, "o-", ms=3.5, lw=1.2, color=COLORS[key], label=SOURCES[key])
dw = d[inwin]
rows.append({
"well": name, "source": key, "n_anchors": int(inwin.sum()),
"min_ms": dw.min(), "max_ms": dw.max(), "span_ms": dw.max() - dw.min(),
"mean_ms": dw.mean(), "max_abs_ms": np.abs(dw).max(),
})
ax.axvline(0, color="k", lw=0.8)
ax.axhspan(*WINDOW_MS, color="#f0c040", alpha=0.15, lw=0)
ax.set_title(f"{name} ({int(inwin.sum())} anchor trong cửa sổ)", fontsize=10)
ax.set_xlabel("TWT nguồn − TWT marker (ms)")
ax.grid(alpha=0.3)
axes[0].set_ylabel("TWT marker (ms)")
axes[0].set_ylim(1300, 400)
fig.legend(*axes[0].get_legend_handles_labels(), loc="outside lower center", ncol=3, fontsize=9)
fig.suptitle("Lệch của các nguồn TD so với marker TD; dải vàng: cửa sổ 600–1100 ms", fontsize=11)
out = outputs_dir()
(out / "figures").mkdir(exist_ok=True)
fig.savefig(out / "figures" / "td_drift.png", dpi=150)
df = pd.DataFrame(rows).round(1)
df.to_csv(out / "td_qc.csv", index=False)
print(df.to_string(index=False))
if __name__ == "__main__":
main()