23 __all__ = [
"MakePsfCandidatesConfig", 
"MakePsfCandidatesTask"]
 
   29 import lsst.pex.config 
as pexConfig
 
   32 from . 
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. 
   62         starCat : `lsst.afw.table.SourceCatalog` 
   63             Catalog of stars, as returned by 
   64             ``lsst.meas.algorithms.starSelector.run()``. 
   65         exposure : `lsst.afw.image.Exposure` 
   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 
   77                 (`list` of `lsst.meas.algorithms.PsfCandidate`). 
   78             - ``goodStarCat`` : Subset of ``starCat`` that was successfully made 
   79                 into PSF candidates (`lsst.afw.table.SourceCatalog`). 
   84         if psfCandidateField 
is not None:
 
   85             isStarKey = starCat.schema[psfCandidateField].asKey()
 
   86             for star 
in psfResult.goodStarCat:
 
   87                 star.set(isStarKey, 
True)
 
   92         """Make a list of PSF candidates from a star catalog. 
   96         starCat : `lsst.afw.table.SourceCatalog` 
   97             Catalog of stars, as returned by 
   98             ``lsst.meas.algorithms.starSelector.run()``. 
   99         exposure : `lsst.afw.image.Exposure` 
  100             The exposure containing the sources. 
  104         struct : `lsst.pipe.base.Struct` 
  105             Results struct containing: 
  107             - ``psfCandidates`` : List of PSF candidates 
  108                 (`list` of `lsst.meas.algorithms.PsfCandidate`). 
  109             - ``goodStarCat`` : Subset of ``starCat`` that was successfully made 
  110                 into PSF candidates (`lsst.afw.table.SourceCatalog`). 
  114         psfCandidateList = []
 
  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.
warn(
"Failed to make a psfCandidate from star %d: %s", star.getId(), err)
 
  135             if not np.isfinite(vmax):
 
  137             psfCandidateList.append(psfCandidate)
 
  138             goodStarCat.append(star)
 
  140         return pipeBase.Struct(
 
  141             psfCandidates=psfCandidateList,
 
  142             goodStarCat=goodStarCat,