60 catalog: SourceCatalog,
62 shape: tuple[int, int] |
None =
None,
63 xy0: tuple[int, int] |
None =
None,
66 """Convert all of the footprints in a catalog into a boolean array.
71 The source catalog containing the footprints.
72 This is typically a mergeDet catalog, or a full source catalog
73 with the parents removed.
75 The final shape of the output array.
77 The lower-left corner of the array that will contain the spans.
82 The array with pixels contained in `spans` marked as `True`.
84 if bbox
is None and shape
is None:
85 raise RuntimeError(
"Must provide either bbox or shape")
88 width, height = bbox.getDimensions()
89 shape = (height, width)
90 xy0 = (bbox.getMinX(), bbox.getMinY())
95 offset = (-xy0[0], -xy0[1])
97 result = np.zeros(shape, dtype=int)
99 spans = src.getFootprint().spans
100 yidx, xidx = spans.shiftedBy(*offset).indices()
101 result[yidx, xidx] = src.getId()
np.ndarray footprintsToNumpy(SourceCatalog catalog, geom.Box2I|None bbox=None, tuple[int, int]|None shape=None, tuple[int, int]|None xy0=None, bool asBool=True)