From d45cb71b7a64ff8b83f7a6c13b0f1377befcd8f4 Mon Sep 17 00:00:00 2001 From: Fabian Neumann Date: Sun, 23 Jul 2023 11:07:45 +0200 Subject: [PATCH 1/5] match build_powerplants FuelType (closes #754) --- scripts/build_powerplants.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/build_powerplants.py b/scripts/build_powerplants.py index f25f111bb..cefc0ee50 100755 --- a/scripts/build_powerplants.py +++ b/scripts/build_powerplants.py @@ -98,13 +98,13 @@ def add_custom_powerplants(ppl, custom_powerplants, custom_ppl_query=False): def replace_natural_gas_technology(df): - mapping = {"Steam Turbine": "OCGT", "Combustion Engine": "OCGT"} - tech = df.Technology.replace(mapping).fillna("OCGT") - return df.Technology.where(df.Fueltype != "Natural Gas", tech) + mapping = {"Steam Turbine": "CCGT", "Combustion Engine": "OCGT"} + tech = df.Technology.replace(mapping).fillna("CCGT") + return df.Technology.mask(df.Fueltype == "Natural Gas", tech) def replace_natural_gas_fueltype(df): - return df.Fueltype.where(df.Fueltype != "Natural Gas", df.Technology) + return df.Fueltype.mask(df.Technology == "OCGT" | df.Technology == "CCGT", "Natural Gas") if __name__ == "__main__": From 3f3e73a0ecf5654f9e6a30bfb308d61d47b9c82a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 23 Jul 2023 09:08:27 +0000 Subject: [PATCH 2/5] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- scripts/build_powerplants.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/build_powerplants.py b/scripts/build_powerplants.py index cefc0ee50..af67ee300 100755 --- a/scripts/build_powerplants.py +++ b/scripts/build_powerplants.py @@ -104,7 +104,9 @@ def replace_natural_gas_technology(df): def replace_natural_gas_fueltype(df): - return df.Fueltype.mask(df.Technology == "OCGT" | df.Technology == "CCGT", "Natural Gas") + return df.Fueltype.mask( + df.Technology == "OCGT" | df.Technology == "CCGT", "Natural Gas" + ) if __name__ == "__main__": From 6110fe784d4b083f112af9ccc2b9ce53c31e9a1f Mon Sep 17 00:00:00 2001 From: Fabian Neumann Date: Sun, 23 Jul 2023 14:59:28 +0200 Subject: [PATCH 3/5] wrap comparisons in brackets --- scripts/build_powerplants.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/build_powerplants.py b/scripts/build_powerplants.py index cefc0ee50..1a714b397 100755 --- a/scripts/build_powerplants.py +++ b/scripts/build_powerplants.py @@ -104,7 +104,7 @@ def replace_natural_gas_technology(df): def replace_natural_gas_fueltype(df): - return df.Fueltype.mask(df.Technology == "OCGT" | df.Technology == "CCGT", "Natural Gas") + return df.Fueltype.mask((df.Technology == "OCGT") | (df.Technology == "CCGT"), "Natural Gas") if __name__ == "__main__": From 7575dd03514d5fb6c0c81b90a537b2bef7b2bceb Mon Sep 17 00:00:00 2001 From: Fabian Neumann Date: Wed, 26 Jul 2023 07:24:12 +0200 Subject: [PATCH 4/5] handling of natural gas in add_existing_baseyear and add_electricity --- scripts/add_electricity.py | 7 +++++++ scripts/add_existing_baseyear.py | 15 ++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/scripts/add_electricity.py b/scripts/add_electricity.py index 7cea165bf..68d2d5fa4 100755 --- a/scripts/add_electricity.py +++ b/scripts/add_electricity.py @@ -426,6 +426,13 @@ def attach_conventional_generators( add_missing_carriers(n, carriers) add_co2_emissions(n, costs, carriers) + # Replace carrier "natural gas" with the respective technology (OCGT or + # CCGT) to align with PyPSA names of "carriers" and avoid filtering "natural + # gas" powerplants in ppl.query("carrier in @carriers") + ppl.loc[ppl["carrier"] == "natural gas", "carrier"] = ppl.loc[ + ppl["carrier"] == "natural gas", "technology" + ] + ppl = ( ppl.query("carrier in @carriers") .join(costs, on="carrier", rsuffix="_r") diff --git a/scripts/add_existing_baseyear.py b/scripts/add_existing_baseyear.py index f80bffb87..668fab67c 100644 --- a/scripts/add_existing_baseyear.py +++ b/scripts/add_existing_baseyear.py @@ -129,10 +129,14 @@ def add_power_capacities_installed_before_baseyear(n, grouping_years, costs, bas "Oil": "oil", "OCGT": "OCGT", "CCGT": "CCGT", - "Natural Gas": "gas", "Bioenergy": "urban central solid biomass CHP", } + # Replace Fueltype "Natural Gas" with the respective technology (OCGT or CCGT) + df_agg.loc[df_agg["Fueltype"] == "Natural Gas", "Fueltype"] = df_agg.loc[ + df_agg["Fueltype"] == "Natural Gas", "Technology" + ] + fueltype_to_drop = [ "Hydro", "Wind", @@ -601,12 +605,13 @@ def add_heating_capacities_installed_before_baseyear( snakemake = mock_snakemake( "add_existing_baseyear", + configfiles="config/test/config.myopic.yaml", simpl="", - clusters="45", - ll="v1.0", + clusters="5", + ll="v1.5", opts="", - sector_opts="8760H-T-H-B-I-A-solar+p3-dist1", - planning_horizons=2020, + sector_opts="24H-T-H-B-I-A-solar+p3-dist1", + planning_horizons=2030, ) logging.basicConfig(level=snakemake.config["logging"]["level"]) From 74be5261fc7a03dfd72be685453a8452b1d6cb9b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 26 Jul 2023 05:24:31 +0000 Subject: [PATCH 5/5] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- scripts/add_existing_baseyear.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/add_existing_baseyear.py b/scripts/add_existing_baseyear.py index 668fab67c..ab7d2cb63 100644 --- a/scripts/add_existing_baseyear.py +++ b/scripts/add_existing_baseyear.py @@ -605,7 +605,7 @@ def add_heating_capacities_installed_before_baseyear( snakemake = mock_snakemake( "add_existing_baseyear", - configfiles="config/test/config.myopic.yaml", + configfiles="config/test/config.myopic.yaml", simpl="", clusters="5", ll="v1.5",