Skip to content

Commit

Permalink
Merge pull request #155 from wsp-sag/bicounty_2035_hwy_update
Browse files Browse the repository at this point in the history
Bicounty 2035 hwy update
  • Loading branch information
jawadmhoque committed Feb 22, 2024
2 parents 92784b0 + 60052ac commit f382620
Show file tree
Hide file tree
Showing 3 changed files with 297 additions and 94 deletions.
5 changes: 4 additions & 1 deletion lasso/mtc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1751,8 +1751,11 @@ def roadway_standard_to_mtc_network(
lambda g: g.y
)

roadway_network.nodes_mtc_df["pnr"] = np.where(roadway_network.nodes_mtc_df['pnr']==0, '0.0', '1.0')

# CUBE expect node id to be N
roadway_network.nodes_mtc_df.rename(columns={"model_node_id": "N"}, inplace=True)
# roadway_network.nodes_mtc_df.rename(columns={"model_node_id": "N"}, inplace=True)
roadway_network.nodes_mtc_df['model_node_id']=roadway_network.nodes_mtc_df['N']

return roadway_network

Expand Down
108 changes: 15 additions & 93 deletions scripts/01-BCM_ApplyHighwayProjectCards.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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"
]
},
{
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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",
Expand Down
Loading

0 comments on commit f382620

Please sign in to comment.