From 509f7e614fbdef6143a717f5aa2e38eec249e86d Mon Sep 17 00:00:00 2001 From: Thomas Gilon Date: Thu, 11 Apr 2024 10:29:30 +0200 Subject: [PATCH] Clarify suffix usage in add existing baseyear --- doc/release_notes.rst | 2 ++ scripts/add_existing_baseyear.py | 27 ++++++++----------------- scripts/build_industry_sector_ratios.py | 2 +- 3 files changed, 11 insertions(+), 20 deletions(-) diff --git a/doc/release_notes.rst b/doc/release_notes.rst index d42b149f..a1bff4b5 100644 --- a/doc/release_notes.rst +++ b/doc/release_notes.rst @@ -181,6 +181,8 @@ Upcoming Release * Fix custom busmap read in `cluster_network`. +* Clarify suffix usage in `add_existing_baseyear`. + PyPSA-Eur 0.10.0 (19th February 2024) ===================================== diff --git a/scripts/add_existing_baseyear.py b/scripts/add_existing_baseyear.py index f445efe3..c57b3fdc 100644 --- a/scripts/add_existing_baseyear.py +++ b/scripts/add_existing_baseyear.py @@ -152,7 +152,7 @@ def add_power_capacities_installed_before_baseyear(n, grouping_years, costs, bas technology_to_drop = ["Pv", "Storage Technologies"] - # drop unused fueltyps and technologies + # drop unused fueltypes and technologies df_agg.drop(df_agg.index[df_agg.Fueltype.isin(fueltype_to_drop)], inplace=True) df_agg.drop(df_agg.index[df_agg.Technology.isin(technology_to_drop)], inplace=True) df_agg.Fueltype = df_agg.Fueltype.map(rename_fuel) @@ -230,6 +230,7 @@ def add_power_capacities_installed_before_baseyear(n, grouping_years, costs, bas ] suffix = "-ac" if generator == "offwind" else "" name_suffix = f" {generator}{suffix}-{grouping_year}" + name_suffix_by = f" {generator}{suffix}-{baseyear}" asset_i = capacity.index + name_suffix if generator in ["solar", "onwind", "offwind"]: # to consider electricity grid connection costs or a split between @@ -259,21 +260,11 @@ def add_power_capacities_installed_before_baseyear(n, grouping_years, costs, bas # for offshore the splitting only includes coastal regions inv_ind = [ - i - for i in inv_ind - if (i + name_suffix) - in n.generators.index.str.replace( - str(baseyear), str(grouping_year) - ) + i for i in inv_ind if (i + name_suffix_by) in n.generators.index ] - p_max_pu = n.generators_t.p_max_pu[ - [i + name_suffix for i in inv_ind] - ] - p_max_pu.columns = [ - i + name_suffix.replace(str(grouping_year), str(baseyear)) - for i in inv_ind - ] + p_max_pu = n.generators_t.p_max_pu[[i + name_suffix_by for i in inv_ind]] + p_max_pu.columns = [i + name_suffix for i in inv_ind] n.madd( "Generator", @@ -291,15 +282,13 @@ def add_power_capacities_installed_before_baseyear(n, grouping_years, costs, bas ) else: - p_max_pu = n.generators_t.p_max_pu[ - capacity.index + f" {generator}{suffix}-{baseyear}" - ] + p_max_pu = n.generators_t.p_max_pu[capacity.index + name_suffix_by] if not new_build.empty: n.madd( "Generator", new_capacity.index, - suffix=" " + name_suffix, + suffix=name_suffix, bus=new_capacity.index, carrier=generator, p_nom=new_capacity, @@ -412,7 +401,7 @@ def add_heating_capacities_installed_before_baseyear( linear decommissioning of heating capacities from 2020 to 2045 is currently assumed heating capacities split between residential and services proportional to heating load in both 50% capacities - in rural busess 50% in urban buses + in rural buses 50% in urban buses """ logger.debug(f"Adding heating capacities installed before {baseyear}") diff --git a/scripts/build_industry_sector_ratios.py b/scripts/build_industry_sector_ratios.py index 52e83f60..87c80c0d 100644 --- a/scripts/build_industry_sector_ratios.py +++ b/scripts/build_industry_sector_ratios.py @@ -313,7 +313,7 @@ def chemicals_industry(): df.loc["methane", sector] += s_fec["Natural gas"] # LPG and other feedstock materials are assimilated to naphtha - # since they will be produced through Fischer-Tropsh process + # since they will be produced through Fischer-Tropsch process sel = [ "Solids", "Refinery gas",