Commit 1c6a7d87 authored by inhuszar's avatar inhuszar
Browse files

Bugfix: masking missing data does not leave infs now.

parent f3961fe2
......@@ -1790,7 +1790,12 @@ class TImage(TField):
# Perform interpolation and cast output
# (storage mode is handled implicitly by the interpolator)
data = self.interpolator(vcoords, input_array=self.data)
if ts.TIMAGE_MASK_MISSING_DATA:
fill_value = np.inf
interpolator = self.interpolator.copy(fill_value=np.inf)
else:
interpolator = self.interpolator
data = interpolator(vcoords, input_array=self.data)
if self.mask is not None:
maskip = locate(ts.TIMAGE_MASK_INTERPOLATOR)
......@@ -1819,15 +1824,22 @@ class TImage(TField):
if ts.TIMAGE_MASK_MISSING_DATA:
if mask is None:
mask = np.ones(target_domain.shape, dtype=np.float32)
indices = [np.flatnonzero(np.any(vcoords < 0, axis=-1))]
for dim in range(self.vdim):
ix = np.flatnonzero(vcoords[:, dim] >= self.vshape[dim])
indices.append(ix)
if self.taxes:
indices = np.flatnonzero(np.all(
data == np.inf, axis=self.taxes))
else:
# These are the linear indices of all voxels outside
# the voxel grid
indices = np.unique(np.concatenate(indices))
indices = np.flatnonzero(data == np.inf)
data[data == np.inf] = ts.FILL_VALUE
mask.flat[indices] = 0
# indices = [np.flatnonzero(np.any(vcoords < 0, axis=-1))]
# for dim in range(self.vdim):
# ix = np.flatnonzero(vcoords[:, dim] >= self.vshape[dim])
# indices.append(ix)
# else:
# # These are the linear indices of all voxels outside
# # the voxel grid
# indices = np.unique(np.concatenate(indices))
# mask.flat[indices] = 0
# Create new TImage
new_name = "%s.%s" % (self.name, target_domain.name)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment