Well

petrophys.model.Well

Also available as petrophys.Well

class Well(name='')[source]

Primary container for well log data and metadata.

The Well class serves as the central data structure for petrophysical analysis, containing log curves, header information, and computed results.

Parameters:

name (str, optional) – Well name

Examples

>>> import petrophys as pp
>>> well = pp.Well.from_las(pp.sample("HW-3"))
>>> print(well.curves)
['GR', 'RHOB', 'NPHI', 'DT', 'PHIE_CC', 'RT', 'SW_INPUT', 'PERM_CC']
>>> # Access curves
>>> gr = well["GR"]
>>> print(round(gr.mean(), 1))
12.3
>>> # Add computed curve (arithmetic keeps the RHOB unit, so set the result's)
>>> well["PHID"] = (2.65 - well["RHOB"]) / (2.65 - 1.0)
>>> well["PHID"].unit = "v/v"

Attributes

bottom

Return bottom depth.

curves

Return the list of curve mnemonics; curves["GR"] gives the curve.

depth

Return depth array.

depth_unit

Return depth unit.

n_curves

Return number of curves.

n_samples

Return number of depth samples.

name

Return well name.

start_depth

Alias for top (for visualization module compatibility).

step

the median spacing of the depth samples, in the well's depth unit.

stop_depth

Alias for bottom (for visualization module compatibility).

top

Return top depth.

Methods

add_curve

Add a new curve to the well.

depth_slice

Extract well data within depth range.

describe

Summarize the well as JSON-serializable data.

from_dataframe

Create Well from pandas DataFrame.

from_dlis

Load well from DLIS file.

from_las

Load well from LAS file.

get

Get curve or return default if not found.

get_parameter

Get a parameter value.

get_result

Get a computed result.

has_curve

Check if curve exists.

has_curves

Check if all specified curves exist.

info

Return summary information about the well.

remove_curve

Remove a curve by mnemonic.

rename_curve

Rename a curve.

select

Extract the samples selected by a slice, boolean mask or index array.

set_parameter

Set a parameter value.

set_result

Store a computed result.

to_csv

Export well to CSV file.

to_dataframe

Convert well data to pandas DataFrame.

to_las

Export well to LAS file.

property name: str

Return well name.

property depth: ndarray | None

Return depth array.

property depth_unit: str

Return depth unit.

property curves: CurveNames

Return the list of curve mnemonics; curves["GR"] gives the curve.

property n_curves: int

Return number of curves.

property n_samples: int

Return number of depth samples.

property top: float | None

Return top depth.

property bottom: float | None

Return bottom depth.

property start_depth: float | None

Alias for top (for visualization module compatibility).

property stop_depth: float | None

Alias for bottom (for visualization module compatibility).

property step: float | None

the median spacing of the depth samples, in the well’s depth unit.

None for a well with fewer than two finite depths.

Type:

Return the depth step

get(mnemonic, default=None)[source]

Get curve or return default if not found.

Parameters:
Return type:

Curve | None

add_curve(mnemonic, data, unit='', description='', data_type=DataType.CURVE)[source]

Add a new curve to the well.

A curve already stored under mnemonic is replaced.

Parameters:
  • mnemonic (str) – Curve mnemonic (stored in upper case)

  • data (array-like) – Curve data values, one per depth sample; another length raises ValueError when the well has a depth

  • unit (str, optional) – Unit of measurement

  • description (str, optional) – Curve description

  • data_type (DataType, optional) – Data type classification

Returns:

The newly added curve

Return type:

Curve

remove_curve(mnemonic)[source]

Remove a curve by mnemonic.

Parameters:

mnemonic (str)

Return type:

bool

rename_curve(old_name, new_name)[source]

Rename a curve.

Raises:

ValueError – If another curve already has new_name.

Parameters:
  • old_name (str)

  • new_name (str)

Return type:

bool

has_curve(mnemonic)[source]

Check if curve exists.

Parameters:

mnemonic (str)

Return type:

bool

has_curves(mnemonics)[source]

Check if all specified curves exist.

Parameters:

mnemonics (List[str])

Return type:

bool

to_dataframe(curves=None, include_depth=True)[source]

Convert well data to pandas DataFrame.

