- 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>
86 lines
3.9 KiB
Python
86 lines
3.9 KiB
Python
import numpy as np
|
|
import pytest
|
|
import yaml
|
|
|
|
from ml_porosity.data.geometry import SurveyGeometry
|
|
from ml_porosity.data.seismic_io import SeismicCube
|
|
from ml_porosity.data.volve_io import VOLVE_KEY_WELLS, read_checkshot, read_horizon, read_well_picks
|
|
from ml_porosity.paths import REPO_ROOT, volve_root
|
|
|
|
GI = volve_root() / "Geophysical_Interpretations"
|
|
HUGIN = GI / "Horizons/Horizons_TWT/Official_Horizons/Hugin_Fm_Top+ST10010ZC11_Near_190314+STAT+TIME.dat"
|
|
PICKS = GI / "Wells/Well_picks_Volve_v1.dat"
|
|
CFG = yaml.safe_load((REPO_ROOT / "configs/d3_volve.yaml").read_text())
|
|
VSP = volve_root() / CFG["well_logs_dir"]
|
|
CUBE = volve_root() / CFG["cube"]
|
|
pytestmark = pytest.mark.skipif(not GI.exists(), reason="missing data/Volve/Geophysical_Interpretations")
|
|
|
|
|
|
@pytest.fixture(scope="module")
|
|
def hugin():
|
|
return read_horizon(HUGIN)
|
|
|
|
|
|
@pytest.fixture(scope="module")
|
|
def picks():
|
|
return read_well_picks(PICKS)
|
|
|
|
|
|
def test_from_points_recovers_affine():
|
|
g0 = SurveyGeometry((1000.0, 3.0, -12.0), (5000.0, 12.0, 3.0), (0, 0, 1), (0, 0, 1), (0, 0, 0))
|
|
il, xl = np.meshgrid(np.arange(10, 20), np.arange(100, 130, 2))
|
|
g = SurveyGeometry.from_points(il, xl, *g0.bin_to_xy(il, xl))
|
|
assert g.x_coef == pytest.approx(g0.x_coef) and g.y_coef == pytest.approx(g0.y_coef)
|
|
assert g.il_range == (10, 19, 1) and g.xl_range == (100, 128, 2)
|
|
|
|
|
|
def test_horizon_grid_is_st10010(hugin):
|
|
assert hugin.survey == "ST10010" and hugin.domain == "TIME"
|
|
g = hugin.geometry()
|
|
assert g.bin_spacing() == pytest.approx((12.5, 12.5), abs=1e-3)
|
|
x, y = g.bin_to_xy(hugin.il, hugin.xl)
|
|
assert np.hypot(x - hugin.x, y - hugin.y).max() < 0.05
|
|
i = len(hugin.z) // 2
|
|
assert hugin.at(hugin.il[i], hugin.xl[i], radius=0) == pytest.approx(hugin.z[i])
|
|
assert np.isnan(hugin.at(0, 0))
|
|
|
|
|
|
def test_well_picks(picks):
|
|
assert len(picks) == 409 and picks.well.nunique() == 35
|
|
assert set(VOLVE_KEY_WELLS) <= set(picks.well)
|
|
assert picks.twt_ms.notna().sum() > 300
|
|
deep = picks[picks.well.isin(VOLVE_KEY_WELLS) & picks.twt_ms.between(2280, 2900) & ~picks.qlf.isin(["NL", "NR"])]
|
|
assert deep.groupby("well").md.nunique().min() >= 6
|
|
|
|
|
|
@pytest.mark.skipif(not VSP.exists(), reason="missing data/Volve/Well_logs_pr_WELL")
|
|
def test_checkshot_md_reference(picks):
|
|
"""F-15 A: the checkshot records MD from MSL and the picks take their TWT from this same checkshot, so they match to 0 ms once MD is referenced to RKB."""
|
|
cs = read_checkshot(VSP / "15_9-F-15 A/08.VSP_VELOCITY/TZV_TIME_CHECKSHOT_1.ASC")
|
|
p = picks[(picks.well == "NO 15/9-F-15 A") & picks.twt_ms.notna() & picks.md.between(cs.md.min(), cs.md.max())]
|
|
assert len(p) >= 5
|
|
assert np.abs(p.twt_ms - np.interp(p.md, cs.md, cs.twt_ms)).max() < 0.5
|
|
|
|
|
|
@pytest.mark.skipif(not VSP.exists(), reason="missing data/Volve/Well_logs_pr_WELL")
|
|
def test_f11t2_picks_vs_nivsp(picks):
|
|
cs = read_checkshot(VSP / "15_9-F-11 T2/08.VSP_VELOCITY/TZV_TIME_CHECKSHOT_1.ASC")
|
|
p = picks[(picks.well == "NO 15/9-F-11 T2") & picks.twt_ms.notna() & picks.md.between(cs.md.min(), cs.md.max())]
|
|
assert len(p) >= 5
|
|
assert np.abs(p.twt_ms - np.interp(p.md, cs.md, cs.twt_ms)).max() < 7
|
|
|
|
|
|
@pytest.mark.skipif(not CUBE.exists(), reason="missing ST10010 cube")
|
|
def test_volve_cube(hugin):
|
|
"""Byte 215 = 3 is not a valid time scalar; segyio still multiplies delrt by it, giving t0 = 12 ms instead of the correct
|
|
4 ms (EBCDIC C11). The cube lacks 26 edge traces, so it must be read via the IL/XL table from the headers."""
|
|
with SeismicCube(CUBE) as c:
|
|
assert (c.times_ms[0], c.times_ms[-1], c.dt_ms) == (4.0, 3400.0, 4.0)
|
|
assert (c.ilines[0], c.ilines[-1], c.xlines[0], c.xlines[-1]) == (9961, 10361, 1961, 2680)
|
|
with pytest.raises(KeyError):
|
|
c.trace(9961, 1961)
|
|
assert c.trace(10150, 2250).shape == (850,)
|
|
x, y = c.coords(10150, 2250)
|
|
gx, gy = hugin.geometry().bin_to_xy(10150, 2250)
|
|
assert np.hypot(x - gx, y - gy) < 0.5
|