Hide keyboard shortcuts

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

1# 

2# LSST Data Management System 

3# 

4# Copyright 2008-2017 AURA/LSST. 

5# 

6# This product includes software developed by the 

7# LSST Project (http://www.lsst.org/). 

8# 

9# This program is free software: you can redistribute it and/or modify 

10# it under the terms of the GNU General Public License as published by 

11# the Free Software Foundation, either version 3 of the License, or 

12# (at your option) any later version. 

13# 

14# This program is distributed in the hope that it will be useful, 

15# but WITHOUT ANY WARRANTY; without even the implied warranty of 

16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

17# GNU General Public License for more details. 

18# 

19# You should have received a copy of the LSST License Statement and 

20# the GNU General Public License along with this program. If not, 

21# see <https://www.lsstcorp.org/LegalNotices/>. 

22# 

23import unittest 

24 

25import lsst.utils.tests 

26import lsst.afw.detection as afwDet 

27import lsst.geom as geom 

28import lsst.afw.geom as afwGeom 

29import lsst.afw.image as afwImage 

30from lsst.meas.deblender.plugins import clipFootprintToNonzeroImpl 

31 

32 

33class ClipFootprintTestCase(lsst.utils.tests.TestCase): 

34 ''' 

35 This is s a test to verify that clipping footprints to a non-zero region 

36 works as intended. It is expected that spans which contain leading or 

37 trailing zeros will be trimmed as to not include these values, while zeros 

38 which occur inside a span will be preserved. 

39 ''' 

40 def testClip(self): 

41 im = afwImage.ImageI(geom.Box2I(geom.Point2I(-2, -2), 

42 geom.Extent2I(20, 20))) 

43 

44 span1 = afwGeom.SpanSet.fromShape(5, afwGeom.Stencil.BOX, (6, 6)) 

45 span1.setImage(im, 20) 

46 

47 im.getArray()[6+2, 6+2] = 0 

48 

49 # Set some negative pixels to ensure they are not clipped 

50 im.getArray()[12, :] *= -1 

51 

52 span2 = afwGeom.SpanSet.fromShape(6, afwGeom.Stencil.BOX, (6, 6)) 

53 

54 foot = afwDet.Footprint(span2) 

55 

56 clipFootprintToNonzeroImpl(foot, im) 

57 

58 self.assertEqual(foot.spans, span1) 

59 

60 

61class TestMemory(lsst.utils.tests.MemoryTestCase): 

62 pass 

63 

64 

65def setup_module(module): 

66 lsst.utils.tests.init() 

67 

68 

69if __name__ == "__main__": 69 ↛ 70line 69 didn't jump to line 70, because the condition on line 69 was never true

70 lsst.utils.tests.init() 

71 unittest.main()