- 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>
71 lines
2.6 KiB
Python
71 lines
2.6 KiB
Python
"""QC of the TD sources against the TD markers (draft of figure F2 and the tables in §1.2b–c).
|
||
|
||
python scripts/02_td_qc.py
|
||
|
||
Outputs: 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": "Integrated DT (thesis)",
|
||
"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())} anchors in window)", fontsize=10)
|
||
ax.set_xlabel("source TWT − marker TWT (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("Offset of the TD sources from the TD markers; yellow band: 600–1100 ms window", 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()
|