Files
ML-Porosity/ml_porosity/data/horizons.py
lamlvh a76e61398a 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>
2026-10-26 08:41:11 +00:00

41 lines
1.5 KiB
Python

"""Horizon F3 dạng ASCII (X, Y, TWT ms) trong Rawdata/Surface_data/."""
from __future__ import annotations
from pathlib import Path
import numpy as np
from ml_porosity.data.geometry import SurveyGeometry
from ml_porosity.paths import f3_root
# Thứ tự từ nông đến sâu tại khu vực giếng.
F3_HORIZONS = ("Shallow", "FS8", "FS7", "Truncation", "Top-Foresets", "FS6", "MFS4")
def horizon_path(name: str) -> Path:
return f3_root() / "Rawdata" / "Surface_data" / f"F3-Horizon-{name}.txt"
def load_horizon_bins(name: str, geom: SurveyGeometry) -> dict[tuple[int, int], float]:
"""Ánh xạ (IL, XL) → TWT (ms). Mỗi dòng XY được gán về bin gần nhất."""
a = np.loadtxt(horizon_path(name))
il, xl = geom.xy_to_bin(a[:, 0], a[:, 1])
il, xl = np.rint(il).astype(int), np.rint(xl).astype(int)
return {(i, j): t for i, j, t in zip(il, xl, a[:, 2])}
def horizon_at(name: str, geom: SurveyGeometry, bins: list[tuple[int, int]], radius: int = 2) -> np.ndarray:
"""TWT của horizon tại từng bin; nếu bin không có pick thì lấy trung bình các pick trong
ô (2r+1)², NaN nếu ô cũng trống."""
h = load_horizon_bins(name, geom)
out = []
for il, xl in bins:
if (il, xl) in h:
out.append(h[(il, xl)])
continue
vals = [h[(il + a, xl + b)] for a in range(-radius, radius + 1)
for b in range(-radius, radius + 1) if (il + a, xl + b) in h]
out.append(float(np.mean(vals)) if vals else np.nan)
return np.asarray(out)