NMRData

petrophys.interpretation.nmr.NMRData

class NMRData(
depth,
mphi,
mffi=None,
mbvi=None,
bins=None,
t2lm_stored=None,
t2_cutoff_curve=None,
t2_centers=<factory>,
t2_cutoff=33.0,
stored_permeability=<factory>,
extra_curves=<factory>,
metadata=<factory>,
)[source]

NMR log data container.

Parameters:
  • depth (np.ndarray) – Measured depth (ft or m).

  • mphi (np.ndarray) – Total NMR porosity — sum of all T2 bins (porosity units, pu).

  • mffi (np.ndarray, optional) – Free Fluid Index (pu). If absent, computed from bins.

  • mbvi (np.ndarray, optional) – Bulk Volume Irreducible (pu). If absent, computed from bins.

  • bins (np.ndarray, optional) – Shape (n_depth, n_bins) — porosity contribution (pu) per T2 bin.

  • t2lm_stored (np.ndarray, optional) – Pre-computed T2 log mean (ms) loaded directly from the LAS file. Used by t2_lm() when bin data are not available.

  • t2_cutoff_curve (np.ndarray, optional) – T2 cutoff at each depth (ms). When set, the bin-based BVI and FFI use it in place of t2_cutoff unless a cutoff is passed to them.

  • t2_centers (np.ndarray) – T2 bin centre times (ms). Default: [4, 8, 16, 32, 64, 128, 256, 512] ms.

  • t2_cutoff (float) – T2 cutoff separating MBVI from MFFI (ms). Default: 33 ms.

  • stored_permeability (dict, optional) – Permeability curves delivered with the log (mD), keyed "KSDR" and "KTIM". permeability_sdr() and permeability_coates() return them when called with their default coefficients and prefer_stored.

  • extra_curves (dict, optional) – Other curves of the source file, by mnemonic, one value per depth; kept with the data and included in its table.

  • metadata (dict) – Source file info, well name, etc.

Examples

>>> import petrophys
>>> nmr = NMRData.from_las(petrophys.sample("daydream1_cmr"),
...                        mphi_mnemonic="TCMR", mffi_mnemonic="CMFF")
>>> k_tc  = nmr.permeability_coates()

This scalar CMR sample has no T2 bins or T2LM curve. Coates permeability can use its free/bound-fluid volumes, but T2 log mean and SDR cannot be reconstructed from them. With a different file containing T2 data, check nmr.has_t2lm before calling t2_lm() or permeability_sdr().

Attributes

Methods

bin_cumulative

Cumulative T2 distribution per depth, normalised to the sum of the bins.

bvi_from_bins

Bulk Volume Irreducible from T2 bins (the bins below the cutoff).

calibrate_coates

Calibrate Timur-Coates parameters against core permeability.

calibrate_sdr

Calibrate the SDR constant c against core permeability.

ffi_from_bins

Free Fluid Index from T2 bins (the bins above the cutoff).

filter_by_depth

Return a new NMRData filtered to [top, bottom].

from_cmr_las

Load a processed Schlumberger CMR LAS summary log.

from_csv

Load NMR data from a CSV file.

from_dataframe

Create NMRData from a pandas DataFrame.

from_las

Load NMR data from a LAS file.

permeability_coates

Timur-Coates NMR permeability.

permeability_sdr

SDR (Schlumberger-Doll Research) NMR permeability.

pore_size

Estimate a characteristic pore body radius from T2lm.

swirr_nmr

NMR irreducible water saturation: MBVI / MPHI.

t2_distribution

Return (t2_centers, bin_porosities) at one depth index.

t2_lm

Logarithmic mean T2 (T2lm) in ms.

to_dataframe

Export to a pandas DataFrame.

depth: ndarray
mphi: ndarray
mffi: ndarray | None = None
mbvi: ndarray | None = None
bins: ndarray | None = None
t2lm_stored: ndarray | None = None
t2_cutoff_curve: ndarray | None = None
t2_centers: ndarray
t2_cutoff: float = 33.0
stored_permeability: Dict[str, ndarray]
extra_curves: Dict[str, ndarray]
metadata: Dict[str, Any]
property n_samples: int
property n_bins: int
property top: float | None
property bottom: float | None
property has_bins: bool
property has_t2lm: bool

True if T2lm is available either from bins or a stored curve.

classmethod from_csv(
filepath,
depth_col='Depth',
mphi_col='MPHI',
mffi_col='MFFI',
mbvi_col='MBVI',
bin_cols=None,
t2lm_col=None,
t2_centers=None,
t2_cutoff=T2_CUTOFF_CLASTIC,
null_value=-999.25,
porosity_unit=None,
**read_csv_kwargs,
)[source]

Load NMR data from a CSV file.

Default column layout matches the standard MRIL-style CSV export:

