From ac48fdaaf43c4ca200efd913af3e6773ec5cd501 Mon Sep 17 00:00:00 2001 From: Philipp Glaum Date: Fri, 17 May 2024 14:46:20 +0200 Subject: [PATCH] base_network.py: connect new tyndp links only to closest AC bus --- scripts/base_network.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/scripts/base_network.py b/scripts/base_network.py index 870fcf19..b811f625 100644 --- a/scripts/base_network.py +++ b/scripts/base_network.py @@ -272,14 +272,15 @@ def _add_links_from_tyndp(buses, links, links_tyndp, europe_shape): if links_tyndp.empty: return buses, links - tree = spatial.KDTree(buses[["x", "y"]]) + tree_buses = buses.query("carrier=='AC'") + tree = spatial.KDTree(tree_buses[["x", "y"]]) _, ind0 = tree.query(links_tyndp[["x1", "y1"]]) - ind0_b = ind0 < len(buses) - links_tyndp.loc[ind0_b, "bus0"] = buses.index[ind0[ind0_b]] + ind0_b = ind0 < len(tree_buses) + links_tyndp.loc[ind0_b, "bus0"] = tree_buses.index[ind0[ind0_b]] _, ind1 = tree.query(links_tyndp[["x2", "y2"]]) - ind1_b = ind1 < len(buses) - links_tyndp.loc[ind1_b, "bus1"] = buses.index[ind1[ind1_b]] + ind1_b = ind1 < len(tree_buses) + links_tyndp.loc[ind1_b, "bus1"] = tree_buses.index[ind1[ind1_b]] links_tyndp_located_b = ( links_tyndp["bus0"].notnull() & links_tyndp["bus1"].notnull()