Merge pull request #1067 from PyPSA/fix_DC_cluster_issue
fix_DC_cluster_issue
This commit is contained in:
commit
cf8ee69f94
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user