134 def run(self, exposure, sources, expId=0, matches=None):
139 exposure : `lsst.afw.image.Exposure`
140 Exposure to process; measured PSF will be added.
142 Measured sources on exposure; flag fields will be set marking
143 stars chosen by the star selector and the PSF determiner if a schema
144 was passed to the task constructor.
145 expId : `int`, optional
146 Exposure id used for generating random seed.
147 matches : `list`, optional
148 A list of ``lsst.afw.table.ReferenceMatch`` objects
149 (i.e. of ``lsst.afw.table.Match`` with @c first being
150 of type ``lsst.afw.table.SimpleRecord`` and @c second
151 type lsst.afw.table.SourceRecord --- the reference object and detected
152 object respectively) as returned by @em e.g. the AstrometryTask.
153 Used by star selectors that choose to refer to an external catalog.
157 measurement : `lsst.pipe.base.Struct`
158 PSF measurement as a struct with attributes:
161 The measured PSF (also set in the input exposure).
163 An `lsst.afw.math.SpatialCellSet` containing the PSF candidates
164 as returned by the psf determiner.
166 self.log.info(
"Measuring PSF")
172 displayPsfCandidates =
lsstDebug.Info(__name__).displayPsfCandidates
180 stars = self.starSelector.run(sourceCat=sources, matches=matches, exposure=exposure)
181 selectionResult = self.makePsfCandidates.run(stars.sourceCat, exposure=exposure)
182 self.log.info(
"PSF star selector found %d candidates", len(selectionResult.psfCandidates))
183 reserveResult = self.reserve.run(selectionResult.goodStarCat, expId=expId)
185 psfDeterminerList = [cand
for cand, use
186 in zip(selectionResult.psfCandidates, reserveResult.use)
if use]
188 if selectionResult.psfCandidates
and self.
candidateKey is not None:
189 for cand
in selectionResult.psfCandidates:
190 source = cand.getSource()
193 self.log.info(
"Sending %d candidates to PSF determiner", len(psfDeterminerList))
198 disp = afwDisplay.Display(frame=frame)
199 disp.mtv(exposure, title=
"psf determination")
204 psf, cellSet = self.psfDeterminer.determinePsf(exposure, psfDeterminerList, self.metadata,
206 self.log.info(
"PSF determination using %d/%d stars.",
207 self.metadata.getScalar(
"numGoodStars"), self.metadata.getScalar(
"numAvailStars"))
214 disp = afwDisplay.Display(frame=frame)
218 if displayPsfCandidates:
224 showBadCandidates=showBadCandidates,
225 normalizeResiduals=normalizeResiduals,
228 disp = afwDisplay.Display(frame=frame)
229 maUtils.showPsfMosaic(exposure, psf, display=disp, showFwhm=
True)
230 disp.scale(
"linear", 0, 1)
233 return pipeBase.Struct(