LSST Applications g011c388f00+f985364e28,g0265f82a02+cefac37fe7,g16a3bce237+cefac37fe7,g2079a07aa2+b9108c1c87,g2bbee38e9b+cefac37fe7,g337abbeb29+cefac37fe7,g3ddfee87b4+425a3f5e02,g4cf46543a9+2ef32aa566,g50ff169b8f+8309cf5058,g52b1c1532d+43dac7135f,g5d89126706+46afc7f72d,g83996f0134+2fb8039c37,g858d7b2824+59f22cc8bb,g87e100324b+59f22cc8bb,g8a8a8dda67+43dac7135f,g99855d9996+1ea0a8cf94,g9d147d8712+4559cd7206,g9ddcbc5298+389b8f2b7e,ga1e77700b3+4bafba478f,ga8c6da7877+1b58c58f75,gae46bcf261+cefac37fe7,gb700894bec+f0b514b300,gb8350603e9+4979c46fed,gba4ed39666+fb465f0d3e,gbeb006f7da+bf3b4a8997,gc86a011abf+59f22cc8bb,gcf0d15dbbd+425a3f5e02,gd162630629+d0c22ff203,gd44f2fa1a7+91fd017016,gdaeeff99f8+6b435c3f92,ge79ae78c31+cefac37fe7,ge9008a0c34+425a3f5e02,gee10cc3b42+43dac7135f,gf041782ebf+713927f999,gf1cff7945b+59f22cc8bb,w.2024.07
LSST Data Management Base Package
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | List of all members
lsst.ip.diffim.diaCatalogSourceSelector.DiaCatalogSourceSelectorTask Class Reference
Inheritance diagram for lsst.ip.diffim.diaCatalogSourceSelector.DiaCatalogSourceSelectorTask:

Public Member Functions

 selectSources (self, sourceCat, matches=None, exposure=None)
 

Static Public Attributes

 ConfigClass = DiaCatalogSourceSelectorConfig
 
bool usesMatches = True
 

Detailed Description

A task that selects sources for Kernel candidates.

A naive star selector based on second moments. Use with caution.

Definition at line 103 of file diaCatalogSourceSelector.py.

Member Function Documentation

◆ selectSources()

lsst.ip.diffim.diaCatalogSourceSelector.DiaCatalogSourceSelectorTask.selectSources (   self,
  sourceCat,
  matches = None,
  exposure = None 
)
Return a selection of sources for Kernel candidates.

Parameters
----------
sourceCat : `lsst.afw.table.SourceCatalog`
    Catalog of sources to select from.
    This catalog must be contiguous in memory.
matches : `list` of `lsst.afw.table.ReferenceMatch`
     A match vector as produced by meas_astrom.
exposure : `lsst.afw.image.Exposure` or None
    The exposure the catalog was built from; used for debug display.

Returns
-------
struct : `lsst.pipe.base.Struct`
    The struct contains the following data:

    - selected : `array` of `bool``
        Boolean array of sources that were selected, same length as
        sourceCat.

Definition at line 112 of file diaCatalogSourceSelector.py.

112 def selectSources(self, sourceCat, matches=None, exposure=None):
113 """Return a selection of sources for Kernel candidates.
114
115 Parameters
116 ----------
117 sourceCat : `lsst.afw.table.SourceCatalog`
118 Catalog of sources to select from.
119 This catalog must be contiguous in memory.
120 matches : `list` of `lsst.afw.table.ReferenceMatch`
121 A match vector as produced by meas_astrom.
122 exposure : `lsst.afw.image.Exposure` or None
123 The exposure the catalog was built from; used for debug display.
124
125 Returns
126 -------
127 struct : `lsst.pipe.base.Struct`
128 The struct contains the following data:
129
130 - selected : `array` of `bool``
131 Boolean array of sources that were selected, same length as
132 sourceCat.
133 """
134 import lsstDebug
135 display = lsstDebug.Info(__name__).display
136 displayExposure = lsstDebug.Info(__name__).displayExposure
137 pauseAtEnd = lsstDebug.Info(__name__).pauseAtEnd
138
139 if matches is None:
140 raise RuntimeError("DiaCatalogSourceSelector requires matches")
141
142 mi = exposure.getMaskedImage()
143
144 if display and displayExposure:
145 disp = afwDisplay.Display(frame=lsstDebug.frame)
146 disp.mtv(mi, title="Kernel candidates")
147 #
148 # Look for flags in each Source
149 #
150 isGoodSource = CheckSource(sourceCat, self.config.fluxLim, self.config.fluxMax, self.config.badFlags)
151
152 # Go through and find all the acceptable candidates in the catalogue
153 selected = np.zeros(len(sourceCat), dtype=bool)
154
155 if display and displayExposure:
156 symbs = []
157 ctypes = []
158
159 doColorCut = True
160
161 refSchema = matches[0][0].schema
162 rRefFluxField = measAlg.getRefFluxField(refSchema, "r")
163 gRefFluxField = measAlg.getRefFluxField(refSchema, "g")
164 for i, (ref, source, d) in enumerate(matches):
165 if not isGoodSource(source):
166 if display and displayExposure:
167 symbs.append("+")
168 ctypes.append(afwDisplay.RED)
169 else:
170 isStar = not ref.get("resolved")
171 isVar = not ref.get("photometric")
172 gMag = None
173 rMag = None
174 if doColorCut:
175 try:
176 gMag = -2.5 * np.log10(ref.get(gRefFluxField))
177 rMag = -2.5 * np.log10(ref.get(rRefFluxField))
178 except KeyError:
179 self.log.warning("Cannot cut on color info; fields 'g' and 'r' do not exist")
180 doColorCut = False
181 isRightColor = True
182 else:
183 isRightColor = (gMag-rMag) >= self.config.grMin and (gMag-rMag) <= self.config.grMax
184
185 isRightType = (self.config.selectStar and isStar) or (self.config.selectGalaxy and not isStar)
186 isRightVar = (self.config.includeVariable) or (self.config.includeVariable is isVar)
187 if isRightType and isRightVar and isRightColor:
188 selected[i] = True
189 if display and displayExposure:
190 symbs.append("+")
191 ctypes.append(afwDisplay.GREEN)
192 elif display and displayExposure:
193 symbs.append("o")
194 ctypes.append(afwDisplay.BLUE)
195
196 if display and displayExposure:
197 disp = afwDisplay.Display(frame=lsstDebug.frame)
198 with disp.Buffering():
199 for (ref, source, d), symb, ctype in zip(matches, symbs, ctypes):
200 disp.dot(symb, source.getX() - mi.getX0(), source.getY() - mi.getY0(),
201 size=4, ctype=ctype)
202
203 if display:
204 lsstDebug.frame += 1
205 if pauseAtEnd:
206 input("Continue? y[es] p[db] ")
207
208 return Struct(selected=selected)

Member Data Documentation

◆ ConfigClass

lsst.ip.diffim.diaCatalogSourceSelector.DiaCatalogSourceSelectorTask.ConfigClass = DiaCatalogSourceSelectorConfig
static

Definition at line 109 of file diaCatalogSourceSelector.py.

◆ usesMatches

bool lsst.ip.diffim.diaCatalogSourceSelector.DiaCatalogSourceSelectorTask.usesMatches = True
static

Definition at line 110 of file diaCatalogSourceSelector.py.


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