示例#1
0
    def runScaledAddTest(self, coeff0, coeff1):
        """Run one test of scaledPlus

        Inputs:
        - coeff0: coefficient of image 0
        - coeff1: coefficient of image 1
        """
        desMaskedImage = afwImage.MaskedImageF(
            self.maskedImage0.getDimensions())
        desMaskedImage[:] = self.maskedImage0
        desMaskedImage *= coeff0
        desMaskedImage.scaledPlus(coeff1, self.maskedImage1)

        actMaskedImage = afwImage.MaskedImageF(
            lsst.geom.Extent2I(self.imWidth, self.imHeight))
        afwMath.randomUniformImage(actMaskedImage.getImage(), self.random)
        afwMath.randomUniformImage(actMaskedImage.getVariance(), self.random)

        afwMath.scaledPlus(actMaskedImage, coeff0, self.maskedImage0, coeff1,
                           self.maskedImage1)

        actImage = afwImage.ImageF(
            lsst.geom.Extent2I(self.imWidth, self.imHeight))
        afwMath.randomUniformImage(actImage, self.random)
        afwMath.scaledPlus(actImage, coeff0, self.maskedImage0.getImage(),
                           coeff1, self.maskedImage1.getImage())

        msg = f"scaledPlus failed for images; coeff0={coeff0}, coeff1={coeff1}"
        self.assertImagesAlmostEqual(actImage,
                                     desMaskedImage.getImage(),
                                     msg=msg)
        msg = f"scaledPlus failed for masked images; coeff0={coeff0}, coeff1={coeff1}"
        self.assertMaskedImagesAlmostEqual(actMaskedImage,
                                           desMaskedImage,
                                           msg=msg)
示例#2
0
    def runScaledAddTest(self, coeff0, coeff1):
        """Run one test of scaledPlus
        
        Inputs:
        - coeff0: coefficient of image 0
        - coeff1: coefficient of image 1
        """
        desMaskedImage = afwImage.MaskedImageF(self.maskedImage0.getDimensions())
        desMaskedImage[:] = self.maskedImage0
        desMaskedImage *= coeff0
        desMaskedImage.scaledPlus(coeff1, self.maskedImage1)
        
        actMaskedImage = afwImage.MaskedImageF(afwGeom.Extent2I(self.imWidth, self.imHeight))
        afwMath.randomUniformImage(actMaskedImage.getImage(), self.random)
        afwMath.randomUniformImage(actMaskedImage.getVariance(), self.random)

        afwMath.scaledPlus(actMaskedImage, coeff0, self.maskedImage0, coeff1, self.maskedImage1)
        
        actImage = afwImage.ImageF(afwGeom.Extent2I(self.imWidth, self.imHeight))
        afwMath.randomUniformImage(actImage, self.random)
        afwMath.scaledPlus(actImage, coeff0, self.maskedImage0.getImage(), coeff1, self.maskedImage1.getImage())
        
        msg = "scaledPlus failed for images; coeff0=%s, coeff1=%s" % (coeff0, coeff1)
        self.assertImagesNearlyEqual(actImage, desMaskedImage.getImage(), msg=msg)
        msg = "scaledPlus failed for masked images; coeff0=%s, coeff1=%s" % (coeff0, coeff1)
        self.assertMaskedImagesNearlyEqual(actMaskedImage, desMaskedImage, msg=msg)
示例#3
0
    def runScaledAddTest(self, coeff0, coeff1):
        """Run one test of scaledPlus
        
        Inputs:
        - coeff0: coefficient of image 0
        - coeff1: coefficient of image 1
        """
        im0ArrSet = self.maskedImage0.getArrays()
        im1ArrSet = self.maskedImage1.getArrays()
        
        desMaskedImage = afwImage.MaskedImageF(self.maskedImage0.getDimensions())
        desMaskedImage <<= self.maskedImage0
        desMaskedImage *= coeff0
        desMaskedImage.scaledPlus(coeff1, self.maskedImage1)
        desImArrSet = desMaskedImage.getArrays()
        
        actMaskedImage = afwImage.MaskedImageF(afwGeom.Extent2I(self.imWidth, self.imHeight))
        afwMath.randomUniformImage(actMaskedImage.getImage(), self.random)
        afwMath.randomUniformImage(actMaskedImage.getVariance(), self.random)

        afwMath.scaledPlus(actMaskedImage, coeff0, self.maskedImage0, coeff1, self.maskedImage1)
        actImArrSet = actMaskedImage.getArrays()
        
        actImage = afwImage.ImageF(afwGeom.Extent2I(self.imWidth, self.imHeight))
        afwMath.randomUniformImage(actImage, self.random)
        afwMath.scaledPlus(actImage, coeff0, self.maskedImage0.getImage(), coeff1, self.maskedImage1.getImage())
        actImArr = actImage.getArray()
        
        errStr = imTestUtils.imagesDiffer(actImArr, desImArrSet[0])
        if errStr:
            self.fail("scaledPlus failed in images; coeff0=%s, coeff1=%s:\n%s" % (coeff0, coeff1, errStr,))
        errStr = imTestUtils.maskedImagesDiffer(actImArrSet, desImArrSet)
        if errStr:
            self.fail("scaledPlus failed on masked images; coeff0=%s, coeff1=%s:\n%s" %
                (coeff0, coeff1, errStr,))
示例#4
0
    def runScaledAddTest(self, coeff0, coeff1):
        """Run one test of scaledPlus
        
        Inputs:
        - coeff0: coefficient of image 0
        - coeff1: coefficient of image 1
        """
        im0ArrSet = self.maskedImage0.getArrays()
        im1ArrSet = self.maskedImage1.getArrays()

        desMaskedImage = afwImage.MaskedImageF(
            self.maskedImage0.getDimensions())
        desMaskedImage <<= self.maskedImage0
        desMaskedImage *= coeff0
        desMaskedImage.scaledPlus(coeff1, self.maskedImage1)
        desImArrSet = desMaskedImage.getArrays()

        actMaskedImage = afwImage.MaskedImageF(
            afwGeom.Extent2I(self.imWidth, self.imHeight))
        afwMath.randomUniformImage(actMaskedImage.getImage(), self.random)
        afwMath.randomUniformImage(actMaskedImage.getVariance(), self.random)

        afwMath.scaledPlus(actMaskedImage, coeff0, self.maskedImage0, coeff1,
                           self.maskedImage1)
        actImArrSet = actMaskedImage.getArrays()

        actImage = afwImage.ImageF(
            afwGeom.Extent2I(self.imWidth, self.imHeight))
        afwMath.randomUniformImage(actImage, self.random)
        afwMath.scaledPlus(actImage, coeff0, self.maskedImage0.getImage(),
                           coeff1, self.maskedImage1.getImage())
        actImArr = actImage.getArray()

        errStr = imTestUtils.imagesDiffer(actImArr, desImArrSet[0])
        if errStr:
            self.fail(
                "scaledPlus failed in images; coeff0=%s, coeff1=%s:\n%s" % (
                    coeff0,
                    coeff1,
                    errStr,
                ))
        errStr = imTestUtils.maskedImagesDiffer(actImArrSet, desImArrSet)
        if errStr:
            self.fail(
                "scaledPlus failed on masked images; coeff0=%s, coeff1=%s:\n%s"
                % (
                    coeff0,
                    coeff1,
                    errStr,
                ))