Skip to content

Commit

Permalink
Merge pull request #66 from PyPSA/fneum-patch-1
Browse files Browse the repository at this point in the history
base_network: return zero underwater fraction if no link geometry given
  • Loading branch information
coroa authored Aug 12, 2019
2 parents 4a63552 + f7159de commit 7a18740
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions scripts/base_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,10 +411,13 @@ def findforeignbus(G, i):

def _set_links_underwater_fraction(n):
if n.links.empty: return

offshore_shape = gpd.read_file(snakemake.input.offshore_shapes).unary_union
links = gpd.GeoSeries(n.links.geometry.dropna().map(shapely.wkt.loads))
n.links['underwater_fraction'] = links.intersection(offshore_shape).length / links.length

if not hasattr(n.links, 'geometry'):
n.links['underwater_fraction'] = 0.
else:
offshore_shape = gpd.read_file(snakemake.input.offshore_shapes).unary_union
links = gpd.GeoSeries(n.links.geometry.dropna().map(shapely.wkt.loads))
n.links['underwater_fraction'] = links.intersection(offshore_shape).length / links.length

def _adjust_capacities_of_under_construction_branches(n):
lines_mode = snakemake.config['lines'].get('under_construction', 'undef')
Expand Down

0 comments on commit 7a18740

Please sign in to comment.