From c9c749542d2a594a70f51afc25ab40858df43b40 Mon Sep 17 00:00:00 2001 From: Jawad Mahmud Hoque <35570340+jawadmhoque@users.noreply.github.com> Date: Thu, 22 Feb 2024 09:53:30 -0500 Subject: [PATCH] Update 01-BCM_ApplyHighwayProjectCards.ipynb Deleted 2020 network creation step. --- scripts/01-BCM_ApplyHighwayProjectCards.ipynb | 108 +++--------------- 1 file changed, 15 insertions(+), 93 deletions(-) diff --git a/scripts/01-BCM_ApplyHighwayProjectCards.ipynb b/scripts/01-BCM_ApplyHighwayProjectCards.ipynb index a4147a5..257a1f2 100644 --- a/scripts/01-BCM_ApplyHighwayProjectCards.ipynb +++ b/scripts/01-BCM_ApplyHighwayProjectCards.ipynb @@ -125,36 +125,6 @@ "## List of Project Cards to be Applied to the 2015 Scenario" ] }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "['Added_networkforexternals_Sacto2_GN_11142022.yml',\n", - " 'assignable_and_ace_transit_connectors.yml',\n", - " 'CCTA.yml',\n", - " 'Externals_SJQ_Add_complete_network_10032022.yml',\n", - " 'Sonoma_Marin_Area_Rail_Transit_add_rail_link.yml',\n", - " 'Year 2015 Modify Express Lanes and USE on I-580 EB (segment 02) Hacienda Drive to Airway Blvd_v2.yml',\n", - " 'Year 2015 Modify HOV Lanes and USE on CA-237 EB US 101 to North 1st Street_v2.yml',\n", - " 'Year 2015 Modify HOV Lanes and USE on CA-237 WB North 1st Street to US 101_v2.yml',\n", - " 'Year 2015 Modify HOV Lanes and USE on I-680 NB from Alcosta Blvd to Livorna Road_v2.yml',\n", - " 'Year 2015 Modify HOV Lanes and USE on I-680 SB from Benicia Bridge to Alcosta Blvd_v2.yml',\n", - " 'year_2015_managed_lane_i680n_ca_242_to_benicia_bridge.yml']" - ] - }, - "execution_count": 8, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "os.listdir(os.path.join(card_dir, '2020'))" - ] - }, { "cell_type": "code", "execution_count": 72, @@ -8318,61 +8288,6 @@ "updated_net = mtc.roadway_standard_to_mtc_network(model_net, parameters=parameters)" ] }, - { - "cell_type": "code", - "execution_count": 48, - "metadata": {}, - "outputs": [], - "source": [ - "updated_net.nodes_mtc_df['pnr']=updated_net.nodes_mtc_df['pnr'].apply(lambda x: 0 if x==\"\" else int(x))\n", - "updated_net.nodes_mtc_df['model_node_id']=updated_net.nodes_mtc_df['N']" - ] - }, - { - "cell_type": "code", - "execution_count": 52, - "metadata": {}, - "outputs": [], - "source": [ - "transit_links=pd.read_csv(os.path.join(transit_dir,'2020', \"all_transit_links.csv\"))\n", - "transit_links=transit_links.rename(columns={'line':'has_transit'})\n", - "transit_links['has_transit'] = 1\n", - "has_transit = pd.merge(transit_links, updated_net.links_mtc_df[['A','B','model_link_id']])\n", - "\n", - "updated_net.links_mtc_df['name']=updated_net.links_mtc_df['name'].apply(lambda x: \"\" if type(x)==int else x)\n", - "updated_net.links_mtc_df['name']=updated_net.links_mtc_df['name'].apply(lambda x: util.shorten_name(x))\n", - "updated_net.links_mtc_df['has_transit']=updated_net.links_mtc_df['model_link_id'].map(dict(zip(has_transit['model_link_id'],has_transit['has_transit']))).fillna(0)\n" - ] - }, - { - "cell_type": "code", - "execution_count": 53, - "metadata": {}, - "outputs": [], - "source": [ - "\n", - "# curr_scenario.road_net.links_df = updated_net.links_mtc_df.copy()\n", - "# curr_scenario.road_net.nodes_df = updated_net.nodes_mtc_df.copy()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "curr_scenario.road_net.links_df=curr_scenario.road_net.links_df[curr_scenario.road_net.links_df['geometry'].notnull()]" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "scenario_2020 = Scenario.create_scenario(base_scenario = curr_scenario)" - ] - }, { "cell_type": "code", "execution_count": 54, @@ -14071,21 +13986,18 @@ }, { "cell_type": "code", - "execution_count": 78, + "execution_count": 79, "metadata": {}, "outputs": [], "source": [ - "updated_net.nodes_mtc_df['pnr']=updated_net.nodes_mtc_df['pnr'].apply(lambda x: 0 if x==\"\" else int(x))\n", - "updated_net.nodes_mtc_df['model_node_id']=updated_net.nodes_mtc_df['N']" + "updated_net.links_mtc_df=updated_net.links_mtc_df[updated_net.links_mtc_df['geometry'].notnull()]" ] }, { - "cell_type": "code", - "execution_count": 79, + "cell_type": "markdown", "metadata": {}, - "outputs": [], "source": [ - "updated_net.links_mtc_df=updated_net.links_mtc_df[updated_net.links_mtc_df['geometry'].notnull()]" + "# Add has_transit attribute to links carrying transit" ] }, { @@ -18932,6 +18844,16 @@ " 'lanes_EA', 'lanes_AM', 'lanes_MD', 'lanes_PM', 'lanes_EV','geometry', 'has_transit']].to_file(os.path.join(pickle_dir, 'all_projects',\"complete_network_2035.shp\"))" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "outpur_network_2035_dir = os.path.join(pickle_dir, '2035')\n", + "os.makedirs(outpur_network_2035_dir, exist_ok=True)" + ] + }, { "cell_type": "code", "execution_count": 92, @@ -18979,7 +18901,7 @@ ], "source": [ "model_net_updated.write_roadway_as_fixedwidth(\n", - " output_dir = os.path.join(pickle_dir, 'all_projects'),\n", + " output_dir = outpur_network_2035_dir,\n", " output_link_txt = 'links.txt',\n", " output_node_txt = 'nodes.txt',\n", " output_link_header_width_txt = 'links_header_width.txt',\n",