The default behavior for adding and solving with noisemodels has changed from Pastas 1.5. Find more information here

CompareModels#

class CompareModels(models, names=None)[source]#

Class for visually comparing pastas Models.

This is a versatile class for constructing visual model comparison plots. The default CompareModels.plot() method mimics ml.plots.results() but allows multiple models to be included in the figure. Instead of parameter uncertainties, by default only optimal values are shown for each model and a table containing fit metrics is included in the top right of the figure.

The visualization of each component (i.e. time series, a table) is controlled by separate functions allowing users to easily customize their figure. The layout of the figure is controlled by a so-called “mosaic”, which is essentially a 2D array (in the form of nested lists) containing labels that refer to specific axes:

mosaic = [
    ["sim", "sim", "met"],   # oseries+simulation (2x2), metrics       (1x1)
    ["sim", "sim", "tab"],   # oseries+simulation (2x2), parameters    (2x1)
    ["res", "res", "tab"],   # residuals+noise    (1x2), parameters    (2x1)
    ["con0", "con0", "rf0"]  # contributions      (1x2), step response (1x1)
]

In this example, the “sim” axis will be 2x2 in the top left portion of the figure (with total dimensions (4x3)), while the “met” axis will be 1x1 in the top right. Users can either use the default mosaic or provide their own.

Additional logic is available to control plotting of multiple contributions of stresses on the same set of axes. Additionally, some helper methods are defined to obtain relevant information from the models passed to CompareModels.

Example usage:

mc = ps.CompareModels([ml1, ml2])
mc.plot()

# obtain axes handles
sim_ax = mc.axes["sim"]
sim_ax.grid(False)

# save figure
mc.figure.savefig("modelcomparison.png")
Parameters

Methods#

__init__

Initialize model compare class.

get_default_mosaic

Get default mosaic for matplotlib.subplot_mosaic().

get_diagnostics

Get p-values of statistical tests in a DataFrame.

get_metrics

get metrics of all models in a DataFrame.

get_parameters

get parameter values of all models in a DataFrame.

get_tmin_tmax

get tmin and tmax of all models.

get_unique_stressmodels

Get all unique stressmodel names.

initialize_adjust_height_figure

initialize subplots based on a mosaic with equal vertical scales.

initialize_figure

initialize a custom figure based on a mosaic.

plot

plot the models in a comparison plot.

plot_acf

plot autocorrelation plot.

plot_contribution

plot stressmodel contributions.

plot_noise

plot noise.

plot_oseries

Plot all oseries, unless all oseries are the same.

plot_residuals

plot residuals.

plot_response

plot step or block responses.

plot_simulation

plot model simulation.

plot_stress

plot stresses time series.

plot_table

Plot dataframe as table.

plot_table_diagnostics

plot diagnostics table.

plot_table_metrics

plot metrics table.

plot_table_params

plot model parameters table.

share_xaxes

share x-axes.

share_yaxes

share y-axes.