wellcast.io¶
io ¶
Read field production data and well logs into standard DataFrames.
Canonical production schema. read_production returns a DataFrame with
a DatetimeIndex named date, sorted by well and date, and the columns
below. Only well is mandatory; the others are present when the source
provides them. Columns that do not match the schema are kept unchanged after
the canonical ones.
| Column | Unit | dtype | Description |
|---|---|---|---|
well |
str | Well identifier | |
oil_rate |
bbl/d | float64 | Oil rate at stock-tank conditions |
gas_rate |
Mscf/d | float64 | Gas rate at standard conditions |
water_rate |
bbl/d | float64 | Water rate |
water_inj_rate |
bbl/d | float64 | Water injection rate |
gas_inj_rate |
Mscf/d | float64 | Gas injection or gas lift rate |
whp |
psi | float64 | Wellhead (tubing head) pressure |
wht |
degF | float64 | Wellhead temperature |
bhp |
psi | float64 | Bottomhole (downhole gauge) pressure |
bht |
degF | float64 | Bottomhole temperature |
choke |
in/64 | float64 | Choke bean size |
on_stream_hours |
h | float64 | Producing hours in the period |
ColumnSpec
dataclass
¶
Description of one column in the canonical production schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Canonical column name. |
required |
unit
|
str
|
Unit symbol understood by |
required |
dtype
|
str
|
Expected dtype. |
required |
description
|
str
|
Human-readable description. |
required |
standardize_columns ¶
Rename source columns to canonical names.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
Raw table. |
required |
alias_map
|
mapping of str to str
|
Extra aliases |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
Copy of |
Examples:
read_production ¶
read_production(path: str | PathLike[str], alias_map: Mapping[str, str] | None = None, *, units: Mapping[str, str] | None = None, well: str | None = None, sheet_name: str | int = 0, dayfirst: bool = False) -> pd.DataFrame
Read a CSV or Excel production table into the canonical schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str or path - like
|
|
required |
alias_map
|
mapping of str to str
|
Extra column aliases |
None
|
units
|
mapping of str to str
|
Units of canonical columns in the source, for example
|
None
|
well
|
str
|
Well name to use when the file has no well column. |
None
|
sheet_name
|
str or int
|
Excel sheet. Default is the first sheet. |
0
|
dayfirst
|
bool
|
Parse ambiguous dates as day first ( |
False
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
Table indexed by a |
Raises:
| Type | Description |
|---|---|
DataValidationError
|
If the file type is unsupported, no date column is found, dates cannot be parsed, or no well identifier is available. |
MissingDependencyError
|
If an Excel file is read without |
Examples:
>>> import tempfile, pathlib
>>> from wellcast.io import read_production
>>> tmp = pathlib.Path(tempfile.mkdtemp()) / "prod.csv"
>>> _ = tmp.write_text("DATEPRD,WELL,BORE_OIL_VOL\n2024-01-01,A-1,100\n")
>>> df = read_production(tmp, units={"oil_rate": "m3/d"})
>>> round(float(df["oil_rate"].iloc[0]), 1)
629.0
from_dataframe ¶
from_dataframe(raw: DataFrame, alias_map: Mapping[str, str] | None = None, *, units: Mapping[str, str] | None = None, well: str | None = None, dayfirst: bool = False) -> pd.DataFrame
Convert an in-memory table into the canonical schema.
Same processing as read_production, for data that is already in
a DataFrame (for example from a database query or a web upload).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw
|
DataFrame
|
Source table with a date column; its index is ignored. |
required |
alias_map
|
mapping of str to str
|
Extra column aliases |
None
|
units
|
mapping of str to str
|
Source units of canonical columns, converted to canonical units. |
None
|
well
|
str
|
Well name to use when the table has no well column. |
None
|
dayfirst
|
bool
|
Parse ambiguous dates as day first. |
False
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
Table indexed by a |
Raises:
| Type | Description |
|---|---|
DataValidationError
|
If no date column is found, dates cannot be parsed, or no well identifier is available. |
Examples:
read_las ¶
Read a LAS well log file into a depth-indexed DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str or path - like
|
LAS 1.2, 2.0 or 3.0 file. |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
Curves as columns, indexed by the first (depth) curve. Header items
from the |
Raises:
| Type | Description |
|---|---|
MissingDependencyError
|
If |
Examples:
>>> import tempfile, pathlib, numpy as np
>>> import lasio
>>> las = lasio.LASFile()
>>> las.append_curve("DEPT", np.array([1000.0, 1000.5]), unit="ft")
>>> las.append_curve("GR", np.array([45.0, 60.0]), unit="API")
>>> tmp = pathlib.Path(tempfile.mkdtemp()) / "log.las"
>>> las.write(str(tmp))
>>> read_las(tmp)["GR"].tolist()
[45.0, 60.0]