Depth, MPHI, P1, P2, P3, P4, P5, P6, P7, P8, MFFI, MBVI
Parameters:
  • filepath (str or Path)

  • depth_col (str)

  • mphi_col (str)

  • mffi_col (str, optional)

  • mbvi_col (str, optional)

  • bin_cols (list of str, optional) – T2 bin columns in T2-ascending order. Default: [“P1”…”P8”] when present.

  • t2lm_col (str, optional) – Column containing a pre-computed T2 log mean (ms).

  • t2_centers (np.ndarray, optional) – T2 bin centre values (ms).

  • t2_cutoff (float)

  • null_value (float)

  • porosity_unit ({"v/v", "pu"}, optional) – Unit of the porosity columns; see from_dataframe().

Return type:

NMRData

classmethod from_dataframe(
df,
depth_col='Depth',
mphi_col='MPHI',
mffi_col='MFFI',
mbvi_col='MBVI',
bin_cols=None,
t2lm_col=None,
t2_centers=None,
t2_cutoff=T2_CUTOFF_CLASTIC,
null_value=-999.25,
porosity_unit=None,
)[source]

Create NMRData from a pandas DataFrame.

Column names match without regard to case. The NMR calculations take porosity in porosity units (pu, percent): porosity_unit="v/v" multiplies the porosity and bin columns by 100, "pu" keeps them. Unset, a total porosity of at most 1.5 everywhere is read as v/v and converted, with a warning.

Parameters:
Return type:

NMRData

classmethod from_las(
filepath,
mphi_mnemonic='MPHI',
mffi_mnemonic='MFFI',
mbvi_mnemonic='MBVI',
t2lm_mnemonic='T2LM',
t2_cutoff_mnemonic='T2CUTOFF',
ksdr_mnemonic='KSDR',
ktim_mnemonic='KTIM',
bin_mnemonics=None,
t2_centers=None,
t2_cutoff=None,
null_value=-999.25,
derive_mbvi=True,
)[source]

Load NMR data from a LAS file.

Depth is read via lasio’s las.index property, which always returns the first column regardless of its mnemonic name.

Parameters:
  • filepath (str or Path)

  • mphi_mnemonic (str)

  • mffi_mnemonic (str, optional)

  • mbvi_mnemonic (str, optional)

  • t2lm_mnemonic (str, optional) – Mnemonic for a pre-computed T2 log mean curve (e.g. "T2LM" from Halliburton MRIL output). Used when bin curves are absent.

  • t2_cutoff_mnemonic (str, optional) – Mnemonic of a T2 cutoff curve (ms); None reads no such curve.

  • ksdr_mnemonic (str, optional) – Mnemonics of delivered SDR and Timur-Coates permeability curves (mD), kept in stored_permeability; None reads no such curve.

  • ktim_mnemonic (str, optional) – Mnemonics of delivered SDR and Timur-Coates permeability curves (mD), kept in stored_permeability; None reads no such curve.

  • bin_mnemonics (list of str, optional) – Ordered T2 bin curve mnemonics (e.g. ["T2B01",…,"T2B08"]).

  • t2_centers (np.ndarray, optional)

  • t2_cutoff (float, optional) – T2 cutoff, ms. Set, it is used at every depth and a T2CUTOFF curve in the file is kept as an extra curve only. Default: the T2CUTOFF curve where the file has one (its median as the scalar cutoff), else 33 ms (clastic).

  • null_value (float)

  • derive_mbvi (bool, default True) – When the file has no bound-fluid curve but has a free-fluid curve, take MBVI as MPHI - MFFI (NaN where that is negative). False leaves MBVI unset.

Return type:

NMRData

classmethod from_cmr_las(filepath, **kwargs)[source]

Load a processed Schlumberger CMR LAS summary log.

Parameters:

filepath (str | Path)

Return type:

NMRData

t2_lm(min_bin_coverage=1.0)[source]

Logarithmic mean T2 (T2lm) in ms.

Computed from T2 bins when available (preferred); falls back to the t2lm_stored curve loaded from LAS. Raises ValueError if neither is present.

\[T2_{lm} = \exp\!\left( \frac{\sum_i \phi_i \ln T2_i}{\sum_i \phi_i} \right)\]
Parameters:

min_bin_coverage (float)

Return type:

ndarray

bvi_from_bins(cutoff_ms=None, min_bin_coverage=1.0, partial_bins=True)[source]

Bulk Volume Irreducible from T2 bins (the bins below the cutoff).

The bin that straddles the cutoff counts with the part of its log-T2 width below it (t2_fraction_below_cutoff).

Parameters:
  • cutoff_ms (float, optional) – T2 cutoff (ms). Defaults to self.t2_cutoff.

  • min_bin_coverage (float) – Share of the summed bins that must have a value at a depth, 0 to 1 (default 1: all of them); below it the result is NaN there.

  • partial_bins (bool) – False counts whole bins with centre < cutoff, the split some vendor summaries use.

Return type:

ndarray

ffi_from_bins(cutoff_ms=None, min_bin_coverage=1.0, partial_bins=True)[source]

