Skip to content

Commit

Permalink
fix: calculate valid_mask from bias_var
Browse files Browse the repository at this point in the history
  • Loading branch information
ameliefroessl committed Jun 7, 2024
1 parent b46d20c commit 0452bd8
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion xdem/coreg/biascorr.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,17 @@ def _fit_biascorr( # type: ignore
if all(isinstance(dem, (da.Array, Delayed)) for dem in (ref_elev, tba_elev)):
diff = da.subtract(ref_elev, tba_elev)

# calculate the valid mask from which to sample from
data = [inlier_mask, da.isfinite(diff), *(da.isfinite(var) for var in bias_vars.values())]
valid_mask = da.map_blocks(
lambda *arrays: np.logical_and.reduce(arrays), *data, chunks=inlier_mask.chunks, dtype="bool"
)

# clearing some memory
del ref_elev, tba_elev

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

0 comments on commit 0452bd8

Please sign in to comment.