Analyze a trip table

Analyze a trip table#

This example shows how to: - Analyze a trip table after it has been generated by Polaris - Analyze a trip table from file (exogenous trips)

Imports

from pathlib import Path

import pandas as pd

from polaris import Polaris
from polaris.analyze.demand_report import demand_report
from polaris.utils.database.data_table_access import DataTableAccess
model_dir = Path("/tmp/Austin")
supply_file = Polaris.from_dir(model_dir).supply_file
demand_file = Polaris.from_dir(model_dir).demand_file

Read Locations table from the Supply database

dta = DataTableAccess(supply_file)
locations = dta.get("Location")

Read trip table from the Exogenous file

trips = pd.read_csv(model_dir / "demand/trip.zip")

# Reading from the demand database is also easy:
# dta_demand = DataTableAccess(demand_file)
# trips = dta_demand.get("Trip")

Now we can run the demand report analysis on the trip table

report = demand_report(trips=trips, locations=locations)
Trips per hour, Trips (thousands) by mode, Trips (thousands) by type, Trips (1,000s) by Land-Use of origin, Trips (1,000s) by Land-Use of destination, Trip length (Manhatan) frequency distribution (SOV), Delaunay assignment for SOV, Trip length (Manhatan) frequency distribution (MD_TRUCK), Delaunay assignment for MD_TRUCK, Trip length (Manhatan) frequency distribution (HD_TRUCK), Delaunay assignment for HD_TRUCK
/home/gitlab-runner/builds/polaris/code/polarislib/polaris/analyze/demand_report.py:114: FutureWarning: DataFrame.applymap has been deprecated. Use DataFrame.map instead.
  return df.applymap(fmt)
/home/gitlab-runner/builds/polaris/code/polarislib/polaris/analyze/demand_report.py:114: FutureWarning: DataFrame.applymap has been deprecated. Use DataFrame.map instead.
  return df.applymap(fmt)
/home/gitlab-runner/builds/polaris/code/polarislib/polaris/analyze/demand_report.py:114: FutureWarning: DataFrame.applymap has been deprecated. Use DataFrame.map instead.
  return df.applymap(fmt)
delaunay                                          :   0%|          | 0/2102 [00:00<?, ?it/s]
Equilibrium Assignment                            :   0%|          | 0/250 [00:00<?, ?it/s]

We can save the report to disk if we want

report.savefig(model_dir / "report_demand.png", dpi=600)

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

Gallery generated by Sphinx-Gallery