- 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>
47 lines
1.6 KiB
Python
47 lines
1.6 KiB
Python
import numpy as np
|
||
import pytest
|
||
import segyio
|
||
|
||
from ml_porosity.data.geometry import SurveyGeometry
|
||
from ml_porosity.data.seismic_io import SeismicCube
|
||
from ml_porosity.paths import f3_root, f3_segy
|
||
|
||
pytestmark = [
|
||
pytest.mark.data,
|
||
pytest.mark.skipif(not f3_segy().exists(), reason="missing F3_entire.segy"),
|
||
]
|
||
|
||
|
||
@pytest.fixture(scope="module")
|
||
def cube():
|
||
with SeismicCube() as c:
|
||
yield c
|
||
|
||
|
||
def test_axes(cube):
|
||
assert (cube.ilines[0], cube.ilines[-1], len(cube.ilines)) == (100, 750, 651)
|
||
assert (cube.xlines[0], cube.xlines[-1], len(cube.xlines)) == (300, 1250, 951)
|
||
# DelayRecordingTime = 4 ms: the first sample is at 4 ms, not 0
|
||
assert cube.times_ms[0] == 4.0 and cube.dt_ms == 4.0 and len(cube.times_ms) == 462
|
||
|
||
|
||
@pytest.mark.parametrize("il,xl", [(100, 300), (244, 387), (722, 848), (750, 1250)])
|
||
def test_trace_index_matches_headers(cube, il, xl):
|
||
idx = cube._index(il, xl)
|
||
h = cube._f.header[idx]
|
||
assert (h[segyio.TraceField.INLINE_3D], h[segyio.TraceField.CROSSLINE_3D]) == (il, xl)
|
||
# Header coordinates (scalar −100) match the .survey transform
|
||
geom = SurveyGeometry.from_survey(f3_root())
|
||
x, y = geom.bin_to_xy(il, xl)
|
||
assert h[segyio.TraceField.CDP_X] / 100 == pytest.approx(x, abs=0.5)
|
||
assert h[segyio.TraceField.CDP_Y] / 100 == pytest.approx(y, abs=0.5)
|
||
|
||
|
||
def test_patch(cube):
|
||
p = cube.patch(244, 387, 1)
|
||
assert p.shape == (9, 462)
|
||
np.testing.assert_array_equal(p[4], cube.trace(244, 387))
|
||
np.testing.assert_array_equal(p[0], cube.trace(243, 386))
|
||
with pytest.raises(KeyError):
|
||
cube.patch(100, 300, 1)
|