-
Notifications
You must be signed in to change notification settings - Fork 387
Fix corine bool and offshore keyerror #2113
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
base: master
Are you sure you want to change the base?
Changes from all commits
ff70a33
999711d
3b86799
ac6c09b
2fb49f5
9704e1c
fdb9918
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -157,6 +157,7 @@ | |||||||||||||||||||||||||||||||||||||
| if snakemake.wildcards.technology.startswith("offwind"): | ||||||||||||||||||||||||||||||||||||||
| # for offshore regions, the shortest distance to the shoreline is used | ||||||||||||||||||||||||||||||||||||||
| offshore_regions = availability.coords["bus"].values | ||||||||||||||||||||||||||||||||||||||
| offshore_regions = np.intersect1d(offshore_regions, regions.index) | ||||||||||||||||||||||||||||||||||||||
| regions = regions.loc[offshore_regions] | ||||||||||||||||||||||||||||||||||||||
| regions = regions.map(lambda g: _simplify_polys(g, minarea=1)).set_crs( | ||||||||||||||||||||||||||||||||||||||
| regions.crs | ||||||||||||||||||||||||||||||||||||||
|
|
@@ -294,6 +295,9 @@ | |||||||||||||||||||||||||||||||||||||
| average_distance = [] | ||||||||||||||||||||||||||||||||||||||
| bus_bins = layoutmatrix.indexes["bus_bin"] | ||||||||||||||||||||||||||||||||||||||
| for bus, bin in bus_bins: | ||||||||||||||||||||||||||||||||||||||
| if bus not in regions.index: | ||||||||||||||||||||||||||||||||||||||
| average_distance.append(0.0) | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
297
to
+299
|
||||||||||||||||||||||||||||||||||||||
| for bus, bin in bus_bins: | |
| if bus not in regions.index: | |
| average_distance.append(0.0) | |
| # Identify buses present in the layout but missing geometry in regions | |
| missing_buses = {bus for bus, _ in bus_bins} - set(regions.index) | |
| if missing_buses: | |
| logger.warning( | |
| "Average distance could not be computed for %d bus(es) missing from " | |
| "`regions.index`: %s. Distances for these buses will be set to NaN.", | |
| len(missing_buses), | |
| ", ".join(sorted(map(str, missing_buses))), | |
| ) | |
| for bus, bin in bus_bins: | |
| if bus not in regions.index: | |
| # Mark missing geometry explicitly instead of assuming zero distance | |
| average_distance.append(np.nan) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Filtering
offshore_regionsonly when selectingregionsleavesavailability(and laterresource_regions/class_masks) still containing buses that were dropped during clustering. This can produce profiles/potentials for buses that have no corresponding offshore distance geometry and makes outputs inconsistent (e.g.class_regionswritten only for the filtered bus set). Consider subsettingavailabilityto the sameoffshore_regionsintersection here (and similarly filterresource_regionsafter loading) so all downstream computations operate on a consistent bus index.