def testMasksRemoved(self): for dataProduct in self.coaddNameList: image = self.butler.get(self.mocksTask.config.coaddName + dataProduct + "_mock", {'filter': 'r', 'tract': 0, 'patch': '0,0'}) keys = image.getMaskedImage().getMask().getMaskPlaneDict().keys() self.assertNotIn('CROSSTALK', keys) self.assertNotIn('NOT_DEBLENDED', keys)
def testMaskPlanesExist(self): # Get the dataId for each calexp in the repository calexpDataIds = getCalexpIds(self.butler) # Loop over each Id and verify the mask planes were added for ID in calexpDataIds: image = self.butler.get('calexp', ID) mask = image.getMaskedImage().getMask() self.assertIn('CROSSTALK', list(mask.getMaskPlaneDict().keys())) self.assertIn('NOT_DEBLENDED', list(mask.getMaskPlaneDict().keys()))
def addMaskPlanes(butler): # Get the dataId for each calexp in the repository calexpDataIds = getCalexpIds(butler) # Loop over each of the calexp and add the CROSSTALK and NOT_DEBLENDED mask planes for Id in calexpDataIds: image = butler.get('calexp', Id) mask = image.getMaskedImage().getMask() mask.addMaskPlane("CROSSTALK") mask.addMaskPlane("NOT_DEBLENDED") butler.put(image, 'calexp', dataId=Id)
def checkMaskPlanesExist(self): butler = lsst.daf.persistence.Butler(DATAREPO_ROOT) # Get the dataId for each calexp in the repository calexpDataIds = self.getCalexpIds(butler) # Loop over each Id and verify the mask planes were added for ID in calexpDataIds: image = butler.get('calexp', ID) mask = image.getMaskedImage().getMask() self.assert_('CROSSTALK' in mask.getMaskPlaneDict().keys()) self.assert_('NOT_DEBLENDED' in mask.getMaskPlaneDict().keys())
def addMaskPlanes(self): butler = lsst.daf.persistence.Butler(DATAREPO_ROOT) # Get the dataId for each calexp in the repository calexpDataIds = self.getCalexpIds(butler) # Loop over each of the calexp and add the CROSSTALK and NOT_DEBLENDED mask planes for Id in calexpDataIds: image = butler.get('calexp', Id) mask = image.getMaskedImage().getMask() mask.addMaskPlane("CROSSTALK") mask.addMaskPlane("NOT_DEBLENDED") butler.put(image, 'calexp', dataId=Id)
def addMaskPlanes(butler): # Get the dataId for each calexp in the repository calexpDataIds = getCalexpIds(butler) # Loop over each of the calexp and add the CROSSTALK and NOT_DEBLENDED mask planes for Id in calexpDataIds: # TODO: pybind11 remvoe `immediate=True` once DM-9112 is resolved image = butler.get('calexp', Id, immediate=True) mask = image.getMaskedImage().getMask() mask.addMaskPlane("CROSSTALK") mask.addMaskPlane("NOT_DEBLENDED") butler.put(image, 'calexp', dataId=Id)
def readWriteMaskedImage(self, image, filename, imageOptions, maskOptions, varianceOptions): """Read the MaskedImage after it has been written This implementation does the persistence using methods on the MaskedImage class. Parameters ---------- image : `lsst.afw.image.Image` Image to compress. filename : `str` Filename to which to write. imageOptions, maskOptions, varianceOptions : `lsst.afw.fits.ImageWriteOptions` Options for writing the image, mask and variance planes. """ image.writeFits(filename, imageOptions, maskOptions, varianceOptions) if hasattr(image, "getMaskedImage"): image = image.getMaskedImage() return lsst.afw.image.MaskedImageF(filename)
def checkCompressedMaskedImage(self, image, imageOptions, maskOptions, varianceOptions, atol=0.0): """Check that compression works on a MaskedImage Parameters ---------- image : `lsst.afw.image.MaskedImage` or `lsst.afw.image.Exposure` MaskedImage or exposure to compress. imageOptions, maskOptions, varianceOptions : `lsst.afw.fits.ImageWriteOptions` Parameters for writing (compression and scaling) the image, mask and variance planes. atol : `float` Absolute tolerance for comparing unpersisted image. """ with lsst.utils.tests.getTempFilePath(self.extension) as filename: self.readWriteMaskedImage(image, filename, imageOptions, maskOptions, varianceOptions) unpersisted = type(image)(filename) if hasattr(image, "getMaskedImage"): image = image.getMaskedImage() unpersisted = unpersisted.getMaskedImage() self.assertEqual(image.getBBox(), unpersisted.getBBox()) self.assertImagesAlmostEqual(unpersisted.getImage(), image.getImage(), atol=atol) self.assertImagesAlmostEqual(unpersisted.getMask(), image.getMask(), atol=atol) self.assertImagesAlmostEqual(unpersisted.getVariance(), image.getVariance(), atol=atol) for mp in image.getMask().getMaskPlaneDict(): self.assertIn(mp, unpersisted.getMask().getMaskPlaneDict()) unpersisted.getMask().getPlaneBitMask(mp)
def testMasksRemoved(self): image = self.butler.get(self.mocksTask.config.coaddName + 'Coadd_mock',\ {'filter':'r','tract':0, 'patch':'0,0'}) keys = image.getMaskedImage().getMask().getMaskPlaneDict().keys() self.assert_('CROSSTALK' not in keys) self.assert_('NOT_DEBLENDED' not in keys)