Paths

Paths#

Paths (also called trajectories) are written to the H5 file for a sub-set of the total trips which were made during simuation according to parameter vehicle_trajectory_sample_rate. Generally this is set to approximately 1% of the total population.

In order to work with Path data, it is recommended to use the H5_Results class to extract the raw data and make it easier to manipulate.

from polaris.runs.results.h5_results import H5_Results

results = H5_Results("~/models/Bloomington/Bloomington-Result.h5")
paths = results.load_paths()

This will return a single pandas DataFrame with all the paths that are available across the entire simulation. This includes only high level metadata on the paths, not the actual link sequences traversed. To get the link sequences use the load_path_links method:

    path_links = results.load_path_links()              # Load link sequences for all paths
    path_link_17 = results.load_path_links(path_id=17)  # Load link sequences for just path 17

The path_id corresponds to the path_id column in the Trip table in the Demand database.