wellcast.dca¶
dca ¶
Arps decline curve analysis.
Time is measured in days from the start of the fitted decline, rates in
volume per day (for example bbl/d) and cumulative volumes in the same volume
unit. The nominal decline rate di is expressed per year, as is customary
in reserves reporting.
The three Arps (1945) models are
Arps, J. J. (1945), "Analysis of decline curves", Transactions of the AIME 160(1), 228-247, SPE-945228-G.
Probabilistic bands follow the petroleum reserves convention (SPE-PRMS): P90 is the low estimate (exceeded with 90 percent probability), P50 the best estimate and P10 the high estimate.
DeclineModel ¶
DeclineModel(model: Literal['auto', 'exponential', 'hyperbolic', 'harmonic'] = 'auto', *, b_bounds: tuple[float, float] = (0.01, 2.0), from_peak: bool = True, loss: str = 'soft_l1')
Fit, forecast and evaluate an Arps decline.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
('auto', 'exponential', 'hyperbolic', 'harmonic')
|
Model to fit. |
"auto"
|
b_bounds
|
tuple of float
|
Bounds on the hyperbolic exponent. Default (0.01, 2.0); values above 1 occur during transient (unconventional) flow. |
(0.01, 2.0)
|
from_peak
|
bool
|
Start the fit at the peak of the 7-sample rolling median rate, so the ramp-up period is ignored. Default True. |
True
|
loss
|
str
|
Loss passed to |
'soft_l1'
|
Attributes:
| Name | Type | Description |
|---|---|---|
model_ |
str
|
Selected model name. |
qi_, di_, b_ |
float
|
Fitted initial rate (volume/day), nominal decline (1/year) and exponent. |
aic_ |
dict of str to float
|
AIC of every candidate model. |
start_ |
Timestamp or None
|
Date of |
t_offset_ |
float
|
Time of the decline start ( |
t_last_ |
float
|
Time of the last observation used in the fit, days after decline start. |
n_obs_ |
int
|
Number of observations used. |
Notes
Zero, negative and missing rates (shut-ins and gaps) are excluded before fitting. Fitting minimizes residuals of \(\ln q\), which treats rate errors as multiplicative.
Examples:
>>> import numpy as np
>>> from wellcast.dca import DeclineModel, arps_rate
>>> t = np.arange(0.0, 1000.0, 10.0)
>>> q = arps_rate(t, 1500.0, 0.8, 0.5)
>>> m = DeclineModel("hyperbolic").fit(q, time=t)
>>> round(m.qi_, 1), round(m.di_, 3), round(m.b_, 3)
(1500.0, 0.8, 0.5)
>>> round(m.eur(econ_limit=50.0) / 1e6, 4)
1.1196
from_params
classmethod
¶
from_params(qi: float, di: float, b: float, *, start: Timestamp | str | None = None) -> DeclineModel
Create a fitted model from known parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
qi
|
float
|
Initial rate, volume/day. |
required |
di
|
float
|
Initial nominal decline, 1/year. |
required |
b
|
float
|
Arps exponent. |
required |
start
|
Timestamp or str
|
Date of |
None
|
Returns:
| Type | Description |
|---|---|
DeclineModel
|
A model that can predict and compute EUR but has no bootstrap samples. |
Examples:
fit ¶
Fit the decline model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rates
|
Series or array_like
|
Rates in volume/day. A Series with a |
required |
time
|
array_like
|
Observation times in days, for array input. |
None
|
Returns:
| Type | Description |
|---|---|
DeclineModel
|
The fitted model ( |
Raises:
| Type | Description |
|---|---|
FitError
|
If fewer than 4 positive observations remain or every candidate fit fails. |
DataValidationError
|
If inputs are inconsistent. |
predict ¶
Predict rates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
array_like or DatetimeIndex
|
Days since the start of decline, or dates (when fitted on a date-indexed Series). |
required |
Returns:
| Type | Description |
|---|---|
float or ndarray
|
Rate, volume/day. |
Raises:
| Type | Description |
|---|---|
FitError
|
If the model is not fitted. |
cumulative ¶
Cumulative production from the start of decline.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
array_like or DatetimeIndex
|
Days since the start of decline, or dates. |
required |
Returns:
| Type | Description |
|---|---|
float or ndarray
|
Cumulative volume. |
Raises:
| Type | Description |
|---|---|
FitError
|
If the model is not fitted. |
time_to_limit ¶
Days from the start of decline until the rate reaches econ_limit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
econ_limit
|
float
|
Economic limit rate, volume/day. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Time in days. |
Raises:
| Type | Description |
|---|---|
FitError
|
If the model is not fitted. |
eur ¶
Estimated ultimate recovery from the start of decline.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
econ_limit
|
float
|
Economic limit rate, volume/day. |
required |
max_years
|
float
|
Cap on the producing life after the start of decline, years. |
None
|
Returns:
| Type | Description |
|---|---|
float
|
Cumulative volume from |
Raises:
| Type | Description |
|---|---|
FitError
|
If the model is not fitted. |
DataValidationError
|
If |
remaining ¶
Remaining reserves after the last observation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
econ_limit
|
float
|
Economic limit rate, volume/day. |
required |
max_years
|
float
|
Cap on the producing life after the start of decline, years. |
None
|
Returns:
| Type | Description |
|---|---|
float
|
|
forecast ¶
Daily forecast after the last observation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
days
|
int
|
Number of days to forecast. |
required |
econ_limit
|
float
|
Stop the forecast when the rate falls below this value. |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
Columns |
Raises:
| Type | Description |
|---|---|
FitError
|
If the model is not fitted. |
bootstrap ¶
Estimate parameter uncertainty by residual bootstrap.
Log-rate residuals of the fit are resampled with replacement, added to
the fitted curve and the selected model is refitted n_samples
times.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_samples
|
int
|
Number of bootstrap replicates. Default 200. |
200
|
seed
|
int or None
|
Random seed. Default 0. |
0
|
Returns:
| Type | Description |
|---|---|
DeclineModel
|
|
Raises:
| Type | Description |
|---|---|
FitError
|
If the model was not fitted on data. |
predict_interval ¶
P90, P50 and P10 rate bands from the bootstrap samples.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
array_like or DatetimeIndex
|
Days since decline start, or dates. |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
Columns |
Raises:
| Type | Description |
|---|---|
FitError
|
If |
eur_quantiles ¶
P90, P50 and P10 EUR from the bootstrap samples.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
econ_limit
|
float
|
Economic limit rate, volume/day. |
required |
max_years
|
float
|
Cap on the producing life after decline start, years. |
None
|
Returns:
| Type | Description |
|---|---|
Series
|
Index |
Raises:
| Type | Description |
|---|---|
FitError
|
If |
summary ¶
Fitted parameters and diagnostics.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
econ_limit
|
float
|
When given, |
None
|
Returns:
| Type | Description |
|---|---|
Series
|
|
Raises:
| Type | Description |
|---|---|
FitError
|
If the model is not fitted. |
plot ¶
plot(rates: Series | None = None, *, forecast_days: int = 3650, econ_limit: float | None = None, title: str | None = None) -> Any
Plot observed rates, the fitted curve and bootstrap bands.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rates
|
Series
|
Observed rates to overlay (date-indexed if the model is). |
None
|
forecast_days
|
int
|
Forecast horizon after the last observation. Default 3650. |
3650
|
econ_limit
|
float
|
Stop the forecast at this rate and draw the limit. |
None
|
title
|
str
|
Figure title. |
None
|
Returns:
| Type | Description |
|---|---|
Figure
|
Interactive figure with a logarithmic rate axis. |
Raises:
| Type | Description |
|---|---|
MissingDependencyError
|
If plotly is not installed. |
arps_rate ¶
Arps decline rate.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
array_like
|
Time since the start of decline, days. |
required |
qi
|
float
|
Initial rate at |
required |
di
|
float
|
Initial nominal decline rate, 1/year. |
required |
b
|
float
|
Arps exponent: 0 exponential, 1 harmonic, otherwise hyperbolic. |
required |
Returns:
| Type | Description |
|---|---|
float or ndarray
|
Rate, volume/day. |
Notes
See the module docstring for the equations; \(D_i\) is converted to
1/day as di / 365.25.
Examples:
arps_cumulative ¶
Cumulative production of an Arps decline from t = 0.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
array_like
|
Time since the start of decline, days. |
required |
qi
|
float
|
Initial rate, volume/day. |
required |
di
|
float
|
Initial nominal decline rate, 1/year. |
required |
b
|
float
|
Arps exponent. |
required |
Returns:
| Type | Description |
|---|---|
float or ndarray
|
Cumulative volume. |
Notes
With \(D = D_i / 365.25\) (1/day):
Examples:
arps_time_to_rate ¶
Time at which an Arps decline reaches rate q.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
q
|
array_like
|
Target rate, volume/day. |
required |
qi
|
float
|
Initial rate, volume/day. |
required |
di
|
float
|
Initial nominal decline rate, 1/year. |
required |
b
|
float
|
Arps exponent. |
required |
Returns:
| Type | Description |
|---|---|
float or ndarray
|
Time in days (0 when |
Notes
\(t = \ln(q_i/q)/D\) for \(b = 0\), otherwise \(t = [(q_i/q)^b - 1]/(bD)\).
Examples:
fit_many ¶
fit_many(df: DataFrame, by: str = 'well', rate_column: str = 'oil_rate', *, model: Literal['auto', 'exponential', 'hyperbolic', 'harmonic'] = 'auto', econ_limit: float | None = None, **kwargs: Any) -> pd.DataFrame
Fit a decline model to every well.
Wells that cannot be fitted are reported with status set to the error
message instead of aborting the batch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
Production table with a |
required |
by
|
str
|
Grouping column. Default |
'well'
|
rate_column
|
str
|
Rate column to fit. Default |
'oil_rate'
|
model
|
str
|
Passed to |
'auto'
|
econ_limit
|
float
|
Economic limit for EUR and remaining reserves. |
None
|
**kwargs
|
Any
|
Other |
{}
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
One row per well (index |
Raises:
| Type | Description |
|---|---|
DataValidationError
|
If |
Examples: