Recode channel network storage to 8xLxW logical arrays. This has two advantages:
(1) it's much faster than storing the network in cell arrays, and
(2) it's easy to implement the max number of branches as a parameter.
details
The new method is similar to the way we have handled searching for neighbors in the past, which is looking at a list of NW-N-NE-E-SE-S-SW-W neighbors. Now, we use these as the fixed indices into a set of 8xLxW arrays. Instead of using a list in a cell array for flowsTo, we use an identity matrix like approach, where a connection between cells is marked by a 1. In practice, we store as logical arrays, because these datatypes are 1-byte per cell, (so very efficient) and allow direct slicing (no conversion to bool necessary).
Some important new arrays are (created in makeGrids.m):
grid.flowsToGraph is an 8xLxW logical array with true where connection goes from in 2nd-3rd dimensions to neighbor in 1st dimension. So for cell i=8, j=5 connected to i-1, j-1 (NW neighbor) we would place a true in (1, 8, 5).
grid.flowsFromGraph is an 8xLxW logical array with true where connection comes from in 1st dimension to cell in 2nd-3rd dimension. So for example above, a true in (5, 7, 4) (the SE neighbor of cell (8, 5).
grid.nghbrs is an 8xLxW array storing the flat indices of the d8 neighbors of each cell.
grid.S.d8 is an 8xLxW array storing the bed slope to each of the d8 neighbors of each cell. This replaces the grid.S.XX explicitly named direction fields. Also fixes #57.
This PR also fixed the bugs in checkNeighborsChannelsCrossover that were allowing crossover channels to form again.
branchLimit change results
branchLimit
result water basin
result dry basin
2
3
8
WRITE UP RESULTS NEEDED HERE Did this fix #53?
todo:
[ ] merge #56 and rebase
[ ] add this detailed description of arrays to the code somewhere?
[x] refactor the avulsion check mechanisms to use nghbrs and S.d8 in calcuations
summary
Recode channel network storage to
8xLxW
logical arrays. This has two advantages: (1) it's much faster than storing the network in cell arrays, and (2) it's easy to implement the max number of branches as a parameter.details
The new method is similar to the way we have handled searching for neighbors in the past, which is looking at a list of NW-N-NE-E-SE-S-SW-W neighbors. Now, we use these as the fixed indices into a set of
8xLxW
arrays. Instead of using a list in a cell array forflowsTo
, we use an identity matrix like approach, where a connection between cells is marked by a 1. In practice, we store as logical arrays, because these datatypes are 1-byte per cell, (so very efficient) and allow direct slicing (no conversion to bool necessary).Some important new arrays are (created in
makeGrids.m
):grid.flowsToGraph
is an8xLxW
logical array withtrue
where connection goes from in 2nd-3rd dimensions to neighbor in 1st dimension. So for celli=8
,j=5
connected toi-1
,j-1
(NW neighbor) we would place atrue
in(1, 8, 5)
.grid.flowsFromGraph
is an8xLxW
logical array withtrue
where connection comes from in 1st dimension to cell in 2nd-3rd dimension. So for example above, atrue
in(5, 7, 4)
(the SE neighbor of cell(8, 5)
.grid.nghbrs
is an8xLxW
array storing the flat indices of thed8
neighbors of each cell.grid.S.d8
is an8xLxW
array storing the bed slope to each of thed8
neighbors of each cell. This replaces thegrid.S.XX
explicitly named direction fields. Also fixes #57.This PR also fixed the bugs in
checkNeighborsChannelsCrossover
that were allowing crossover channels to form again.branchLimit change results
branchLimit
2
3
8
WRITE UP RESULTS NEEDED HERE Did this fix #53?
todo:
nghbrs
andS.d8
in calcuationscloses #57