From 72b484dd6b7d32cd82ec4d3a9e3ef43464cb2a88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20H=C3=B6rsch?= Date: Thu, 27 Sep 2018 18:25:41 +0200 Subject: [PATCH] base_network: Only buses with at least one finished connection may have load --- scripts/base_network.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/base_network.py b/scripts/base_network.py index 9d18b97c..57623c4a 100644 --- a/scripts/base_network.py +++ b/scripts/base_network.py @@ -289,7 +289,13 @@ def _set_countries_and_substations(n): buses.loc[offshore_country_b, 'country'] = country - buses['substation_lv'] = lv_b & onshore_b & (~ buses['under_construction']) + # Only accept buses as low-voltage substations (where load is attached), if + # they have at least one connection which is not under_construction + has_connections_b = pd.Series(False, index=buses.index) + for b, df in product(('bus0', 'bus1'), (n.lines, n.links)): + has_connections_b |= ~ df.groupby(b).under_construction.min() + + buses['substation_lv'] = lv_b & onshore_b & (~ buses['under_construction']) & has_connections_b buses['substation_off'] = (offshore_b | (hv_b & onshore_b)) & (~ buses['under_construction']) # Nearest country in numbers of hops defines country of homeless buses