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
13 48453 48491 274212.0 274592.0 548804.0 768.0 960.0 1728.0 8.0 8.0 16.0 3228.0 3008.0 6236.0 1228.0 1320.0 2548.0 19528.0 19360.0 38888.0 19524.0 19936.0 39460.0
11 48209 48453 69984.0 69312.0 139296.0 0.0 0.0 0.0 0.0 0.0 0.0 776.0 1000.0 1776.0 456.0 388.0 844.0 4520.0 4772.0 9292.0 4880.0 4696.0 9576.0
3 48021 48453 19256.0 18988.0 38244.0 0.0 36.0 36.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1820.0 1796.0 3616.0 1668.0 1776.0 3444.0
8 48055 48209 7872.0 7892.0 15764.0 0.0 0.0 0.0 0.0 0.0 0.0 32.0 40.0 72.0 0.0 0.0 0.0 508.0 408.0 916.0 420.0 432.0 852.0
7 48053 48491 7084.0 7232.0 14316.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 224.0 264.0 488.0
9 48055 48453 5088.0 5080.0 10168.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 4.0 4.0 4.0 4.0 8.0 388.0 376.0 764.0 408.0 420.0 828.0
6 48053 48453 4676.0 4308.0 8984.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 220.0 436.0
1 48021 48055 2924.0 2960.0 5884.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 64.0 60.0 124.0 52.0 60.0 112.0
4 48021 48491 2016.0 1992.0 4008.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 96.0 144.0 240.0 92.0 100.0 192.0
12 48209 48491 1972.0 1816.0 3788.0 0.0 0.0 0.0 0.0 0.0 0.0 20.0 16.0 36.0 8.0 8.0 16.0 76.0 88.0 164.0 80.0 92.0 172.0
2 48021 48209 740.0 696.0 1436.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 36.0 84.0 32.0 48.0 80.0
10 48055 48491 180.0 188.0 368.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
5 48053 48209 172.0 120.0 292.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
0 48021 48053 4.0 4.0 8.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 7.429 seconds)

Gallery generated by Sphinx-Gallery