backup
crowd_to_dict
Contains functions to represent the crowd data in dictionary format.
- configuration.backup.crowd_to_dict.get_light_agents_params(current_crowd)[source]
Retrieve the physical and geometric parameters of all agents in a structured format.
- Parameters:
current_crowd (Crowd) -- The current crowd object containing agent data.
- Returns:
A dictionary containing agent data for all agents in the crowd.
- Return type:
StaticCrowdDataType
- configuration.backup.crowd_to_dict.get_static_params(current_crowd)[source]
Retrieve the physical and geometric parameters of all agents in a structured format.
- Parameters:
current_crowd (Crowd) -- The current crowd object containing agent data.
- Returns:
Static parameters of all agents in the crowd.
- Return type:
StaticCrowdDataType
- configuration.backup.crowd_to_dict.get_dynamic_params(current_crowd)[source]
Retrieve the physical and geometric parameters of all agents in a structured format.
- Parameters:
current_crowd (Crowd) -- The current crowd object containing agent data.
- Returns:
Dynamical parameters for all agents in the crowd.
- Return type:
DynamicCrowdDataType
- configuration.backup.crowd_to_dict.get_geometry_params(current_crowd)[source]
Retrieve the parameters of the boundaries.
- Parameters:
current_crowd (Crowd) -- The current crowd object containing agent data.
- Returns:
A dictionary containing the geometric parameters of the boundaries, including dimensions (Lx and Ly) and wall corner data.
- Return type:
GeometryDataType
- configuration.backup.crowd_to_dict.get_interactions_params(current_crowd)[source]
Retrieve the parameters for agent interactions.
- Parameters:
current_crowd (Crowd) -- The current crowd object containing agent data.
- Returns:
A dictionary containing the parameters for agent interactions.
- Return type:
InteractionsDataType
dict_to_xml_and_reverse
Contains functions to go from a dictionary representation of the crowd parameters to a XML representation and the reverse.
- configuration.backup.dict_to_xml_and_reverse.save_light_agents_params_dict_to_xml(crowd_data_dict)[source]
Generate a pretty-printed XML string of agent parameters from a dictionary.
- Parameters:
crowd_data_dict (StaticCrowdDataType) -- A dictionary containing static agent data for all agents in the crowd.
- Returns:
A string representation of the dictionary.
- Return type:
- configuration.backup.dict_to_xml_and_reverse.static_dict_to_xml(crowd_dict)[source]
Convert a static crowd dictionary to a prettified XML representation.
- Parameters:
crowd_dict (StaticCrowdDataType) -- Dictionary with agent data.
- Returns:
UTF-8 encoded, pretty-printed XML representation of all agents' static parameters.
- Return type:
- configuration.backup.dict_to_xml_and_reverse.dynamic_dict_to_xml(dynamical_parameters_crowd)[source]
Convert a dictionary of agents' dynamic parameters to a prettified XML representation.
- Parameters:
dynamical_parameters_crowd (DynamicCrowdDataType) -- Dictionary with agent data.
- Returns:
UTF-8 encoded, pretty-printed XML representation of all agents' dynamic parameters.
- Return type:
- configuration.backup.dict_to_xml_and_reverse.geometry_dict_to_xml(boundaries_dict)[source]
Convert a dictionary of geometry data to a prettified XML representation.
- Parameters:
boundaries_dict (GeometryDataType) -- Dictionary with boundary data.
- Returns:
UTF-8 encoded, pretty-printed XML representation of the boundaries.
- Return type:
- configuration.backup.dict_to_xml_and_reverse.materials_dict_to_xml(material_dict)[source]
Convert a dictionary of material properties to a prettified XML representation.
- Parameters:
material_dict (MaterialsDataType) -- Dictionary with material data.
- Returns:
UTF-8 encoded, pretty-printed XML representation of the materials.
- Return type:
- configuration.backup.dict_to_xml_and_reverse.interactions_dict_to_xml(data)[source]
Convert a dictionary of interactions data to a prettified XML representation.
- Parameters:
data (InteractionsDataType) -- Dictionary with interactions data.
- Returns:
UTF-8 encoded, pretty-printed XML representation of all agents and their interactions.
- Return type:
- configuration.backup.dict_to_xml_and_reverse.static_xml_to_dict(xml_file)[source]
Convert an XML string representing agents' static data into a dictionary.
- Parameters:
xml_file (str) -- XML data as a string.
- Returns:
A dictionary representation of the XML data.
- Return type:
StaticCrowdDataType
- Raises:
ValueError -- If the XML structure or attribute types are incorrect.
- configuration.backup.dict_to_xml_and_reverse.dynamic_xml_to_dict(xml_data)[source]
Convert an XML string representing agents' dynamic parameters into a dictionary.
- Parameters:
xml_data (str) -- A string containing XML data.
- Returns:
A dictionary representation of the XML data.
- Return type:
DynamicCrowdDataType
- Raises:
ValueError -- If the XML structure or attribute types are incorrect.
- configuration.backup.dict_to_xml_and_reverse.geometry_xml_to_dict(xml_data)[source]
Convert an XML string representing geometric data into a dictionary.
- Parameters:
xml_data (str) -- A string containing XML data.
- Returns:
A dictionary representation of the XML data.
- Return type:
GeometryDataType
- Raises:
ValueError -- If the XML structure or attribute types are incorrect.
- configuration.backup.dict_to_xml_and_reverse.materials_xml_to_dict(xml_data)[source]
Convert an XML string representing material properties into a dictionary.
- Parameters:
xml_data (str) -- A string containing XML data.
- Returns:
A dictionary representation of the XML data.
- Return type:
MaterialsDataType
- Raises:
ValueError -- If the XML structure or attribute types are incorrect.
- configuration.backup.dict_to_xml_and_reverse.interactions_xml_to_dict(xml_data)[source]
Convert an XML string describing interactions between agents and with boundaries into a dictionary.
- Parameters:
xml_data (str) -- A string containing XML data.
- Returns:
A dictionary representation of the XML data.
- Return type:
InteractionsDataType
- Raises:
ValueError -- If the XML structure or attribute types are incorrect.
crowd_to_zip_and_reverse
Contains functions to export crowd data to a ZIP file and save it.
- configuration.backup.crowd_to_zip_and_reverse.write_crowd_data_to_zip(current_crowd)[source]
Generate an in-memory ZIP file containing XML representations of the nested dictionaries that summarize the crowd parameters.
- Parameters:
current_crowd (Crowd) -- The current crowd object containing the parameters to be saved.
- Returns:
An in-memory ZIP file containing the XML representations of crowd parameters.
- Return type:
- configuration.backup.crowd_to_zip_and_reverse.save_crowd_data_to_zip(current_crowd, output_zip_path)[source]
Save crowd data as a ZIP file containing multiple XML files.
- Parameters:
current_crowd (Crowd) -- The current crowd object containing the parameters to be saved.
output_zip_path (Path) -- The path where the ZIP file will be saved.
- Raises:
TypeError -- If output_zip_path is not a Path object.
ValueError -- If output_zip_path does not have a .zip extension.
- Return type:
xml_to_Chaos
Export agent trajectories from XML files to CHAOS format.
- configuration.backup.xml_to_Chaos.get_list_of_agents_and_times_from_XML(folder_path)[source]
Extract a sorted list of unique agent IDs, sorted list of times, and a dictionary of filenames from XML files in a folder.
- Parameters:
folder_path (Path) -- Path to the folder containing XML files.
- Return type:
- Returns:
list[str] -- Sorted list of unique agent IDs found in the XML files.
list[float] -- Sorted list of times extracted from the filenames.
dict[int, str] -- Dictionary mapping time (as int, scaled by 1000) to the corresponding filename.
Notes
Assumes XML files are named with the pattern 'AgentDyn...input t=<time>.xml'.
- configuration.backup.xml_to_Chaos.create_dict_of_agent_trajectories(folder_path)[source]
Create a dictionary of agent trajectories from XML files in a folder.
For each agent, stores their position and velocity at each time point.
- Parameters:
folder_path (Path) -- Path to the folder containing XML files.
- Return type:
tuple[list[float],dict[str,dict[float,dict[str,float]]]]- Returns:
list[float] -- Sorted list of all time points extracted from the XML filenames.
dict[str, dict[float, dict[str, float]]] -- Nested dictionary such that: agents[agent_id][time] = {
'x': pos_x, 'y': pos_y, 'vx': vel_x, 'vy': vel_y
}.
Notes
Assumes XML files are named and structured as expected by get_list_of_agents_and_times_from_XML.
- configuration.backup.xml_to_Chaos.export_XML_to_CSV(PathCSV, PathXML)[source]
Export agent trajectories to a CSV file with header: t,ID,x,y,vx,vy.
Each row of the CSV contains the time, agent ID, position (x, y), and velocity (vx, vy) for each agent at each time point.
- Parameters:
PathCSV (Path) -- Path to the folder where the CSV file will be saved.
PathXML (Path) -- Path to the folder containing the XML files (AgentDynamics).
- Return type:
- configuration.backup.xml_to_Chaos.export_CSV_to_CHAOS(PathCSV, dt)[source]
Read agent trajectories from a CSV file and exports them into multiple text files in the format required by the ChAOS software.
For each unique agent ID, creates a file containing interpolated positions at regular time steps.
- Parameters:
PathCSV (Path) -- Path to the folder containing the CSV file containing columns: t, ID, x, y, vx, vy.
dt (float) -- Timestep to use for interpolation in the CHAOS output.
- Return type:
Notes
Each output file is named 'trajXXX.csv' where XXX is the zero-padded agent index. Each line in the output file contains: t, x, y, 0.0
xml_to_PedPy
Export agent trajectories from XML files to TrajectoryData and WalkableArea formats used in PedPy.
- configuration.backup.xml_to_PedPy.GeometryDict_to_PedPyWalkableArea(geometry_dict)[source]
Convert a geometry dictionary (from XML) to a PedPy WalkableArea object.
- Parameters:
geometry_dict (GeometryDataType) --
- Dictionary containing geometry information, expected to have a structure with "Geometry" -> "Wall" -> "Wall0" with "Corners"
for the main walkable area, and optionally other wallsrepresenting obstacles.
- Returns:
A PedPy WalkableArea object with the main polygon defined by "Wall0" and any additional walls as obstacles.
- Return type:
WalkableArea
- configuration.backup.xml_to_PedPy.export_XML_to_PedPy(PathAgentDynamicsXML, PathGeometryXMLfile, PathCSVfile=None)[source]
Export trajectories from the AgentDynamics XML files to a TrajectoryData and WalkableArea objects used in PedPy Python library.
- Parameters:
PathAgentDynamicsXML (Path) -- Path to the XML directory containing the AgentDynamics XML files.
PathGeometryXMLfile (Path) -- Path to the XML file containing geometry information.
PathCSVfile (Path | None) -- Optional path for the intermediate CSV. If None, uses xml_path.with_suffix(".csv").
- Returns:
PedPy trajectory data with columns ["id", "frame", "x", "y"] and frame_rate = 1/dt.
- Return type:
tuple[TrajectoryData, WalkableArea]
Notes
Assumes XML files are named with the pattern 'AgentDyn...input t=<time>.xml'. The AgentDynamics XML files are first converted into a single CSV file and then converted into a TrajectoryData object. Expected CSV columns: t, ID, x, y.