pastas.model.Model#

class pastas.model.Model(oseries: pandas.Series, constant: bool = True, noisemodel=None, 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).

  • noisemodel (bool, optional) – The noisemodel argument is deprecated and will be removed in Pastas version 2.0.0. To add a noisemodel, use ml.add_noisemodel(n), where is an instance of a noisemodel (e.g., n = ps.ArNoiseModel()). The use of the noisemodel argument will raise a ValueError.

  • 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 fit#

Deprecated attribute, use ml.solver instead.

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)

Adds a noisemodel to the time series Model.

del_stressmodel(name)

Method to safely delete a stress model from the Model.

del_constant(→ None)

Method to safely delete the Constant from the Model.

del_transform(→ None)

Method to safely delete the transform from the Model.

del_noisemodel(→ None)

Method to safely delete the noise model from the Model.

simulate(→ pandas.Series)

Method to simulate the time series model.

residuals(→ pandas.Series)

Method to calculate the residual series.

noise(→ pandas.Series | None)

Method to simulate the noise when a noisemodel is present.

noise_weights(→ pastas.typing.ArrayLike)

Internal method to calculate the noise weights.

observations(→ pandas.Series)

Method that returns the observations series used for calibration.

initialize(→ None)

Method to initialize the model.

add_solver(→ None)

Method to add a solver to the model.

solve(→ None)

Method to solve the time series model.

set_parameter(→ None)

Method to change the parameter properties.

set_oseries(→ None)

Set a new oseries for an existing Model.

get_tmin(→ pandas.Timestamp)

Method that checks and returns valid values for tmin.

get_tmax(→ pandas.Timestamp)

Method that checks and returns valid values for tmax.

get_init_parameters(→ pandas.DataFrame)

Method to get all initial parameters from the individual objects.

get_parameters(→ pastas.typing.ArrayLike)

Method to obtain the parameters needed for calculation.

get_stressmodel_names(→ list[str])

Returns list of stressmodel names.

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

Method to obtain the time series settings for a stress model.

get_contribution(→ pandas.Series)

Method to get the contribution of a stressmodel.

get_contributions(→ list[pandas.Series])

Method to get contributions of all stressmodels.

get_transform_contribution(→ pandas.Series)

Method to get the contribution of a transform.

get_output_series(→ pandas.DataFrame)

Method to get all the modeled output time series from the Model.

get_block_response(→ pandas.Series | None)

Method to obtain the block response for a stressmodel.

get_step_response(→ pandas.Series | None)

Method to obtain the step response for a stressmodel.

get_response_tmax(→ float | None)

Method to get the tmax used for the response function.

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

Method to obtain the stress(es) from the stressmodel.

fit_report(→ str)

Method that reports on the fit after a model is optimized.

to_dict(→ dict)

Method to export a model to a dictionary.

to_file(→ None)

Method to save the Pastas model to a file.

copy(→ pastas.typing.Model)

Method to copy a model.