Skip to content

determine_availability_matrix_MD_UA crashes when corine: false #2111

@MarcoAnarmo

Description

@MarcoAnarmo

Version Checks (indicate both or one)

  • I have confirmed this bug exists on the lastest release of PyPSA-Eur.

  • I have confirmed this bug exists on the current master branch of PyPSA-Eur.

Issue Description

When a renewable technology sets corine: false in the config (typical for offshore technologies), the script crashes with TypeError: argument of type 'bool' is not iterable at every line that checks "key" in corine.

This affects determine_availability_matrix_MD_UA.py.

Reproducible Example

1. Set `corine: false` for any offwind technology in the config:


renewable:
  'offwind-dc':
    corine: false
    copernicus: {}


2. Run the availability matrix rule:


snakemake solve_elec_networks --configfile ./config/config.yaml --cores 14


3. Produces the following error traceback:


File "determine_availability_matrix_MD_UA.py", line 63, in <module>
    if "grid_codes" in corine:
       ^^^^^^^^^^^^^^^^^^^^^^
TypeError: argument of type 'bool' is not iterable

Expected Behavior

Proposed fix:

After the line where corine is read from the config, add a type guard that converts non-dict values to an empty dict. This way all downstream "key" in corine checks simply evaluate to False, which is the intended skip behavior.

corine = config.get("corine", {})

# Add this line
if not isinstance(corine, dict):
    corine = {}

Installed Versions

Details Replace this line.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions