23__all__ = [
"MakePsfCandidatesConfig",
"MakePsfCandidatesTask"]
31import lsst.pipe.base
as pipeBase
32from .
import makePsfCandidate
36 kernelSize = pexConfig.Field[int](
37 doc=
"Size of the postage stamp in pixels (excluding the border) around each star that is extracted "
38 "for fitting. Should be odd and preferably at least 25.",
41 borderWidth = pexConfig.Field[int](
42 doc=
"Number of pixels to ignore around the edge of PSF candidate postage stamps",
48 """Create PSF candidates given an input catalog.
50 ConfigClass = MakePsfCandidatesConfig
51 _DefaultName = "makePsfCandidates"
53 def run(self, starCat, exposure, psfCandidateField=None):
54 """Make a list of PSF candidates from a star catalog.
59 Catalog of stars, as returned by
60 ``lsst.meas.algorithms.starSelector.run()``.
62 The exposure containing the sources.
63 psfCandidateField : `str`, optional
64 Name of flag field to set
True for PSF candidates,
or None to
not
65 set a field; the field
is left unchanged
for non-candidates.
69 struct : `lsst.pipe.base.Struct`
70 Results struct containing:
72 - ``psfCandidates`` : List of PSF candidates
74 - ``goodStarCat`` : Subset of ``starCat`` that was successfully made
80 if psfCandidateField
is not None:
81 isStarKey = starCat.schema[psfCandidateField].asKey()
82 for star
in psfResult.goodStarCat:
83 star.set(isStarKey,
True)
87 def makePsfCandidates(self, starCat, exposure):
88 """Make a list of PSF candidates from a star catalog.
93 Catalog of stars, as returned by
94 ``lsst.meas.algorithms.starSelector.run()``.
96 The exposure containing the sources.
100 struct : `lsst.pipe.base.Struct`
101 Results struct containing:
103 - ``psfCandidates`` : List of PSF candidates
105 - ``goodStarCat`` : Subset of ``starCat`` that was successfully made
108 goodStarCat = SourceCatalog(starCat.schema)
110 psfCandidateList = []
114 psfCandidate = makePsfCandidate(star, exposure)
120 psfCandidate.setBorderWidth(self.config.borderWidth)
121 psfCandidate.setWidth(self.config.kernelSize + 2*self.config.borderWidth)
122 psfCandidate.setHeight(self.config.kernelSize + 2*self.config.borderWidth)
125 im = psfCandidate.getMaskedImage().getImage()
127 self.log.warning(
"Failed to make a psfCandidate from star %d: %s", star.getId(), err)
130 vmax = afwMath.makeStatistics(im, afwMath.MAX).getValue()
131 if not np.isfinite(vmax):
133 psfCandidateList.append(psfCandidate)
134 goodStarCat.append(star)
136 return pipeBase.Struct(
137 psfCandidates=psfCandidateList,
138 goodStarCat=goodStarCat,
Class stored in SpatialCells for spatial Psf fitting.
def run(self, starCat, exposure, psfCandidateField=None)
def makePsfCandidates(self, starCat, exposure)