Load Trajectories#

Load trajectories to the internal trajectory data format.

exception LoadTrajectoryError(message)#

Class reflecting errors when loading trajectories with PedPy.

Create LoadTrajectoryError with the given message.

Parameters:

message – Error message

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:

pedpy.data.trajectory_data.TrajectoryData

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:

pedpy.data.trajectory_data.TrajectoryData

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:

pedpy.data.trajectory_data.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:

pedpy.data.trajectory_data.TrajectoryData

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

Raises:

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

Return type:

pedpy.data.trajectory_data.TrajectoryData

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 ware 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:

pedpy.data.geometry.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:

pedpy.data.geometry.WalkableArea