Free Fluid Index from T2 bins (the bins above the cutoff).

The complement of bvi_from_bins(); partial_bins=False counts whole bins with centre >= cutoff.

Parameters:
  • cutoff_ms (float, optional) – T2 cutoff (ms). Defaults to self.t2_cutoff.

  • min_bin_coverage (float) – Share of the summed bins that must have a value at a depth, 0 to 1 (default 1: all of them); below it the result is NaN there.

  • partial_bins (bool) – False counts whole bins with centre >= cutoff.

Return type:

ndarray

t2_distribution(depth_index)[source]

Return (t2_centers, bin_porosities) at one depth index.

Parameters:

depth_index (int)

Return type:

Tuple[ndarray, ndarray]

permeability_sdr(c=None, calibration=None, prefer_stored=True)[source]

SDR (Schlumberger-Doll Research) NMR permeability.

\[k_{SDR} = C \cdot \phi_{NMR}^{4} \cdot T2_{lm}^{2}\]

where φ is in fraction (0–1) and T2lm in ms.

Parameters:
  • c (float, optional) – Empirical constant in mD/ms² (default 4.0, the value commonly used for sandstones). Ignored when calibration is supplied.

  • calibration (NMRCalibration, optional) – Result of calibrate_sdr(). When provided, the fitted constant overrides c.

  • prefer_stored (bool) – Return the stored vendor KSDR curve, when one was loaded, instead of computing it. Applies only when neither c nor calibration is given.

Returns:

Permeability (mD).

Return type:

np.ndarray

permeability_coates(
c=None,
a=None,
b=None,
calibration=None,
prefer_stored=True,
)[source]

Timur-Coates NMR permeability.

\[k_{TC} = \left(\frac{\phi_{NMR}}{C}\right)^{a} \cdot \left(\frac{FFI}{BVI}\right)^{b}\]
Parameters:
  • c (float, optional) – Coates parameters (defaults 10, 4, 2). Ignored when calibration is supplied.

  • a (float, optional) – Coates parameters (defaults 10, 4, 2). Ignored when calibration is supplied.

  • b (float, optional) – Coates parameters (defaults 10, 4, 2). Ignored when calibration is supplied.

  • calibration (NMRCalibration, optional) – Result of calibrate_coates(). When provided, fitted parameters override c, a, b.

  • prefer_stored (bool) – Return the stored vendor KTIM curve, when one was loaded, instead of computing it. Applies only when none of c, a, b or calibration is given.

Returns:

Permeability (mD). NaN where BVI = 0.

Return type:

np.ndarray

calibrate_sdr(core_depth, core_perm)[source]

Calibrate the SDR constant c against core permeability.

Finds c that minimises the mean squared error between log10(k_SDR) and log10(k_core). The empirical porosity and T2lm exponents stay at 4 and 2.

Parameters:
  • core_depth (array-like) – Depths of core plug measurements (same units as self.depth).

  • core_perm (array-like) – Core air/Klinkenberg permeability (mD).

Return type:

NMRCalibration

calibrate_coates(core_depth, core_perm, fit_exponents=False)[source]

Calibrate Timur-Coates parameters against core permeability.

Parameters:
  • core_depth (array-like)

  • core_perm (array-like) – Core permeability (mD).

  • fit_exponents (bool) – If False (default), only c is fitted (a=4, b=2 fixed). If True, a, b, and c are all fitted via linear regression in log space.

Return type:

NMRCalibration

pore_size(surface_relaxivity=10.0, geometry='sphere')[source]

Estimate a characteristic pore body radius from T2lm.

\[r = F \cdot \rho_2 \cdot T2_{lm}\]

where F = 3 (sphere), 2 (cylinder), or 1 (slit), ρ₂ is surface relaxivity (µm/s), and T2lm is in s.

Parameters:
  • surface_relaxivity (float) – ρ₂ (µm/s). Typical: 10–30 µm/s clastics, 1–10 µm/s carbonates.

  • geometry ({"sphere", "cylinder", "slit"})

Returns:

Pore body radius (µm).

Return type:

np.ndarray

swirr_nmr()[source]

NMR irreducible water saturation: MBVI / MPHI.

Returns:

Swirr (0–1). NaN where MPHI = 0.

Return type:

np.ndarray

bin_cumulative()[source]

Cumulative T2 distribution per depth, normalised to the sum of the bins.

Returns:

Shape (n_depth, n_bins). Each row ends at 1 where the bins sum to more than 0; NaN bins are skipped (they add nothing); NaN rows where the depth has no bin data.

Return type:

np.ndarray

filter_by_depth(top, bottom)[source]

Return a new NMRData filtered to [top, bottom].

Parameters:
Return type:

NMRData

to_dataframe(include_derived=True)[source]

Export to a pandas DataFrame.

Parameters:

include_derived (bool) – When True, appends T2LM, K_SDR, K_COATES, PORE_R, and SWIRR columns (requires T2lm to be computable).

Return type:

DataFrame