Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 24 additions & 5 deletions Database/batch_file.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,31 @@
# Project details
model_version: c26q2
scenario_code: 100
scenario_code: 600
year: 2040 # make sure this matches scenario_code
#--- Scenario Code - Year Mapping ---#
# 100: 2019
# 200: 2026
# 300: 2030
# 500: 2035
# 600: 2040
# 800: 2050

exportAs: "full_region"
# "im" to just output IM/nonIM Excel workbooks
# "im_county" to output IM/nonIM Excel workbooks for each county in the region
# "county" to output workbooks for each county (include both IM and nonIM regions)
# "full_region" for the entire CMAP region

# ---------------- Work from home module inputs (trip generation)
validationfiles: N
usualwfhpct: 0.0510
tc14pct: 0.1031
# ---------------- Select link analysis files: provide file name (ex: RSP32_links.txt [stored in Database\Select_Link\]) or use None
# ---------------- Can submit up to 5, comma-separated, any order, no spaces, (ex: None,test4.txt,test1.txt,None,None)
selectLinkFile: None,None,None,None,None
# ---------------- Transaction file path: include the path to the transaction files that will build the scenario networks in double quotes (spaces OK),
# ---------------- point to directory above highway\ and transit\, no ending backslash (ex: "M:\catslib\modelprod\c24q2" or "M:/catslib/modelprod/24q2")
transactionFilePath: "M:/proj1/nrf/Conformity/c25q4"
transactionFilePath: "M:/proj1/nrf/Conformity/c25q2"
# ---------------- Run Transit Assignment at the end of the model run? Default is False.
runTransitAsmt: False
# ---------------- Transit select line analysis file: provide file name (ex: rsp57_line.txt [stored in Database\Select_Line\]) or use None
Expand All @@ -17,6 +36,6 @@ util_files: False
UrbanSim_file: False
# ---------------- Is this an RSP evaluation run? Default is False.
RSP: False
# ---------------- PUMA version used in Trip Generation. 2010 is the current option.
pumaVersion: 2010

# ---------------- sourceCode will force CMAP-TRIP2 to use the source code in this model setup if set to True. Default is True.
# ---------------- Set to False if this is the second of two simultaneous runs being submitted.
sourceCode: True
Binary file added Database/data/seasonal_VMT.xlsx
Binary file not shown.
45 changes: 45 additions & 0 deletions Database/post_macros/MOVES_constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
### Defines constants for the createMOVESinputfile.py file

SOURCE_TYPES = [
11, # Motorcycle
21, # Passenger Car
31, # Passenger Truck
32, # Light Commercial Truck
41, # Other Buses
42, # Transit Bus
43, # School Bus
51, # Refuse Truck
52, # Single Unit Short-haul Truck
53, # Single Unit Long-haul Truck
54, # Motor Homes
61, # Combination Short-haul Truck
62 # Combination Long-haul Truck
]

ROAD_TYPES = [
2, # Rural Restricted Access
3, # Rural Unrestricted Access
4, # Urban Restricted Access
5 # Urban Unrestricted Access
] # note: ROAD_TYPE 1 is off-network, and not included in all tabs except hourly VMT fraction

SPEED_BINS = [
1, # <2.5 mph
2, # 2.5 - 7.5 mph
3, # 7.5 - 12.5 mph
4, # 12.5 - 17.5 mph
5, # 17.5 - 22.5 mph
6, # 22.5 - 27.5 mph
7, # 27.5 - 32.5 mph
8, # 32.5 - 37.5 mph
9, # 37.5 - 42.5 mph
10, # 42.5 - 47.5 mph
11, # 47.5 - 52.5 mph
12, # 52.5 - 57.5 mph
13, # 57.5 - 62.5 mph
14, # 62.5 - 67.5 mph
15, # 67.5 - 72.5 mph
16 # >=72.5
]

HOURS = list(range(1,25)) # range end is exclusive
90 changes: 90 additions & 0 deletions Database/post_macros/QC_createMOVESinputfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import pandas as pd, numpy as np
from pathlib import Path
from functools import reduce

## This file runs two quality checks for createMOVESinputfile.py
## (1) check_im(): Checks if all tabs in two comparison workbooks match for a given imregion and scenario
## (2) check_im_county(): Checks if the VHT/VMT in initial_model_output for each county in a given imregion
## sum up to the correct aggregated values

