def process(self, clipboard):
     """
     """
     self.log.log(Log.INFO, "Doing bias subtraction.")
     
     #grab exposure and bias from clipboard
     biasexposure = clipboard.get(self.policy.getString("inputKeys.biasexposure"))
     exposure = clipboard.get(self.policy.getString("inputKeys.exposure"))
     ipIsr.biasCorrection(exposure, biasexposure)
     #output products
     clipboard.put(self.policy.get("outputKeys.biasSubtractedExposure"), exposure)
示例#2
0
    def bias(self, exposure, bias):
        """Bias subtraction

        @param exposure Exposure to process
        @param bias Bias frame to apply
        """
        assert exposure, "No exposure provided"
        assert bias, "No bias provided"
        bias = self._checkDimensions("bias", exposure, bias)
        self.log.log(self.log.INFO, "Debiasing image")
        ipIsr.biasCorrection(exposure, bias)
        return
    def process(self, clipboard):
        """
        """
        self.log.log(Log.INFO, "Doing bias subtraction.")

        #grab exposure and bias from clipboard
        biasexposure = clipboard.get(
            self.policy.getString("inputKeys.biasexposure"))
        exposure = clipboard.get(self.policy.getString("inputKeys.exposure"))
        ipIsr.biasCorrection(exposure, biasexposure)
        #output products
        clipboard.put(self.policy.get("outputKeys.biasSubtractedExposure"),
                      exposure)
示例#4
0
    def test_biasCorrection(self):
        """Expect smaller median image value after.
        Expect RuntimeError if sizes are different.
        """
        biasExp = isrMock.BiasMock().run()
        biasMi = biasExp.getMaskedImage()

        mi = self.mi.clone()
        ipIsr.biasCorrection(self.mi, biasMi, trimToFit=True)
        self.assertLess(computeImageMedianAndStd(self.mi.getImage())[0],
                        computeImageMedianAndStd(mi.getImage())[0])

        biasMi = biasMi[1:-1, 1:-1, afwImage.LOCAL]
        with self.assertRaises(RuntimeError):
            ipIsr.biasCorrection(self.mi, biasMi, trimToFit=False)
    def test_biasCorrection(self):
        """Expect smaller median image value after.
        Expect RuntimeError if sizes are different.
        """
        biasExp = isrMock.BiasMock().run()
        biasMi = biasExp.getMaskedImage()

        mi = self.mi.clone()
        ipIsr.biasCorrection(self.mi, biasMi, trimToFit=True)
        self.assertLess(
            computeImageMedianAndStd(self.mi.getImage())[0],
            computeImageMedianAndStd(mi.getImage())[0])

        biasMi = biasMi[1:-1, 1:-1, afwImage.LOCAL]
        with self.assertRaises(RuntimeError):
            ipIsr.biasCorrection(self.mi, biasMi, trimToFit=False)
示例#6
0
    def testBias(self):
        maskedImage = afwImage.MaskedImageF(lsst.geom.Box2I(self.pmin, self.pmax))
        maskedImage.getImage().set(10)

        bias = afwImage.MaskedImageF(lsst.geom.Box2I(self.pmin, self.pmax))
        bias.getImage().set(1)
        biasexposure = afwImage.ExposureF(bias, None)
        bmetadata = biasexposure.getMetadata()
        bmetadata.setDouble(self.meanCountsKeyword, 1.)
        bmetadata.setString(self.filenameKeyword, 'Unittest Bias')

        ipIsr.biasCorrection(maskedImage, biasexposure.getMaskedImage())

        height = maskedImage.getHeight()
        width = maskedImage.getWidth()
        for j in range(height):
            for i in range(width):
                self.assertEqual(maskedImage.image[i, j, afwImage.LOCAL], 9)
示例#7
0
    def testBias(self):
        maskedImage = afwImage.MaskedImageF(lsst.geom.Box2I(self.pmin, self.pmax))
        maskedImage.getImage().set(10)

        bias = afwImage.MaskedImageF(lsst.geom.Box2I(self.pmin, self.pmax))
        bias.getImage().set(1)
        biasexposure = afwImage.ExposureF(bias, None)
        bmetadata = biasexposure.getMetadata()
        bmetadata.setDouble(self.meanCountsKeyword, 1.)
        bmetadata.setString(self.filenameKeyword, 'Unittest Bias')

        ipIsr.biasCorrection(maskedImage, biasexposure.getMaskedImage())

        height = maskedImage.getHeight()
        width = maskedImage.getWidth()
        for j in range(height):
            for i in range(width):
                self.assertEqual(maskedImage.image[i, j, afwImage.LOCAL], 9)
示例#8
0
    def biasCorrection(self, exposure, biasExposure):
        """Apply bias correction in place

        DECam bias products have been trimmed and are smaller than
        the raw exposure.  The size of edge trim is computed based
        on the dimensions of the input data.  Only process the inner
        part of the raw exposure, and mask the outer pixels as EDGE.

        @param[in,out] exposure: exposure to process
        @param[in] biasExposure: bias exposure
        """
        nEdge = _computeEdgeSize(exposure, biasExposure)
        if nEdge > 0:
            rawMaskedImage = exposure.getMaskedImage()[nEdge:-nEdge,
                                                       nEdge:-nEdge]
        else:
            rawMaskedImage = exposure.getMaskedImage()
        biasCorrection(rawMaskedImage, biasExposure.getMaskedImage())
        # Mask the unprocessed edge pixels as EDGE
        SourceDetectionTask.setEdgeBits(
            exposure.getMaskedImage(), rawMaskedImage.getBBox(),
            exposure.getMaskedImage().getMask().getPlaneBitMask("EDGE"))
示例#9
0
    def biasCorrection(self, exposure, biasExposure):
        """Apply bias correction in place

        DECam bias products have been trimmed and are smaller than
        the raw exposure.  The size of edge trim is computed based
        on the dimensions of the input data.  Only process the inner
        part of the raw exposure, and mask the outer pixels as EDGE.

        @param[in,out] exposure: exposure to process
        @param[in] biasExposure: bias exposure
        """
        nEdge = _computeEdgeSize(exposure, biasExposure)
        if nEdge > 0:
            rawMaskedImage = exposure.getMaskedImage()[nEdge:-nEdge, nEdge:-nEdge]
        else:
            rawMaskedImage = exposure.getMaskedImage()
        biasCorrection(rawMaskedImage, biasExposure.getMaskedImage())
        # Mask the unprocessed edge pixels as EDGE
        SourceDetectionTask.setEdgeBits(
            exposure.getMaskedImage(),
            rawMaskedImage.getBBox(),
            exposure.getMaskedImage().getMask().getPlaneBitMask("EDGE"),
        )