flag_intervals

petrophys.evaluation.intervals.flag_intervals

flag_intervals(flag, depth, *, max_gap=None, min_thickness=0.0)[source]

List the depth intervals where a flag is set.

Consecutive flagged samples form one interval. Each interval spans the full cells of its samples: from halfway to the sample above the first flagged sample to halfway to the sample below the last (next to a data gap, the half step on the other side), so a single flagged sample has the thickness of one sample step, a change of sampling rate is followed exactly, and the thicknesses of contiguous intervals add up to the flagged thickness.

Parameters:
  • flag (array-like or Curve) – Per-sample flag: booleans, or numbers where values above 0.5 count as set (the convention of NET_PAY-style flag curves). NaN is treated as not set.

  • depth (array-like or Well) – Sample depths (or a well, whose depth is used), same length as flag, in increasing or decreasing order.

  • max_gap (float, optional) – Largest distance, in depth units, between two flagged sample depths that still joins them into one interval; unflagged samples inside a bridged gap are included in the interval. By default only neighbouring samples whose cells touch are joined: no unflagged sample and no data gap lies between them.

  • min_thickness (float, default 0.0) – Drop intervals thinner than this (depth units).

Returns:

One row per interval, shallowest first, with top and bottom (cell boundaries), thickness and samples (flagged samples in the interval).

Return type:

DataFrame

Raises:

ValueError – If the lengths differ or max_gap / min_thickness are invalid.

Examples

>>> import numpy as np
>>> depth = np.arange(2000.0, 2005.0, 0.5)
>>> pay = np.array([0, 1, 1, 1, 0, 0, 1, 0, 1, 1])
>>> table = flag_intervals(pay, depth)
>>> table["top"].tolist(), table["bottom"].tolist()
([2000.25, 2002.75, 2003.75], [2001.75, 2003.25, 2004.75])
>>> table["thickness"].tolist(), table["samples"].tolist()
([1.5, 0.5, 1.0], [3, 1, 2])
>>> flag_intervals(pay, depth, max_gap=1.0)["samples"].tolist()
[3, 3]