-
Notifications
You must be signed in to change notification settings - Fork 2
MHN Module
This module (MHN.py), imported by virtually all of the other MHN processing scripts, provides a centralized location to store variables and useful functions pertaining to the processing of the Master Highway Network. This allows for the individual processing scripts to be shorter and simpler, and the perils of code duplication are all but eliminated. Additionally, changes to MHN-specific properties that are used in multiple scripts (such as the scenario years for Conformity analyses and their corresponding numeric codes) can be made in a single location and be consistently applied by all scripts.
Some such variables are:
-
base_year: the year which the MHN baselinks and their attributes represent, not necessarily the same as the Scenario 100 year -- should be updated if the base year is changed with the Update MHN Base Year (Utilities) tool -
bus_years: a dictionary specifying the years represented by the bus routes in bus_base and bus_current -- should be updated if new GTFS data is loaded with the Import GTFS Bus Routes tool -
centroid_ranges: a dictionary of the zone centroids corresponding to various geographies (i.e.centroid_ranges['Chicago']returns the range 1-717) -
min_node_id&max_node_id: the lowest and highest numbers that can be assigned as node IDs (other than zone centroids & POEs) -- currently capped at 29999 to avoid overlapping with MRN nodes -
projection: the definition of the specific Illinois State Plane (NAD27) projection that all MHN/MRN data is stored in -
scenario_years: a dictionary of the numeric scenario codes used for Conformity networks, and the years they correspond to -
tod_periods: a dictionary of the time-of-day period codes and their corresponding hours (as well as a SQL-formatted query for selecting all of the bus runs that fall within each) -
ampm_tods: a dictionary for converting the AMPM1/AMPM2 codes from the MHN links into the travel models time-of-day periods
The module also specifies a number of paths for feature classes, itinerary tables, and input/output directories based on the location of the version of the MHN geodatabase currently being processed.
Numerous functions have been included to reduce lengthy code duplication in the processing scripts. Some of the most prominent examples are:
-
delete_if_exists(): check for existence of a file or ArcGIS object and delete it if so -
die(): stop the processing script with an error message -
make_attribute_dict(): create a dictionary from a feature layer or table view's attributes, with a specified field providing the keys and a list of other fields as the values -
submit_sas(): call a specified SAS program with a list of arguments -
write_attribute_csv(): write a CSV of specified attributes from any feature layer or table view, commonly used to create inputs for the SAS programs