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

14
configs/b2_smoke.yaml Normal file
View File

@@ -0,0 +1,14 @@
# B2 (CNN–GRU v2, pipeline đã sửa, loss gốc), chạy thử hạ tầng P0.
# KHÔNG phải kết quả baseline: protocol.yaml phải được commit trước khi chạy thật (plan mục 5.2).
dataset: f3_wells.npz
tdr: calibrated
label: PHIE
test_well: F06-1
val_well: F03-2
train_wells: [F03-4] # F02-1 có định nghĩa PHIE khác (plan mục 1.2d) nên không trộn ở đây
epochs: 100
lr: 5.0e-3
d_channels: 64
p_dropout: 0.05
grad_clip: 5.0
seed: 0

18
configs/d1_f3.yaml Normal file
View File

@@ -0,0 +1,18 @@
# D1: F3 Demo 2023, 4 giếng. Đường dẫn dữ liệu lấy từ ml_porosity/paths.py
# (mặc định data/F3_Demo_2023/F3_Demo_2023, đổi bằng biến ML_POROSITY_F3_ROOT).
wells: [F02-1, F03-2, F03-4, F06-1]
time_window_ms: [600, 1100] # cửa sổ chính; D-2 chưa chốt
ext_window_ms: [400, 1300] # cửa sổ lưu trữ (biên cho inversion B1 và synthetic)
patch_radius: 1 # 3×3 trace như luận văn
curves: [PHIE, PHIE_DT, DT, RHOB, GR, AI] # PHIE_DT = −0.2018 + 0.0011·DT (D-1)
# Các TDR được dựng cho mỗi giếng (xem ml_porosity/data/tdr.py):
# legacy tích phân DT từ mẫu LAS đầu, không hiệu chỉnh (cách của luận văn, chỉ để audit)
# calibrated marker-calibrated sonic: tham chiếu chấm điểm theo plan mục 5.2
# anchors nội suy tuyến tính giữa các cặp marker TD, không dùng DT của giếng
# wlt Depth2Time model của OpendTect (WellInfo/*.wlt), dùng cho phân tích độ nhạy
tdrs: [legacy, calibrated, anchors, wlt]
resample:
fine_dt_ms: 0.25
cutoff_frac: 0.8 # lọc thông thấp ở 0.8·Nyquist của lưới 4 ms (100 Hz)

41
configs/d3_volve.yaml Normal file
View File