### TO RUN: specify the scenario year and model ###################################################################
### This set-up assumes the files are in data/MOVES_cXXqX_scenXXX. The files you want to compare to must have
### the suffix "_old", for example MOVES_c26q2_scen100_IM_old.xlsx and MOVES_c26q2_scen100_nonIM_old.xlsx
SCEN = "600"
MODEL = "c26q2"
##################################################################################################################

DB_DIR = Path(__file__).resolve().parents[1]
FOLDER_PATH = DB_DIR.joinpath("data",f"MOVES_{MODEL}_scen{SCEN}")

def check_im(scen, imregion):
""""
Compares the new and old Excel workbooks for a specific IM region and scenario,
ex. MOVES_c26q2_scen100_IM.xlsx and MOVES_c26q2_scen100_IM_old.xlsx
Prints True if all cells match, False otherwise.
"""
# Get paths of new and old files
new_file_path = FOLDER_PATH.joinpath(f"MOVES_{MODEL}_scen{scen}_{imregion}.xlsx")
old_file_path = FOLDER_PATH.joinpath(f"MOVES_{MODEL}_scen{scen}_{imregion}_old.xlsx")

tab_names = ["initial_model_output","AvgSpeedDistribution", "RoadTypeDistribution","hourVMTFraction", "HPMSDailyVMT"]

print("check_im()")
print(f"... Comparing MOVES_{MODEL}_scen{scen}_{imregion}.xlsx and MOVES_{MODEL}_scen{scen}_{imregion}_old.xlsx")

# Check equality of each tab
for tab in tab_names:
old_data = pd.read_excel(old_file_path,sheet_name=tab)
new_data = pd.read_excel(new_file_path,sheet_name=tab)

print(f"--> {tab} equality: {old_data.equals(new_data)}")


def check_im_county(scen, imregion):
"""
Checks to see if the VMT/VHT in the initial_model_output tab from each county sum up to the aggregated VMT/VHT.
For VMT and VHT, prints True if they match, False otherwise.
"""
# Specify counties for given IM region
if imregion == "IM":
counties = ['COOK', 'DUPAGE', 'KANE', 'KENDALL', 'LAKE', 'MCHENRY', 'WILL']
if imregion == "nonIM":
counties = ['KANE', 'KENDALL', 'LAKE', 'MCHENRY', 'WILL','GRUNDY']

# Merge all county initial_model_output datasets together for given imregion
dfs = []
for county in counties:
county_file_path = FOLDER_PATH.joinpath(f"MOVES_{MODEL}_scen{scen}_{imregion}_{county}.xlsx")

# get initial_model_output tab from county file
initial_model_output = pd.read_excel(county_file_path,sheet_name="initial_model_output")
initial_model_output = initial_model_output.rename(columns={"vmt": f"vmt_{county}", "vht": f"vht_{county}"})

dfs.append(initial_model_output)

ids = ["sourceTypeID","roadTypeID","hourDayID","avgSpeedBinID","imarea"]
merged_df = reduce(lambda left, right: pd.merge(left, right, on=ids, how='outer'), dfs)

# Create totals for VMT/VHT
merged_df["vmt_TOTAL"] = sum([merged_df[f"vmt_{county}"] for county in counties])
merged_df["vht_TOTAL"] = sum([merged_df[f"vht_{county}"] for county in counties])

# Use OLD aggregated file for given im region
aggregated_file_path = FOLDER_PATH.joinpath(f"MOVES_{MODEL}_scen{scen}_{imregion}_old.xlsx")
agg_initial_model_output = pd.read_excel(aggregated_file_path,sheet_name="initial_model_output")

# Check for approximate equality (necessary because floats, tolerance = 1e-8)
print()
print("check_im_county()")
print(f"... Aggregating {counties}")
print(f"... Comparing to MOVES_{MODEL}_scen{scen}_{imregion}_old.xlsx")
print("--> VMT Equality:", np.all(np.isclose(merged_df["vmt_TOTAL"], agg_initial_model_output["vmt"])))
print("--> VHT Equality:", np.all(np.isclose(merged_df["vht_TOTAL"], agg_initial_model_output["vht"])))
print()


if __name__ == "__main__":
for imregion in ["nonIM", "IM"]:
print(f"** SCENARIO YEAR: {SCEN}, REGION: {imregion} **")
check_im(SCEN, imregion)
check_im_county(SCEN, imregion)
Loading