LSST Applications g0603fd7c41+022847dfd1,g180d380827+84552d2356,g2079a07aa2+86d27d4dc4,g2305ad1205+696e5f3872,g2bbee38e9b+047b288a59,g337abbeb29+047b288a59,g33d1c0ed96+047b288a59,g3a166c0a6a+047b288a59,g3d1719c13e+f45185db35,g3de15ee5c7+21d867f780,g487adcacf7+777bbf561e,g50ff169b8f+96c6868917,g52b1c1532d+585e252eca,g591dd9f2cf+248b16177b,g63cd9335cc+585e252eca,g858d7b2824+f45185db35,g88963caddf+4b08a23952,g991b906543+f45185db35,g99cad8db69+1747e75aa3,g9b9dfce982+78139cbddb,g9ddcbc5298+9a081db1e4,ga1e77700b3+a912195c07,gae0086650b+585e252eca,gb0e22166c9+60f28cb32d,gb3a676b8dc+b4feba26a1,gb4b16eec92+f82f04eb54,gba4ed39666+c2a2e4ac27,gbb8dafda3b+7cdca563f4,gc120e1dc64+1a5de9e6d7,gc28159a63d+047b288a59,gc3e9b769f7+dcad4ace9a,gcf0d15dbbd+78139cbddb,gd040fa1545+f45185db35,gdaeeff99f8+f9a426f77a,ge79ae78c31+047b288a59,w.2024.19
LSST Data Management Base Package
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Static Protected Attributes | List of all members
lsst.meas.algorithms.setPrimaryFlags.SetPrimaryFlagsTask Class Reference
Inheritance diagram for lsst.meas.algorithms.setPrimaryFlags.SetPrimaryFlagsTask:

Public Member Functions

 __init__ (self, *schema, isSingleFrame=False, **kwargs)
 
 run (self, sources, skyMap=None, tractInfo=None, patchInfo=None)
 

Public Attributes

 schema
 
 isSingleFrame
 
 includeDeblend
 
 isPatchInnerKey
 
 isTractInnerKey
 
 isPrimaryKey
 
 isDeblendedSourceKey
 
 fromBlendKey
 
 isIsolatedKey
 
 isDeblendedModelKey
 

Static Public Attributes

 ConfigClass = SetPrimaryFlagsConfig
 

Protected Member Functions

 _getPseudoSources (self, sources)
 

Static Protected Attributes

str _DefaultName = "setPrimaryFlags"
 

Detailed Description

Set the ``isPrimary`` flag and either various blendedness, or
patch/tract flags to a catalog (for single frame or coadd catalogs,
respectively), based on other properties of the sources.

Parameters
----------
schema : `lsst.afw.table.Schema`
    Source catalog schema to add fields to.
isSingleFrame : `bool`
    Flag specifying if task is operating with single frame imaging.
includeDeblend : `bool`
    Include deblend information in isPrimary and add blendedness fields?

Notes
-----
The tests for this task still live in
``pipe_tasks/tests/test_isPrimaryFlag.py``; see discussion on DM-42720.

Definition at line 36 of file setPrimaryFlags.py.

Constructor & Destructor Documentation

◆ __init__()

lsst.meas.algorithms.setPrimaryFlags.SetPrimaryFlagsTask.__init__ ( self,
* schema,
isSingleFrame = False,
** kwargs )

Definition at line 59 of file setPrimaryFlags.py.

59 def __init__(self, *, schema, isSingleFrame=False, **kwargs):
60 super().__init__(**kwargs)
61 self.schema = schema
62 self.isSingleFrame = isSingleFrame
63 self.includeDeblend = False
64 if not self.isSingleFrame:
65 primaryDoc = ("True if source has no children and is in the inner region of a coadd patch "
66 "and is in the inner region of a coadd tract "
67 "and is not \"detected\" in a pseudo-filter (see config.pseudoFilterList)")
68 self.isPatchInnerKey = self.schema.addField(
69 "detect_isPatchInner", type="Flag",
70 doc="True if source is in the inner region of a coadd patch",
71 )
72 self.isTractInnerKey = self.schema.addField(
73 "detect_isTractInner", type="Flag",
74 doc="True if source is in the inner region of a coadd tract",
75 )
76 else:
77 primaryDoc = "True if source has no children and is not a sky source."
78 self.isPrimaryKey = self.schema.addField(
79 "detect_isPrimary", type="Flag",
80 doc=primaryDoc,
81 )
82
83 if "deblend_nChild" in schema.getNames():
84 self.includeDeblend = True
85 self.isDeblendedSourceKey = self.schema.addField(
86 "detect_isDeblendedSource", type="Flag",
87 doc=primaryDoc + " and is either an unblended isolated source or a "
88 "deblended child from a parent with 'deblend_nChild' > 1")
89 self.fromBlendKey = self.schema.addField(
90 "detect_fromBlend", type="Flag",
91 doc="This source is deblended from a parent with more than one child."
92 )
93 self.isIsolatedKey = self.schema.addField(
94 "detect_isIsolated", type="Flag",
95 doc="This source is not a part of a blend."
96 )
97 if "deblend_scarletFlux" in schema.getNames():
98 self.isDeblendedModelKey = self.schema.addField(
99 "detect_isDeblendedModelSource", type="Flag",
100 doc=primaryDoc + " and is a deblended child")
101 else:
102 self.isDeblendedModelKey = None
103