@@ -0,0 +1,41 @@
# D3: Volve. Dữ liệu tải từ data village nằm ở data/Volve (ml_porosity.paths.volve_root, đổi bằng
# ML_POROSITY_VOLVE_ROOT); mọi đường dẫn dưới đây tính từ đó. Hash ở data_manifest/volve.json.
well_logs_dir: Well_logs_pr_WELL
# Stack ST10010 (time, Kirchhoff final, góc 3–41°), tải từ data village ngày 26/10/2026
cube: Seismic/ST10010/Stacks/ST10010ZC11_PZ_PSDM_KIRCH_FULL_T.MIG_FIN.POST_STACK.3D.JS-017536.segy
picks: Geophysical_Interpretations/Wells/Well_picks_Volve_v1.dat
horizons_twt: Geophysical_Interpretations/Horizons/Horizons_TWT
grid_horizon: Official_Horizons/Hugin_Fm_Top+ST10010ZC11_Near_190314+STAT+TIME.dat
# 9 giếng có PHIF và F-15 A (có VSP checkshot, không có PHIF)
wells: [NO 15/9-F-1, NO 15/9-F-1 A, NO 15/9-F-1 B, NO 15/9-F-1 C, NO 15/9-F-11 A, NO 15/9-F-11 B,
NO 15/9-F-11 T2, NO 15/9-F-12, NO 15/9-F-15 A, NO 15/9-F-15 D]
# Mặt pick ↔ horizon TWT để đối chiếu (BCU so với Draupne Fm. Top)
pick_horizons:
Utsira Fm. Top: Other_Horizons/Utsira_Top+ST10010_Pz_PSDM_Full+STAT+TIME.dat
Ty Fm. Top: Official_Horizons/Ty_Fm_Top+ST10010_Full+STAT+TIME.dat
SHETLAND GP. Top: Official_Horizons/SHETLAND_GP_Top+ST10010ZC11_Full+STAT+TIME.dat
Hod Fm. Top: Other_Horizons/Hod+ST10010_Pz-PSDM-Full+STAT+TIME.dat
Draupne Fm. Top: Official_Horizons/BCU+ST10010ZC11_Full+STAT+TIME.dat
Hugin Fm. VOLVE Top: Official_Horizons/Hugin_Fm_Top+ST10010ZC11_Near_190314+STAT+TIME.dat
Hugin Fm. VOLVE Base: Official_Horizons/Hugin_Fm_Base+ST10010ZC11_Near_190314+STAT+TIME.dat
# TWT của các pick nông không dùng làm anchor: cùng một MD (F-1 A/B/C dùng chung lỗ khoan) nhưng TWT
# lệch nhau ~110 ms, và ở F-11 T2 lệch checkshot ~100 ms.
anchor_exclude_surfaces: [Seabed, NORDLAND GP. Top, Utsira Fm. Top, HORDALAND GP. Top]
# NL (not logged): đoạn giếng không có log; 31/51 pick NL vẫn ghi TWT nhưng không kiểm chứng được.
# NR (not reached, ví dụ F-11 B đi ngang trong Hugin): điểm quay đầu của giếng, không nằm trên mặt phản xạ
# (lệch horizon ~−40 ms) và mỗi dòng bị lặp hai lần.
anchor_exclude_qlf: [NL, NR]
checkshots:
NO 15/9-F-11 T2:
NIVSP: 15_9-F-11 T2/08.VSP_VELOCITY/TZV_TIME_CHECKSHOT_1.ASC
RSVSP: 15_9-F-11 T2/08.VSP_VELOCITY/TZV_TIME_CHECKSHOT_2.ASC
OPTIMIZED: 15_9-F-11 T2/08.VSP_VELOCITY/TZV_TIME_CHECKSHOT_3.ASC
NO 15/9-F-15 A:
VSP: 15_9-F-15 A/08.VSP_VELOCITY/TZV_TIME_CHECKSHOT_1.ASC
# ROI từ quỹ đạo của 10 giếng trên + 500 m (inventory D3 mục 4), ED50 / UTM 31N
roi_xy: [433308, 437150, 6477323, 6479997]

2
configs/protocol.sha256 Normal file
View File

@@ -0,0 +1,2 @@
c1c771950538ed89fbb1e6c26fed31506b44999610dc0e79d027fa6e205aa962 configs/protocol.yaml
# v2 khoá lúc 2026-10-26T04:28:09Z, trước mọi lần chạy mô hình P1 (v1: a87ac336…, không có lần chạy nào)

73
configs/protocol.yaml Normal file
View File

