It's not a minor issue, but currently the number of hours is hard coded, which ignores at least leap years that have not 8760 hours but 8784 hours. This is particulary nasty if it's happening within functions, not so much after "__main__" (?) (at least for me...). However it might be useful to adapt this also outside of functions.
Any idea on how to fix it? If we knew for certain which year is modelled, we could write a short _helpers script to calculate n_hours of a year. But the snapshot index does not necessarily have to be a DateRange, does it?
It's not a minor issue, but currently the number of hours is hard coded, which ignores at least leap years that have not 8760 hours but 8784 hours. This is particulary nasty if it's happening within functions, not so much after
"__main__"
(?) (at least for me...). However it might be useful to adapt this also outside of functions.My quick scan spotted this issue within three functions/scripts: https://github.com/PyPSA/pypsa-eur/blob/master/scripts/_helpers.py#L122 https://github.com/PyPSA/pypsa-eur/blob/master/scripts/make_summary.py#L405 https://github.com/PyPSA/pypsa-eur/blob/master/scripts/solve_network.py#L131
Additionally outside of functions (ie. after
"__main__"
) here: https://github.com/PyPSA/pypsa-eur/blob/master/scripts/add_electricity.py#L548 https://github.com/PyPSA/pypsa-eur/blob/master/scripts/add_extra_components.py#L199 https://github.com/PyPSA/pypsa-eur/blob/master/scripts/cluster_network.py#L357 https://github.com/PyPSA/pypsa-eur/blob/master/scripts/prepare_network.py#L212 https://github.com/PyPSA/pypsa-eur/blob/master/scripts/simplify_network.py#L394Any idea on how to fix it? If we knew for certain which year is modelled, we could write a short
_helpers
script to calculaten_hours
of a year. But the snapshot index does not necessarily have to be a DateRange, does it?