def testWholeImageGrid(self): """Test that a 1-cell `grid` is actually the whole image""" config = ZogyConfig() task = ZogyTask(config=config) bb = geom.Box2I(geom.Point2I(5, 10), geom.Extent2I(200, 300)) D = afwImage.ImageI(bb) grid = task.generateGrid(bb, geom.Extent2I(15, 15), bb.getDimensions()) self.assertTrue(len(grid) == 1, "Grid length is not 1") x = grid[0] D[x.innerBox] += 1 self.assertTrue(np.all(D.array == 1), "Single cell does not cover the original image.")
def testGenerateGrid(self): """Test that the generated grid covers the whole image""" config = ZogyConfig() task = ZogyTask(config=config) bb = geom.Box2I(geom.Point2I(5, 10), geom.Extent2I(200, 300)) D = afwImage.ImageI(bb) grid = task.generateGrid(bb, geom.Extent2I(15, 15), geom.Extent2I(20, 30), powerOfTwo=True) for x in grid: h = x.outerBox.getHeight() w = x.outerBox.getWidth() self.assertTrue(isPowerOfTwo(h), "Box height is not power of two") self.assertTrue(isPowerOfTwo(w), "Box width is not power of two") D[x.innerBox] += 1 self.assertTrue( np.all(D.array == 1), "Grid inner boxes do not cover all pixels exactly once.")