This is the Carousel models module that contains definitions for the Model class.

The Carousel model contains five layers: Data, Formulas, Calculations, Outputs and Simulations. The Data layer organizes Data Sources by providing methods to add and load data for Carousel. The Formulas layer loads Formulas used by Calculations calculations. The Outputs layer organizes the calculated outputs for use in other calculations. Finally the Simulations layer organizes options such as how long the simulation should run and takes care of actually running the simulation.

Model Parameter

class carousel.core.models.ModelParameter(*args, **kwargs)[source]
  • layer (str) – name of the layer class of these parameters, optional
  • module (str) – module that the sources are defined in, optional
  • package (str) – package that the source module is contained in, optional
  • path (str) – path to source package if not on PYTHONPATH, optional
  • sources (list) – name of classes with each layers parameters

Model Base

class carousel.core.models.ModelBase[source]

Base model meta class. If model has class attributes “modelpath” and “modelfile” then layer class names and model configuration will be read from the file on that path. Otherwise layer class names will be read from the class attributes.


class carousel.core.models.Model(modelfile=None)[source]

A class for models. Carousel is a subclass of the Model class.

Parameters:modelfile (str) – The name of the JSON file with model data.
add(layer, items)[source]

Add items in model.

command(cmd, progress_hook=None, *args, **kwargs)[source]

Execute a model command.

  • cmd – Name of the command.
  • progress_hook – A function to which progress updates are passed.
delete(layer, items)[source]

Delete items in model.

edit(layer, item, delete=False)[source]

Edit model.

  • layer (str) – Layer of model to edit
  • item (dict) – Items to edit.
  • delete (bool) – Flag to return Layer to delete item.
layers = None

dictionary of model layer classes

load(modelfile, layer=None)[source]

Load or update a model or layers in a model.

  • modelfile (str) – The name of the json file to load.
  • layer (str) – Optionally load only specified layer.
model = None

dictionary of the model

param_file = None

model file

save(modelfile, layer=None)[source]

Save a model file.

  • modelfile (str) – The name of the json file to save.
  • layer (str) – Optionally save only specified layer.

current state of the model