Skip to content

Commit

Permalink
Merge branch 'main' into visualizer
Browse files Browse the repository at this point in the history
  • Loading branch information
AshishKuls authored Aug 31, 2023
2 parents 37c3c59 + fe07461 commit a601c67
Show file tree
Hide file tree
Showing 793 changed files with 223,223 additions and 16 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Publish documents
on:
push:
branches: [main, develop]
jobs:
build:
name: Deploy docs to GitHub Pages
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Build
uses: Tiryoh/actions-mkdocs@v0
with:
mkdocs_version: 'latest'
requirements: 'docs_requirements.txt'
configfile: 'mkdocs.yml'
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./site
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
sandag_rsm/__pycache__
rsm/__pycache__
**/__pycache__
.idea
.ipynb_checkpoints
sandag_rsm.egg-info
rsm.egg-info
_version.py
.DS_Store
test/data/*
notebooks/**/*.omx
visualizer/simwrapper/data/processed/pipeline.log
visualizer/simwrapper/data/external
*.pyc
sandag_rsm.egg-info/*
site/*
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
repos:

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
rev: v4.3.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
exclude: .*\.ipynb
- id: trailing-whitespace

- repo: https://github.com/kynan/nbstripout
rev: 0.5.0
rev: 0.6.1
hooks:
- id: nbstripout

Expand All @@ -20,11 +20,11 @@ repos:
args: ["--profile", "black", "--filter-files"]

- repo: https://github.com/psf/black
rev: 21.12b0
rev: 22.10.0
hooks:
- id: black

- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
rev: 5.0.4
hooks:
- id: flake8
32 changes: 29 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
# RSM
Rapid Strategic Model for the San Diego Association of Governments

## Source Code Access

The source code for the RSM is stored in this repository. You can access it
via GitHub, or check out the repository using Git. Some larger files (especially
for testing) are stored using [git-lfs](https://git-lfs.github.com/) (large file
storage). This is mostly transparent, but for best results you do need to make
sure that the LFS extension is installed before you clone the repository. Visit
[git-lfs](https://git-lfs.github.com/) for platform-specific instructions.


## Installing

To install, activate the python or conda environment you want to use,
Expand All @@ -10,6 +20,13 @@ the cd into the repository directory and run:
python -m pip install -e .
```

This will make the `sandag_rsm` package available, so you can `import sandag_rsm`
to access the functions in this tool, without regard for the current working
directory or pointing the python path to the right place(s). Using the `-e` flag
installs in `editable` mode, so if you make changes or pull updates from GitHub,
those updates will be available to Python without re-installing.


## Code Formatting

This repo use several tools to ensure a consistent code format throughout the project:
Expand All @@ -34,19 +51,28 @@ with `git commit --no-verify`.

## Developing with Docker

To build the docker container, change into the repository root and run:
This project uses [Docker](https://www.docker.com/). For development, to build
the docker container, change into the repository root and run:

```shell
docker build --tag sandag_rsm .
````

### Jupyter Notebook for Development

On the host machine, run:
On the host machine, on linux or macOS run:

```shell
docker run -v $(pwd):/home/mambauser/sandag_rsm -p 8899:8899 \
-it sandag_rsm jupyter notebook --ip 0.0.0.0 --no-browser --allow-root \
-it --rm sandag_rsm jupyter notebook --ip 0.0.0.0 --no-browser --allow-root \
--port 8899 --notebook-dir=/home/mambauser
```

or in `cwd` on Windows, run:

```shell
docker run -v %cd%:/home/mambauser/sandag_rsm -p 8899:8899 ^
-it --rm sandag_rsm jupyter notebook --ip 0.0.0.0 --no-browser --allow-root ^
--port 8899 --notebook-dir=/home/mambauser
```

Expand Down
97 changes: 97 additions & 0 deletions abm/src/main/emme/init_emme_project.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#///////////////////////////////////////////////////////////////////////////////
#//// ///
#//// Copyright INRO, 2016-2019. ///
#//// Rights to use and modify are granted to the ///
#//// San Diego Association of Governments and partner agencies. ///
#//// This copyright notice must be preserved. ///
#//// ///
#//// init_emme_project.py ///
#//// ///
#//// Usage: init_emme_project.py [-r root] [-t title] ///
#//// ///
#//// [-r root]: Specifies the root directory in which to create ///
#//// the Emme project. ///
#//// If omitted, defaults to the current working directory ///
#//// [-t title]: The title of the Emme project and Emme database. ///
#//// If omitted, defaults to SANDAG empty database. ///
#//// [-v emmeversion]: Emme version to use to create the project. ///
#//// If omitted, defaults to 4.3.7. ///
#//// ///
#//// ///
#//// ///
#//// ///
#///////////////////////////////////////////////////////////////////////////////

import inro.emme.desktop.app as _app
import inro.emme.desktop.types as _ws_types
import inro.emme.database.emmebank as _eb
import argparse
import os

WKT_PROJECTION = 'PROJCS["NAD_1983_NSRS2007_StatePlane_California_VI_FIPS_0406_Ft_US",GEOGCS["GCS_NAD_1983_NSRS2007",DATUM["D_NAD_1983_NSRS2007",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Lambert_Conformal_Conic"],PARAMETER["False_Easting",6561666.666666666],PARAMETER["False_Northing",1640416.666666667],PARAMETER["Central_Meridian",-116.25],PARAMETER["Standard_Parallel_1",32.78333333333333],PARAMETER["Standard_Parallel_2",33.88333333333333],PARAMETER["Latitude_Of_Origin",32.16666666666666],UNIT["Foot_US",0.3048006096012192]];-118608900 -91259500 3048.00609601219;-100000 10000;-100000 10000;3.28083333333333E-03;0.001;0.001;IsHighPrecision'

def init_emme_project(root, title, emmeversion):
project_path = _app.create_project(root, "emme_project")
desktop = _app.start_dedicated(
project=project_path, user_initials="WS", visible=False)
project = desktop.project
project.name = "SANDAG Emme project"
prj_file_path = os.path.join(os.path.dirname(project_path), 'NAD 1983 NSRS2007 StatePlane California VI FIPS 0406 (US Feet).prj')
with open(prj_file_path, 'w') as f:
f.write(WKT_PROJECTION)
project.spatial_reference_file = prj_file_path
project.initial_view = _ws_types.Box(6.18187e+06, 1.75917e+06, 6.42519e+06, 1.89371e+06)
project_root = os.path.dirname(project_path)
dimensions = {
'scalar_matrices': 9999,
'destination_matrices': 999,
'origin_matrices': 999,
'full_matrices': 1600,

'scenarios': 10,
'centroids': 5000,
'regular_nodes': 29999,
'links': 90000,
'turn_entries': 13000,
'transit_vehicles': 200,
'transit_lines': 450,
'transit_segments': 40000,
'extra_attribute_values': 28000000,

'functions': 99,
'operators': 5000
}

# for Emme version > 4.3.7, add the sola_analyses dimension
if emmeversion != '4.3.7':
dimensions['sola_analyses'] = 240

os.mkdir(os.path.join(project_root, "Database"))
emmebank = _eb.create(os.path.join(project_root, "Database", "emmebank"), dimensions)
emmebank.title = title
emmebank.coord_unit_length = 0.000189394 # feet to miles
emmebank.unit_of_length = "mi"
emmebank.unit_of_cost = "$"
emmebank.unit_of_energy = "MJ"
emmebank.node_number_digits = 6
emmebank.use_engineering_notation = True
scenario = emmebank.create_scenario(100)
scenario.title = "Empty scenario"
emmebank.dispose()

desktop.data_explorer().add_database(emmebank.path)
desktop.add_modeller_toolbox("%<$ProjectPath>%/scripts/sandag_toolbox.mtbx")
desktop.add_modeller_toolbox("%<$ProjectPath>%/scripts/solutions.mtbx")
project.save()


if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Create a new empty Emme project and database with Sandag defaults.")
parser.add_argument('-r', '--root', help="path to the root ABM folder, default is the working folder",
default=os.path.abspath(os.getcwd()))
parser.add_argument('-t', '--title', help="the Emmebank title",
default="SANDAG empty database")
parser.add_argument('-v', '--emmeversion', help='the Emme version', default='4.3.7')
args = parser.parse_args()

init_emme_project(args.root, args.title, args.emmeversion)
3 changes: 3 additions & 0 deletions abm/src/main/emme/python_virtualenv.pth
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Inserts defined python_virtualenv site-packages into the python module search path if defined
#
import sys, os; r=os.environ.get("PYTHON_VIRTUALENV"); t = 1 if r is None else sys.path.insert(0, os.path.join(r, "Lib\site-packages"));
Binary file added abm/src/main/emme/solutions.mtbx
Binary file not shown.
Binary file not shown.
5 changes: 5 additions & 0 deletions abm/src/main/emme/start_emme_with_virtualenv.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
set python_virtualenv=C:\python_virtualenv\abm14_2_0
set RSM_PYTHON_VIRTUALENV=T:\ABM\WSP_Space\Python_Env\python3_rsm
set RSM_PYTHON2_VIRTUALENV=T:\ABM\WSP_Space\Python_Env\python2_rsm
set RSM_SCRIPT_DIR=T:\ABM\WSP_Space\RSM\src
start "TITLE" "C:\\Program Files\\INRO\\Emme\\Emme 4\\Emme-4.3.7\\programs\\EmmeDesktop.exe" ./emme_project.emp
Loading

0 comments on commit a601c67

Please sign in to comment.