Coverage for python/lsst/afw/table/_source.py : 62%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# This file is part of afw.
2#
3# Developed for the LSST Data Management System.
4# This product includes software developed by the LSST Project
5# (https://www.lsst.org).
6# See the COPYRIGHT file at the top-level directory of this distribution
7# for details of code ownership.
8#
9# This program is free software: you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation, either version 3 of the License, or
12# (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with this program. If not, see <https://www.gnu.org/licenses/>.
22__all__ = []
24from lsst.utils import continueClass
25from lsst.utils.deprecated import deprecate_pybind11
26from ._base import Catalog
27from ._table import SourceCatalog, SourceTable
29Catalog.register("Source", SourceCatalog)
32@continueClass # noqa: F811
33class SourceCatalog:
35 def getChildren(self, parent, *args):
36 """Return the subset of self for which the parent field equals the
37 given value.
39 In order for this method to return the correct result, it must be
40 sorted by parent (i.e. self.isSorted(SourceTable.getParentKey()) must
41 be True). This is naturally the case with SourceCatalogs produced by
42 the detection and deblending tasks, but it may not be true when
43 concatenating multiple such catalogs.
45 Additional Catalogs or sequences whose elements correspond in order to
46 the records of self (i.e. ``zip(self, *args)`` is valid) will be
47 subset using the same slice object used on self, and these subsets
48 will be returned along with the subset of self.
50 Parameters
51 ----------
52 parent : `int`
53 ID of the parent to get children for.
54 args : `~lsst.afw.table.Catalog`
55 Additional catalogs to subset for the childrens to return.
57 Returns
58 -------
59 children : iterable of `~lsst.afw.table.SourceRecord`
60 Children sources.
61 """
62 if not self.isSorted(SourceTable.getParentKey()):
63 raise AssertionError(
64 "The table is not sorted by parent, so cannot getChildren")
65 s = self.equal_range(parent, SourceTable.getParentKey())
66 if args:
67 return (self[s],) + tuple(arg[s] for arg in args)
68 else:
69 return self[s]
72SourceTable.getCentroidDefinition = deprecate_pybind11(
73 SourceTable.getCentroidDefinition,
74 reason='Use `getSchema().getAliasMap().get("slot_Centroid")` instead. To be removed after 20.0.0.')
75SourceTable.hasCentroidSlot = deprecate_pybind11(
76 SourceTable.hasCentroidSlot,
77 reason='Use `getCentroidSlot().isValid()` instead. To be removed after 20.0.0.')
78SourceTable.getCentroidKey = deprecate_pybind11(
79 SourceTable.getCentroidKey,
80 reason='Use `getCentroidSlot().getMeasKey()` instead. To be removed after 20.0.0.')
81SourceTable.getCentroidErrKey = deprecate_pybind11(
82 SourceTable.getCentroidErrKey,
83 reason='Use `getCentroidSlot().getErrKey()` instead. To be removed after 20.0.0.')
84SourceTable.getCentroidFlagKey = deprecate_pybind11(
85 SourceTable.getCentroidFlagKey,
86 reason='Use `getCentroidSlot().getFlagKey()` instead. To be removed after 20.0.0.')
87SourceTable.getShapeDefinition = deprecate_pybind11(
88 SourceTable.getShapeDefinition,
89 reason='Use `getSchema().getAliasMap().get("slot_Shape")` instead. To be removed after 20.0.0.')
90SourceTable.hasShapeSlot = deprecate_pybind11(
91 SourceTable.hasShapeSlot,
92 reason='Use `getShapeSlot().isValid()` instead. To be removed after 20.0.0.')
93SourceTable.getShapeKey = deprecate_pybind11(
94 SourceTable.getShapeKey,
95 reason='Use `getShapeSlot().getMeasKey()` instead. To be removed after 20.0.0.')
96SourceTable.getShapeErrKey = deprecate_pybind11(
97 SourceTable.getShapeErrKey,
98 reason='Use `getShapeSlot().getErrKey()` instead. To be removed after 20.0.0.')
99SourceTable.getShapeFlagKey = deprecate_pybind11(
100 SourceTable.getShapeFlagKey,
101 reason='Use `getShapeSlot().getFlagKey()` instead. To be removed after 20.0.0.')