-
Notifications
You must be signed in to change notification settings - Fork 313
Fix nuts3 es #1579
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
Closed
Closed
Fix nuts3 es #1579
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Not needed anymore
for more information, see https://pre-commit.ci
I tried to make a PR only in a newly created branch with a small addition, but obviously I did it wrong, and the PR includes other updates associated with the fork pypsa-spain. Please ignore this PR, I will try again. Sorry for the noise. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I've been testing the new NUTS clustering feature (congratulations, it's a great update!). It works pretty well, but I get an error when running it only for Spain and for clustering at NUTS3 level.
The error occurs during the 'base_network' rule.
In short, the problem seems to be that the "clean_dict" function is not robust if the provided dic has no values with len=1.
In detail: At some point, "build_admin_shapes" calls to "merge_regions_recursive" at:
pypsa-eur/scripts/base_network.py
Line 1551 in a3938fe
In this function there is a call to the function "clean_dict" on line:
pypsa-eur/scripts/base_network.py
Line 1387 in a3938fe
where the input dictionary at this point is just: {'ES532': ['ES531', 'ES533']}
(just for info: ES531 and ES533 are two small islands without electrical buses, and here the code aims to add them to the larger island of Mallorca, ES532, which is connected with peninsular Spain with a DC-link).
The problem is that "clean_dict" seems to break at line:
pypsa-eur/scripts/base_network.py
Line 1250 in a3938fe
because the variable "single_occurrences" is empty, due to the fact that there are no values in the input dictionary with length=1). This probably does not happen when running a case for Europe, but for the case of a single country like Spain, it leads to the mentioned break.
So, this PR is just to add a check step on "single_occurrences", to proceed only if it is not empty.
Checklist
envs/environment.yaml
.config/config.default.yaml
.doc/configtables/*.csv
.doc/data_sources.rst
.doc/release_notes.rst
is added.