Merge pull request #958 from PyPSA/fix-lifetime

compute lifetime after grouping DateIn
This commit is contained in:
Fabian Neumann 2024-03-06 08:55:29 +01:00 committed by GitHub
commit cb5d9c4319
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 5 deletions

View File

@ -353,7 +353,7 @@ solar_thermal:
# docs in https://pypsa-eur.readthedocs.io/en/latest/configuration.html#existing-capacities # docs in https://pypsa-eur.readthedocs.io/en/latest/configuration.html#existing-capacities
existing_capacities: existing_capacities:
grouping_years_power: [1980, 1985, 1990, 1995, 2000, 2005, 2010, 2015, 2020, 2025, 2030] grouping_years_power: [1960, 1965, 1970, 1975, 1980, 1985, 1990, 1995, 2000, 2005, 2010, 2015, 2020, 2025, 2030]
grouping_years_heat: [1980, 1985, 1990, 1995, 2000, 2005, 2010, 2015, 2019] # these should not extend 2020 grouping_years_heat: [1980, 1985, 1990, 1995, 2000, 2005, 2010, 2015, 2019] # these should not extend 2020
threshold_capacity: 10 threshold_capacity: 10
default_heating_lifetime: 20 default_heating_lifetime: 20

View File

@ -10,6 +10,10 @@ Release Notes
Upcoming Release Upcoming Release
================ ================
* Corrected a bug leading to power plants operating after their DateOut
(https://github.com/PyPSA/pypsa-eur/pull/958). Added additional grouping years
before 1980.
* The Eurostat data was updated to the 2023 version in :mod:`build_energy_totals`. * The Eurostat data was updated to the 2023 version in :mod:`build_energy_totals`.
* The latest `Swiss energy totals * The latest `Swiss energy totals

View File

@ -171,10 +171,6 @@ def add_power_capacities_installed_before_baseyear(n, grouping_years, costs, bas
phased_out = df_agg[df_agg["DateOut"] < baseyear].index phased_out = df_agg[df_agg["DateOut"] < baseyear].index
df_agg.drop(phased_out, inplace=True) df_agg.drop(phased_out, inplace=True)
# calculate remaining lifetime before phase-out (+1 because assuming
# phase out date at the end of the year)
df_agg["lifetime"] = df_agg.DateOut - df_agg.DateIn + 1
# assign clustered bus # assign clustered bus
busmap_s = pd.read_csv(snakemake.input.busmap_s, index_col=0).squeeze() busmap_s = pd.read_csv(snakemake.input.busmap_s, index_col=0).squeeze()
busmap = pd.read_csv(snakemake.input.busmap, index_col=0).squeeze() busmap = pd.read_csv(snakemake.input.busmap, index_col=0).squeeze()
@ -195,6 +191,10 @@ def add_power_capacities_installed_before_baseyear(n, grouping_years, costs, bas
grouping_years, np.digitize(df_agg.DateIn, grouping_years, right=True) grouping_years, np.digitize(df_agg.DateIn, grouping_years, right=True)
) )
# calculate (adjusted) remaining lifetime before phase-out (+1 because assuming
# phase out date at the end of the year)
df_agg["lifetime"] = df_agg.DateOut - df_agg["grouping_year"] + 1
df = df_agg.pivot_table( df = df_agg.pivot_table(
index=["grouping_year", "Fueltype"], index=["grouping_year", "Fueltype"],
columns="cluster_bus", columns="cluster_bus",