Illuminator Data Models

class illuminator.models.CSV_reader_v3.CSV(**kwargs)

A model for reading time series data from CSV files.

This model reads data from a CSV file line by line, synchronizing with simulation time. The CSV file should contain a header row with column names and a timestamp column.

Parameters:
  • date_format (str) – Format of the date/time column in the CSV file

  • delimiter (str) – Column delimiter character in the CSV file (default ‘,’)

  • datafile (str) – Path to the CSV file to read from

Inputs:

None

Outputs:

next_row (dict) – The data from the current row, with column names as keys

States:

None

finalize() None

Closes the file object within self.datafile.

init(sid, time_resolution=1, **sim_params)
Initialize the simulator with the ID sid and pass the

time_resolution and additional parameters (sim_params) sent by mosaik. Return the meta data meta.

If your simulator has no sim_params, you don’t need to override this method.

inputs: Dict = {}
meta: Meta

Meta data describing the simulator (the same that is returned by init()).

{
    'api_version': 'x.y',
    'type': 'time-based'|'event-based'|'hybrid',
    'models': {
        'ModelName': {
            'public': True|False,
            'params': ['param_1', ...],
            'attrs': ['attr_1', ...],
            'any_inputs': True|False,
            'trigger': ['attr_1', ...],
            'non-persistent': ['attr_2', ...],
        },
        ...
    },
    'extra_methods': [
        'do_cool_stuff',
        'set_static_data'
    ]
}

The api_version is a string that defines which version of the mosaik API the simulator implements. Since mosaik API version 2.3, the simulator’s major version (“x”, in the snippet above) has to be equal to mosaik’s. Mosaik will cancel the simulation if a version mismatch occurs.

The type defines how the simulator is advanced through time and whether its attributes are persistent in time or transient.

models is a dictionary describing the models provided by this simulator. The entry public determines whether a model can be instantiated by a user (True) or if it is a sub-model that cannot be created directly (False). params is a list of parameter names that can be passed to the model when creating it. attrs is a list of attribute names that can be accessed (reading or writing). If the optional any_inputs flag is set to true, any attributes can be connected to the model, even if they are not attrs. This may, for example, be useful for databases that don’t know in advance which attributes of an entity they’ll receive. trigger is a list of attribute names that cause the simulator to be stepped when another simulator provides output which is connected to one of those.

extra_methods is an optional list of methods that a simulator provides in addition to the standard API calls (init(), create() and so on). These methods can be called while the scenario is being created and can be used for operations that don’t really belong into init() or create().

outputs: Dict = {'next_row': ''}
parameters: Dict = {'datafile': '', 'date_format': '', 'delimiter': ','}
states: Dict = {}
step(time, inputs, max_advance=900) None

Perform one step of the simulation.

Parameters:

timeint

The current time of the simulation.

inputsdict

Input values for the simulation step.

max_advanceint

Maximum time the simulator can advance (default is 900 seconds).

Returns:

int

The next simulation time.

time = None
time_step_size: int = 1