Version Checks (indicate both or one)
Issue Description
Specifying the individual NUTS levels for some countries as a dictionary in clustering.administrative.countries config setting, seems not to working as expected in the clustering documentation.
In particular, the level defined in clustering.administrative.level is applied also to the countries in clustering.administrative.countries , despite they have a different level.
This seems to be due to this part of code in build_admin_shapes in base_network.py:
country_level = {
k: v for k, v in admin_levels.items() if (k != "level") and (k in countries)
}
Instead, it might work changing it into:
country_level = {
k: v for k, v in admin_levels.get("countries", {}).items()
if k in countries
}
Reproducible Example
When using this setting:
clustering:
mode: administrative
administrative:
level: bz
countries: {'DE': 2}
and checking the admin_shapes.geojson:
admin_shapes = gpd.read_file("[...]/admin_shapes.geojson")
display(admin_shapes[admin_shapes["country"] == "DE"].admin)
one would see DE00.
Expected Behavior
When using this setting:
clustering:
mode: administrative
administrative:
level: bz
countries: {'DE': 2}
and checking the admin_shapes.geojson:
admin_shapes = gpd.read_file("[...]/admin_shapes.geojson")
display(admin_shapes[admin_shapes["country"] == "DE"].admin)
one would expect:
Installed Versions
Too long to post.
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
masterbranch of PyPSA-Eur.Issue Description
Specifying the individual NUTS levels for some countries as a dictionary in
clustering.administrative.countriesconfig setting, seems not to working as expected in the clustering documentation.In particular, the level defined in
clustering.administrative.levelis applied also to the countries inclustering.administrative.countries, despite they have a different level.This seems to be due to this part of code in
build_admin_shapesinbase_network.py:Instead, it might work changing it into:
Reproducible Example
When using this setting:
and checking the
admin_shapes.geojson:one would see
DE00.Expected Behavior
When using this setting:
and checking the
admin_shapes.geojson:one would expect:
Installed Versions
Too long to post.