wellcast.plotting¶
plotting ¶
Interactive charts for production engineering, built on plotly.
Every helper returns a plotly.graph_objects.Figure styled with the
"wellcast" template:
- Series colors follow the entity, never its rank. Fluids keep fixed colors and dash patterns everywhere (oil green solid, gas red dashed, water blue dotted), so identity never relies on color alone.
- Categorical series take colors from
SERIES_COLORSin fixed order; scatter-type charts color at most three wells and show the rest in one neutral color with the well name on hover. - Quantities with different units go into separate stacked panels sharing the time axis, never onto a second y-axis.
Requires the viz extra: pip install 'wellcast[viz]'.
register_theme ¶
Register the "wellcast" plotly template and return its name.
Returns:
| Type | Description |
|---|---|
str
|
|
Raises:
| Type | Description |
|---|---|
MissingDependencyError
|
If plotly is not installed. |
Examples:
production_history ¶
production_history(df: DataFrame, well: str | None = None, *, rates: Sequence[str] = ('oil_rate', 'gas_rate', 'water_rate'), pressures: Sequence[str] = ('bhp', 'whp'), by: str = 'well') -> Any
Rates and pressures of one well in two stacked panels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
Production table with a |
required |
well
|
str
|
Well to show. Default: the first well, alphabetically, with data in the requested columns. |
None
|
rates
|
sequence of str
|
Columns for the upper (rates) and lower (pressures) panel; absent columns are skipped. |
('oil_rate', 'gas_rate', 'water_rate')
|
pressures
|
sequence of str
|
Columns for the upper (rates) and lower (pressures) panel; absent columns are skipped. |
('oil_rate', 'gas_rate', 'water_rate')
|
by
|
str
|
Well column. Default |
'well'
|
Returns:
| Type | Description |
|---|---|
Figure
|
Figure with a shared time axis. |
Examples:
decline_plot ¶
decline_plot(model: DeclineModel, rates: Series | None = None, *, forecast_days: int = 3650, econ_limit: float | None = None, title: str | None = None) -> Any
Observed rates, fitted Arps curve and bootstrap P90 to P10 band.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
DeclineModel
|
A fitted model (bands are drawn when it was bootstrapped). |
required |
rates
|
Series
|
Observed rates to overlay. |
None
|
forecast_days
|
int
|
Horizon after the last observation, days. Default 3650. |
3650
|
econ_limit
|
float
|
Economic limit rate. The forecast stops when it is reached and the limit is drawn as a horizontal line. |
None
|
title
|
str
|
Figure title. |
None
|
Returns:
| Type | Description |
|---|---|
Figure
|
Figure with a logarithmic rate axis. |
importance_bar ¶
Horizontal bar chart of feature importances, largest on top.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
importance
|
Series
|
Importance per feature, sorted ascending (largest last). |
required |
title
|
str
|
Figure title. |
required |
x_title
|
str
|
Axis title for the importance values. |
required |
Returns:
| Type | Description |
|---|---|
Figure
|
Bar chart in the wellcast theme. |
Examples:
ipr_plot ¶
ipr_plot(curves: DataFrame | Mapping[str, DataFrame], *, operating_point: tuple[float, float] | None = None, title: str = 'Inflow performance') -> Any
Plot one or more IPR curves (pressure against rate).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
curves
|
pandas.DataFrame or mapping of str to DataFrame
|
Output of |
required |
operating_point
|
tuple of float
|
|
None
|
title
|
str
|
Figure title. |
'Inflow performance'
|
Returns:
| Type | Description |
|---|---|
Figure
|
Rate on x, flowing bottomhole pressure on y. |
Examples:
predicted_vs_actual ¶
predicted_vs_actual(y_true: Series, y_pred: Series, wells: Series | None = None, *, title: str = 'Predicted vs actual') -> Any
Cross-plot of predictions against observations with a 1:1 line.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
y_true
|
Series
|
Observed and predicted values, aligned by position. |
required |
y_pred
|
Series
|
Observed and predicted values, aligned by position. |
required |
wells
|
Series
|
Well names. Up to three wells are colored; with more, all points share one color and the well name appears on hover. |
None
|
title
|
str
|
Figure title. |
'Predicted vs actual'
|
Returns:
| Type | Description |
|---|---|
Figure
|
Square-aspect cross-plot. |
prediction_interval_plot ¶
prediction_interval_plot(actual: Series, interval: DataFrame, *, title: str = 'Prediction with interval') -> Any
Observed values against predictions with a shaded interval.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
actual
|
Series
|
Observed values, indexed like |
required |
interval
|
DataFrame
|
Output of |
required |
title
|
str
|
Figure title. |
'Prediction with interval'
|
Returns:
| Type | Description |
|---|---|
Figure
|
Time-series figure with the interval as a band. |
Examples:
>>> import pandas as pd
>>> idx = pd.date_range("2024-01-01", periods=3, freq="D")
>>> band = pd.DataFrame(
... {
... "lower": [1.0, 2.0, 3.0],
... "prediction": [2.0, 3.0, 4.0],
... "upper": [3.0, 4.0, 5.0],
... },
... index=idx,
... )
>>> fig = prediction_interval_plot(pd.Series([2.1, 2.9, 4.2], index=idx), band)
>>> [t.name for t in fig.data]
['upper', 'interval', 'prediction', 'actual']
chan_plot ¶
Chan diagnostic plot: WOR and WOR' against time on log-log axes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chan
|
DataFrame
|
Output of |
required |
well
|
str
|
Well to show. Default: the first well. |
None
|
Returns:
| Type | Description |
|---|---|
Figure
|
Log-log figure with two series. |
hall_plot ¶
Hall plot of the pressure-time integral against cumulative injection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hall
|
DataFrame
|
Output of |
required |
change
|
Series
|
Output of |
None
|
title
|
str
|
Figure title. |
'Hall plot'
|
Returns:
| Type | Description |
|---|---|
Figure
|
Figure with cumulative injection on x. |
anomaly_overlay ¶
anomaly_overlay(df: DataFrame, anomalies: DataFrame, column: str, well: str | None = None, *, by: str = 'well') -> Any
Time series of one signal with flagged periods shaded.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
Production table with a |
required |
anomalies
|
DataFrame
|
Output of |
required |
column
|
str
|
Signal to draw. |
required |
well
|
str
|
Well to show. Default: the first well. |
None
|
by
|
str
|
Well column. Default |
'well'
|
Returns:
| Type | Description |
|---|---|
Figure
|
Line chart with one labelled rectangle per anomaly period. |