Example #1
0
    def runBasicConvolveEdgeTest(self, kernel, kernelDescr):
        """Verify that basicConvolve does not write to edge pixels for this kind of kernel
        """
        fullBox = afwGeom.Box2I(
            afwGeom.Point2I(0, 0),
            ShiftedBBox.getDimensions(),
        )
        goodBox = kernel.shrinkBBox(fullBox)
        cnvMaskedImage = afwImage.MaskedImageF(FullMaskedImage, ShiftedBBox, afwImage.LOCAL, True)
        cnvMaskedImageCopy = afwImage.MaskedImageF(cnvMaskedImage, fullBox, afwImage.LOCAL, True)
        cnvMaskedImageCopyViewOfGoodRegion = afwImage.MaskedImageF(cnvMaskedImageCopy, goodBox, afwImage.LOCAL, False)

        # convolve with basicConvolve, which should leave the edge pixels alone
        convControl = afwMath.ConvolutionControl()
        mathDetail.basicConvolve(cnvMaskedImage, self.maskedImage, kernel, convControl)

        # reset the good region to the original convolved image;
        # this should reset the entire convolved image to its original self
        cnvMaskedImageGoodView = afwImage.MaskedImageF(cnvMaskedImage, goodBox, afwImage.LOCAL, False)
        cnvMaskedImageGoodView <<= cnvMaskedImageCopyViewOfGoodRegion

        # assert that these two are equal
        cnvImMaskVarArr = cnvMaskedImage.getArrays()
        desCnvImMaskVarArr = cnvMaskedImageCopy.getArrays()
        errStr = imTestUtils.maskedImagesDiffer(cnvImMaskVarArr, desCnvImMaskVarArr,
            doVariance = True, rtol=0, atol=0)
        shortKernelDescr = kernelDescr.translate(NullTranslator, GarbageChars)
        if errStr:
            cnvMaskedImage.writeFits("actBasicConvolve%s" % (shortKernelDescr,))
            cnvMaskedImageCopy.writeFits("desBasicConvolve%s" % (shortKernelDescr,))
            self.fail("basicConvolve(MaskedImage, kernel=%s) wrote to edge pixels:\n%s" % \
                (kernelDescr, errStr))
Example #2
0
    def runBasicConvolveEdgeTest(self, kernel, kernelDescr):
        """Verify that basicConvolve does not write to edge pixels for this kind of kernel
        """
        fullBox = afwGeom.Box2I(
            afwGeom.Point2I(0, 0),
            ShiftedBBox.getDimensions(),
        )
        goodBox = kernel.shrinkBBox(fullBox)
        cnvMaskedImage = afwImage.MaskedImageF(FullMaskedImage, ShiftedBBox, afwImage.LOCAL, True)
        cnvMaskedImageCopy = afwImage.MaskedImageF(cnvMaskedImage, fullBox, afwImage.LOCAL, True)
        cnvMaskedImageCopyViewOfGoodRegion = afwImage.MaskedImageF(
            cnvMaskedImageCopy, goodBox, afwImage.LOCAL, False)

        # convolve with basicConvolve, which should leave the edge pixels alone
        convControl = afwMath.ConvolutionControl()
        mathDetail.basicConvolve(cnvMaskedImage, self.maskedImage, kernel, convControl)

        # reset the good region to the original convolved image;
        # this should reset the entire convolved image to its original self
        cnvMaskedImageGoodView = afwImage.MaskedImageF(cnvMaskedImage, goodBox, afwImage.LOCAL, False)
        cnvMaskedImageGoodView[:] = cnvMaskedImageCopyViewOfGoodRegion

        # assert that these two are equal
        msg = "basicConvolve(MaskedImage, kernel=%s) wrote to edge pixels" % (kernelDescr,)
        try:
            self.assertMaskedImagesNearlyEqual(cnvMaskedImage, cnvMaskedImageCopy,
                                               doVariance=True, rtol=0, atol=0, msg=msg)
        except Exception:
            # write out the images, then fail
            shortKernelDescr = self.removeGarbageChars(kernelDescr)
            cnvMaskedImage.writeFits("actBasicConvolve%s" % (shortKernelDescr,))
            cnvMaskedImageCopy.writeFits("desBasicConvolve%s" % (shortKernelDescr,))
            raise
