DigitalCoreFacies

petrophys.interpretation.core_analysis.DigitalCoreFacies

class DigitalCoreFacies(n_facies=12, n_init=20, max_iter=300, random_state=42)[source]

K-means facies classifier for multi-parameter core data.

Combines mechanical, geochemical, and textural measurements into discrete facies classes using standardized, weighted features.

Parameters:
  • n_facies (int) – Number of facies classes (K in K-means).

  • n_init (int) – Number of K-means initialisations (best inertia is kept).

  • max_iter (int) – Maximum K-means iterations per run.

  • random_state (int) – Random seed for reproducibility.

Examples

>>> clf = DigitalCoreFacies(n_facies=12)
>>> result = clf.fit(
...     depth=depth,
...     data={
...         "D50_um":   grain_size_d50,
...         "UCS_MPa":  ucs,
...         "Al_pct":   xrf.get("Al"),
...         "Ca_pct":   xrf.get("Ca"),
...     },
...     weights={"D50_um": 4, "Al_pct": 2},   # rest default to 1
... )
>>> stats = result.statistics(data)

Methods

fit

Fit K-means on depth-aligned core measurements and return facies labels.

from_las

Load a pre-computed facies log from a LAS file.

predict

Assign facies labels to new samples using the fitted model.

fit(depth, data, weights=None)[source]

Fit K-means on depth-aligned core measurements and return facies labels.

Samples where any feature is NaN are excluded from fitting and assigned facies label 0 (unknown) in the output.

Parameters:
  • depth (np.ndarray) – Depth array (same length as all arrays in data).

  • data (dict) – Feature name → depth-aligned array. All arrays must have the same length as depth.

  • weights (dict, optional) – Feature name → relative weight (positive float). Features not listed default to weight 1. Weights are applied by scaling each feature’s values by sqrt(weight) before clustering, so a weight of 4 gives a feature twice the influence of weight 1.

Return type:

FaciesResult

predict(data)[source]

Assign facies labels to new samples using the fitted model.

Parameters:

data (dict) – Same features as used in fit, in the same order.

Returns:

Facies labels (1-based; 0 = unknown / NaN input).

Return type:

np.ndarray of int

classmethod from_las(
filepath,
facies_mnemonic='FACIES',
null_value=-999.25,
**kwargs,
)[source]

Load a pre-computed facies log from a LAS file.

Depth is read via lasio’s las.index property. Use this when the facies were computed externally (e.g. by EpsLog) and you want to load them for analysis or plotting.

Returns:

A minimal FaciesResult with depth and facies arrays.

Return type:

FaciesResult

Parameters: