:py:mod:`starling_sim.basemodel.output.simulation_events` ========================================================= .. py:module:: starling_sim.basemodel.output.simulation_events Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: starling_sim.basemodel.output.simulation_events.SimulationEvents Attributes ~~~~~~~~~~ .. autoapisummary:: starling_sim.basemodel.output.simulation_events.VERSION .. py:data:: VERSION :value: '0.0.1' .. py:class:: SimulationEvents Class for generating an event file output from a simulation. .. py:attribute:: from_simulation_model .. py:attribute:: from_file .. py:method:: create_empty_root() .. py:method:: set_tree(element_tree: xml.etree.ElementTree.ElementTree) .. py:method:: add_agent(agent_element) .. py:method:: from_simulation_model(simulation_model) :staticmethod: Create a SimulationEvents instance from a simulation. Add events for all the agents of the population. :param simulation_model: SimulationModel instance :return: SimulationEvents instance .. py:method:: from_file(filepath) :staticmethod: Create a SimulationEvents instance from a simulation event file. :param filepath: path to the event file :return: SimulationEvents instance .. py:method:: 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. :param agent_type: agent type filter :return: list of "agent" elements matching the agent type .. py:method:: agent_element(agent_id: str) -> xml.etree.ElementTree.Element | None Find the "agent" element corresponding to the given id. :param agent_id: agent id to find in the events :return: "agent" element matching the id, or None if it is not found .. py:method:: tostring() -> str Convert the tree to an indented string. :return: tree as a string .. py:method:: write(filepath) Write the tree to a XML file. If the filepath ends with ".gz", the output file is compressed. :param filepath: path to the target file