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()
132 self.log.warning(
"Could not get stamp for psfCandidate with source id=%s: %s",
133 star.getId(), psfCandidate)
136 self.log.error(
"%s raised making psfCandidate from source id=%s: %s",
137 e.__class__.__name__, star.getId(), psfCandidate)
138 self.log.error(
"psfCandidate exception: %s", e)
141 vmax = afwMath.makeStatistics(im, afwMath.MAX).getValue()
142 if not np.isfinite(vmax):
144 if 'psf_max_value' in star.schema:
145 star[
'psf_max_value'] = vmax
146 psfCandidateList.append(psfCandidate)
147 goodStarCat.append(star)
149 return pipeBase.Struct(
150 psfCandidates=psfCandidateList,
151 goodStarCat=goodStarCat,