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")
# And let's see what modes we have:
matrix_trips.names
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 vehicle types we have:
matrix_vehicles.matrices
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 |
14 |
48453 |
48491 |
218896.0 |
217236.0 |
436132.0 |
1508.0 |
1460.0 |
2968.0 |
72.0 |
60.0 |
132.0 |
3856.0 |
3200.0 |
7056.0 |
3232.0 |
4788.0 |
8020.0 |
19648.0 |
19404.0 |
39052.0 |
19504.0 |
19684.0 |
39188.0 |
12 |
48209 |
48453 |
89956.0 |
89784.0 |
179740.0 |
0.0 |
0.0 |
0.0 |
0.0 |
0.0 |
0.0 |
860.0 |
1256.0 |
2116.0 |
1556.0 |
676.0 |
2232.0 |
4456.0 |
4700.0 |
9156.0 |
12004.0 |
12388.0 |
24392.0 |
3 |
48021 |
48453 |
19852.0 |
19180.0 |
39032.0 |
8.0 |
4.0 |
12.0 |
0.0 |
0.0 |
0.0 |
0.0 |
0.0 |
0.0 |
0.0 |
0.0 |
0.0 |
1708.0 |
1788.0 |
3496.0 |
1700.0 |
1744.0 |
3444.0 |
9 |
48055 |
48209 |
11168.0 |
11360.0 |
22528.0 |
0.0 |
0.0 |
0.0 |
0.0 |
0.0 |
0.0 |
292.0 |
384.0 |
676.0 |
0.0 |
0.0 |
0.0 |
436.0 |
524.0 |
960.0 |
596.0 |
660.0 |
1256.0 |
8 |
48053 |
48491 |
8004.0 |
8044.0 |
16048.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 |
256.0 |
240.0 |
496.0 |
13 |
48209 |
48491 |
6252.0 |
5800.0 |
12052.0 |
0.0 |
0.0 |
0.0 |
0.0 |
0.0 |
0.0 |
4.0 |
8.0 |
12.0 |
12.0 |
0.0 |
12.0 |
84.0 |
116.0 |
200.0 |
96.0 |
76.0 |
172.0 |
10 |
48055 |
48453 |
5872.0 |
5716.0 |
11588.0 |
0.0 |
0.0 |
0.0 |
0.0 |
0.0 |
0.0 |
4.0 |
16.0 |
20.0 |
8.0 |
0.0 |
8.0 |
428.0 |
352.0 |
780.0 |
872.0 |
808.0 |
1680.0 |
7 |
48053 |
48453 |
5200.0 |
4812.0 |
10012.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 |
136.0 |
356.0 |
1 |
48021 |
48055 |
4080.0 |
4148.0 |
8228.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 |
68.0 |
116.0 |
88.0 |
52.0 |
140.0 |
4 |
48021 |
48491 |
2520.0 |
2504.0 |
5024.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 |
128.0 |
112.0 |
240.0 |
112.0 |
152.0 |
264.0 |
2 |
48021 |
48209 |
896.0 |
1160.0 |
2056.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 |
52.0 |
24.0 |
76.0 |
48.0 |
28.0 |
76.0 |
11 |
48055 |
48491 |
1000.0 |
1048.0 |
2048.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 |
6 |
48053 |
48209 |
156.0 |
212.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 |
4.0 |
0.0 |
4.0 |
5 |
48053 |
48055 |
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 |
0 |
48021 |
48053 |
4.0 |
0.0 |
4.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 |
Vehicle matrices sorted by largest amount of HD_TRUCK trips
(matrix_trips.to_df()).sort_values("HD_TRUCK_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 |
14 |
48453 |
48491 |
218896.0 |
217236.0 |
436132.0 |
1508.0 |
1460.0 |
2968.0 |
72.0 |
60.0 |
132.0 |
3856.0 |
3200.0 |
7056.0 |
3232.0 |
4788.0 |
8020.0 |
19648.0 |
19404.0 |
39052.0 |
19504.0 |
19684.0 |
39188.0 |
12 |
48209 |
48453 |
89956.0 |
89784.0 |
179740.0 |
0.0 |
0.0 |
0.0 |
0.0 |
0.0 |
0.0 |
860.0 |
1256.0 |
2116.0 |
1556.0 |
676.0 |
2232.0 |
4456.0 |
4700.0 |
9156.0 |
12004.0 |
12388.0 |
24392.0 |
3 |
48021 |
48453 |
19852.0 |
19180.0 |
39032.0 |
8.0 |
4.0 |
12.0 |
0.0 |
0.0 |
0.0 |
0.0 |
0.0 |
0.0 |
0.0 |
0.0 |
0.0 |
1708.0 |
1788.0 |
3496.0 |
1700.0 |
1744.0 |
3444.0 |
10 |
48055 |
48453 |
5872.0 |
5716.0 |
11588.0 |
0.0 |
0.0 |
0.0 |
0.0 |
0.0 |
0.0 |
4.0 |
16.0 |
20.0 |
8.0 |
0.0 |
8.0 |
428.0 |
352.0 |
780.0 |
872.0 |
808.0 |
1680.0 |
9 |
48055 |
48209 |
11168.0 |
11360.0 |
22528.0 |
0.0 |
0.0 |
0.0 |
0.0 |
0.0 |
0.0 |
292.0 |
384.0 |
676.0 |
0.0 |
0.0 |
0.0 |
436.0 |
524.0 |
960.0 |
596.0 |
660.0 |
1256.0 |
8 |
48053 |
48491 |
8004.0 |
8044.0 |
16048.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 |
256.0 |
240.0 |
496.0 |
7 |
48053 |
48453 |
5200.0 |
4812.0 |
10012.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 |
136.0 |
356.0 |
4 |
48021 |
48491 |
2520.0 |
2504.0 |
5024.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 |
128.0 |
112.0 |
240.0 |
112.0 |
152.0 |
264.0 |
13 |
48209 |
48491 |
6252.0 |
5800.0 |
12052.0 |
0.0 |
0.0 |
0.0 |
0.0 |
0.0 |
0.0 |
4.0 |
8.0 |
12.0 |
12.0 |
0.0 |
12.0 |
84.0 |
116.0 |
200.0 |
96.0 |
76.0 |
172.0 |
1 |
48021 |
48055 |
4080.0 |
4148.0 |
8228.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 |
68.0 |
116.0 |
88.0 |
52.0 |
140.0 |
2 |
48021 |
48209 |
896.0 |
1160.0 |
2056.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 |
52.0 |
24.0 |
76.0 |
48.0 |
28.0 |
76.0 |
6 |
48053 |
48209 |
156.0 |
212.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 |
4.0 |
0.0 |
4.0 |
0 |
48021 |
48053 |
4.0 |
0.0 |
4.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 |
48055 |
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 |
11 |
48055 |
48491 |
1000.0 |
1048.0 |
2048.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 |
Total running time of the script: (0 minutes 47.427 seconds)
Gallery generated by Sphinx-Gallery