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

View File

@@ -0,0 +1,69 @@
"""Wavelet: Ricker, wavelet thống kê pha không, xoay pha hằng và ước lượng từ giếng.
Mọi wavelet có số mẫu lẻ, tâm ở giữa, bước `dt_ms`.
"""
from __future__ import annotations
import numpy as np
from scipy import signal
from scipy.linalg import toeplitz
def ricker(f_peak_hz: float, dt_ms: float = 4.0, length_ms: float = 128.0) -> np.ndarray:
n = int(round(length_ms / dt_ms)) // 2
t = np.arange(-n, n + 1) * dt_ms / 1000.0
a = (np.pi * f_peak_hz * t) ** 2
return (1 - 2 * a) * np.exp(-a)
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)."""
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."""
traces = np.atleast_2d(traces)
nt = traces.shape[1]
nfft = int(2 ** np.ceil(np.log2(4 * nt)))
spec = np.mean(np.abs(np.fft.rfft(traces * np.hanning(nt), nfft)), axis=0)
w = np.fft.fftshift(np.fft.irfft(spec, nfft))
n = int(round(length_ms / dt_ms)) // 2
c = nfft // 2
w = w[c - n : c + n + 1] * np.hanning(2 * n + 1)
return w / np.max(np.abs(w))
def estimate_wavelet_ls(
reflectivity: list[np.ndarray],
seismic: list[np.ndarray],
dt_ms: float = 4.0,
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.
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."""
n = int(round(length_ms / dt_ms)) // 2
m = 2 * n + 1
R = np.zeros(m)
g = np.zeros(m)
for r, s in zip(reflectivity, seismic):
L = len(r)
acf = np.correlate(r, r, mode="full")[L - 1 : L - 1 + m]
R += acf
ccf = np.correlate(s, r, mode="full") # ccf[L-1+k] = Σ s[i+k] r[i]
g += ccf[L - 1 - n : L + n]
A = toeplitz(R)
A[np.diag_indices(m)] += damping * R[0]
w = np.linalg.solve(A, g)
return w * np.hanning(m + 2)[1:-1]
def convolve_same(r: np.ndarray, w: np.ndarray) -> np.ndarray:
return np.convolve(r, w, mode="same")