def testMakeHeavy(self): """Test that we can make a FootprintSet heavy""" fs = afwDetect.FootprintSet(self.mi, afwDetect.Threshold(1)) ctrl = afwDetect.HeavyFootprintCtrl(afwDetect.HeavyFootprintCtrl.NONE) fs.makeHeavy(self.mi, ctrl) if display: ds9.mtv(self.mi, frame=0, title="input") #ds9.mtv(omi, frame=1, title="output") omi = self.mi.Factory(self.mi.getDimensions()) for foot in fs.getFootprints(): self.assertNotEqual(afwDetect.cast_HeavyFootprint(foot, self.mi), None) afwDetect.cast_HeavyFootprint(foot, self.mi).insert(omi) for foot in fs.getFootprints(): self.assertNotEqual(afwDetect.HeavyFootprintF.cast(foot), None) afwDetect.HeavyFootprintF.cast(foot).insert(omi) self.assertTrue( np.all( np.equal(self.mi.getImage().getArray(), omi.getImage().getArray())))
def testSetFootprint(self): """Check that we can create a HeavyFootprint and set the pixels under it""" ctrl = afwDetect.HeavyFootprintCtrl() ctrl.setModifySource(afwDetect.HeavyFootprintCtrl.SET) # clear the pixels in the Footprint ctrl.setMaskVal(self.objectPixelVal[1]) hfoot = afwDetect.makeHeavyFootprint(self.foot, self.mi, ctrl) # # Check that we cleared all the pixels # self.assertEqual(np.min(self.mi.getImage().getArray()), 0.0) self.assertEqual(np.max(self.mi.getImage().getArray()), 0.0) self.assertEqual(np.min(self.mi.getMask().getArray()), 0.0) self.assertEqual(np.max(self.mi.getMask().getArray()), 0.0) self.assertEqual(np.min(self.mi.getVariance().getArray()), 0.0) self.assertEqual(np.max(self.mi.getVariance().getArray()), 0.0)
def testCast_HeavyFootprint(self): """Test that we can cast a Footprint to a HeavyFootprint""" hfoot = afwDetect.makeHeavyFootprint(self.foot, self.mi) ctrl = afwDetect.HeavyFootprintCtrl(afwDetect.HeavyFootprintCtrl.NONE) hfoot = afwDetect.makeHeavyFootprint(self.foot, self.mi, ctrl) # # This isn't quite a full test, as hfoot is already a HeavyFootprint, # the complete test is in testMakeHeavy # self.assertNotEqual(afwDetect.cast_HeavyFootprint(hfoot, self.mi), None, "Cast to the right sort of HeavyFootprint") self.assertNotEqual(afwDetect.HeavyFootprintF.cast(hfoot), None, "Cast to the right sort of HeavyFootprint") self.assertEqual(afwDetect.cast_HeavyFootprint(self.foot, self.mi), None, "Can't cast a Footprint to a HeavyFootprint") self.assertEqual(afwDetect.HeavyFootprintI.cast(hfoot), None, "Cast to the wrong sort of HeavyFootprint")
def testMakeHeavy(self): """Test that we can make a FootprintSet heavy""" fs = afwDetect.FootprintSet(self.mi, afwDetect.Threshold(1)) ctrl = afwDetect.HeavyFootprintCtrl(afwDetect.HeavyFootprintCtrl.NONE) fs.makeHeavy(self.mi, ctrl) if display: ds9.mtv(self.mi, frame=0, title="input") omi = self.mi.Factory(self.mi.getDimensions()) for foot in fs.getFootprints(): foot.insert(omi) for foot in fs.getFootprints(): foot.insert(omi) self.assertFloatsEqual(self.mi.getImage().getArray(), omi.getImage().getArray())