compute lifetime after grouping DateIn

This commit is contained in:
Michael Lindner 2024-03-05 12:00:50 +01:00
parent 986c7be48e
commit 7f5f0ee45e

View File

@ -171,9 +171,7 @@ def add_power_capacities_installed_before_baseyear(n, grouping_years, costs, bas
phased_out = df_agg[df_agg["DateOut"] < baseyear].index
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
busmap_s = pd.read_csv(snakemake.input.busmap_s, index_col=0).squeeze()
@ -195,6 +193,10 @@ def add_power_capacities_installed_before_baseyear(n, grouping_years, costs, bas
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(
index=["grouping_year", "Fueltype"],
columns="cluster_bus",