sensitivity_sobol(output, param_ranges, measures=None, **kwargs)[source]

Calculates Sobol Sensitivity Indices and adds them to the output, using SALib.analyze.sobol.analyze().

  • output (DataDict) – The output of an experiment that was set to only one iteration (default) and used a parameter sample that was generated with sample_saltelli().

  • param_ranges (dict) – The same dictionary that was used for the generation of the parameter sample with sample_saltelli().

  • measures (str or list of str, optional) – The measures that should be used for the analysis. If none are passed, all are used.

  • **kwargs – Will be forwarded to SALib.analyze.sobol.analyze(). The kwarg calc_second_order must be the same as for sample_saltelli().


animate(model, fig, axs, plot, steps=None, skip=0, fargs=(), **kwargs)[source]

Returns an animation of the model simulation, using matplotlib.animation.FuncAnimation().

  • model (Model) – The model instance.

  • fig (matplotlib.figure.Figure) – Figure for the animation.

  • axs (matplotlib.axes.Axes or list) – Axis or list of axis of the figure.

  • plot (function) – Function that takes (model, ax, *fargs) and creates the desired plots on each axis at each time-step.

  • steps (int, optional) – Maximum number of steps for the simulation to run. If none is given, the parameter ‘Model.p.steps’ will be used. If there is no such parameter, ‘steps’ will be set to 1000.

  • skip (int, optional) – Number of rounds to skip before the animation starts (default 0).

  • fargs (tuple, optional) – Forwarded fo the plot function.

  • **kwargs – Forwarded to matplotlib.animation.FuncAnimation().


An animation can be generated as follows:

def my_plot(model, ax):
    pass  # Call pyplot functions here

fig, ax = plt.subplots()
my_model = MyModel(parameters)
animation = ap.animate(my_model, fig, ax, my_plot)

One way to display the resulting animation object in Jupyter:

from IPython.display import HTML


gridplot(grid, color_dict=None, convert=False, ax=None, **kwargs)[source]

Visualizes values on a two-dimensional grid with matplotlib.pyplot.imshow().

  • grid (list of list) – Two-dimensional grid with values. numpy.nan values will be plotted as empty patches.

  • color_dict (dict, optional) – Dictionary that translates each value in grid to a color specification.

  • convert (bool, optional) – Convert values to rgba vectors, using matplotlib.colors.to_rgba() (default False).

  • ax (matplotlib.pyplot.axis, optional) – Axis to be used for plot.

  • **kwargs – Forwarded to matplotlib.pyplot.imshow().