Skip to content

Commit 6dbb6ce

Browse files
committed
fix: calculate valid_mask from bias_var
1 parent 1ead52b commit 6dbb6ce

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

xdem/coreg/biascorr.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,17 @@ def _fit_biascorr( # type: ignore
193193
if all(isinstance(dem, (da.Array, Delayed)) for dem in (ref_elev, tba_elev)):
194194
diff = da.subtract(ref_elev, tba_elev)
195195

196+
# calculate the valid mask from which to sample from
197+
data = [inlier_mask, da.isfinite(diff), *(da.isfinite(var) for var in bias_vars.values())]
198+
valid_mask = da.map_blocks(
199+
lambda *arrays: np.logical_and.reduce(arrays), *data, chunks=inlier_mask.chunks, dtype="bool"
200+
)
201+
196202
# clearing some memory
197203
del ref_elev, tba_elev
198204

199205
# TODO the output is called mask but it's the indices. Find a nicer way to handle this
200-
subsample_mask = self._get_subsample_indices_dask(data=inlier_mask)
206+
subsample_mask = self._get_subsample_indices_dask(data=valid_mask)
201207
else:
202208
diff = ref_elev - tba_elev
203209
valid_mask = np.logical_and.reduce(

0 commit comments

Comments
 (0)