You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use the DM mask instead of numpy.ndarray(dtype=int) for existed masks. The followings are the example code by Robert:
import matplotlib.pyplot as plt
%matplotlib ipympl
plt.rcParams['figure.figsize'] = [7, 6]
import lsst.afw.image as afwImage
import lsst.afw.display as afwDisplay
afwDisplay.setDefaultBackend("matplotlib")
# Add a new mask plane called "AOS" to all Masks in this session
AOS = 1 << afwImage.Mask.addMaskPlane("AOS")
afwDisplay.setDefaultMaskPlaneColor("AOS", afwDisplay.CYAN) # actually most color names are accepted
# create a MaskedImage with an image, a mask, and a variance plane
mi = afwImage.MaskedImageF(11, 21)
#
# Set some pixels in the image and mask. I could do this "natively", but in the case
# I'm using the numpy interface (the .array)
mi.image.array[5:15, 5:6] = 10
mi.mask.array[10, 5] |= AOS
mi.mask.array[0:3, :] |= afwImage.Mask.getPlaneBitMask("BAD")
mi.mask.array[1, 1] |= afwImage.Mask.getPlaneBitMask("DETECTED")
#
# Make use of that mask; I could have used np.where instead
#
mi.image.array[(mi.mask.array & AOS) != 0] = 20
#
# And display the result.
#
if False:
fig = 1; plt.close(fig); fig = plt.figure(fig)
disp = afwDisplay.Display(fig)
else:
disp = afwDisplay.Display(1, reopenPlot=True)
disp.setImageColormap('gray')
disp.scale('linear', 'minmax')
disp.mtv(mi, title="Using a Mask")
The text was updated successfully, but these errors were encountered:
Use the DM mask instead of
numpy.ndarray(dtype=int)
for existed masks. The followings are the example code by Robert:The text was updated successfully, but these errors were encountered: