From d51ca8695bf2591ba3eb9698b8cfe1c5241194bc Mon Sep 17 00:00:00 2001 From: Philipp Glaum Date: Mon, 19 Sep 2022 11:46:58 +0200 Subject: [PATCH] update Fabians comments --- config.default.yaml | 3 ++- config.tutorial.yaml | 3 ++- doc/configtables/clustering.csv | 6 ++++-- scripts/cluster_network.py | 3 ++- scripts/simplify_network.py | 6 +++--- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/config.default.yaml b/config.default.yaml index 0c2c8218..920e4809 100755 --- a/config.default.yaml +++ b/config.default.yaml @@ -258,10 +258,11 @@ clustering: to_substations: false # network is simplified to nodes with positive or negative power injection (i.e. substations or offwind connections) algorithm: kmeans # choose from: [hac, kmeans] feature: solar+onwind-time # only for hac. choose from: [solar+onwind-time, solar+onwind-cap, solar-time, solar-cap, solar+offwind-cap] etc. + exclude_carriers: [] cluster_network: algorithm: kmeans feature: solar+onwind-time - exclude_carriers: [] # list of carriers which will not be aggregated. If empty, all carriers will be aggregated. + exclude_carriers: [] aggregation_strategies: generators: p_nom_max: sum # use "min" for more conservative assumptions diff --git a/config.tutorial.yaml b/config.tutorial.yaml index 0cfdc5ab..cf9fd318 100755 --- a/config.tutorial.yaml +++ b/config.tutorial.yaml @@ -188,10 +188,11 @@ clustering: to_substations: false # network is simplified to nodes with positive or negative power injection (i.e. substations or offwind connections) algorithm: kmeans # choose from: [hac, kmeans] feature: solar+onwind-time # only for hac. choose from: [solar+onwind-time, solar+onwind-cap, solar-time, solar-cap, solar+offwind-cap] etc. + exclude_carriers: [] cluster_network: algorithm: kmeans feature: solar+onwind-time - exclude_carriers: [] # list of carriers which will not be aggregated. If empty, all carriers will be aggregated. + exclude_carriers: [] aggregation_strategies: generators: p_nom_max: sum # use "min" for more conservative assumptions diff --git a/doc/configtables/clustering.csv b/doc/configtables/clustering.csv index 02a7b1fc..1ef6e21b 100644 --- a/doc/configtables/clustering.csv +++ b/doc/configtables/clustering.csv @@ -3,11 +3,13 @@ simplify_network,,, -- to_substations,bool,"{'true','false'}","Aggregates all nodes without power injection (positive or negative, i.e. demand or generation) to electrically closest ones" -- algorithm,str,"One of {‘kmeans’, ‘hac’, ‘modularity‘}", -- feature,str,"Str in the format ‘carrier1+carrier2+...+carrierN-X’, where CarrierI can be from {‘solar’, ‘onwind’, ‘offwind’, ‘ror’} and X is one of {‘cap’, ‘time’}.", -cluster_network +-- exclude_carriers,list,"List of Str like [ 'solar', 'onwind'] or empy list []","List of carriers which will not be aggregated. If empty, all carriers will be aggregated." +cluster_network,,, -- algorithm,str,"One of {‘kmeans’, ‘hac’}", -- feature,str,"Str in the format ‘carrier1+carrier2+...+carrierN-X’, where CarrierI can be from {‘solar’, ‘onwind’, ‘offwind’, ‘ror’} and X is one of {‘cap’, ‘time’}.", +-- exclude_carriers,list,"List of Str like [ 'solar', 'onwind'] or empy list []","List of carriers which will not be aggregated. If empty, all carriers will be aggregated." aggregation_strategies,,, -- generators,,, -- -- {key},str,"{key} can be any of the component of the generator (str). It’s value can be any that can be converted to pandas.Series using getattr(). For example one of {min, max, sum}.","Aggregates the component according to the given strategy. For example, if sum, then all values within each cluster are summed to represent the new generator." -- buses,,, --- -- {key},str,"{key} can be any of the component of the bus (str). It’s value can be any that can be converted to pandas.Series using getattr(). For example one of {min, max, sum}.","Aggregates the component according to the given strategy. For example, if sum, then all values within each cluster are summed to represent the new bus." +-- -- {key},str,"{key} can be any of the component of the bus (str). It’s value can be any that can be converted to pandas.Series using getattr(). For example one of {min, max, sum}.","Aggregates the component according to the given strategy. For example, if sum, then all values within each cluster are summed to represent the new bus." \ No newline at end of file diff --git a/scripts/cluster_network.py b/scripts/cluster_network.py index a392d024..9b0f9377 100644 --- a/scripts/cluster_network.py +++ b/scripts/cluster_network.py @@ -393,7 +393,8 @@ if __name__ == "__main__": for tech in n.generators.carrier.unique() if tech in snakemake.config['renewable']]) - aggregate_carriers=set(n.carriers.index)-set(snakemake.config["clustering"]["exclude_carriers"]) + exclude_carriers = snakemake.config["clustering"]["cluster_network"].get("exclude_carriers", []) + aggregate_carriers = set(n.generators.carrier) - set(exclude_carriers) if snakemake.wildcards.clusters.endswith('m'): n_clusters = int(snakemake.wildcards.clusters[:-1]) aggregate_carriers = snakemake.config["electricity"].get("conventional_carriers") diff --git a/scripts/simplify_network.py b/scripts/simplify_network.py index 16726156..b6e0afae 100644 --- a/scripts/simplify_network.py +++ b/scripts/simplify_network.py @@ -211,7 +211,7 @@ def _aggregate_and_move_components(n, busmap, connection_costs_to_bus, output, _, generator_strategies = get_aggregation_strategies(aggregation_strategies) - carriers=set(n.carriers.index)-set(exclude_carriers) + carriers = set(n.generators.carrier) - set(exclude_carriers) generators, generators_pnl = aggregategenerators( n, busmap, carriers=carriers, custom_strategies=generator_strategies ) @@ -321,7 +321,7 @@ def simplify_links(n, costs, config, output, aggregation_strategies=dict()): logger.debug("Collecting all components using the busmap") - exclude_carriers=config["clustering"]["exclude_carriers"] + exclude_carriers = config["clustering"]["simplify_network"].get("exclude_carriers", []) _aggregate_and_move_components(n, busmap, connection_costs_to_bus, output, aggregation_strategies=aggregation_strategies, exclude_carriers=exclude_carriers) return n, busmap @@ -333,7 +333,7 @@ def remove_stubs(n, costs, config, output, aggregation_strategies=dict()): connection_costs_to_bus = _compute_connection_costs_to_bus(n, busmap, costs, config) - exclude_carriers=config["clustering"]["exclude_carriers"] + exclude_carriers = config["clustering"]["simplify_network"].get("exclude_carriers", []) _aggregate_and_move_components(n, busmap, connection_costs_to_bus, output, aggregation_strategies=aggregation_strategies, exclude_carriers=exclude_carriers)