Skip to content

Commit

Permalink
Merge pull request #154 from BayAreaMetro/remove-taz-district-file-ac…
Browse files Browse the repository at this point in the history
…ceptance

Remove standalone `taz-district` crosswalk from Acceptance Summaries
  • Loading branch information
DavidOry authored Jul 1, 2024
2 parents 133b36d + 1746a7d commit c81ab14
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
1 change: 0 additions & 1 deletion examples/canonical_crosswalk.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
canonical_agency_names_file = "canonical-agency-names.csv"
canonical_station_names_file = "canonical-station-names.csv"
block_group_to_maz_url = "https://raw.githubusercontent.com/BayAreaMetro/travel-model-two/master/maz_taz/crosswalks/Census%202010%20hhs%20maz%20share%20of%20blockgroups_ACS2017.csv"
taz_to_district_file = "taz-district-crosswalk.csv"
pems_station_to_tm2_links_file = "pems_station_to_TM2_links_crosswalk.csv"
standard_to_emme_nodes_file = "emme_drive_network_node_id_crosswalk.csv"

2 changes: 1 addition & 1 deletion examples/scenario_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
name = "Example scenario"
year = 2015
verify = false
maz_landuse_file = "inputs\\landuse\\maz_data.csv"
maz_landuse_file = "inputs/landuse/maz_data.csv"
root_dir = "/Users/wsp/Documents/GitHub/tm2py/examples/temp_acceptance/"

[run]
Expand Down
14 changes: 1 addition & 13 deletions tm2py/acceptance/canonical.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class Canonical:

gtfs_to_tm2_mode_codes_df: pd.DataFrame
standard_transit_to_survey_df: pd.DataFrame
taz_to_district_df: pd.DataFrame

standard_to_emme_node_crosswalk_df: pd.DataFrame
pems_to_link_crosswalk_df: pd.DataFrame
Expand Down Expand Up @@ -80,7 +79,6 @@ def __init__(

if not on_board_assign_summary:
self._make_census_maz_crosswalk()
self._read_taz_to_district_crosswalk()
self._read_pems_to_link_crosswalk()
self._read_standard_to_emme_node_crosswalk()

Expand Down Expand Up @@ -240,23 +238,13 @@ def aggregate_line_names_across_time_of_day(

return return_df

def _read_taz_to_district_crosswalk(self):
file_root = self.canonical_dict["remote_io"]["crosswalk_folder_root"]
in_file = self.canonical_dict["crosswalks"]["taz_to_district_file"]

df = pd.read_csv(os.path.join(file_root, in_file))

self.taz_to_district_df = df

return

def _read_pems_to_link_crosswalk(self) -> pd.DataFrame:
file_root = self.canonical_dict["remote_io"]["crosswalk_folder_root"]
in_file = self.canonical_dict["crosswalks"]["pems_station_to_tm2_links_file"]

df = pd.read_csv(os.path.join(file_root, in_file))

df = df[["station_id", "A", "B"]]
df = df[["station", "A", "B"]]

self.pems_to_link_crosswalk_df = df

Expand Down
21 changes: 17 additions & 4 deletions tm2py/acceptance/simulated.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class Simulated:
transit_access_mode_dict = {}
transit_mode_dict = {}

taz_to_district_df: pd.DataFrame

simulated_boardings_df: pd.DataFrame
simulated_home_work_flows_df: pd.DataFrame
simulated_maz_data_df: pd.DataFrame
Expand Down Expand Up @@ -387,9 +389,10 @@ def _reduce_simulated_home_work_flows(self):
return

def _make_simulated_maz_data(self):
in_file = os.path.join("inputs", "landuse", "maz_data.csv")
root_dir = self.scenario_dict["scenario"]["root_dir"]
in_file = self.scenario_dict["scenario"]["maz_landuse_file"]

df = pd.read_csv(in_file)
df = pd.read_csv(os.path.join(root_dir, in_file))

index_file = os.path.join("inputs", "landuse", "mtc_final_network_zone_seq.csv")

Expand All @@ -405,6 +408,16 @@ def _make_simulated_maz_data(self):
on="MAZ_ORIGINAL",
)

self._make_taz_district_crosswalk()

return

def _make_taz_district_crosswalk(self):

df = self.simulated_maz_data_df[["TAZ_ORIGINAL", "DistID"]].copy()
df = df.rename(columns={"TAZ_ORIGINAL": "taz", "DistID": "district"})
self.taz_to_district_df = df.drop_duplicates().reset_index(drop=True)

return

def _reduce_simulated_rail_access_summaries(self):
Expand Down Expand Up @@ -1062,8 +1075,8 @@ def _make_dataframe_from_omx(self, input_mtx: omx, core_name: str):
return df

def _make_district_to_district_transit_summaries(self):
taz_district_dict = self.c.taz_to_district_df.set_index("taz_tm2")[
"district_tm2"
taz_district_dict = self.taz_to_district_df.set_index("taz")[
"district"
].to_dict()

s_dem_df = self.simulated_transit_demand_df.copy()
Expand Down

0 comments on commit c81ab14

Please sign in to comment.