Hardcoding nhours of a year ignores leap years
@martacki is already working on this.
Since Feb 25, 2022.
- Dominant language
- Python
- Stars
- 615
- Forks
- 459
- Avg merge
- 4d 14h
- Merged PRs (30d)
- 6
Description
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#L394
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?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.