Coverage for tests/test_ticket2019.py : 24%
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
|
im = afwImage.ImageF(100, 100) im += 42. spanSet = afwGeom.SpanSet.fromShape(10).shiftedBy(50, 50) fp = afwDet.Footprint(spanSet) mi = afwImage.MaskedImageF(im) # set a mask bit before grabbing the heavyfootprint mi.mask[50, 50, afwImage.LOCAL] = 1 heavy = afwDet.makeHeavyFootprint(fp, mi) # reset it mi.mask[50, 50, afwImage.LOCAL] = 0
schema = afwTable.SourceTable.makeMinimalSchema() table = afwTable.SourceTable.make(schema) table.preallocate(10) catalog = afwTable.SourceCatalog(table) catalog.addNew() # This used to segfault catalog[0].setFootprint(heavy)
fp = catalog[0].getFootprint() # change one pixel... self.assertEqual(mi.image[50, 50, afwImage.LOCAL], 42) self.assertEqual(mi.mask[50, 50, afwImage.LOCAL], 0) mi.image[50, 50, afwImage.LOCAL] = 100 mi.mask[50, 50, afwImage.LOCAL] = 2 mi.mask[51, 50, afwImage.LOCAL] = 2 self.assertEqual(mi.image[50, 50, afwImage.LOCAL], 100) self.assertEqual(mi.mask[50, 50, afwImage.LOCAL], 2) self.assertEqual(mi.mask[51, 50, afwImage.LOCAL], 2) # reinsert the heavy footprint; it should reset the pixel value. # insert(MaskedImage) fp.insert(mi) self.assertEqual(mi.image[50, 50, afwImage.LOCAL], 42) self.assertEqual(mi.mask[50, 50, afwImage.LOCAL], 1) self.assertEqual(mi.mask[51, 50, afwImage.LOCAL], 0)
# Also test insert(Image) im = mi.image self.assertEqual(im[50, 50, afwImage.LOCAL], 42) im[50, 50, afwImage.LOCAL] = 100 self.assertEqual(im[50, 50, afwImage.LOCAL], 100) self.assertEqual(mi.image[50, 50, afwImage.LOCAL], 100) # reinsert the heavy footprint; it should reset the pixel value. fp.insert(im) self.assertEqual(im[50, 50, afwImage.LOCAL], 42) self.assertEqual(mi.image[50, 50, afwImage.LOCAL], 42) self.assertEqual(mi.mask[50, 50, afwImage.LOCAL], 1) self.assertEqual(mi.mask[51, 50, afwImage.LOCAL], 0)
lsst.utils.tests.init()
lsst.utils.tests.init() unittest.main() |