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`).
110 psfCandidateList = []
115 psfCandidate.setPsfColorValue(star[
"psf_color_value"])
116 psfCandidate.setPsfColorType(star[
"psf_color_type"])
118 psfCandidate.setPsfColorValue(np.nan)
119 psfCandidate.setPsfColorType(
"")
125 psfCandidate.setBorderWidth(self.config.borderWidth)
126 psfCandidate.setWidth(self.config.kernelSize + 2 * self.config.borderWidth)
127 psfCandidate.setHeight(self.config.kernelSize + 2 * self.config.borderWidth)
130 im = psfCandidate.getMaskedImage().getImage()
133 "Could not get stamp for psfCandidate with source id=%s: %s", star.getId(), psfCandidate
138 "%s raised making psfCandidate from source id=%s: %s",
139 e.__class__.__name__,
143 self.log.error(
"psfCandidate exception: %s", e)
146 vmax = afwMath.makeStatistics(im, afwMath.MAX).getValue()
147 if not np.isfinite(vmax):
149 if "psf_max_value" in star.schema:
150 star[
"psf_max_value"] = vmax
151 psfCandidateList.append(psfCandidate)
152 goodStarCat.append(star)
154 return pipeBase.Struct(
155 psfCandidates=psfCandidateList,
156 goodStarCat=goodStarCat,