Skip to content

Commit 2065a27

Browse files
author
Nikolaos Mastrantonas
committed
fix bug of adding in the mask individual cells in the outlets
1 parent 5534c54 commit 2065a27

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/lisfloodutilities/mctrivers/mctrivers.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,19 @@ def mct_mask(channels_slope_file, ldd_file, uparea_file, mask_file='',
178178
# Loop nloops times and use downstream function to find out if each cell has nloop MCT cells downstream
179179
# Downstream function gives the value in the downstream pixel in a map:
180180
# here it gives 1 if the downstream pixel is Muskingum, zero otherwise.
181+
# Note that for pits it always gives its own value so we need to mask out all pits as ann intermidiate step
182+
183+
# modify data, so that the most downstream point is masked out (otherwise the below loop gives for all points the same value)
184+
downstream_actual_mask_pcr = pcr.downstreamdist(ldd_pcr)
185+
downstream_actual_mask_pcr = pcr.ifthenelse(downstream_actual_mask_pcr == 0, pcr.boolean(0), pcr.boolean(1))
186+
downstream_actual_mask_pcr = pcr.scalar(downstream_actual_mask_pcr)
187+
181188
# The loop is used to count how many pixels are MCT downstream, as at each loop we move the values 1 pixel upstream
182189
# At the end of the loop, each element of the array has the number of downstream MCT pixels for that pixel
183190
for loops in range(0, nloops):
184191
# get the value on the downstream cell and put it in a mask
185192
downstream_cells_pcr = pcr.downstream(ldd_pcr, downstream_cells_pcr)
193+
downstream_cells_pcr = downstream_cells_pcr*downstream_actual_mask_pcr
186194
sum_rivers_pcr = sum_rivers_pcr + downstream_cells_pcr
187195

188196
# ---------------- Generate a new MCT rivers mask
Binary file not shown.

0 commit comments

Comments
 (0)