Coverage for python/lsst/meas/extensions/scarlet/utils.py: 13%
11 statements
« prev ^ index » next coverage.py v6.5.0, created at 2023-01-06 02:39 -0800
« prev ^ index » next coverage.py v6.5.0, created at 2023-01-06 02:39 -0800
1import numpy as np
4def footprintsToNumpy(catalog, shape, xy0=None):
5 """Convert all of the footprints in a catalog into a boolean array
7 Parameters
8 ----------
9 catalog : `lsst.afw.SourceCatalog`
10 The source catalog containing the footprints.
11 This is typically a mergeDet catalog, or a full source catalog
12 with the parents removed.
13 shape : `tuple` of `int`
14 The final shape of the output array.
15 xy0 : `tuple` of `int`
16 The lower-left corner of the array that will contain the spans.
18 Returns
19 -------
20 result : `numpy.ndarray`
21 The array with pixels contained in `spans` marked as `True`.
22 """
23 if xy0 is None:
24 offset = (0, 0)
25 else:
26 offset = (-xy0[0], -xy0[1])
28 result = np.zeros(shape, dtype=bool)
29 for src in catalog:
30 spans = src.getFootprint().spans
31 yidx, xidx = spans.shiftedBy(*offset).indices()
32 result[yidx, xidx] = 1
33 return result