Skip to content

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_COLORS in 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_theme() -> str

Register the "wellcast" plotly template and return its name.

Returns:

Type Description
str

"wellcast", usable as template="wellcast" in any plotly figure.

Raises:

Type Description
MissingDependencyError

If plotly is not installed.

Examples:

>>> register_theme()
'wellcast'

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 DatetimeIndex.

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".

'well'

Returns:

Type Description
Figure

Figure with a shared time axis.

Examples:

>>> from wellcast.datasets import make_synthetic_field
>>> field = make_synthetic_field(n_wells=1, years=1, n_injectors=0)
>>> fig = production_history(field.production)
>>> [t.name for t in fig.data]
['oil (bbl/d)', 'gas (Mscf/d)', 'water (bbl/d)', 'BHP (psi)', 'WHP (psi)']

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

importance_bar(importance: Series, *, title: str, x_title: str) -> Any

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:

>>> import pandas as pd
>>> fig = importance_bar(
...     pd.Series({"whp": 1.0, "choke": 3.0}), title="t", x_title="x"
... )
>>> list(fig.data[0].y)
['whp', 'choke']

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 wellcast.ipr.ipr_curve, or several keyed by label.

required
operating_point tuple of float

(rate, pwf) of a measured test, drawn as a marker.

None
title str

Figure title.

'Inflow performance'

Returns:

Type Description
Figure

Rate on x, flowing bottomhole pressure on y.

Examples:

>>> from wellcast.ipr import ipr_curve
>>> fig = ipr_plot({"Vogel": ipr_curve("vogel", 2500.0, qmax=1000.0)})
>>> fig.data[0].name
'Vogel'

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 interval (typically by date).

required
interval DataFrame

Output of wellcast.ml.Predictor.predict_interval, with columns lower, prediction and upper.

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_plot(chan: DataFrame, well: str | None = None) -> Any

Chan diagnostic plot: WOR and WOR' against time on log-log axes.

Parameters:

Name Type Description Default
chan DataFrame

Output of wellcast.diagnostics.chan_plot_data.

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(hall: DataFrame, change: Series | None = None, *, title: str = 'Hall plot') -> Any

Hall plot of the pressure-time integral against cumulative injection.

Parameters:

Name Type Description Default
hall DataFrame

Output of wellcast.diagnostics.hall_plot_data.

required
change Series

Output of wellcast.diagnostics.hall_slope_change; the breakpoint is marked and both slopes are labelled.

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 DatetimeIndex.

required
anomalies DataFrame

Output of wellcast.diagnostics.detect_anomalies.

required
column str

Signal to draw.

required
well str

Well to show. Default: the first well.

None
by str

Well column. Default "well".

'well'

Returns:

Type Description
Figure

Line chart with one labelled rectangle per anomaly period.