diff --git a/rules/build_electricity.smk b/rules/build_electricity.smk index 6db8bcd7..2b4d9af6 100644 --- a/rules/build_electricity.smk +++ b/rules/build_electricity.smk @@ -588,6 +588,7 @@ rule prepare_network: costs=config_provider("costs"), adjustments=config_provider("adjustments", "electricity"), autarky=config_provider("electricity", "autarky", default={}), + drop_leap_day=config_provider("enable", "drop_leap_day"), input: resources("networks/elec_s{simpl}_{clusters}_ec.nc"), tech_costs=lambda w: resources( diff --git a/scripts/prepare_network.py b/scripts/prepare_network.py index f38a3619..f7a3f6b0 100755 --- a/scripts/prepare_network.py +++ b/scripts/prepare_network.py @@ -204,6 +204,9 @@ def average_every_nhours(n, offset): m = n.copy(with_time=False) snapshot_weightings = n.snapshot_weightings.resample(offset).sum() + sns = snapshot_weightings.index + if snakemake.params.drop_leap_days: + sns = sns[~((sns.month == 2) & (sns.day == 29))] m.set_snapshots(snapshot_weightings.index) m.snapshot_weightings = snapshot_weightings diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index 5757a88b..e5f0dac8 100755 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -812,6 +812,10 @@ def average_every_nhours(n, offset): m = n.copy(with_time=False) snapshot_weightings = n.snapshot_weightings.resample(offset).sum() + sns = snapshot_weightings.index + if snakemake.params.drop_leap_days: + sns = sns[~((sns.month == 2) & (sns.day == 29))] + snapshot_weightings = snapshot_weightings.loc[sns] m.set_snapshots(snapshot_weightings.index) m.snapshot_weightings = snapshot_weightings @@ -3660,8 +3664,7 @@ if __name__ == "__main__": solver_name = snakemake.config["solving"]["solver"]["name"] resolution = snakemake.params.time_resolution - drop_leap_day = snakemake.params.drop_leap_day - n = set_temporal_aggregation(n, resolution, solver_name, drop_leap_day) + n = set_temporal_aggregation(n, resolution, solver_name) co2_budget = snakemake.params.co2_budget if isinstance(co2_budget, str) and co2_budget.startswith("cb"):