Bands

petrophys.model.Bands

Also available as petrophys.evaluation.diagnostics.Bands

class Bands(base, steps)[source]

A one-curve classification: base for every valid sample, then each (op, threshold, label) step in order (op one of >, >=, <, <=).

Examples

>>> b = Bands("POOR", ((">", 1.0, "FAIR"), (">", 10.0, "GOOD")))
>>> list(b.classify([0.5, 1.0, 5.0, 50.0])), b.edges, b.labels
(['POOR', 'POOR', 'FAIR', 'GOOD'], (1.0, 10.0), ('POOR', 'FAIR', 'GOOD'))

Attributes

edges

The thresholds, ascending.

labels

The labels from the lowest to the highest values.

base

steps

Methods

classify

The label of every sample (missing where the value is not valid; default validity: finite).

describe

The range of each label as text, e.g. "LOW < 0.5; HIGH >= 0.5".

label_of

The label of one value (None when it is not finite).

ranges

The range of each label, from the lowest to the highest values.

without_edges

A coarsening of these bands: the steps at edges dropped.

Parameters:
base: str
steps: Tuple[Tuple[str, float, str], ...]
classify(values, valid=None, missing='NO_DATA')[source]

The label of every sample (missing where the value is not valid; default validity: finite).

Parameters:
Return type:

ndarray

label_of(value)[source]

The label of one value (None when it is not finite).

Parameters:

value (float)

Return type:

str | None

property edges: Tuple[float, ...]

The thresholds, ascending.

property labels: Tuple[str, ...]

The labels from the lowest to the highest values.

without_edges(*edges)[source]

A coarsening of these bands: the steps at edges dropped.

The classes either side of a dropped edge merge, under the label the remaining steps give them.

Examples

>>> b = Bands("POOR", ((">", 1.0, "FAIR"), ("<=", 0.1, "VERY_POOR")))
>>> b.without_edges(0.1).labels
('POOR', 'FAIR')
Parameters:

edges (float)

Return type:

Bands

ranges()[source]

The range of each label, from the lowest to the highest values.

Each item is (label, lower, lower_closed, upper, upper_closed); an open end is -inf or inf.

Raises:

ValueError – If a label covers more than one range.

Return type:

Tuple[Tuple[str, float, bool, float, bool], …]

describe()[source]

The range of each label as text, e.g. "LOW < 0.5; HIGH >= 0.5".

Return type:

str