Skip to content

Commit 6e21cb2

Browse files
authored
Merge pull request #2231 from larrybradley/sourcecat-docs
Update SourceCatalog docstrings to note scalar vs. multi-source catalogs
2 parents a7ad935 + 967fc62 commit 6e21cb2

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

photutils/segmentation/catalog.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,21 @@ class SourceCatalog:
299299
outside the source segment, masked pixels from the ``mask`` input,
300300
or any non-finite ``data`` values (NaN and inf).
301301
302+
**Scalar vs. Multi-source Catalogs**
303+
304+
A `SourceCatalog` can represent a single source or multiple
305+
sources. Most properties adapt their return type accordingly: for
306+
a multi-source catalog, properties return arrays or lists (one
307+
element per source); for a single-source (scalar) catalog, the
308+
same properties return a scalar value or a single object. For
309+
example, `kron_aperture` returns a list of aperture objects for a
310+
multi-source catalog, but a single aperture object for a scalar
311+
catalog. Similarly, `data` returns a list of 2D cutout arrays for a
312+
multi-source catalog, but a single 2D array for a scalar catalog. A
313+
scalar catalog is created when the input segmentation image contains
314+
only one source or when a multi-source catalog is indexed to select
315+
a single source.
316+
302317
.. _SourceExtractor: https://sextractor.readthedocs.io/en/latest/
303318
"""
304319

@@ -1060,6 +1075,9 @@ def label(self):
10601075
10611076
This label number corresponds to the assigned pixel value in the
10621077
`~photutils.segmentation.SegmentationImage`.
1078+
1079+
Returns an array for multi-source catalogs, or a scalar for a
1080+
single-source catalog.
10631081
"""
10641082
return self._labels
10651083

@@ -1083,6 +1101,9 @@ def slices(self):
10831101
"""
10841102
A tuple of slice objects defining the minimal bounding box of
10851103
the source.
1104+
1105+
Returns a list for multi-source catalogs, or a single tuple for
1106+
a single-source catalog.
10861107
"""
10871108
return self._slices
10881109

