Esempio n. 1
0
 def _remove_at_edge(object_labels):
     mask_edge = np.zeros_like(mask)
     mask_edge[
         :, :, 1
     ] = True  # has to be k==1 because object identification codes treats actual edges as ghost cells
     mask_edge[:, :, -2] = True
     cloud_identification.remove_intersecting(object_labels, mask_edge)
Esempio n. 2
0
def filter_objects_by_mask(objects, mask):
    if mask.dims != objects.dims:
        if mask.dims == ("yt", "xt"):
            assert objects.dims[:2] == mask.dims
            # mask_3d = np.zeros(objects.shape, dtype=bool)
            _, _, nz = objects.shape
            # XXX: this is pretty disguisting, there must be a better way...
            # inspired from https://stackoverflow.com/a/44151668
            mask_3d = np.moveaxis(np.repeat(mask.values[None, :], nz, axis=0), 0, 2)
        else:
            raise Exception(mask.dims)
    else:
        mask_3d = mask

    cloud_identification.remove_intersecting(objects, ~mask_3d)

    return objects