Member Function Documentation

◆ _getPseudoSources()

lsst.meas.algorithms.setPrimaryFlags.SetPrimaryFlagsTask._getPseudoSources ( self,
sources )
protected
Get a flag that marks pseudo sources.

Some categories of sources, for example sky objects, are not really
detected sources and should not be considered primary sources.

Parameters
----------
sources : `lsst.afw.table.SourceCatalog`
    The catalog of sources for which to identify "pseudo"
    (e.g. sky) objects.

Returns
-------
isPseudo : array-like of `bool`
    True for each source that is a pseudo source.
    Note: to remove pseudo sources use `~isPseudo`.

Definition at line 157 of file setPrimaryFlags.py.

157 def _getPseudoSources(self, sources):
158 """Get a flag that marks pseudo sources.
159
160 Some categories of sources, for example sky objects, are not really
161 detected sources and should not be considered primary sources.
162
163 Parameters
164 ----------
165 sources : `lsst.afw.table.SourceCatalog`
166 The catalog of sources for which to identify "pseudo"
167 (e.g. sky) objects.
168
169 Returns
170 -------
171 isPseudo : array-like of `bool`
172 True for each source that is a pseudo source.
173 Note: to remove pseudo sources use `~isPseudo`.
174 """
175 # Filter out sources that should never be primary.
176 isPseudo = np.zeros(len(sources), dtype=bool)
177 for filt in self.config.pseudoFilterList:
178 try:
179 pseudoFilterKey = self.schema.find("merge_peak_%s" % filt).getKey()
180 isPseudo |= sources[pseudoFilterKey]
181 except KeyError:
182 self.log.warning("merge_peak is not set for pseudo-filter %s", filt)
183 return isPseudo
184
185

◆ run()

lsst.meas.algorithms.setPrimaryFlags.SetPrimaryFlagsTask.run ( self,
sources,
skyMap = None,
tractInfo = None,
patchInfo = None )
Set isPrimary and related flags on sources.

For coadded imaging, the `isPrimary` flag returns True when an object
has no children, is in the inner region of a coadd patch, is in the
inner region of a coadd trach, and is not detected in a pseudo-filter
(e.g., a sky_object).
For single frame imaging, the isPrimary flag returns True when a
source has no children and is not a sky source.

Parameters
----------
sources : `lsst.afw.table.SourceCatalog`
    A sourceTable. Reads in centroid fields and an nChild field.
    Writes is-patch-inner, is-tract-inner, and is-primary flags.
skyMap : `lsst.skymap.BaseSkyMap`
    Sky tessellation object
tractInfo : `lsst.skymap.TractInfo`, optional
    Tract object; required if ``self.isSingleFrame`` is False.
patchInfo : `lsst.skymap.PatchInfo`
    Patch object; required if ``self.isSingleFrame`` is False.

Definition at line 104 of file setPrimaryFlags.py.

