County-to-county trip matrices#

A common resource for a quick initial analysis of a model result is to look into county-to-county trip matrices, as that can shed light on the general validity of the demand model and help detect bigger issues with the model run.

from pathlib import Path

from polaris.analyze.trip_metrics import TripMetrics

Creating county-to-county matrices#

%% sphinx_gallery_thumbnail_path = ‘../../examples/result_analysis/county_to_county.png’

Let’s work with the Austin model

project_dir = Path("/tmp/Austin")
last_iter = TripMetrics(project_dir / "Austin-Supply.sqlite", project_dir / "Austin-Demand.sqlite")

We can get the trip matrix for the last iteration from the trip table

matrix_trips = last_iter.trip_matrix(from_start_time=0, to_start_time=24 * 3600, aggregation="county")

# # Or we can make specify the particular modes we are interested in
# modes = ["SOV", "TAXI"]
# matrix_vehicles = last_iter.trip_matrix(from_start_time=0, to_start_time=24 * 3600, modes=modes, aggregation="county")

# And let's see what modes we have:
matrix_trips.names

Let’s look at some trips by the largest to smallest flow?#

Trip matrices sorted by largest amount of SOV trips

matrix_trips.to_df().sort_values("SOV_tot", ascending=False)
from_id to_id SOV_ab SOV_ba SOV_tot BUS_ab BUS_ba BUS_tot RAIL_ab RAIL_ba RAIL_tot TAXI_ab TAXI_ba TAXI_tot TNC_AND_RIDE_ab TNC_AND_RIDE_ba TNC_AND_RIDE_tot MD_TRUCK_ab MD_TRUCK_ba MD_TRUCK_tot HD_TRUCK_ab HD_TRUCK_ba HD_TRUCK_tot
12 48453 48491 288740.0 289560.0 578300.0 368.0 500.0 868.0 0.0 0.0 0.0 3184.0 2872.0 6056.0 1112.0 1272.0 2384.0 19464.0 19468.0 38932.0 19848.0 19764.0 39612.0
10 48209 48453 80148.0 79304.0 159452.0 0.0 0.0 0.0 0.0 0.0 0.0 824.0 1052.0 1876.0 460.0 392.0 852.0 4552.0 4836.0 9388.0 4620.0 4532.0 9152.0
2 48021 48453 21328.0 21172.0 42500.0 0.0 16.0 16.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1592.0 1808.0 3400.0 1556.0 1824.0 3380.0
7 48055 48209 8912.0 8932.0 17844.0 0.0 0.0 0.0 0.0 0.0 0.0 12.0 24.0 36.0 0.0 0.0 0.0 404.0 452.0 856.0 480.0 444.0 924.0
6 48053 48491 8056.0 8148.0 16204.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 252.0 204.0 456.0
8 48055 48453 6160.0 6032.0 12192.0 0.0 0.0 0.0 0.0 0.0 0.0 4.0 12.0 16.0 0.0 0.0 0.0 416.0 348.0 764.0 416.0 380.0 796.0
5 48053 48453 4708.0 4412.0 9120.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 216.0 192.0 408.0
0 48021 48055 2892.0 2868.0 5760.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 44.0 68.0 112.0 24.0 52.0 76.0
3 48021 48491 2680.0 2564.0 5244.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 100.0 140.0 240.0 172.0 128.0 300.0
11 48209 48491 2364.0 2320.0 4684.0 0.0 0.0 0.0 0.0 0.0 0.0 64.0 64.0 128.0 4.0 4.0 8.0 76.0 72.0 148.0 68.0 100.0 168.0
1 48021 48209 932.0 920.0 1852.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 36.0 36.0 72.0 60.0 48.0 108.0
9 48055 48491 232.0 224.0 456.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 4.0 0.0 4.0 0.0 0.0 0.0
4 48053 48209 160.0 128.0 288.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0


Total running time of the script: (0 minutes 36.789 seconds)

Gallery generated by Sphinx-Gallery