@@ -1103,6 +1124,9 @@ def segment(self):
11031124
"""
11041125
A 2D `~numpy.ndarray` cutout of the segmentation image using the
11051126
minimal bounding box of the source.
1127+
1128+
Returns a list of arrays for multi-source catalogs, or a single
1129+
array for a single-source catalog.
11061130
"""
11071131
return self._prepare_cutouts(self._segment_img_cutouts, units=False,
11081132
masked=False)
@@ -1117,6 +1141,9 @@ def segment_ma(self):
11171141
The mask is `True` for pixels outside the source segment
11181142
(labeled region of interest), masked pixels from the ``mask``
11191143
input, or any non-finite ``data`` values (NaN and inf).
1144+
1145+
Returns a list of arrays for multi-source catalogs, or a single
1146+
array for a single-source catalog.
11201147
"""
11211148
return self._prepare_cutouts(self._segment_img_cutouts, units=False,
11221149
masked=True)
@@ -1127,6 +1154,9 @@ def data(self):
11271154
"""
11281155
A 2D `~numpy.ndarray` cutout from the data using the minimal
11291156
bounding box of the source.
1157+
1158+
Returns a list of arrays for multi-source catalogs, or a single
1159+
array for a single-source catalog.
11301160
"""
11311161
return self._prepare_cutouts(self._data_cutouts, units=True,
11321162
masked=False, dtype=float)
@@ -1141,6 +1171,9 @@ def data_ma(self):
11411171
The mask is `True` for pixels outside the source segment
11421172
(labeled region of interest), masked pixels from the ``mask``
11431173
input, or any non-finite ``data`` values (NaN and inf).
1174+
1175+
Returns a list of arrays for multi-source catalogs, or a single
1176+
array for a single-source catalog.
11441177
"""
11451178
return self._prepare_cutouts(self._data_cutouts, units=False,
11461179
masked=True, dtype=float)
@@ -1151,6 +1184,9 @@ def convdata(self):
11511184
"""
11521185
A 2D `~numpy.ndarray` cutout from the convolved data using the
11531186
minimal bounding box of the source.
1187+
1188+
Returns a list of arrays for multi-source catalogs, or a single
1189+
array for a single-source catalog.
11541190
"""
11551191
return self._prepare_cutouts(self._convdata_cutouts, units=True,
11561192
masked=False, dtype=float)
@@ -1165,6 +1201,9 @@ def convdata_ma(self):
11651201
The mask is `True` for pixels outside the source segment
11661202
(labeled region of interest), masked pixels from the ``mask``
11671203
input, or any non-finite ``data`` values (NaN and inf).
1204+
1205+
Returns a list of arrays for multi-source catalogs, or a single
1206+
array for a single-source catalog.
11681207
"""
11691208
return self._prepare_cutouts(self._convdata_cutouts, units=False,
11701209
masked=True, dtype=float)
@@ -1175,6 +1214,9 @@ def error(self):
11751214
"""
11761215
A 2D `~numpy.ndarray` cutout from the error array using the
11771216
minimal bounding box of the source.
1217+
1218+
Returns a list of arrays for multi-source catalogs, or a single
1219+
array for a single-source catalog.
11781220
"""
11791221
if self._error is None:
11801222
return self._null_objects
@@ -1191,6 +1233,9 @@ def error_ma(self):
11911233
The mask is `True` for pixels outside the source segment
11921234
(labeled region of interest), masked pixels from the ``mask``
11931235
input, or any non-finite ``data`` values (NaN and inf).
1236+
1237+
Returns a list of arrays for multi-source catalogs, or a single
1238+
array for a single-source catalog.
11941239
"""
11951240
if self._error is None:
11961241
return self._null_objects
@@ -1203,6 +1248,9 @@ def background(self):
12031248
"""
12041249
A 2D `~numpy.ndarray` cutout from the background array using the
12051250
minimal bounding box of the source.
1251+
1252+
Returns a list of arrays for multi-source catalogs, or a single
1253+
array for a single-source catalog.
12061254
"""
12071255
if self._background is None:
12081256
return self._null_objects
@@ -1219,6 +1267,9 @@ def background_ma(self):
12191267
The mask is `True` for pixels outside the source segment
12201268
(labeled region of interest), masked pixels from the ``mask``
12211269
input, or any non-finite ``data`` values (NaN and inf).
1270+
1271+
Returns a list of arrays for multi-source catalogs, or a single
1272+
array for a single-source catalog.
12221273
"""
12231274
if self._background is None:
12241275
return self._null_objects
@@ -1815,6 +1866,9 @@ def bbox(self):
18151866
"""
18161867
The `~photutils.aperture.BoundingBox` of the minimal rectangular
18171868
region containing the source segment.
1869+
1870+
Returns a list for multi-source catalogs, or a single
1871+
`~photutils.aperture.BoundingBox` for a single-source catalog.
18181872
"""
18191873
return self._bbox
18201874

@@ -2737,6 +2791,9 @@ def local_background_aperture(self):
27372791
"""
27382792
The `~photutils.aperture.RectangularAnnulus` aperture used to
27392793
estimate the local background.
2794+
2795+
Returns a list of apertures for multi-source catalogs, or a
2796+
single aperture for a single-source catalog.
27402797
"""
27412798
return self._local_background_apertures
27422799

@@ -3267,6 +3324,9 @@ def kron_aperture(self):
32673324
32683325
If a ``detection_cat`` was input to `SourceCatalog`, then its
32693326
``kron_aperture`` will be returned.
3327+
3328+
Returns a list of apertures for multi-source catalogs, or a
3329+
single aperture for a single-source catalog.
32703330
"""
32713331
return self._make_kron_apertures(self.kron_params)
32723332

0 commit comments

Comments
 (0)