From 1746a7d8b2200e8d0dd5bdf2f636f9f74241566c Mon Sep 17 00:00:00 2001 From: DavidOry Date: Mon, 1 Jul 2024 10:07:51 -0400 Subject: [PATCH] remove standalone taz-district-file This information in available in the maz_data file --- examples/canonical_crosswalk.toml | 1 - examples/scenario_config.toml | 2 +- tm2py/acceptance/canonical.py | 14 +------------- tm2py/acceptance/simulated.py | 21 +++++++++++++++++---- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/examples/canonical_crosswalk.toml b/examples/canonical_crosswalk.toml index fa0f4127..deee8ba1 100644 --- a/examples/canonical_crosswalk.toml +++ b/examples/canonical_crosswalk.toml @@ -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" diff --git a/examples/scenario_config.toml b/examples/scenario_config.toml index 59a57be3..5f61fa1e 100644 --- a/examples/scenario_config.toml +++ b/examples/scenario_config.toml @@ -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] diff --git a/tm2py/acceptance/canonical.py b/tm2py/acceptance/canonical.py index 74f4967d..8c5509e3 100644 --- a/tm2py/acceptance/canonical.py +++ b/tm2py/acceptance/canonical.py @@ -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 @@ -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() @@ -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 diff --git a/tm2py/acceptance/simulated.py b/tm2py/acceptance/simulated.py index ecd6d051..69074946 100644 --- a/tm2py/acceptance/simulated.py +++ b/tm2py/acceptance/simulated.py @@ -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 @@ -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") @@ -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): @@ -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()