starling_sim.basemodel.output.simulation_events

Module Contents

Classes

SimulationEvents

Class for generating an event file output from a simulation.

Attributes

VERSION

starling_sim.basemodel.output.simulation_events.VERSION = '0.0.1'
class starling_sim.basemodel.output.simulation_events.SimulationEvents

Class for generating an event file output from a simulation.

from_simulation_model
from_file
create_empty_root()
set_tree(element_tree: xml.etree.ElementTree.ElementTree)
add_agent(agent_element)
static from_simulation_model(simulation_model)

Create a SimulationEvents instance from a simulation.

Add events for all the agents of the population.

Parameters:

simulation_model – SimulationModel instance

Returns:

SimulationEvents instance

static from_file(filepath)

Create a SimulationEvents instance from a simulation event file.

Parameters:

filepath – path to the event file

Returns:

SimulationEvents instance

agents_events(agent_type: str = None) list

Return an iterable over the “agent”-tagged elements.

If an agent type is provided, return only the agents of the matching agent type.

Parameters:

agent_type – agent type filter

Returns:

list of “agent” elements matching the agent type

agent_element(agent_id: str) xml.etree.ElementTree.Element | None

Find the “agent” element corresponding to the given id.

Parameters:

agent_id – agent id to find in the events

Returns:

“agent” element matching the id, or None if it is not found

tostring() str

Convert the tree to an indented string.

Returns:

tree as a string

write(filepath)

Write the tree to a XML file.

If the filepath ends with “.gz”, the output file is compressed.

Parameters:

filepath – path to the target file