Load Trajectories#

Load trajectories to the internal trajectory data format.

class TrajectoryUnit(*args, **kwds)#

Identifier of the unit of the trajectory coordinates.

CENTIMETER = 100#

centimeter (cm)

METER = 1#

meter (m)

load_trajectory(*, trajectory_file, default_frame_rate=None, default_unit=None)#

Loads the trajectory file in the internal TrajectoryData format.

Loads the relevant data: trajectory data, frame rate, and type of trajectory from the given trajectory file. If the file does not contain some data, defaults can be submitted.

Parameters:
  • trajectory_file (pathlib.Path) – file containing the trajectory

  • default_frame_rate (float) – frame rate of the file, None if frame rate from file is used

  • default_unit (TrajectoryUnit) – unit in which the coordinates are stored in the file, None if unit should be parsed from the file

Returns:

TrajectoryData

representation of the file data

Return type:

TrajectoryData

load_trajectory_from_crowdit(*, trajectory_file)#

Loads data from Crowdit file as TrajectoryData.

This function reads a CSV file containing trajectory data from Crowdit simulations and converts it into a TrajectoryData object.

Parameters:

trajectory_file (pathlib.Path) – The full path of the CSV file containing the Crowdit trajectory data. The expected format is a CSV file with comma as delimiter, and it should contain at least the following columns: pedID, time, posX, posY.

Returns:

TrajectoryData representation

of the file data

Return type:

TrajectoryData

Raises:

LoadTrajectoryError – If the provided path does not exist or is not a file.

load_trajectory_from_jupedsim_sqlite(trajectory_file)#

Loads data from the sqlite file as TrajectoryData.

Parameters:

trajectory_file (pathlib.Path) – trajectory file in JuPedSim sqlite format

Returns:

TrajectoryData

representation of the file data

Return type:

TrajectoryData

load_trajectory_from_pathfinder_csv(*, trajectory_file)#

Loads data from Pathfinder-CSV file as TrajectoryData.

This function reads a CSV file containing trajectory data from Pathfinder simulations and converts it into a TrajectoryData object.

Note

Pathfinder data have a time column, that is going to be converted to a frame column for use with PedPy.

Warning

Currently only Pathfinder files with a time column can be loaded.

Parameters:

trajectory_file (pathlib.Path) – The full path of the CSV file containing the Pathfinder trajectory data. The expected format is a CSV file with comma as delimiter, and it should contain at least the following columns: id, t, x, y.

Returns:

TrajectoryData representation

of the file data

Return type:

TrajectoryData

Raises:

LoadTrajectoryError – If the provided path does not exist or is not a file.

load_trajectory_from_pathfinder_json(*, trajectory_file)#

Loads Pathfinder-JSON as TrajectoryData.

This function reads a JSON file containing trajectory data from Pathfinder simulations and converts it into a TrajectoryData object.

Note

Pathfinder JSON data have a time-based structure that is going to be converted to a frame column for use with PedPy.

Parameters:

trajectory_file (pathlib.Path) – The full path of the JSON containing the Pathfinder trajectory data. The expected format is a JSON file with agent IDs as top-level keys, and time-stamped position data as nested objects.

Returns:

TrajectoryData representation

of the file data

Return type:

TrajectoryData

Raises:

LoadTrajectoryError – If the provided path does not exist or is not a file, or if the JSON structure is invalid.

load_trajectory_from_ped_data_archive_hdf5(trajectory_file)#

Loads data from the hdf5 file as TrajectoryData.

Loads data from files in the Pedestrian Dynamics Data Archive HDF5 format. The format is explained in more detail here.

In short: The file format includes the trajectory data in a data set trajectory which contains the trajectory data, e.g., x, y, z coordinates, frame number and a person identifier. The dataset is additionally annotated with an attribute fps which gives the frame rate in which the data was recorded.

Parameters:

trajectory_file (pathlib.Path) – trajectory file in Pedestrian Dynamics Data Archive HDF5 format

Returns:

TrajectoryData representation

of the file data

Return type:

TrajectoryData

load_trajectory_from_txt(*, trajectory_file, default_frame_rate=None, default_unit=None)#

Loads the trajectory file in the internal TrajectoryData format.

Loads the relevant data: trajectory data, frame rate, and type of trajectory from the given trajectory file. If the file does not contain some data, defaults can be submitted.

Parameters:
  • trajectory_file (pathlib.Path) – file containing the trajectory

  • default_frame_rate (float) – frame rate of the file, None if frame rate from file is used

  • default_unit (TrajectoryUnit) – unit in which the coordinates are stored in the file, None if unit should be parsed from the file

