Duplicated offshore regions
Checklist
- [x] I am using the current
masterbranch or the latest release. Please indicate. - [x] I am running on an up-to-date
pypsa-eurenvironment. Update viaconda env update -f envs/environment.yaml.
Describe the Bug
This is not a real bug, as it does not cause any error. However, in the offshore regions there are bus regions which have exactly the same shape (polygon)
Can be fixed with a one-liner in build_bus_regions
Noticed that, too. I think it's worth fixing. If you know how, go ahead!
I just remove the duplicate regions afterwards but I did not dig deeper into the cause. I am not sure if there are identical buses as well. For my fix, I just did:
offshore_regions_c.drop_duplicates(subset="geometry", inplace=True )
I just remove the duplicate regions afterwards but I did not dig deeper into the cause. I am not sure if there are identical buses as well.
Could you quickly check that? At least then we know where this is coming from.
I just checked and apparently there are buses with an offshore substation having identical x and y coordinates (bus (5859, 5860), (6660, 6661) and (6744, 6745)). This is an error in the buses.csv, as there are duplicated entries for those buses. So we can just adjust it under data/entsoegridkit/buses.csv
I will open a PR
Thanks for tracing the bug to its origin @p-glaum !
Apparently, the substation have the same coordinates but not the same voltage level. In the script base_network, for the "substations_off" they select the substation with the higher voltage level for on onshore buses. But the problem there is for the buses which are offshore, there is no such filter that only the high voltage buses are selected. So for a few offshore buses, there are two voltage levels and both are selected which duplicates the regions.
https://github.com/PyPSA/pypsa-eur/blob/80eadcf24aea9b1805d8ebfa66de0422e10f0c04/scripts/base_network.py#L546-L548
I am not 100% sure if we can just have instead:
buses["substation_off"] = ((hv_b & offshore_b) | (hv_b & onshore_b)) & (
~buses["under_construction"]
)