22 from __future__
import absolute_import, division, print_function
26 from builtins
import range
27 from builtins
import object
31 from .box
import Box2I, Box2D
35 """!Divide a box into nx by ny sub-boxes that tile the region
39 """!Construct a BoxGrid
41 The sub-boxes will be of the same type as `box` and will exactly tile `box`;
42 they will also all be the same size, to the extent possible (some variation
43 is inevitable for integer boxes that cannot be evenly divided.
45 @param[in] box box (an lsst.afw.geom.Box2I or Box2D);
46 the boxes in the grid will be of the same type
47 @param[in] numColRow number of columns and rows (a pair of ints)
49 if len(numColRow) != 2:
51 "numColRow=%r; must be a sequence of two integers" % (numColRow,))
52 self.
_numColRow = tuple(int(val)
for val
in numColRow)
54 if isinstance(box, Box2I):
56 elif isinstance(box, Box2D):
59 raise RuntimeError(
"Unknown class %s of box %s" % (type(box), box))
63 minPoint = box.getMin()
65 dtype = np.array(minPoint).dtype
67 self.
_divList = [np.linspace(start=box.getMin()[i],
71 dtype=dtype)
for i
in range(2)]
78 """!Return the box at the specified x,y index (a pair of ints)
86 return self.shape[0]*self.shape[1]
89 """!Return an iterator over all boxes, where column varies most quickly
def __init__
Construct a BoxGrid.
def __iter__
Return an iterator over all boxes, where column varies most quickly.
Divide a box into nx by ny sub-boxes that tile the region.
def __getitem__
Return the box at the specified x,y index (a pair of ints)