pastas.model.Model#

class pastas.model.Model(oseries: pandas.Series, constant: bool = True, name: str | None = None, metadata: dict[str, Any] | None = None, freq: str = 'D')#

Class that initiates a Pastas time series model.

Parameters:
  • oseries (pandas.Series) – pandas.Series object containing the dependent time series. The observation can be non-equidistant.

  • constant (bool, optional) – Add a constant to the model (Default=True).

  • name (str, optional) – String with the name of the model, used in plotting and saving.

  • metadata (dict, optional) – Dictionary containing metadata of the oseries, passed on to the oseries when creating a pastas TimeSeries object. hence, ml.oseries.metadata will give you the metadata.

  • freq (str, optional) – String with the frequency the stressmodels are simulated. Must be one of the following: (D, h, m, s, ms, us, ns) or a multiple of that e.g. “7D”. Default is “D”. New in 0.18.0.

Returns:

ml – Pastas Model instance, the base object in Pastas.

Return type:

pastas.model.Model

Examples

A minimal working example of the Model class is shown below:

>>> oseries = pd.Series([1,2,1], index=pd.to_datetime(range(3), unit="D"))
>>> ml = Model(oseries)
property parameters: pandas.DataFrame#

Get model parameters DataFrame.

Returns:

parameters – DataFrame containing the model parameters. This is a read-only view; modifications to this DataFrame will not affect the model.

Return type:

pandas.DataFrame

Notes

The parameters attribute is read-only. To modify parameter properties, use the set_parameter method instead.

See also

set_parameter

Method to change parameter properties.

property settings: dict[str, Any]#

Get model settings dictionary.

Returns:

settings – Dictionary containing the model settings. This is a read-only view; modifications to this dictionary will not affect the model.

Return type:

dict

Notes

The settings attribute is read-only. Model settings are automatically updated through methods like ml.solve() and ml.set_settings().

property oseries_calib#

Deprecated property for calibration observations.

Use ml.observations() instead.

property time_offset: pandas.Timedelta#

Property to get the time offset from the settings.

property sim_index: pandas.DatetimeIndex#

Property that returns the simulation index, including the warmup.

Using the tmin, tmax, freq, and warmup from the model settings, a DatetimeIndex is created that includes the warmup period. This index is used for simulating the model and calculating the residuals.

Returns:

sim_index – Pandas DatetimeIndex instance with the datetimes values for which the model is simulated.

Return type:

pandas.DatetimeIndex

Methods#

add_stressmodel(→ None)

Add a stressmodel to the main model.

add_constant(→ None)

Add a Constant to the time series Model.

add_transform(transform)

Add a Transform to the time series Model.

add_noisemodel(→ None)

Add a noisemodel to the time series Model.

add_solver(→ None)

Add a solver to the model.

del_stressmodel(name)

Safely delete a stress model from the Model.

del_constant(→ None)

Safely delete the Constant from the Model.

del_transform(→ None)

Safely delete the transform from the Model.

del_noisemodel(→ None)

Safely delete the noise model from the Model.

simulate(→ pandas.Series)

Simulate the time series model.

residuals(→ pandas.Series)

Calculate the residual series.

noise(→ pandas.Series)

Simulate the noise when a noisemodel is present.

observations(→ pandas.Series)

Return the observations series used for calibration.

initialize(→ None)

Initialize the model.

solve(→ None)

Solve the time series model.

reset_settings(→ None)

Reset the model settings to the default settings.

set_settings(→ None)

Change the model settings.

set_parameter(→ None)

Change the parameter properties.

set_oseries(→ None)

Set a new oseries for an existing Model.

get_tmin(→ pandas.Timestamp)

Check and return valid values for tmin.

get_tmax(→ pandas.Timestamp)

Check and return valid values for tmax.

get_init_parameters(→ pandas.DataFrame)

Get all initial parameters from the individual objects.

get_parameters(→ pastas.typing.ArrayLike)

Obtain the parameters needed for calculation.

get_stressmodel_names(→ list[str])

Return list of stressmodel names.

get_stressmodel_settings(→ dict[str, Any] | None)

Obtain the time series settings for a stress model.

get_contribution(→ pandas.Series)

Get contribution of a stressmodel.

get_contributions(→ list[pandas.Series])

Get contributions of all stressmodels.

get_transform_contribution(→ pandas.Series)

Get contribution of a transform.

get_output_series(→ pandas.DataFrame)

Get all the modeled output time series from the Model.

get_block_response(→ pandas.Series | None)

Obtain the block response for a stressmodel.

get_step_response(→ pandas.Series | None)

Obtain the step response for a stressmodel.

get_response_tmax(→ float | None)

Get tmax used for the response function.

get_stress(→ pandas.Series | list[pandas.Series])

Obtain the stress(es) from the stressmodel.

fit_report(→ str)

Fit report of the model solve.

to_dict(→ dict)

Export a model to a dictionary.

to_file(→ None)

Save the Pastas model to a file.

copy(→ pastas.typing.Model)

Copy a model.