held_reading_mask

petrophys.preprocessing.quality.held_reading_mask

Also available as petrophys.preprocessing.held_reading_mask

held_reading_mask(values, *, min_run=10, tolerance=0.0)[source]

Flag samples that repeat the reading above them in a long run.

A run is a sequence of consecutive finite samples whose values agree within tolerance. In every run of at least min_run samples, all samples after the first are flagged. The first sample is the reading being repeated and is kept (at the bottom of a logging run it is the deepest real measurement). Missing values break a run.

Parameters:
  • values (array-like or Curve) – One log curve, in any unit.

  • min_run (int, default 10) – Minimum run length, in samples, counting the first sample. Short repeats are common in quantized or resampled curves; lower this only after looking at the curve.

  • tolerance (float, default 0.0) – Largest absolute difference, in the curve’s unit, still treated as a repeat. The default requires an exact repeat.

Returns:

True where a sample repeats the one above inside a long run.

Return type:

ndarray of bool

Raises:

ValueError – If min_run is not an integer of at least 2 or tolerance is negative.

Examples

>>> import numpy as np
>>> gr = np.array([61.2, 63.8, 80.19, 80.19, 80.19, 80.19, 0.0, 0.0])
>>> held_reading_mask(gr, min_run=3).astype(int).tolist()
[0, 0, 0, 1, 1, 1, 0, 0]