From b9fdacad4d428855071a5a221baa3dc175afd73d Mon Sep 17 00:00:00 2001 From: eb5194 Date: Wed, 20 Jan 2021 20:39:22 +0100 Subject: [PATCH 01/12] simplify: delete columns with incorrect/accurate entries --- scripts/simplify_network.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/simplify_network.py b/scripts/simplify_network.py index b05d59aa..8663faa3 100644 --- a/scripts/simplify_network.py +++ b/scripts/simplify_network.py @@ -362,6 +362,7 @@ if __name__ == "__main__": n, cluster_map = cluster(n, int(snakemake.wildcards.simpl)) busmaps.append(cluster_map) + n.buses = n.buses.drop(['substation_lv', 'substation_off', 'under_construction'], axis=1) n.export_to_netcdf(snakemake.output.network) busmap_s = reduce(lambda x, y: x.map(y), busmaps[1:], busmaps[0]) From 1bd3a5a8061c61306fd99997fa8c98621f88a58f Mon Sep 17 00:00:00 2001 From: martacki Date: Tue, 25 May 2021 12:58:23 +0200 Subject: [PATCH 02/12] simplify: drop inaccurate columns only if no simpl wildcard is used --- scripts/simplify_network.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/simplify_network.py b/scripts/simplify_network.py index 8663faa3..4830b87b 100644 --- a/scripts/simplify_network.py +++ b/scripts/simplify_network.py @@ -361,8 +361,8 @@ if __name__ == "__main__": if snakemake.wildcards.simpl: n, cluster_map = cluster(n, int(snakemake.wildcards.simpl)) busmaps.append(cluster_map) - - n.buses = n.buses.drop(['substation_lv', 'substation_off', 'under_construction'], axis=1) + else: + n.buses = n.buses.drop(['symbol', 'tags', 'under_construction', 'substation_lv', 'substation_off'], axis=1) n.export_to_netcdf(snakemake.output.network) busmap_s = reduce(lambda x, y: x.map(y), busmaps[1:], busmaps[0]) From 14cf5815bb9d6f774b493ce5482b56ab3ca60a29 Mon Sep 17 00:00:00 2001 From: martacki Date: Tue, 25 May 2021 13:02:58 +0200 Subject: [PATCH 03/12] clear arrangement --- scripts/simplify_network.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/simplify_network.py b/scripts/simplify_network.py index 4830b87b..26bf96e3 100644 --- a/scripts/simplify_network.py +++ b/scripts/simplify_network.py @@ -363,6 +363,7 @@ if __name__ == "__main__": busmaps.append(cluster_map) else: n.buses = n.buses.drop(['symbol', 'tags', 'under_construction', 'substation_lv', 'substation_off'], axis=1) + n.export_to_netcdf(snakemake.output.network) busmap_s = reduce(lambda x, y: x.map(y), busmaps[1:], busmaps[0]) From b10317ee3c15c7fc2c1be4810bea0fd6808defed Mon Sep 17 00:00:00 2001 From: martacki Date: Wed, 30 Jun 2021 21:07:38 +0200 Subject: [PATCH 04/12] fix p_nom_min values for extendable carriers with positive p_nom --- scripts/_helpers.py | 9 +++++++++ scripts/add_electricity.py | 5 ++++- scripts/cluster_network.py | 6 ++++-- scripts/simplify_network.py | 6 ++++-- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/scripts/_helpers.py b/scripts/_helpers.py index 996baf73..622a3133 100644 --- a/scripts/_helpers.py +++ b/scripts/_helpers.py @@ -125,6 +125,15 @@ def load_network_for_plots(fn, tech_costs, config, combine_hydro_ps=True): return n +def update_p_nom_max(n): + # if extendable carriers (solar/onwind/...) have capacity >= 0, + # e.g. existing assets from the OPSD project are included to the network, + # the installed capacity might exceed the expansion limit. + # Hence, we update the assumptions. + + n.generators.p_nom_max = (n.generators + .apply(lambda b: b[['p_nom_min','p_nom_max']].max(), axis=1)) + def aggregate_p_nom(n): return pd.concat([ n.generators.groupby("carrier").p_nom_opt.sum(), diff --git a/scripts/add_electricity.py b/scripts/add_electricity.py index 45d537c4..bf80e8aa 100755 --- a/scripts/add_electricity.py +++ b/scripts/add_electricity.py @@ -84,7 +84,7 @@ It further adds extendable ``generators`` with **zero** capacity for """ import logging -from _helpers import configure_logging +from _helpers import configure_logging, update_p_nom_max import pypsa import pandas as pd @@ -501,6 +501,7 @@ def attach_OPSD_renewables(n): caps = caps / gens_per_bus.reindex(caps.index, fill_value=1) n.generators.p_nom.update(gens.bus.map(caps).dropna()) + n.generators.p_nom_min.update(gens.bus.map(caps).dropna()) @@ -536,6 +537,7 @@ def estimate_renewable_capacities(n, tech_map=None): .groupby(n.generators.bus.map(n.buses.country)) .transform(lambda s: normed(s) * tech_capacities.at[s.name]) .where(lambda s: s>0.1, 0.)) # only capacities above 100kW + n.generators.loc[tech_i, 'p_nom_min'] = n.generators.loc[tech_i, 'p_nom'] def add_nice_carrier_names(n, config=None): @@ -575,6 +577,7 @@ if __name__ == "__main__": estimate_renewable_capacities(n) attach_OPSD_renewables(n) + update_p_nom_max(n) add_nice_carrier_names(n) diff --git a/scripts/cluster_network.py b/scripts/cluster_network.py index 8356f83b..3503bd9b 100644 --- a/scripts/cluster_network.py +++ b/scripts/cluster_network.py @@ -122,7 +122,7 @@ Exemplary unsolved network clustered to 37 nodes: """ import logging -from _helpers import configure_logging +from _helpers import configure_logging, update_p_nom_max import pypsa import os @@ -282,7 +282,7 @@ def clustering_for_n_clusters(n, n_clusters, custom_busmap=False, aggregate_carr aggregate_generators_carriers=aggregate_carriers, aggregate_one_ports=["Load", "StorageUnit"], line_length_factor=line_length_factor, - generator_strategies={'p_nom_max': p_nom_max_strategy}, + generator_strategies={'p_nom_max': p_nom_max_strategy, 'p_nom_min': np.sum}, scale_link_capital_costs=False) if not n.links.empty: @@ -379,6 +379,8 @@ if __name__ == "__main__": extended_link_costs=hvac_overhead_cost, focus_weights=focus_weights) + update_p_nom_max(n) + clustering.network.export_to_netcdf(snakemake.output.network) for attr in ('busmap', 'linemap'): #also available: linemap_positive, linemap_negative getattr(clustering, attr).to_csv(snakemake.output[attr]) diff --git a/scripts/simplify_network.py b/scripts/simplify_network.py index 5e89b6bf..2cdcd095 100644 --- a/scripts/simplify_network.py +++ b/scripts/simplify_network.py @@ -83,7 +83,7 @@ The rule :mod:`simplify_network` does up to four things: """ import logging -from _helpers import configure_logging +from _helpers import configure_logging, update_p_nom_max from cluster_network import clustering_for_n_clusters, cluster_regions from add_electricity import load_costs @@ -198,7 +198,7 @@ def _aggregate_and_move_components(n, busmap, connection_costs_to_bus, aggregate _adjust_capital_costs_using_connection_costs(n, connection_costs_to_bus) - generators, generators_pnl = aggregategenerators(n, busmap) + generators, generators_pnl = aggregategenerators(n, busmap, custom_strategies={'p_nom_min': np.sum}) replace_components(n, "Generator", generators, generators_pnl) for one_port in aggregate_one_ports: @@ -364,6 +364,8 @@ if __name__ == "__main__": n, cluster_map = cluster(n, int(snakemake.wildcards.simpl)) busmaps.append(cluster_map) + update_p_nom_max(n) + n.export_to_netcdf(snakemake.output.network) busmap_s = reduce(lambda x, y: x.map(y), busmaps[1:], busmaps[0]) From cf2eff4127f27287d2b22e9cac2bec2f15116b8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martha=20Frysztacki=20=5Bfr=C9=A8=CA=82tat=CD=A1sk=CA=B2?= =?UTF-8?q?=5D?= Date: Wed, 30 Jun 2021 21:29:08 +0200 Subject: [PATCH 05/12] style Co-authored-by: FabianHofmann --- scripts/_helpers.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/_helpers.py b/scripts/_helpers.py index 622a3133..0c6a4658 100644 --- a/scripts/_helpers.py +++ b/scripts/_helpers.py @@ -131,8 +131,7 @@ def update_p_nom_max(n): # the installed capacity might exceed the expansion limit. # Hence, we update the assumptions. - n.generators.p_nom_max = (n.generators - .apply(lambda b: b[['p_nom_min','p_nom_max']].max(), axis=1)) + n.generators.p_nom_max = n.generators[['p_nom_min', 'p_nom_max']].max(1) def aggregate_p_nom(n): return pd.concat([ From 89631b240ae39bfd1575953891113deaba56b020 Mon Sep 17 00:00:00 2001 From: martacki Date: Fri, 2 Jul 2021 10:04:22 +0200 Subject: [PATCH 06/12] correct placement of if/else --- scripts/simplify_network.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/scripts/simplify_network.py b/scripts/simplify_network.py index 6a922019..4678f796 100644 --- a/scripts/simplify_network.py +++ b/scripts/simplify_network.py @@ -363,11 +363,10 @@ if __name__ == "__main__": if snakemake.wildcards.simpl: n, cluster_map = cluster(n, int(snakemake.wildcards.simpl)) busmaps.append(cluster_map) - - update_p_nom_max(n) - else: n.buses = n.buses.drop(['symbol', 'tags', 'under_construction', 'substation_lv', 'substation_off'], axis=1) + + update_p_nom_max(n) n.export_to_netcdf(snakemake.output.network) From 34578bf16bebd7884730a478cf95916650a1512b Mon Sep 17 00:00:00 2001 From: martacki Date: Fri, 2 Jul 2021 10:24:30 +0200 Subject: [PATCH 07/12] update release_notes --- doc/release_notes.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/release_notes.rst b/doc/release_notes.rst index 230fc67d..bc09f957 100644 --- a/doc/release_notes.rst +++ b/doc/release_notes.rst @@ -24,6 +24,7 @@ Upcoming Release * The ``focus_weights`` are now also considered when pre-clustering in the :mod:`simplify_network` rule [`#241 `_]. * Continuous integration testing switches to Github Actions from Travis CI [`#252 `_]. * Bugfix in :mod:`build_renewable_profile` where offshore wind profiles could no longer be created [`#249 `_]. +* Bugfix: Lower expansion limit of extendable carriers is now set to the existing capacity, i.e. p_nom_min = p_nom (0 before). Simultaneously, the upper limit (p_nom_max) is now the maximum of the installed capacity (p_nom) and the previous estimate based on land availability (p_nom_max). PyPSA-Eur 0.3.0 (7th December 2020) ================================== From 6983be337ac7f4a6a8499dadf39a74644cfe31ee Mon Sep 17 00:00:00 2001 From: martacki Date: Fri, 2 Jul 2021 10:26:46 +0200 Subject: [PATCH 08/12] release_notes: add PR reference --- doc/release_notes.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/release_notes.rst b/doc/release_notes.rst index bc09f957..c001464d 100644 --- a/doc/release_notes.rst +++ b/doc/release_notes.rst @@ -24,7 +24,7 @@ Upcoming Release * The ``focus_weights`` are now also considered when pre-clustering in the :mod:`simplify_network` rule [`#241 `_]. * Continuous integration testing switches to Github Actions from Travis CI [`#252 `_]. * Bugfix in :mod:`build_renewable_profile` where offshore wind profiles could no longer be created [`#249 `_]. -* Bugfix: Lower expansion limit of extendable carriers is now set to the existing capacity, i.e. p_nom_min = p_nom (0 before). Simultaneously, the upper limit (p_nom_max) is now the maximum of the installed capacity (p_nom) and the previous estimate based on land availability (p_nom_max). +* Bugfix: Lower expansion limit of extendable carriers is now set to the existing capacity, i.e. p_nom_min = p_nom (0 before). Simultaneously, the upper limit (p_nom_max) is now the maximum of the installed capacity (p_nom) and the previous estimate based on land availability (p_nom_max) [`#260 `_]. PyPSA-Eur 0.3.0 (7th December 2020) ================================== From 15ebe63b38738673ef095c3127bf8e3e21516aa0 Mon Sep 17 00:00:00 2001 From: martacki Date: Fri, 2 Jul 2021 10:43:32 +0200 Subject: [PATCH 09/12] release_notes: style --- doc/release_notes.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/release_notes.rst b/doc/release_notes.rst index c001464d..b8aaeba2 100644 --- a/doc/release_notes.rst +++ b/doc/release_notes.rst @@ -24,7 +24,7 @@ Upcoming Release * The ``focus_weights`` are now also considered when pre-clustering in the :mod:`simplify_network` rule [`#241 `_]. * Continuous integration testing switches to Github Actions from Travis CI [`#252 `_]. * Bugfix in :mod:`build_renewable_profile` where offshore wind profiles could no longer be created [`#249 `_]. -* Bugfix: Lower expansion limit of extendable carriers is now set to the existing capacity, i.e. p_nom_min = p_nom (0 before). Simultaneously, the upper limit (p_nom_max) is now the maximum of the installed capacity (p_nom) and the previous estimate based on land availability (p_nom_max) [`#260 `_]. +* Bugfix: Lower expansion limit of extendable carriers is now set to the existing capacity, i.e. ``p_nom_min = p_nom`` (0 before). Simultaneously, the upper limit (``p_nom_max``) is now the maximum of the installed capacity (``p_nom``) and the previous estimate based on land availability (``p_nom_max``) [`#260 `_]. PyPSA-Eur 0.3.0 (7th December 2020) ================================== From 989d8c6abfe6602ea2a3ae70683ba5097f54fe06 Mon Sep 17 00:00:00 2001 From: Fabian Neumann Date: Fri, 9 Jul 2021 10:22:40 +0200 Subject: [PATCH 11/12] specify when to run CI (#262) --- .github/workflows/ci.yaml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a3268243..b0699d74 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -4,7 +4,15 @@ name: CI -on: [push] +on: + push: + branches: + - master + pull_request: + branches: + - master + schedule: + - cron: "0 5 * * TUE" jobs: build: From e2c3118f08bccddbd2eb47002b9d89d1f9eb3087 Mon Sep 17 00:00:00 2001 From: Fabian Neumann Date: Mon, 12 Jul 2021 08:50:37 +0200 Subject: [PATCH 12/12] don't allow pandas 1.3.0 yet --- envs/environment.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/envs/environment.yaml b/envs/environment.yaml index 3d0a3400..979c83df 100644 --- a/envs/environment.yaml +++ b/envs/environment.yaml @@ -28,7 +28,7 @@ dependencies: - lxml - powerplantmatching>=0.4.8 - numpy<=1.19 # until new PyPSA after 27-06-21 - - pandas + - pandas<1.3 # until new PyPSA after 2-7-21, https://github.com/PyPSA/pypsa-eur/pull/261 - geopandas - xarray - netcdf4