Travel Model Two utilities, including post-processing, summaraziation and other utilities for tm2py.
To Run tm2py the Travel Model Two (tm2) repo for model running.
- Note: tm2py-utils was separated out to allow for a the usage of a wide variety of packages without affecting / breaking the main model. This allows for fast development of utilities with relative stability of the model.
[Include license info if applicable]
The environment is intended to work with the python
If you only require the usage of Acceptance Criteria Tools, you can install directly from git:
-
open OpenPaths EMME Shell 24.01.00
-
Install TM2PY Utils
pip install git+https://github.com/BayAreaMetro/tm2py-utils.git
If you would like to develop and/or download example notebooks
-
Open OpenPaths Shell Emme Shell (24.01.00)
-
Create and activate your virtual Environement
python -m venv /path/to/venv
-
Optional if you would like access to OpenPaths API:
Copy emmepath file (usually found in C:\Program Files\Bentley\OpenPaths\EMME 24.01.00) to venv/path/to/venv/Lib/site-packages -
clone tm2py-utils in the appropriate directory
cd path/to/git/repo/location
git clone https://github.com/BayAreaMetro/tm2py-utils.git
- Install tm2py-utils in your virtual environment
cd tm2py-utils
pip install -e .
- Note: The environment is fairly lightweight and should work installed on top of an existing tm2py installation, if this is done it is recommended to create a separate virtual environment.
if the package was installed correctly you should be able to run the below
Generate files related to acceptance criteria
from tm2py_utils.summary.acceptance.canonical import Canonical
from tm2py_utils.summary.acceptance.observed import Observed
from tm2py_utils.summary.acceptance.simulated import Simulated
from tm2py_utils.summary.acceptance.acceptance import Acceptance
# Note, these will have to point to the correct files of a successfully run model
scenario_config_file = "tm2py_utils/examples/scenario_config.toml"
model_config_file = "tm2py_utils/examples/model_config.toml"
canonical_crosswalk_file = "tm2py_utils/examples/canonical_crosswalk.toml"
observed_config_file = "tm2py_utils/examples/observed_data.toml"
output_folder_root = "tm2py_utils/examples/temp_acceptance/"
c = Canonical(canonical_crosswalk_file, scenario_file=scenario_config_file)
o = Observed(canonical=c, observed_file=observed_config_file)
s = Simulated(canonical=c, scenario_file=scenario_config_file, model_file=model_config_file)
a = Acceptance(canonical=c, simulated=s, observed=o, output_file_root=output_folder_root)
a.make_acceptance(make_transit=True, make_roadway=True, make_other=True)
Archive important Files of a specific model run into an archive directory.
assuming your environment is active, you can ensure this by running:
\path\to\venv\Scripts\activate
A model run can then be archived using:
tm2py-utils archive path\to\model\run path\to\model\run
or
tm2py-utils archive path\to\model\run path\to\model\run -n "run name"
Alternatively python script can be used
from tm2py_utils.misc.archive import parse_cli_archive
parse_cli_archive(r"model\run\directory", r"archive\run\directory")