Returns:

TrajectoryData

representation of the file data

Return type:

TrajectoryData

load_trajectory_from_vadere(*, trajectory_file, frame_rate, ignore_too_short_trajectories=False)#

Loads trajectory from Vadere-traj file.

This function reads a traj file containing trajectory data from Vadere simulations and converts it into a TrajectoryData object which can be used for further analysis and processing in PedPy.

Parameters:
  • trajectory_file (pathlib.Path) – Full path of the trajectory file containing Vadere trajectory data. The expected format is a traj file with space character as delimiter, and it should contain the following columns: pedestrianId, simTime (in sec), startX (in m), startY (in m). Additional columns (e.g. endTime, endX, endY, targetId) will be ignored.

  • frame_rate (float) – Frame rate in frames per second.

  • ignore_too_short_trajectories (bool) – If False (default), the operation will abort when a trajectory is detected to be too short. If True, such trajectories will be ignored and a warning logged.

Returns:

TrajectoryData representation of the file data

Return type:

TrajectoryData

Raises:
  • LoadTrajectoryError – If the provided path does not exist,

  • is not a file or has fissing columns.

load_trajectory_from_viswalk(*, trajectory_file)#

Loads data from Viswalk-csv file as TrajectoryData.

This function reads a CSV file containing trajectory data from Viswalk simulations and converts it into a TrajectoryData object which can be used for further analysis and processing in the PedPy framework.

Note

Viswalk data have a time column, that is going to be converted to a frame column for use with PedPy.

Warning

Currently only Viswalk files with a time column can be loaded.

Parameters:

trajectory_file (pathlib.Path) – The full path of the CSV file containing the Viswalk trajectory data. The expected format is a CSV file with ; as delimiter, and it should contain at least the following columns: NO, SIMSEC, COORDCENTX, COORDCENTY. Comment lines may start with a * and will be ignored.

Returns:

TrajectoryData representation

of the file data

Return type:

TrajectoryData

Raises:

LoadTrajectoryError – If the provided path does not exist or is not a file.

load_walkable_area_from_crowdit(*, geometry_file, buffer=0.001)#

Load walkable area from a Crowdit XML geometry file.

Parameters:
  • geometry_file (pathlib.Path) – Path to the XML geometry file.

  • buffer (float) – Optional padding around the bounding box to avoid overlap with obstacles.

Returns:

representation of the walkable area.

Return type:

WalkableArea

load_walkable_area_from_jupedsim_sqlite(trajectory_file)#

Loads the walkable area from the sqlite file as WalkableArea.

Note

When using a JuPedSim sqlite trajectory file with version 2, the walkable area is the union of all provided walkable areas in the file.

Parameters:

trajectory_file (pathlib.Path) – trajectory file in JuPedSim sqlite format

Returns:

WalkableArea used in the simulation

Return type:

WalkableArea

load_walkable_area_from_ped_data_archive_hdf5(trajectory_file)#

Loads the walkable area from the hdf5 file as WalkableArea.

Loads walkable area from files in the Pedestrian Dynamics Data Archive HDF5 format. The format is explained in more detail here.

In short: The file format includes an attribute wkt_geometry at root level, which contains the walkable area of the experiments.

Parameters:

trajectory_file (pathlib.Path) – trajectory file in Pedestrian Dynamics Data Archive HDF5 format

Returns:

WalkableArea used in the experiment

Return type:

WalkableArea

load_walkable_area_from_vadere_scenario(vadere_scenario_file, margin=0, decimals=6)#

Loads walkable area from Vadere scenario file.

Loads walkable area from Vadere scenario file as WalkableArea.

Parameters:
  • vadere_scenario_file (pathlib.Path) – Vadere scenario file (json format)

  • margin (float) – Increases the walkable area by the value of margin to avoid that the topography bound touches obstacles because shapely Polygons used in PedPy do not allow this. By default (margin = .0), the bound of the walkable area in PedPy coincides with the inner bound of the bounding box (obstacle) in Vadere. PedPy cannot process the case where obstacles touch the bounding box defined in Vadere. To avoid errors, either increase the value of margin (e.g. to 1e-3) or make sure that the obstacles in Vadere do not touch the bounding box.

  • decimals (int) – Integer defining the decimals of the coordinates of the walkable area

Returns:

WalkableArea used in the simulation

Return type:

WalkableArea