87 def makePsfCandidates(self, starCat, exposure):
88 """Make a list of PSF candidates from a star catalog.
92 starCat : `lsst.afw.table.SourceCatalog`
93 Catalog of stars, as returned by
94 ``lsst.meas.algorithms.starSelector.run()``.
95 exposure : `lsst.afw.image.Exposure`
96 The exposure containing the sources.
100 struct : `lsst.pipe.base.Struct`
101 Results struct containing:
103 - ``psfCandidates`` : List of PSF candidates
104 (`list` of `lsst.meas.algorithms.PsfCandidate`).
105 - ``goodStarCat`` : Subset of ``starCat`` that was successfully made
106 into PSF candidates (`lsst.afw.table.SourceCatalog`).
108 goodStarCat = SourceCatalog(starCat.schema)
110 psfCandidateList = []
113 psfCandidate = makePsfCandidate(star, exposure)
119 psfCandidate.setBorderWidth(self.config.borderWidth)
120 psfCandidate.setWidth(self.config.kernelSize + 2*self.config.borderWidth)
121 psfCandidate.setHeight(self.config.kernelSize + 2*self.config.borderWidth)
124 im = psfCandidate.getMaskedImage().getImage()
126 self.log.warning(
"Could not get stamp for psfCandidate with source id=%s: %s",
127 star.getId(), psfCandidate)
130 self.log.error(
"%s raised making psfCandidate from source id=%s: %s",
131 e.__class__.__name__, star.getId(), psfCandidate)
132 self.log.error(
"psfCandidate exception: %s", e)
135 vmax = afwMath.makeStatistics(im, afwMath.MAX).getValue()
136 if not np.isfinite(vmax):
138 psfCandidateList.append(psfCandidate)
139 goodStarCat.append(star)
141 return pipeBase.Struct(
142 psfCandidates=psfCandidateList,
143 goodStarCat=goodStarCat,