109 """Return a list of Sources for Kernel candidates
111 @param[in] exposure: the exposure containing the sources
112 @param[in] sources: a source list containing sources that may be candidates
113 @param[in] matches: a match vector as produced by meas_astrom; not optional
114 (passing None just allows us to handle the exception better here
115 than in calling code)
117 @return kernelCandidateSourceList: a list of sources to be used as kernel candidates
127 "Cannot use catalog source selector without running astrometry."
130 mi = exposure.getMaskedImage()
134 ds9.mtv(mi, title=
"Kernel candidates", frame=lsstDebug.frame)
138 isGoodSource =
CheckSource(sources, self.config.fluxLim, self.config.fluxMax, self.config.badPixelFlags)
143 kernelCandidateSourceList = []
146 with ds9.Buffering():
147 refSchema = matches[0][0].schema
148 rRefFluxField = measAlg.getRefFluxField(refSchema,
"r")
149 gRefFluxField = measAlg.getRefFluxField(refSchema, "g")
150 for ref, source, d
in matches:
151 if not isGoodSource(source):
152 symb, ctype =
"+", ds9.RED
154 isStar =
not ref.get(
"resolved")
155 isVar =
not ref.get(
"photometric")
160 gMag = -2.5 * np.log10(ref.get(gRefFluxField))
161 rMag = -2.5 * np.log10(ref.get(rRefFluxField))
163 self.log.warn(
"Cannot cut on color info; fields 'g' and 'r' do not exist")
167 isRightColor = (gMag-rMag) >= self.config.grMin
and (gMag-rMag) <= self.config.grMax
169 isRightType = (self.config.selectStar
and isStar)
or (self.config.selectGalaxy
and not isStar)
170 isRightVar = (self.config.includeVariable)
or (self.config.includeVariable
is isVar)
171 if isRightType
and isRightVar
and isRightColor:
172 kernelCandidateSourceList.append(source)
173 symb, ctype =
"+", ds9.GREEN
175 symb, ctype =
"o", ds9.BLUE
177 if display
and displayExposure:
178 ds9.dot(symb, source.getX() - mi.getX0(), source.getY() - mi.getY0(),
179 size=4, ctype=ctype, frame=lsstDebug.frame)
184 raw_input(
"Continue? y[es] p[db] ")
186 return kernelCandidateSourceList
188 measAlg.starSelectorRegistry.register(
"diacatalog", DiaCatalogSourceSelector)