Skip to content

Commit

Permalink
Use fillsinks_hybrid in FlowObject
Browse files Browse the repository at this point in the history
This is otherwise identical to the implementation in GridObject, but
it also uses the queue array that it allocates as the heap for gwdt,
so it allocates the queue regardless of the value of hybrid.
  • Loading branch information
wkearn committed Dec 5, 2024
1 parent cba261d commit 36405d1
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/topotoolbox/flow_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ class FlowObject():
"""

def __init__(self, grid: GridObject,
bc: np.ndarray | GridObject | None = None):
bc: np.ndarray | GridObject | None = None,
hybrid : bool = True):
"""The constructor for the FlowObject. Takes a GridObject as input,
computes flow direction information and saves them as an FlowObject.
Expand Down Expand Up @@ -58,7 +59,11 @@ def __init__(self, grid: GridObject,
if isinstance(bc, GridObject):
bc = bc.z

_grid.fillsinks(filled_dem, dem, bc, dims)
queue = np.zeros_like(dem, dtype=np.int64, order='F')
if hybrid:
_grid.fillsinks_hybrid(filled_dem, queue, dem, bc, dims)
else:
_grid.fillsinks(filled_dem, dem, bc, dims)

if restore_nans:
dem[nans] = np.nan
Expand All @@ -73,7 +78,7 @@ def __init__(self, grid: GridObject,

dist = np.zeros_like(flats, dtype=np.float32, order='F')
prev = conncomps # prev: dtype=np.int64
heap = np.zeros_like(flats, dtype=np.int64, order='F')
heap = queue # heap: dtype=np.int64
back = np.zeros_like(flats, dtype=np.int64, order='F')
_grid.gwdt(dist, prev, costs, flats, heap, back, dims)

Expand Down

0 comments on commit 36405d1

Please sign in to comment.