CoreData

petrophys.model.CoreData

Also available as petrophys.interpretation.core_analysis.CoreData

class CoreData(
depth,
porosity=None,
permeability=None,
grain_density=None,
sw=None,
so=None,
lithology=None,
metadata=<factory>,
)[source]

Container for core laboratory measurements.

Parameters:
  • depth (np.ndarray) – Measured depth of each core plug (same unit as well logs).

  • porosity (np.ndarray, optional) – Helium porosity (fraction, 0-1).

  • permeability (np.ndarray, optional) – Air/Klinkenberg permeability (mD).

  • grain_density (np.ndarray, optional) – Grain density from pycnometer (g/cm3).

  • sw (np.ndarray, optional) – Water saturation from Dean-Stark (fraction, 0-1).

  • so (np.ndarray, optional) – Oil saturation from Dean-Stark (fraction, 0-1).

  • lithology (np.ndarray, optional) – Lithology description per plug (string array).

  • metadata (dict) – Additional columns or information.

Examples

>>> core = CoreData.from_csv("core_data.csv", depth_col="DEPTH",
...     porosity_col="CPOR", perm_col="CPERM", gd_col="CGD")
>>> print(f"{core.n_plugs} plugs, depth {core.top:.1f}-{core.bottom:.1f}")

Attributes

bottom

Deepest core depth.

grain_density

lithology

n_plugs

Number of core plugs.

permeability

porosity

so

sw

top

Shallowest core depth.

depth

metadata

Methods

filter_by_depth

Return a new CoreData filtered to a depth range.

from_csv

Load CoreData from a CSV file.

from_dataframe

Create CoreData from a pandas DataFrame.

from_excel

Load CoreData from an Excel file.

to_dataframe

Export core data to a pandas DataFrame.

depth: ndarray
porosity: ndarray | None = None
permeability: ndarray | None = None
grain_density: ndarray | None = None
sw: ndarray | None = None
so: ndarray | None = None
lithology: ndarray | None = None
metadata: Dict[str, Any]
property n_plugs: int

Number of core plugs.

property top: float | None

Shallowest core depth.

property bottom: float | None

Deepest core depth.

classmethod from_dataframe(
df,
depth_col='DEPTH',
porosity_col='CPOR',
perm_col='CPERM',
gd_col='CGD',
sw_col=None,
so_col=None,
lithology_col=None,
porosity_unit=None,
saturation_unit=None,
)[source]

Create CoreData from a pandas DataFrame.

Porosity and saturations are stored as fractions (v/v). Without a stated unit, a column whose values are mostly above 1 with a median of at least 2 is read as percent and divided by 100, with a warning; values outside 0-1 after that are masked with a warning (core_saturation_to_fraction()).

Parameters:
  • df (pd.DataFrame) – DataFrame with core measurements.

  • depth_col (str) – Column name for depth.

  • porosity_col (str, optional) – Column name for porosity (fraction).

  • perm_col (str, optional) – Column name for permeability (mD).

  • gd_col (str, optional) – Column name for grain density (g/cm3).

  • sw_col (str, optional) – Column name for water saturation.

  • so_col (str, optional) – Column name for oil saturation.

  • lithology_col (str, optional) – Column name for lithology.

  • porosity_unit (str, optional) – "%" or "v/v" (also "pu", "frac" …) to state the scale of the porosity or saturation columns instead of inferring it.

  • saturation_unit (str, optional) – "%" or "v/v" (also "pu", "frac" …) to state the scale of the porosity or saturation columns instead of inferring it.

Return type:

CoreData

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

Load CoreData from a CSV file.

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

  • **kwargs – Column name mappings passed to from_dataframe.

Return type:

CoreData

classmethod from_excel(filepath, sheet_name=0, **kwargs)[source]

Load CoreData from an Excel file.

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

  • sheet_name (str or int) – Sheet name or index.

  • **kwargs – Column name mappings passed to from_dataframe.

Return type:

CoreData

to_dataframe()[source]

Export core data to a pandas DataFrame.

Per-plug metadata columns (arrays with one value per plug, such as the extra columns kept by from_dataframe()) are exported after the named fields; other metadata is not.

Return type:

DataFrame

filter_by_depth(top, bottom)[source]

Return a new CoreData filtered to a depth range.

Parameters:
Return type:

CoreData