23__all__ = [
"MakePsfCandidatesConfig",
"MakePsfCandidatesTask"]
31import lsst.pipe.base
as pipeBase
32from .
import makePsfCandidate
36 kernelSize = pexConfig.Field(
37 doc=
"size of the kernel to create",
41 borderWidth = pexConfig.Field(
42 doc=
"number of pixels to ignore around the edge of PSF candidate postage stamps",
49 """Create PSF candidates given an input catalog.
51 ConfigClass = MakePsfCandidatesConfig
52 _DefaultName = "makePsfCandidates"
55 pipeBase.Task.__init__(self, **kwds)
57 def run(self, starCat, exposure, psfCandidateField=None):
58 """Make a list of PSF candidates from a star catalog.
63 Catalog of stars, as returned by
64 ``lsst.meas.algorithms.starSelector.run()``.
66 The exposure containing the sources.
67 psfCandidateField : `str`
or None
68 Name of flag field to set
True for PSF candidates,
or None to
not
69 set a field; the field
is left unchanged
for non-candidates.
73 struct : `lsst.pipe.base.Struct`
74 Results struct containing:
76 - ``psfCandidates`` : List of PSF candidates
78 - ``goodStarCat`` : Subset of ``starCat`` that was successfully made
84 if psfCandidateField
is not None:
85 isStarKey = starCat.schema[psfCandidateField].asKey()
86 for star
in psfResult.goodStarCat:
87 star.set(isStarKey,
True)
91 def makePsfCandidates(self, starCat, exposure):
92 """Make a list of PSF candidates from a star catalog.
97 Catalog of stars, as returned by
98 ``lsst.meas.algorithms.starSelector.run()``.
100 The exposure containing the sources.
104 struct : `lsst.pipe.base.Struct`
105 Results struct containing:
107 - ``psfCandidates`` : List of PSF candidates
109 - ``goodStarCat`` : Subset of ``starCat`` that was successfully made
112 goodStarCat = SourceCatalog(starCat.schema)
114 psfCandidateList = []
118 psfCandidate = makePsfCandidate(star, exposure)
124 psfCandidate.setBorderWidth(self.config.borderWidth)
125 psfCandidate.setWidth(self.config.kernelSize + 2*self.config.borderWidth)
126 psfCandidate.setHeight(self.config.kernelSize + 2*self.config.borderWidth)
129 im = psfCandidate.getMaskedImage().getImage()
131 self.log.warning(
"Failed to make a psfCandidate from star %d: %s", star.getId(), err)
134 vmax = afwMath.makeStatistics(im, afwMath.MAX).getValue()
135 if not np.isfinite(vmax):
137 psfCandidateList.append(psfCandidate)
138 goodStarCat.append(star)
140 return pipeBase.Struct(
141 psfCandidates=psfCandidateList,
142 goodStarCat=goodStarCat,
Class stored in SpatialCells for spatial Psf fitting.
def run(self, starCat, exposure, psfCandidateField=None)
def makePsfCandidates(self, starCat, exposure)
def __init__(self, **kwds)