Skip to content

Fix corine bool and offshore keyerror - #2113

Open
MarcoAnarmo wants to merge 7 commits into
PyPSA:masterfrom
MarcoAnarmo:fix/corine-bool-and-offshore-keyerror
Open

Fix corine bool and offshore keyerror#2113
MarcoAnarmo wants to merge 7 commits into
PyPSA:masterfrom
MarcoAnarmo:fix/corine-bool-and-offshore-keyerror

Conversation

@MarcoAnarmo

@MarcoAnarmo MarcoAnarmo commented Mar 4, 2026

Copy link
Copy Markdown
Contributor

Closes #2111 and #2112.

Changes proposed in this Pull Request

Fixes two detected bugs in the renewable availability/profiles pipeline when using offshore technologies with corine: false and non-standard country lists:

  • determine_availability_matrix _MD_UA.py: Convert corine to an empty dict when set to false, preventing TypeError on "key" in corine checks.
  • build_renewable_profiles.py: Filter offshore buses against clustered regions index to avoid KeyError for buses dropped during clustering.

Used config file: config.osm_eem.yaml

Checklist

  • I tested my contribution locally and it works as intended.
  • Code and workflow changes are sufficiently documented.
  • Changed dependencies are added to pixi.toml (using pixi add <dependency-name>).
  • Changes in configuration options are added in config/config.default.yaml.
  • Changes in configuration options are documented in doc/configtables/*.csv.
  • For new data sources or versions, these instructions have been followed.
  • A release note doc/release_notes.rst is added.

When corine is set to false for offshore technologies, convert it to an empty dict so downstream 'key in corine' checks are skipped.

Fixes PyPSA#2111
Filter availability matrix buses against clustered regions index to avoid KeyError when countries' offshore zones are dropped.

Fixes PyPSA#2112
Copilot AI review requested due to automatic review settings March 4, 2026 12:52

This comment was marked as outdated.

MarcoAnarmo and others added 5 commits March 19, 2026 13:48
When clustering.simplify_network.to_380 is set to false, skip simplify_network_to_380() so that original voltage levels and transformers are preserved in the simplified network.
Add v_nom to custom_line_groupers so lines at different voltage levels are not merged. Pass with_country=True to cluster_regions so the output region shapefiles retain a country column for downstream scripts.
Use the 'country' column (when available) instead of slicing the first two characters of the bus name. Also subset sjoin to geometry-only to avoid extra columns and deduplicate plants in overlapping regions.
Write an empty availability matrix and exit early when no valid region geometries exist. Guard WDPA polygon/point reads behind geometry checks to prevent errors on empty GeoDataFrames.
@fneum

fneum commented May 4, 2026

Copy link
Copy Markdown
Member

Could you divide the suggested changes into multiple separate PRs? Then we can decide / discuss one by one. Not all of them are related / dependent on each other.

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.

determine_availability_matrix_MD_UA crashes when corine: false

3 participants