Coverage for tests/test_brighterFatter.py: 31%
Shortcuts 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
Shortcuts 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
1#
2# LSST Data Management System
3# Copyright 2008-2017 AURA/LSST.
4#
5# This product includes software developed by the
6# LSST Project (http://www.lsst.org/).
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation, either version 3 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the LSST License Statement and
19# the GNU General Public License along with this program. If not,
20# see <https://www.lsstcorp.org/LegalNotices/>.
21#
23import unittest
24import numpy as np
26import lsst.utils.tests
27import lsst.afw.cameraGeom as cameraGeom
28import lsst.afw.image as afwImage
29import lsst.ip.isr.isrFunctions as isrFunctions
30from lsst.ip.isr import BrighterFatterKernel
33class BrighterFatterTestCases(lsst.utils.tests.TestCase):
35 def setUp(self):
36 """Set up a no-op BFK dataset
37 """
38 cameraBuilder = cameraGeom.Camera.Builder('fake camera')
39 detectorWrapper = cameraGeom.testUtils.DetectorWrapper(numAmps=4, cameraBuilder=cameraBuilder)
40 self.detector = detectorWrapper.detector
41 camera = cameraBuilder.finish()
43 self.bfk = BrighterFatterKernel(level='AMP', camera=camera, detectorId=1)
44 self.bfk.shape = (17, 17)
45 self.bfk.badAmps = ['amp 3']
47 covar = np.zeros((8, 8))
48 covar[0, 0] = 1.0
50 kernel = np.zeros(self.bfk.shape)
51 kernel[8, 8] = 1.0
53 for amp in self.detector:
54 ampName = amp.getName()
55 self.bfk.means[ampName] = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]
56 self.bfk.variances[ampName] = np.array(self.bfk.means[ampName], dtype=float)
57 self.bfk.rawXcorrs[ampName] = [covar for _ in self.bfk.means[ampName]]
58 self.bfk.gain[ampName] = 1.0
59 self.bfk.noise[ampName] = 5.0
61 self.bfk.meanXcorrs[ampName] = kernel
62 self.bfk.valid[ampName] = (ampName != 'amp 3')
64 self.bfk.ampKernels[ampName] = kernel
66 def test_BrighterFatterInterface(self):
67 """Test brighter fatter correction interface using a delta function kernel on a flat image"""
69 image = afwImage.ImageF(100, 100)
70 image.set(100)
71 ref_image = afwImage.ImageF(image, True)
73 mi = afwImage.makeMaskedImage(image)
74 exp = afwImage.makeExposure(mi)
76 self.bfk.makeDetectorKernelFromAmpwiseKernels(self.detector.getName())
77 kernelToUse = self.bfk.detKernels[self.detector.getName()]
79 isrFunctions.brighterFatterCorrection(exp, kernelToUse, 5, 100, False)
80 self.assertImagesEqual(ref_image, image)
82 def test_BrighterFatterIO(self):
83 dictionary = self.bfk.toDict()
84 newBfk = BrighterFatterKernel().fromDict(dictionary)
85 self.assertEqual(self.bfk, newBfk)
87 tables = self.bfk.toTable()
88 newBfk = BrighterFatterKernel().fromTable(tables)
89 self.assertEqual(self.bfk, newBfk)
92class MemoryTester(lsst.utils.tests.MemoryTestCase):
93 pass
96def setup_module(module):
97 lsst.utils.tests.init()
100if __name__ == "__main__": 100 ↛ 101line 100 didn't jump to line 101, because the condition on line 100 was never true
101 lsst.utils.tests.init()
102 unittest.main()