Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix hydropower and load bugs #1054

Merged
merged 6 commits into from
May 7, 2024
Merged

Conversation

joph
Copy link
Contributor

@joph joph commented May 6, 2024

Changes proposed in this Pull Request

Bugfix for approximate_missing_eia_stats()

If ES or PT were not present in the list of optimized countries, the IEA hydropower approximation would fail, i.e. approximate_missing_eia_stats(). Therefore runs, where the option eia_approximate_missing was activated would fail for weather years not part of the IEA data. The functoin would throw a key error:
KeyError: "None of [Index(['ES', 'PT'], dtype='object', name='name')] are in the [index]"

The reason is that approximate_missing_eia_stats() overwrites anomalous years for 'ES' and 'PT'. By checking if the countries are present before overwriting the data, the bug can be fixed:
if ("ES") in runoff:
runoff.loc[1978, ["ES"]] = runoff.loc[1979, ["ES"]]
if ("PT") in runoff:
runoff.loc[1978, ["PT"]] = runoff.loc[1979, ["PT"]]

Bugfix for manual_adjustment()

The copy_timeslice() procedure will add countries to the load data which are not present in the countries list, if a fn_load object is provided. If manual_adjustment() is called, which uses copy_timeslice(), this will partly add data for some countries such as GB. Later on, this causes an AssertionError: Load data contains nans.

Checklist

  • I tested my contribution locally and it seems to work fine.
  • Code and workflow changes are sufficiently documented.
  • Changed dependencies are added to envs/environment.yaml.
  • Changes in configuration options are added in all of config.default.yaml.
  • Changes in configuration options are also documented in doc/configtables/*.csv.
  • A release note doc/release_notes.rst is added.

joph added 5 commits May 6, 2024 13:20
Function crasehd when 'ET' or 'PT' not present in list of countries.
copy timeslice would add data although country not present in load
Copy link
Member

@fneum fneum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @joph! Looks good with a minor style adjustment.

scripts/build_hydro_profile.py Outdated Show resolved Hide resolved
@fneum fneum merged commit 497797b into PyPSA:master May 7, 2024
4 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants