From 8bec0cc423ca5b570f10a8ab343fe114a9868ae8 Mon Sep 17 00:00:00 2001 From: Martha Frysztacki Date: Tue, 7 Sep 2021 16:28:01 +0200 Subject: [PATCH] simplify: drop incorrect cols if they exist (avoid error) (#272) --- scripts/simplify_network.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/simplify_network.py b/scripts/simplify_network.py index 6e12e5e8..48f0ebe6 100644 --- a/scripts/simplify_network.py +++ b/scripts/simplify_network.py @@ -407,8 +407,11 @@ if __name__ == "__main__": if snakemake.wildcards.simpl: n, cluster_map = cluster(n, int(snakemake.wildcards.simpl)) busmaps.append(cluster_map) - else: - n.buses = n.buses.drop(['symbol', 'tags', 'under_construction', 'substation_lv', 'substation_off'], axis=1) + + # some entries in n.buses are not updated in previous functions, therefore can be wrong. as they are not needed + # and are lost when clustering (for example with the simpl wildcard), we remove them for consistency: + buses_c = {'symbol', 'tags', 'under_construction', 'substation_lv', 'substation_off'}.intersection(n.buses.columns) + n.buses = n.buses.drop(buses_c, axis=1) update_p_nom_max(n)