104 def run(self, sources, skyMap=None, tractInfo=None, patchInfo=None):
105 """Set isPrimary and related flags on sources.
106
107 For coadded imaging, the `isPrimary` flag returns True when an object
108 has no children, is in the inner region of a coadd patch, is in the
109 inner region of a coadd trach, and is not detected in a pseudo-filter
110 (e.g., a sky_object).
111 For single frame imaging, the isPrimary flag returns True when a
112 source has no children and is not a sky source.
113
114 Parameters
115 ----------
116 sources : `lsst.afw.table.SourceCatalog`
117 A sourceTable. Reads in centroid fields and an nChild field.
118 Writes is-patch-inner, is-tract-inner, and is-primary flags.
119 skyMap : `lsst.skymap.BaseSkyMap`
120 Sky tessellation object
121 tractInfo : `lsst.skymap.TractInfo`, optional
122 Tract object; required if ``self.isSingleFrame`` is False.
123 patchInfo : `lsst.skymap.PatchInfo`
124 Patch object; required if ``self.isSingleFrame`` is False.
125 """
126 # Mark whether sources are contained within the inner regions of the
127 # given tract/patch and are not "pseudo" (e.g. sky) sources.
128 if not self.isSingleFrame:
129 isPatchInner = getPatchInner(sources, patchInfo)
130 isTractInner = getTractInner(sources, tractInfo, skyMap)
131 isPseudo = self._getPseudoSources(sources)
132 isPrimary = isTractInner & isPatchInner & ~isPseudo
133
134 sources[self.isPatchInnerKey] = isPatchInner
135 sources[self.isTractInnerKey] = isTractInner
136 else:
137 # Mark all of the sky sources in SingleFrame images
138 # (if they were added)
139 if "sky_source" in sources.schema:
140 isSky = sources["sky_source"]
141 else:
142 isSky = np.zeros(len(sources), dtype=bool)
143 isPrimary = ~isSky
144
145 if self.includeDeblend:
146 result = getDeblendPrimaryFlags(sources)
147 fromBlend, isIsolated, isDeblendedSource, isDeblendedModelSource = result
148 sources[self.fromBlendKey] = fromBlend
149 sources[self.isIsolatedKey] = isIsolated
150 sources[self.isDeblendedSourceKey] = isDeblendedSource
151 if self.isDeblendedModelKey is not None:
152 sources[self.isDeblendedModelKey] = isDeblendedModelSource
153 isPrimary = isPrimary & isDeblendedSource
154
155 sources[self.isPrimaryKey] = isPrimary
156

Member Data Documentation

◆ _DefaultName

str lsst.meas.algorithms.setPrimaryFlags.SetPrimaryFlagsTask._DefaultName = "setPrimaryFlags"
staticprotected

Definition at line 56 of file setPrimaryFlags.py.

◆ ConfigClass

lsst.meas.algorithms.setPrimaryFlags.SetPrimaryFlagsTask.ConfigClass = SetPrimaryFlagsConfig
static

Definition at line 57 of file setPrimaryFlags.py.

◆ fromBlendKey

lsst.meas.algorithms.setPrimaryFlags.SetPrimaryFlagsTask.fromBlendKey

Definition at line 89 of file setPrimaryFlags.py.

◆ includeDeblend

lsst.meas.algorithms.setPrimaryFlags.SetPrimaryFlagsTask.includeDeblend

Definition at line 63 of file setPrimaryFlags.py.

◆ isDeblendedModelKey

lsst.meas.algorithms.setPrimaryFlags.SetPrimaryFlagsTask.isDeblendedModelKey

Definition at line 98 of file setPrimaryFlags.py.

◆ isDeblendedSourceKey

lsst.meas.algorithms.setPrimaryFlags.SetPrimaryFlagsTask.isDeblendedSourceKey

Definition at line 85 of file setPrimaryFlags.py.

◆ isIsolatedKey

lsst.meas.algorithms.setPrimaryFlags.SetPrimaryFlagsTask.isIsolatedKey

Definition at line 93 of file setPrimaryFlags.py.

◆ isPatchInnerKey

lsst.meas.algorithms.setPrimaryFlags.SetPrimaryFlagsTask.isPatchInnerKey

Definition at line 68 of file setPrimaryFlags.py.

◆ isPrimaryKey

lsst.meas.algorithms.setPrimaryFlags.SetPrimaryFlagsTask.isPrimaryKey

Definition at line 78 of file setPrimaryFlags.py.

◆ isSingleFrame

lsst.meas.algorithms.setPrimaryFlags.SetPrimaryFlagsTask.isSingleFrame

Definition at line 62 of file setPrimaryFlags.py.

◆ isTractInnerKey

lsst.meas.algorithms.setPrimaryFlags.SetPrimaryFlagsTask.isTractInnerKey

Definition at line 72 of file setPrimaryFlags.py.

◆ schema

lsst.meas.algorithms.setPrimaryFlags.SetPrimaryFlagsTask.schema

Definition at line 61 of file setPrimaryFlags.py.


The documentation for this class was generated from the following file: