Esempio n. 1
0
    def setUp(self):
        """Generate a mock exposure/camera to test."""
        config = isrMock.IsrMockConfig()
        config.isTrimmed = True
        config.rngSeed = 12345
        biasExposure = isrMock.BiasMock(config=config).run()

        config.rngSeed = 54321
        fakeBias = isrMock.BiasMock(config=config).run()

        self.inputExp = biasExposure.clone()
        mi = self.inputExp.getMaskedImage()
        mi.scaledMinus(1.0, fakeBias.getMaskedImage())
        updateMockExp(self.inputExp)

        self.camera = isrMock.IsrMock().getCamera()
Esempio n. 2
0
    def test_simple(self):
        """Chain raw and calibration mock data.

        This test should confirm the raw data is generated as expected.
        """

        initialMean = np.median(self.mi.getImage().getArray()[:])
        initialStd = np.std(self.mi.getImage().getArray()[:])

        bias = isrMock.BiasMock().run()
        self.mi.getImage().getArray()[:] = (
            self.mi.getImage().getArray()[:] -
            bias.getMaskedImage().getImage().getArray()[:])
        newMean = np.median(self.mi.getImage().getArray()[:])
        newStd = np.std(self.mi.getImage().getArray()[:])

        self.assertLess(newMean, initialMean)

        initialMean = newMean
        initialStd = newStd

        dark = isrMock.DarkMock().run()
        self.mi.getImage().getArray()[:] = (
            self.mi.getImage().getArray()[:] -
            dark.getMaskedImage().getImage().getArray()[:])
        newMean = np.median(self.mi.getImage().getArray()[:])
        newStd = np.std(self.mi.getImage().getArray()[:])

        self.assertLess(newMean, initialMean)

        initialMean = newMean
        initialStd = newStd

        flat = isrMock.FlatMock().run()
        self.mi.getImage().getArray()[:] = (
            self.mi.getImage().getArray()[:] -
            flat.getMaskedImage().getImage().getArray()[:])
        newMean = np.median(self.mi.getImage().getArray()[:])
        newStd = np.std(self.mi.getImage().getArray()[:])

        self.assertAlmostEqual(newMean, initialMean, -2)
        self.assertLess(newStd, initialStd)

        initialMean = newMean
        initialStd = newStd

        fringe = isrMock.FringeMock().run()
        self.mi.getImage().getArray()[:] = (
            self.mi.getImage().getArray()[:] -
            fringe.getMaskedImage().getImage().getArray()[:])
        newMean = np.median(self.mi.getImage().getArray()[:])
        newStd = np.std(self.mi.getImage().getArray()[:])

        self.assertLess(newMean, initialMean)
    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)