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 288072.0 288944.0 577016.0 428.0 540.0 968.0 4.0 0.0 4.0 3396.0 2904.0 6300.0 1188.0 1368.0 2556.0 19444.0 19488.0 38932.0 19608.0 19600.0 39208.0
10 48209 48453 102760.0 102448.0 205208.0 0.0 0.0 0.0 0.0 0.0 0.0 956.0 1220.0 2176.0 692.0 524.0 1216.0 4512.0 4548.0 9060.0 12152.0 12412.0 24564.0
2 48021 48453 21992.0 21808.0 43800.0 0.0 8.0 8.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1664.0 1784.0 3448.0 1692.0 1660.0 3352.0
7 48055 48209 9652.0 9820.0 19472.0 0.0 0.0 0.0 0.0 0.0 0.0 8.0 28.0 36.0 0.0 0.0 0.0 448.0 484.0 932.0 692.0 652.0 1344.0
6 48053 48491 7856.0 7928.0 15784.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 220.0 256.0 476.0
8 48055 48453 6964.0 6796.0 13760.0 0.0 0.0 0.0 0.0 0.0 0.0 8.0 20.0 28.0 16.0 12.0 28.0 380.0 364.0 744.0 860.0 828.0 1688.0
11 48209 48491 6792.0 6596.0 13388.0 0.0 0.0 0.0 0.0 0.0 0.0 76.0 72.0 148.0 20.0 12.0 32.0 80.0 76.0 156.0 88.0 96.0 184.0
5 48053 48453 4712.0 4276.0 8988.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 192.0 204.0 396.0
0 48021 48055 3596.0 3568.0 7164.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 40.0 44.0 84.0 44.0 52.0 96.0
3 48021 48491 2540.0 2408.0 4948.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 156.0 144.0 300.0 128.0 84.0 212.0
1 48021 48209 1016.0 1008.0 2024.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 48.0 28.0 76.0 60.0 40.0 100.0
9 48055 48491 1060.0 948.0 2008.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 184.0 204.0 388.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 42.888 seconds)

Gallery generated by Sphinx-Gallery