Coverage for tests/test_findSetBits.py: 38%
49 statements
« prev ^ index » next coverage.py v6.4.4, created at 2022-09-15 03:29 -0700
« prev ^ index » next coverage.py v6.4.4, created at 2022-09-15 03:29 -0700
1#
2# LSST Data Management System
3# Copyright 2008-2016 LSST Corporation.
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 <http://www.lsstcorp.org/LegalNotices/>.
21#
22import unittest
24import lsst.utils.tests
25import lsst.afw.image as afwImage
26import lsst.geom as geom
27import lsst.ip.diffim as ipDiffim
28import lsst.utils.logging as logUtils
30verbosity = 0
31logUtils.trace_set_at("lsst.ip.diffim", verbosity)
34class DiffimTestCases(unittest.TestCase):
36 def testNoMask(self):
37 mask = afwImage.Mask(geom.Extent2I(20, 20))
38 mask.set(0)
39 fsb = ipDiffim.FindSetBitsU()
41 bbox = geom.Box2I(geom.Point2I(0, 10),
42 geom.Point2I(9, 12))
43 fsb.apply(afwImage.Mask(mask, bbox, afwImage.LOCAL))
45 self.assertEqual(fsb.getBits(), 0)
47 def testOneMask(self):
48 mask = afwImage.Mask(geom.Extent2I(20, 20))
49 mask.set(0)
50 bitmaskBad = mask.getPlaneBitMask('BAD')
51 fsb = ipDiffim.FindSetBitsU()
53 bbox = geom.Box2I(geom.Point2I(9, 10),
54 geom.Point2I(11, 12))
55 submask = afwImage.Mask(mask, bbox, afwImage.LOCAL)
56 submask |= bitmaskBad
58 bbox2 = geom.Box2I(geom.Point2I(8, 8),
59 geom.Point2I(19, 19))
60 fsb.apply(afwImage.Mask(mask, bbox2, afwImage.LOCAL))
62 self.assertEqual(fsb.getBits(), bitmaskBad)
64 def testManyMask(self):
65 mask = afwImage.Mask(geom.Extent2I(20, 20))
66 mask.set(0)
67 bitmaskBad = mask.getPlaneBitMask('BAD')
68 bitmaskSat = mask.getPlaneBitMask('SAT')
69 fsb = ipDiffim.FindSetBitsU()
71 bbox = geom.Box2I(geom.Point2I(9, 10),
72 geom.Point2I(11, 12))
73 submask = afwImage.Mask(mask, bbox, afwImage.LOCAL)
74 submask |= bitmaskBad
76 bbox2 = geom.Box2I(geom.Point2I(8, 8),
77 geom.Point2I(19, 19))
78 submask2 = afwImage.Mask(mask, bbox2, afwImage.LOCAL)
79 submask2 |= bitmaskSat
81 bbox3 = geom.Box2I(geom.Point2I(0, 0),
82 geom.Point2I(19, 19))
83 fsb.apply(afwImage.Mask(mask, bbox3, afwImage.LOCAL))
85 self.assertEqual(fsb.getBits(), bitmaskBad | bitmaskSat)
87#####
90class TestMemory(lsst.utils.tests.MemoryTestCase):
91 pass
94def setup_module(module):
95 lsst.utils.tests.init()
98if __name__ == "__main__": 98 ↛ 99line 98 didn't jump to line 99, because the condition on line 98 was never true
99 lsst.utils.tests.init()
100 unittest.main()