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,4 +1,4 @@
"""Attribute seismic cho B0b, tính trên trace đầy đủ (cửa sổ mở rộng) rồi mới cắt cửa sổ chính."""
"""Seismic attributes for B0b, computed on the full trace (extended window) before cropping to the main window."""
from __future__ import annotations
@@ -9,17 +9,17 @@ FEATURES = ("amplitude", "envelope", "cos_phase", "sin_phase", "inst_freq", "rel
def trace_attributes(trace: np.ndarray, times_ms: np.ndarray, dt_ms: float = 4.0) -> np.ndarray:
"""Ma trận (L, 7) theo thứ tự FEATURES."""
"""(L, 7) matrix in the order of FEATURES."""
s = np.asarray(trace, dtype=float)
a = signal.hilbert(s)
env = np.abs(a)
ph = np.unwrap(np.angle(a))
f_inst = np.gradient(ph) / (2 * np.pi * dt_ms / 1000.0)
# tần số tức thời trọng số theo envelope rồi làm trơn 5 mẫu để bớt gai
# envelope-weighted instantaneous frequency, smoothed over 5 samples to suppress spikes
k = np.ones(5)
f_inst = np.convolve(f_inst * env**2, k, "same") / (np.convolve(env**2, k, "same") + 1e-12)
f_inst = np.clip(f_inst, 0.0, 500.0 / dt_ms)
# relative AI: tích phân trace, bỏ xu hướng < 5 Hz
# relative AI: integrated trace with the < 5 Hz trend removed
rai = np.cumsum(s)
sos = signal.butter(4, 5.0, btype="highpass", fs=1000.0 / dt_ms, output="sos")
rai = signal.sosfiltfilt(sos, rai)