From 7e99f3bba7deecb4cc73568d9fcee9b3ad58950a Mon Sep 17 00:00:00 2001 From: Thomas Gilon Date: Fri, 22 Mar 2024 10:05:40 +0100 Subject: [PATCH] Fix error with symbol of buses in simplify_network --- doc/release_notes.rst | 2 ++ scripts/simplify_network.py | 24 ++++++++++++------------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/doc/release_notes.rst b/doc/release_notes.rst index b868e5e9..1aaaaebd 100644 --- a/doc/release_notes.rst +++ b/doc/release_notes.rst @@ -164,6 +164,8 @@ Upcoming Release * Fix duplicated years in `add_land_use_constraint_m`. +* Fix error with `symbol` of `buses` in `simplify_network`. + PyPSA-Eur 0.10.0 (19th February 2024) ===================================== diff --git a/scripts/simplify_network.py b/scripts/simplify_network.py index eac026a4..24df7312 100644 --- a/scripts/simplify_network.py +++ b/scripts/simplify_network.py @@ -594,18 +594,6 @@ if __name__ == "__main__": ) busmaps.append(busmap_hac) - if snakemake.wildcards.simpl: - n, cluster_map = cluster( - n, - int(snakemake.wildcards.simpl), - params.focus_weights, - solver_name, - params.simplify_network["algorithm"], - params.simplify_network["feature"], - params.aggregation_strategies, - ) - busmaps.append(cluster_map) - # 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: remove = [ @@ -621,6 +609,18 @@ if __name__ == "__main__": n.buses.drop(remove, axis=1, inplace=True, errors="ignore") n.lines.drop(remove, axis=1, errors="ignore", inplace=True) + if snakemake.wildcards.simpl: + n, cluster_map = cluster( + n, + int(snakemake.wildcards.simpl), + params.focus_weights, + solver_name, + params.simplify_network["algorithm"], + params.simplify_network["feature"], + params.aggregation_strategies, + ) + busmaps.append(cluster_map) + update_p_nom_max(n) n.meta = dict(snakemake.config, **dict(wildcards=dict(snakemake.wildcards)))