Example #3
0
    def runBasicConvolveEdgeTest(self, kernel, kernelDescr):
        """Verify that basicConvolve does not write to edge pixels for this kind of kernel
        """
        fullBox = afwGeom.Box2I(
            afwGeom.Point2I(0, 0),
            ShiftedBBox.getDimensions(),
        )
        goodBox = kernel.shrinkBBox(fullBox)
        cnvMaskedImage = afwImage.MaskedImageF(FullMaskedImage, ShiftedBBox, afwImage.LOCAL, True)
        cnvMaskedImageCopy = afwImage.MaskedImageF(cnvMaskedImage, fullBox, afwImage.LOCAL, True)
        cnvMaskedImageCopyViewOfGoodRegion = afwImage.MaskedImageF(cnvMaskedImageCopy, goodBox, afwImage.LOCAL, False)

        # convolve with basicConvolve, which should leave the edge pixels alone
        convControl = afwMath.ConvolutionControl()
        mathDetail.basicConvolve(cnvMaskedImage, self.maskedImage, kernel, convControl)

        # reset the good region to the original convolved image;
        # this should reset the entire convolved image to its original self
        cnvMaskedImageGoodView = afwImage.MaskedImageF(cnvMaskedImage, goodBox, afwImage.LOCAL, False)
        cnvMaskedImageGoodView <<= cnvMaskedImageCopyViewOfGoodRegion

        # assert that these two are equal
        cnvImMaskVarArr = cnvMaskedImage.getArrays()
        desCnvImMaskVarArr = cnvMaskedImageCopy.getArrays()
        errStr = imTestUtils.maskedImagesDiffer(cnvImMaskVarArr, desCnvImMaskVarArr,
            doVariance = True, rtol=0, atol=0)
        shortKernelDescr = kernelDescr.translate(NullTranslator, GarbageChars)
        if errStr:
            cnvMaskedImage.writeFits("actBasicConvolve%s" % (shortKernelDescr,))
            cnvMaskedImageCopy.writeFits("desBasicConvolve%s" % (shortKernelDescr,))
            self.fail("basicConvolve(MaskedImage, kernel=%s) wrote to edge pixels:\n%s" % \
                (kernelDescr, errStr))
Example #4
0
    def runBasicConvolveEdgeTest(self, kernel, kernelDescr):
        """Verify that basicConvolve does not write to edge pixels for this kind of kernel
        """
        fullBox = afwGeom.Box2I(
            afwGeom.Point2I(0, 0),
            ShiftedBBox.getDimensions(),
        )
        goodBox = kernel.shrinkBBox(fullBox)
        cnvMaskedImage = afwImage.MaskedImageF(FullMaskedImage, ShiftedBBox, afwImage.LOCAL, True)
        cnvMaskedImageCopy = afwImage.MaskedImageF(cnvMaskedImage, fullBox, afwImage.LOCAL, True)
        cnvMaskedImageCopyViewOfGoodRegion = afwImage.MaskedImageF(cnvMaskedImageCopy, goodBox, afwImage.LOCAL, False)

        # convolve with basicConvolve, which should leave the edge pixels alone
        convControl = afwMath.ConvolutionControl()
        mathDetail.basicConvolve(cnvMaskedImage, self.maskedImage, kernel, convControl)

        # reset the good region to the original convolved image;
        # this should reset the entire convolved image to its original self
        cnvMaskedImageGoodView = afwImage.MaskedImageF(cnvMaskedImage, goodBox, afwImage.LOCAL, False)
        cnvMaskedImageGoodView[:] = cnvMaskedImageCopyViewOfGoodRegion

        # assert that these two are equal
        msg = "basicConvolve(MaskedImage, kernel=%s) wrote to edge pixels" % (kernelDescr,)
        try:
            self.assertMaskedImagesNearlyEqual(cnvMaskedImage, cnvMaskedImageCopy,
                doVariance = True, rtol=0, atol=0, msg=msg)
        except Exception:
            # write out the images, then fail
            shortKernelDescr = kernelDescr.translate(NullTranslator, GarbageChars)
            cnvMaskedImage.writeFits("actBasicConvolve%s" % (shortKernelDescr,))
            cnvMaskedImageCopy.writeFits("desBasicConvolve%s" % (shortKernelDescr,))
            raise