Parameters:
  • curves (list of str, optional) – Specific curves to include (default: all)

  • include_depth (bool, optional) – Whether to include depth column

Returns:

DataFrame with curve data. The depth index is the first column, DEPTH; a curve named DEPTH is the column DEPTH_CURVE then, with a warning.

Return type:

pd.DataFrame

Raises:

KeyError – If a requested curve is not in the well.

classmethod from_dataframe(
df,
depth_column='DEPTH',
depth_unit=None,
name='',
header_units=True,
)[source]

Create Well from pandas DataFrame.

Parameters:
  • df (pd.DataFrame) – DataFrame with curve data

  • depth_column (str, optional) – Name of depth column (matched case-insensitively). A frame whose index carries this name, as lasio’s LASFile.df() returns, uses the index as depth.

  • depth_unit ({"m", "ft"}) – Unit of depth_column. Required when the frame has a depth column, unless its header gives the unit (DEPTH (m)); when both are given they must agree.

  • name (str, optional) – Well name

  • header_units (bool, optional) – Read a column header NAME (unit) or NAME [unit] as curve NAME with that unit, as petrophys.io.read_csv() does (default: True). False keeps each header as the curve name.

Returns:

New Well instance. Values of mostly numeric columns that are not numbers become NaN and are listed in the COERCED_NON_NUMERIC_VALUES parameter.

Return type:

Well

Raises:

ValueError – If two columns become the same curve name (they differ only in case or unit; curve names are upper case), the depth column is missing or has no numeric value, or the depth header’s unit differs from depth_unit.

classmethod from_las(filepath, **kwargs)[source]

Load well from LAS file.

Parameters:
Returns:

New Well instance

Return type:

Well

classmethod from_dlis(filepath, **kwargs)[source]

Load well from DLIS file.

Parameters:
  • filepath (str or Path) – Path to DLIS file

  • **kwargs – Options of petrophys.io.read_dlis() (frame_name, channels, standardize, …)

Returns:

New Well instance

Return type:

Well

to_las(filepath, **kwargs)[source]

Export well to LAS file.

Parameters:
to_csv(filepath, **kwargs)[source]

Export well to CSV file.

Parameters:
  • filepath (str or Path) – Output file path

  • **kwargs – Additional arguments passed to DataFrame.to_csv

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

Extract well data within depth range.

The header, parameters and results are copied, and the new well remembers the deepest log sample of this one (see select()).

Parameters:
  • top (float, optional) – Top depth of interval, in the well’s depth unit

  • bottom (float, optional) – Bottom depth of interval, in the well’s depth unit

Returns:

New Well with sliced data

Return type:

Well

select(index)[source]

Extract the samples selected by a slice, boolean mask or index array.

Every curve is selected the same way (Curve.select()); the header, parameters and results are copied. Use it for a set of samples that is not one depth range, e.g. a lithology group. The selection remembers the deepest log sample of the well it came from, so an interpretation of it places a bottom-hole temperature at the same depth as an interpretation of the whole well.

Parameters:

index (slice, array of bool or array of int) – The samples to keep, over the well’s depth index.

Returns:

New Well with the selected samples

Return type:

Well

Examples

>>> sand = well.select(well.get("VCL").data < 0.3)
set_parameter(name, value)[source]

Set a parameter value.

Parameters:
get_parameter(name, default=None)[source]

Get a parameter value.

Parameters:
Return type:

Any

set_result(name, value)[source]

Store a computed result.

Parameters:
get_result(name, default=None)[source]

Get a computed result.

Parameters:
Return type:

Any

describe()[source]

Summarize the well as JSON-serializable data.

Returns:

name, header identifiers, depth_unit, top, bottom, step, n_samples, curves (mnemonic, unit, description and share of valid samples), selected header parameters (BHT, RW, RMF, …) and attached geology. Missing values are None.

Return type:

dict

Examples

>>> import petrophys as pp
>>> summary = pp.read(pp.sample("30_6-5")).describe()
>>> summary["depth_unit"], len(summary["curves"]) > 10
('m', True)
info()[source]

Return summary information about the well.

Depths are given to at most three decimals and the step (the median sample spacing) to four significant figures, in the well’s depth unit.

Return type:

str