Curve

petrophys.model.Curve

class Curve(mnemonic, data, unit='', depth=None, depth_unit='ft', metadata=None)[source]

Well log curve with data, units, and metadata.

A Curve object represents a single well log measurement with depth-indexed values, unit information, and associated metadata.

Parameters:
  • mnemonic (str) – Curve mnemonic (e.g., “GR”, “RHOB”, “NPHI”)

  • data (np.ndarray) – Curve data values

  • unit (str) – Unit of measurement

  • depth (np.ndarray, optional) – Depth values for the curve

  • depth_unit (str, optional) – Unit for depth values (default: “ft”)

  • metadata (CurveMetadata, optional) – Additional metadata

Examples

>>> import numpy as np
>>> depth = np.arange(1000, 2000, 0.5)
>>> gr = np.random.uniform(20, 100, len(depth))
>>> curve = Curve("GR", gr, "API", depth=depth)
>>> print(curve)
Curve(GR, unit=API, samples=2000)

Attributes

data

Return curve data as numpy array.

depth

Return depth values.

description

The curve's description (metadata.description).

values

Alias for data property.

Methods

clip

Clip values to specified range.

copy

Create a deep copy of the curve.

depth_slice

Extract curve data within depth range.

describe

Return summary statistics.

fillna

Fill NaN values with specified value.

from_series

Create Curve from pandas Series.

interpolate

Interpolate NaN values between valid samples.

mask

Set values to NaN where condition is True.

max

Return maximum value (excluding NaN).

mean

Return mean value (excluding NaN).

median

Return median value (excluding NaN).

min

Return minimum value (excluding NaN).

null_count

Return count of NaN values.

percentile

Return percentile value (excluding NaN).

rename

Return a copy with a new mnemonic.

select

Return a new curve with the samples selected by a slice, mask or index array.

std

Return standard deviation (excluding NaN).

to_dataframe

Convert to pandas DataFrame with depth column.

to_series

Convert to pandas Series with depth as index.

valid_count

Return count of non-NaN values.

property data: ndarray

Return curve data as numpy array.

property depth: ndarray | None

Return depth values.

property description: str

The curve’s description (metadata.description).

property values: ndarray

Alias for data property.

select(index)[source]

Return a new curve with the samples selected by a slice, mask or index array.

Parameters:

index (Any)

Return type:

Curve

copy()[source]

Create a deep copy of the curve.

Return type:

Curve

rename(new_mnemonic)[source]

Return a copy with a new mnemonic.

Parameters:

new_mnemonic (str)

Return type:

Curve

to_series()[source]

Convert to pandas Series with depth as index.

Return type:

Series

to_dataframe()[source]

Convert to pandas DataFrame with depth column.

Return type:

DataFrame

classmethod from_series(series, unit='')[source]

Create Curve from pandas Series.

The series name is the mnemonic (UNKNOWN without one), and an index other than the default 0, 1, 2, … becomes the depth.

Parameters:
Return type:

Curve

min(axis=None, out=None, **kwargs)[source]

Return minimum value (excluding NaN).

Return type:

float

max(axis=None, out=None, **kwargs)[source]

Return maximum value (excluding NaN).

Return type:

float

mean(axis=None, dtype=None, out=None, **kwargs)[source]

Return mean value (excluding NaN).

Return type:

float

std(axis=None, dtype=None, out=None, ddof=0, **kwargs)[source]

Return standard deviation (excluding NaN).

Return type:

float

median()[source]

Return median value (excluding NaN).

Return type:

float

percentile(q)[source]

Return percentile value (excluding NaN).

Parameters:

q (float)

Return type:

float

valid_count()[source]

Return count of non-NaN values.

Return type:

int

null_count()[source]

Return count of NaN values.

Return type:

int

describe()[source]

Return summary statistics.

Return type:

Dict[str, float]

clip(lower=None, upper=None)[source]

Clip values to specified range.

Parameters:
Return type:

Curve

mask(condition)[source]

Set values to NaN where condition is True.

Parameters:

condition (ndarray)

Return type:

Curve

fillna(value=0.0)[source]

Fill NaN values with specified value.

Parameters:

value (float)

Return type:

Curve

interpolate(method='linear')[source]

Interpolate NaN values between valid samples.

Linear interpolation follows the curve depth when it has one. NaN values before the first and after the last valid sample stay NaN.

Parameters:

method (str)

Return type:

Curve

depth_slice(top=None, bottom=None)[source]

Extract curve data within depth range.

Parameters:
Return type:

Curve