Coverage for tests/test_crosstalk.py : 27%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# # This file is part of obs_decam. # # Developed for the LSST Data Management System. # This product includes software developed by the LSST Project # (http://www.lsst.org). # See the COPYRIGHT file at the top-level directory of this distribution # for details of code ownership. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. #
"""Helper function to get a command-line task config customized by obs_decam.
Borrowed from test_processCcd.py. """ config = TaskClass.ConfigClass() filename = os.path.join(obsDecamDir, 'config', TaskClass._DefaultName + '.py') if os.path.exists(filename): config.load(filename) return config
"""A set of tests for DECam crosstalk correction. """
try: datadir = getPackageDir('testdata_decam') except pexExcept.NotFoundError: message = "testdata_decam not setup. Skipping." warnings.warn(message) raise unittest.SkipTest(message)
self.repoPath = os.path.join(datadir, 'rawData') self.calibPath = os.path.join(datadir, 'rawData/cpCalib') self.butler = dafPersist.Butler( inputs={'root': self.repoPath, 'mapperArgs': {'calibRoot': self.calibPath}}, outputs=None ) self.dataId = {'visit': 229388, 'ccdnum': 1} # Location of pixels where crosstalk is appreciable in the test image self.xtalkX = 1810 self.xtalkY = 2970 self.xtalkRad = 100
del self.butler
"""Run DecamCpIsrTask with or without crosstalk correction """ dataRef = self.butler.dataRef('raw', dataId=self.dataId) rawExposure = self.butler.get('raw', dataId=self.dataId) camera = dataRef.get('camera') config = getObsDecamConfig(DecamCpIsrTask) config.doCrosstalk = doCrosstalk decamCpIsrTask = DecamCpIsrTask(config=config) isrData = decamCpIsrTask.readIsrData(dataRef, rawExposure) isrResult = decamCpIsrTask.run(rawExposure, camera=camera, **isrData.getDict()) return isrResult
"""Compare DECam postISR images with and without crosstalk removal.
A region with known crosstalk from the neighbor amp is inspected to verify the crosstalk is removed, and we also test to see that the image statistics are altered as expected by crosstalk removal. This test requires running DecamCpIsrTask twice. """ # Run ISR with and without crosstalk correction expWithoutCrosstalkCorr = self.runIsr(doCrosstalk=False).exposure expWithCrosstalkCorr = self.runIsr(doCrosstalk=True).exposure image1 = expWithoutCrosstalkCorr.getMaskedImage().getImage() image2 = expWithCrosstalkCorr.getMaskedImage().getImage()
# Work with a small image chunk only pmin = afwGeom.Point2I(self.xtalkX - self.xtalkRad, self.xtalkY - self.xtalkRad) pmax = afwGeom.Point2I(self.xtalkX + self.xtalkRad, self.xtalkY + self.xtalkRad) box = afwGeom.Box2I(pmin, pmax) chunk1 = image1.Factory(image1, box) chunk2 = image2.Factory(image2, box) chunkDiff = chunk1.clone() chunkDiff -= chunk2
# Check that the difference of the two image chunks is nonzero # (the non-crosstalk-corrected and crosstalk-corrected images should differ) all_zeros = not chunkDiff.getArray().any() self.assertFalse(all_zeros)
# Check that the standard deviation with crosstalk signatures still # present is larger than when it has been removed self.assertGreater(chunk1.getArray().std(), chunk2.getArray().std())
# More specific tests for the exact image statistics expected self.assertAlmostEqual(chunk1.getArray().mean(), 3730.96, places=2) self.assertAlmostEqual(chunk2.getArray().mean(), 3727.55, places=2) self.assertAlmostEqual(chunkDiff.getArray().mean(), 3.41, places=2) self.assertAlmostEqual(chunk1.getArray().std(), 33.81, places=2) self.assertAlmostEqual(chunk2.getArray().std(), 33.32, places=2) self.assertAlmostEqual(chunkDiff.getArray().std(), 5.86, places=2)
# Option to display the portions of the image with/without crosstalk if displayDiffs: import lsst.afw.display.ds9 as ds9 ds9.mtv(chunk1, frame=1) ds9.mtv(chunk2, frame=2) ds9.mtv(chunkDiff, frame=3)
lsst.utils.tests.init()
lsst.utils.tests.init() unittest.main() |