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 288156.0 289128.0 577284.0 336.0 436.0 772.0 0.0 0.0 0.0 3256.0 2772.0 6028.0 1092.0 1184.0 2276.0 19856.0 19580.0 39436.0 19708.0 19404.0 39112.0
10 48209 48453 103092.0 102104.0 205196.0 0.0 0.0 0.0 0.0 0.0 0.0 788.0 964.0 1752.0 624.0 552.0 1176.0 4708.0 4928.0 9636.0 12404.0 12148.0 24552.0
2 48021 48453 21828.0 21676.0 43504.0 4.0 32.0 36.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1704.0 1632.0 3336.0 1644.0 1720.0 3364.0
7 48055 48209 9316.0 9216.0 18532.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 8.0 8.0 0.0 0.0 0.0 448.0 440.0 888.0 564.0 688.0 1252.0
6 48053 48491 8124.0 8144.0 16268.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 300.0 228.0 528.0
8 48055 48453 6968.0 6936.0 13904.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 8.0 16.0 24.0 360.0 380.0 740.0 804.0 884.0 1688.0
11 48209 48491 6864.0 6736.0 13600.0 0.0 0.0 0.0 0.0 0.0 0.0 76.0 76.0 152.0 28.0 20.0 48.0 52.0 88.0 140.0 88.0 80.0 168.0
5 48053 48453 4536.0 4336.0 8872.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 208.0 160.0 368.0
0 48021 48055 3120.0 3076.0 6196.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 28.0 64.0 92.0 52.0 68.0 120.0
3 48021 48491 2692.0 2592.0 5284.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 148.0 148.0 296.0 180.0 136.0 316.0
9 48055 48491 1124.0 1052.0 2176.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 4.0 4.0 8.0 0.0 0.0 0.0 4.0 0.0 4.0
1 48021 48209 1060.0 1048.0 2108.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 24.0 68.0 68.0 32.0 100.0
4 48053 48209 140.0 128.0 268.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 4.0 0.0 4.0


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

Gallery generated by Sphinx-Gallery