Skip to content

Commit

Permalink
bugfixes for areas with no lakes and reservoirs
Browse files Browse the repository at this point in the history
  • Loading branch information
jensdebruijn committed Oct 10, 2024
1 parent dba6036 commit 610da5f
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions geb/hydrology/lakes_reservoirs.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,14 +363,14 @@ def get_outflows(self, waterBodyID):
assert np.array_equal(
np.unique(waterbody_outflow_points), np.unique(waterBodyID)
)
# make sure that each outflow point is only used once
assert (
np.unique(
if __debug__:
# make sure that each outflow point is only used once
unique_outflow_points = np.unique(
waterbody_outflow_points[waterbody_outflow_points != -1],
return_counts=True,
)[1].max()
== 1
)
)[1]
if unique_outflow_points.size > 0:
assert unique_outflow_points.max() == 1

return waterbody_outflow_points

Expand Down Expand Up @@ -518,8 +518,13 @@ def routing(

outflow = outflow_lakes + outflow_reservoirs

outflow_grid = np.take(outflow, self.var.waterbody_outflow_points)
outflow_grid[self.var.waterbody_outflow_points == -1] = 0
if outflow.size > 0:
outflow_grid = np.take(outflow, self.var.waterbody_outflow_points)
outflow_grid[self.var.waterbody_outflow_points == -1] = 0
else:
outflow_grid = np.zeros_like(
self.var.waterbody_outflow_points, dtype=outflow.dtype
)

# shift outflow 1 cell downstream
outflow_shifted_downstream = upstream1(
Expand Down

0 comments on commit 610da5f

Please sign in to comment.