Source code for queso_cluster.atoms.flare
import numpy as np
[docs]
def kernelClusterMask(optLabels, kernel=None):
"""
Creates a NaN mask of the kernel cluster
Parameters
----------
optLabels : ndarray
3d array containing the labels in space and time
Returns
-------
ndarray
NaN mask which changes all pixels that are not the kernelCluster to NaN
"""
if kernel is None:
kernel = str(int(np.nanmax(optLabels)))
kernel = float(kernel[0] + '1'*(len(kernel)-1))
hiIntMask = np.zeros(optLabels.shape[1:])
for t in range(optLabels.shape[0]):
hiIntMask = np.logical_or(hiIntMask, optLabels[t, ...] == kernel)
hiIntMask = hiIntMask.astype(float)
hiIntMask[hiIntMask == 0] = np.nan
hiIntMask = np.broadcast_to(hiIntMask, optLabels.shape)
return(hiIntMask)