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
Return bottom depth.
Return the list of curve mnemonics;
curves["GR"]gives the curve.Return depth array.
Return depth unit.
Return number of curves.
Return number of depth samples.
Return well name.
Alias for top (for visualization module compatibility).
the median spacing of the depth samples, in the well's depth unit.
Alias for bottom (for visualization module compatibility).
Return top depth.
Methods
Add a new curve to the well.
Extract well data within depth range.
Summarize the well as JSON-serializable data.
Create Well from pandas DataFrame.
Load well from DLIS file.
Load well from LAS file.
Get curve or return default if not found.
Get a parameter value.
Get a computed result.
Check if curve exists.
Check if all specified curves exist.
Return summary information about the well.
Remove a curve by mnemonic.
Rename a curve.
Extract the samples selected by a slice, boolean mask or index array.
Set a parameter value.
Store a computed result.
Export well to CSV file.
Convert well data to pandas DataFrame.
Export well to LAS file.
- property curves: CurveNames¶
Return the list of curve mnemonics;
curves["GR"]gives the curve.
- 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
- add_curve(mnemonic, data, unit='', description='', data_type=DataType.CURVE)[source]¶
Add a new curve to the well.
A curve already stored under
mnemonicis 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:
- rename_curve(old_name, new_name)[source]¶
Rename a curve.
- Raises:
ValueError – If another curve already has
new_name.- Parameters:
- Return type:
- to_dataframe(curves=None, include_depth=True)[source]¶
Convert well data to pandas DataFrame.
- Parameters:
- Returns:
DataFrame with curve data. The depth index is the first column,
DEPTH; a curve named DEPTH is the columnDEPTH_CURVEthen, 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,
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’sLASFile.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)orNAME [unit]as curveNAMEwith that unit, aspetrophys.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_VALUESparameter.- Return type:
- 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:
filepath (str or Path) – Path to LAS file
**kwargs – Options of
petrophys.io.read_las()(encoding)
- Returns:
New Well instance
- Return type:
- 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:
- to_las(filepath, **kwargs)[source]¶
Export well to LAS file.
- Parameters:
filepath (str or Path) – Output file path
**kwargs – Options of
petrophys.io.export_las()(e.g.curves=[...])
- 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()).
- 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:
Examples
>>> sand = well.select(well.get("VCL").data < 0.3)
- 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 areNone.- Return type:
Examples
>>> import petrophys as pp >>> summary = pp.read(pp.sample("30_6-5")).describe() >>> summary["depth_unit"], len(summary["curves"]) > 10 ('m', True)