close_contacts_calculator
¶
Module Contents¶
Classes¶
Helper class that provides a standard way to create an ABC using |
- class close_contacts_calculator.CloseContactsCalculator(facility: citam.engine.facility.indoor_facility.Facility, contact_distance: float = 6.0)¶
Bases:
citam.engine.calculators.calculator.Calculator
Helper class that provides a standard way to create an ABC using inheritance.
- initialize(agents: OrderedDict[int, citam.engine.core.agent.Agent], workdir: Optional[Union[os.PathLike, str]] = None)¶
- run(current_step: int, active_agents: List[citam.engine.core.agent.Agent]) None ¶
Iterate over agents, compute whether they fall within the contact distance or not and verify that they are indeed making contact (based on whether they are in the same space or not).
- Parameters:
agents (List[Agent]) – list of agents under consideration for contact statistics
contact_outfiles (List[TextIO], optional) – Files to write contact data, one per floor, defaults to None
- finalize(agents: List[citam.engine.core.agent.Agent], work_directory: Optional[Union[str, bytes, os.PathLike]] = None) None ¶
- identify_xy_proximity(positions_vector: numpy.ndarray) numpy.ndarray ¶
Compute pairwise distances, given a vector of xy positions, and return the indices of the ones that fall within the given contact distance.
- Parameters:
positions_vector (np.ndarray) – Array of current xy positions of all active agents
- Returns:
Array of indices of agents that are within the contact distance of each other
- Return type:
np.ndarray
- verify_and_add_contact(current_step: int, floor_number: int, agent1: citam.engine.core.agent.Agent, agent2: citam.engine.core.agent.Agent)¶
Verify if agents are in nearby hallways before creating contact event.
- add_contact_event(current_step: int, agent1: citam.engine.core.agent.Agent, agent2: citam.engine.core.agent.Agent) None ¶
Record contact event between agent1 and agent2.
- extract_contact_distribution_per_agent(agents: List[citam.engine.core.agent.Agent]) Tuple[List[str], List[int]] ¶
Compute and return total contacts per agent.
- Returns:
List of agent ids and their total contacts
- Return type:
Tuple[List[int], List[int]]
- save_to_files(agents: List[citam.engine.core.agent.Agent], work_directory: Union[str, bytes, os.PathLike])¶
Write output files to the output directory
- Parameters:
work_directory (str) – directory where all output files are to be saved.
- create_svg_heatmap(contacts_per_coord: Dict[Tuple[int, int], int], floor_directory: str) None ¶
Create and save a heatmap from coordinate contact data.
- Parameters:
contacts_per_coord (Dict[Tuple[int, int], int]) – dictionary where each key is an (x,y ) tuple and values are the number of contacts in that location.
floor_directory (str) – directory to save the heatmap file.
- Raises:
FileNotFoundError – if the floor svg map file is not found.