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,6 +1,6 @@
"""Wavelet: Ricker, wavelet thống kê pha không, xoay pha hằng và ước lượng từ giếng.
"""Wavelets: Ricker, zero-phase statistical wavelet, constant phase rotation, and well-based estimation.
Mọi wavelet có số mẫu lẻ, tâm ở giữa, bước `dt_ms`.
All wavelets have an odd number of samples, are centred, and are sampled at `dt_ms`.
"""
from __future__ import annotations
@@ -18,15 +18,15 @@ def ricker(f_peak_hz: float, dt_ms: float = 4.0, length_ms: float = 128.0) -> np
def rotate_phase(w: np.ndarray, phase_deg: float) -> np.ndarray:
"""Xoay pha hằng: w·cos φ − H[w]·sin φ (H: biến đổi Hilbert)."""
"""Constant phase rotation: w·cos φ − H[w]·sin φ (H: Hilbert transform)."""
h = np.imag(signal.hilbert(w))
p = np.deg2rad(phase_deg)
return w * np.cos(p) - h * np.sin(p)
def statistical_wavelet(traces: np.ndarray, dt_ms: float = 4.0, length_ms: float = 128.0) -> np.ndarray:
"""Wavelet pha không có phổ biên độ bằng trung bình phổ của các trace (taper Hann),
chuẩn hoá đỉnh = 1."""
"""Zero-phase wavelet whose amplitude spectrum equals the mean spectrum of the traces
(Hann taper), normalised to unit peak."""
traces = np.atleast_2d(traces)
nt = traces.shape[1]
nfft = int(2 ** np.ceil(np.log2(4 * nt)))
@@ -45,10 +45,10 @@ def estimate_wavelet_ls(
length_ms: float = 128.0,
damping: float = 0.05,
) -> np.ndarray:
"""Wavelet (biên độ theo đơn vị seismic) cực tiểu Σ‖s − w∗r‖² + ε‖w‖² trên nhiều giếng.
"""Wavelet (amplitude in seismic units) minimising Σ‖s − w∗r‖² + ε‖w‖² over multiple wells.
Hệ chuẩn tắc dạng Toeplitz từ tự tương quan của r và tương quan chéo r–s; ε tính tương đối
theo đường chéo. Chuỗi phải hữu hạn và cùng độ dài theo từng cặp."""
Toeplitz normal equations built from the autocorrelation of r and the r–s cross-correlation;
ε is relative to the diagonal. Series must be finite and pairwise of equal length."""
n = int(round(length_ms / dt_ms)) // 2
m = 2 * n + 1
R = np.zeros(m)