@@ -0,0 +1,73 @@
# Giao thức đánh giá P1 (pre-registration, plan mục 3, 5.2–5.6).
# Khoá bằng SHA-256 trong configs/protocol.sha256 TRƯỚC khi chạy mô hình; scripts/05_lowo.py từ chối chạy
# nếu hash không khớp. Mọi thay đổi phải tạo phiên bản mới (version) và ghi lý do vào changelog.
version: 2
date: 2026-10-26
changelog:
- "v1: giao thức P1 cho baseline LOWO trên F3 (B0a, B0b, B1, B2, B3a, B3b)."
- "v2 (trước mọi lần chạy mô hình): B1 dùng nhánh explicit + epsI của PyLops (damping Tikhonov về LFM) thay vì epsR,
vì nhánh epsR chỉ dùng m0 làm điểm khởi đầu của lsqr nên kết quả phụ thuộc số vòng lặp. Wavelet B1 ước lượng
theo reflectivity của chính operator PyLops để nhất quán quy ước đạo hàm."
data:
dataset: D1 (F3 Demo 2023), outputs/f3_wells.npz từ scripts/01_build_wells.py với configs/d1_f3.yaml
wells: [F02-1, F03-2, F03-4, F06-1]
window_ms: [600, 1100] # 126 mẫu, 4 ms
seismic_input: patch 3x3 tại bin thật (plan mục 1.2a), z-score theo từng kênh trong từng giếng
labels:
primary: PHIE_DT # −0.2018 + 0.0011·DT, hài hoà 4 giếng (đề xuất D-1, chưa chốt)
secondary: PHIE # nhãn gốc; chỉ F02-1 khác PHIE_DT trong cửa sổ
units_reported: p.u. (×100)
registration:
train_labels: calibrated # marker-calibrated sonic; ngoại lệ: B3a dùng legacy (tích phân DT như luận văn)
evaluation_reference: calibrated
sensitivity_references: [wlt] # chấm lại bằng nhãn theo TD .wlt của OpendTect; không bao giờ chọn tham chiếu "tốt nhất"
split:
outer: LOWO, 4 fold (mỗi giếng làm test một lần)
inner: LOWO trên 3 giếng train để chọn siêu tham số đã liệt kê dưới đây (số epoch, α, e);
mô hình cuối huấn luyện lại trên cả 3 giếng train với lựa chọn đó
seeds: [0, 1, 2, 3, 4]
blind_rule: >
Giếng test chỉ đóng góp nhãn tham chiếu để chấm điểm. Không dùng DT, RHOB, PHIE, marker hay horizon-tie
của giếng test cho huấn luyện, tie, wavelet, LFM, siêu tham số, checkpoint hay shift hậu kiểm.
Seismic và horizon (diễn giải trên seismic) tại vị trí giếng test được phép dùng làm input.
methods:
B0a: {model: OLS, features: [TWT], note: "trend tuyến tính theo TWT"}
B0b:
features: [amplitude, envelope, cos_phase, sin_phase, inst_freq, relative_ai, TWT] # từ trace trung bình của patch
models:
ridge: {alpha_grid: [0.1, 1, 10, 100]}
rf: {n_estimators: 300, min_samples_leaf: 5}
gbm: {max_iter: 200, learning_rate: 0.05, max_depth: 3}
B1:
wavelet: least squares từ giếng train (calibrated), 128 ms, damping 0.05
lfm: log(AI) giếng train, lọc thông thấp 6 Hz, nội suy IDW (p = 2) theo toạ độ địa tầng từ horizon
[Shallow, FS8, FS7, Truncation, MFS4]
inversion: PyLops PoststackInversion(explicit=True, epsI) trên log(AI), cửa sổ 400–1300 ms;
epsI = e·trace(GᵀG)/n với e_grid [0.01, 0.03, 0.1, 0.3, 1.0]
porosity: OLS φ = a + b·AI trên giếng train (calibrated, cửa sổ chính)
B2: {backbone: CNN-GRU v2, loss: legacy_v2, optimizer: Adam, lr: 5.0e-3, max_epochs: 1200, eval_every: 25,
d_channels: 64, p_dropout: 0.05, grad_clip: 5.0, batch: "toàn bộ giếng train, chuỗi đầy đủ"}
B3a: {backbone: CNN-GRU v2 + head heteroscedastic (softplus), loss: Gaussian NLL, train_labels: legacy,
optimizer: Adam, lr: 5.0e-3, max_epochs: 1200, eval_every: 25}
B3b: {as: B3a, train_labels: calibrated}
epoch_selection: epoch có MSE validation trung bình (nhãn gốc) nhỏ nhất trên vòng inner
metrics:
accuracy: [MAE, RMSE, PCC, R2, std_ratio, skill_vs_B0a] # skill = 1 − MSE/MSE_B0a
bands: {f_c_hz: 6, filter: "Butterworth bậc 4 pha không", report: [PCC, RMSE, std_ratio]}
calibration: [NLL, CRPS, coverage_50, coverage_80, coverage_90, coverage_95] # chỉ B3
reporting: từng giếng rồi macro-average; mean ± sd theo seed; không p-value trên từng time sample
best_shift: chỉ là chẩn đoán, bảng riêng
gates:
G-A: >
Baseline tái lập được (5 seed, có phương sai); đã ước lượng misregistration còn lại. Nếu sau tie tốt nhất
misregistration còn < 1/8 chu kỳ trội (≈ 2.5 ms ở 50 Hz) ở mọi giếng VÀ B3a ≈ B3b (|ΔRMSE| < 5% và
|ΔPCC| < 0.05, macro) thì dồn trọng tâm sang D2 + D3.
G-B: "M2 hơn B3/B4 tốt nhất: RMSE băng seismic −10% hoặc PCC băng +0.05 ở ≥ 4/5 seed và đa số realization; không kém hơn 2% khi drift = 0."
G-C: "Chiều cải thiện nhất quán với synthetic ở ≥ 3/4 giếng; coverage 80/90% trong ±5% mức danh nghĩa."
G-D: "Báo cáo kết quả bất kể chiều nào; giới hạn phạm vi claim theo kết quả."