Exemplo n.º 1
0
    def dark(self, exposure, dark):
        """Dark subtraction

        @param exposure Exposure to process
        @param dark Dark frame to apply
        """
        assert exposure, "No exposure provided"
        assert dark, "No dark provided"
        dark = self._checkDimensions("dark", exposure, dark)
        expTime = float(exposure.getCalib().getExptime())
        darkTime = float(dark.getCalib().getExptime())
        self.log.log(self.log.INFO, "Removing dark (%f sec vs %f sec)" % (expTime, darkTime))
        ipIsr.darkCorrection(exposure, dark, expTime, darkTime)
        return
    def process(self, clipboard):
        """
        """
        self.log.log(Log.INFO, "Doing dark subtraction.")
        
        #grab exposure and dark from clipboard
        darkexposure = clipboard.get(self.policy.getString("inputKeys.darkexposure"))
        exposure = clipboard.get(self.policy.getString("inputKeys.exposure"))
        darkscaling = darkexposure.getCalib().getExptime()
        expscaling = exposure.getCalib().getExptime()
        ipIsr.darkCorrection(exposure, darkexposure, float(expscaling),
                float(darkscaling))

        #output products
        clipboard.put(self.policy.get("outputKeys.darkSubtractedExposure"), exposure)
Exemplo n.º 3
0
    def doDark(self, scaling):
        maskedImage = afwImage.MaskedImageF(lsst.geom.Box2I(self.pmin, self.pmax))
        maskedImage.getImage().set(10)

        dark = afwImage.MaskedImageF(lsst.geom.Box2I(self.pmin, self.pmax))
        dark.getImage().set(1)
        darkexposure = afwImage.ExposureF(dark, None)
        dmetadata = darkexposure.getMetadata()
        dmetadata.setString(self.filenameKeyword, 'Unittest Dark')

        ipIsr.darkCorrection(maskedImage, darkexposure.getMaskedImage(), 1., scaling)

        height = maskedImage.getHeight()
        width = maskedImage.getWidth()
        for j in range(height):
            for i in range(width):
                self.assertAlmostEqual(maskedImage.image[i, j, afwImage.LOCAL], 10 - 1./scaling, 5)
Exemplo n.º 4
0
    def doDark(self, scaling):
        maskedImage = afwImage.MaskedImageF(lsst.geom.Box2I(self.pmin, self.pmax))
        maskedImage.getImage().set(10)

        dark = afwImage.MaskedImageF(lsst.geom.Box2I(self.pmin, self.pmax))
        dark.getImage().set(1)
        darkexposure = afwImage.ExposureF(dark, None)
        dmetadata = darkexposure.getMetadata()
        dmetadata.setString(self.filenameKeyword, 'Unittest Dark')

        ipIsr.darkCorrection(maskedImage, darkexposure.getMaskedImage(), 1., scaling)

        height = maskedImage.getHeight()
        width = maskedImage.getWidth()
        for j in range(height):
            for i in range(width):
                self.assertAlmostEqual(maskedImage.image[i, j, afwImage.LOCAL], 10 - 1./scaling, 5)
Exemplo n.º 5
0
    def process(self, clipboard):
        """
        """
        self.log.log(Log.INFO, "Doing dark subtraction.")

        #grab exposure and dark from clipboard
        darkexposure = clipboard.get(
            self.policy.getString("inputKeys.darkexposure"))
        exposure = clipboard.get(self.policy.getString("inputKeys.exposure"))
        darkscaling = darkexposure.getCalib().getExptime()
        expscaling = exposure.getCalib().getExptime()
        ipIsr.darkCorrection(exposure, darkexposure, float(expscaling),
                             float(darkscaling))

        #output products
        clipboard.put(self.policy.get("outputKeys.darkSubtractedExposure"),
                      exposure)
Exemplo n.º 6
0
    def test_darkCorrection(self):
        """Expect round-trip application to be equal.
        Expect RuntimeError if sizes are different.
        """
        darkExp = isrMock.DarkMock().run()
        darkMi = darkExp.getMaskedImage()

        mi = self.mi.clone()

        # The `invert` parameter controls the direction of the
        # application.  This will apply, and un-apply the dark.
        ipIsr.darkCorrection(self.mi, darkMi, 1.0, 1.0, trimToFit=True)
        ipIsr.darkCorrection(self.mi, darkMi, 1.0, 1.0, trimToFit=True, invert=True)

        self.assertMaskedImagesAlmostEqual(self.mi, mi, atol=1e-3)

        darkMi = darkMi[1:-1, 1:-1, afwImage.LOCAL]
        with self.assertRaises(RuntimeError):
            ipIsr.darkCorrection(self.mi, darkMi, 1.0, 1.0, trimToFit=False)
Exemplo n.º 7
0
    def test_darkCorrection(self):
        """Expect round-trip application to be equal.
        Expect RuntimeError if sizes are different.
        """
        darkExp = isrMock.DarkMock().run()
        darkMi = darkExp.getMaskedImage()

        mi = self.mi.clone()

        # The `invert` parameter controls the direction of the
        # application.  This will apply, and un-apply the dark.
        ipIsr.darkCorrection(self.mi, darkMi, 1.0, 1.0, trimToFit=True)
        ipIsr.darkCorrection(self.mi,
                             darkMi,
                             1.0,
                             1.0,
                             trimToFit=True,
                             invert=True)

        self.assertMaskedImagesAlmostEqual(self.mi, mi, atol=1e-3)

        darkMi = darkMi[1:-1, 1:-1, afwImage.LOCAL]
        with self.assertRaises(RuntimeError):
            ipIsr.darkCorrection(self.mi, darkMi, 1.0, 1.0, trimToFit=False)