User Functions Reference

These are the primary functions that control model import and execution.

pysd.read_vensim(mdl_file, initialize=True, missing_values='warning', split_views=False, **kwargs)[source]

Construct a model from Vensim .mdl file.

Parameters:
  • mdl_file (str) – The relative path filename for a raw Vensim .mdl file.
  • initialize (bool (optional)) – If False, the model will not be initialize when it is loaded. Default is True.
  • missing_values (str ("warning", "error", "ignore", "keep") (optional)) – What to do with missing values. If “warning” (default) shows a warning message and interpolates the values. If “raise” raises an error. If “ignore” interpolates the values without showing anything. If “keep” it will keep the missing values, this option may cause the integration to fail, but it may be used to check the quality of the data.
  • split_views (bool (optional)) – If True, the sketch is parsed to detect model elements in each model view, and then translate each view in a separate python file. Setting this argument to True is recommended for large models split in many different views. Default is False.
  • **kwargs ((optional)) –

    Additional keyword arguments for translation. subview_sep: list

    Characters used to separate views and subviews (e.g. [“,”, “.”]). If provided, and split_views=True, each submodule will be placed inside the directory of the parent view.
Returns:

model – Elements from the python model are loaded into the PySD class and ready to run

Return type:

a PySD class object

Examples

>>> model = read_vensim('../tests/test-models/samples/teacup/teacup.mdl')
pysd.read_xmile(xmile_file, initialize=True, missing_values='warning')[source]

Construct a model from .xmile file.

Parameters:
  • xmile_file (str) – The relative path filename for a raw .xmile file.
  • initialize (bool (optional)) – If False, the model will not be initialize when it is loaded. Default is True.
  • missing_values (str ("warning", "error", "ignore", "keep") (optional)) – What to do with missing values. If “warning” (default) shows a warning message and interpolates the values. If “raise” raises an error. If “ignore” interpolates the values without showing anything. If “keep” it will keep the missing values, this option may cause the integration to fail, but it may be used to check the quality of the data.
Returns:

model – Elements from the python model are loaded into the PySD class and ready to run

Return type:

a PySD class object

Examples

>>> model = read_xmile('../tests/test-models/samples/teacup/teacup.xmile')
pysd.load(py_model_file, initialize=True, missing_values='warning')[source]

Load a python-converted model file.

Parameters:
  • py_model_file (str) – Filename of a model which has already been converted into a python format.
  • initialize (bool (optional)) – If False, the model will not be initialize when it is loaded. Default is True.
  • missing_values (str ("warning", "error", "ignore", "keep") (optional)) – What to do with missing values. If “warning” (default) shows a warning message and interpolates the values. If “raise” raises an error. If “ignore” interpolates the values without showing anything. If “keep” it will keep the missing values, this option may cause the integration to fail, but it may be used to check the quality of the data.

Examples

>>> model = load('../tests/test-models/samples/teacup/teacup.py')