24 import lsst.afw.math
as afwMath
26 import lsst.afw.display.ds9
as ds9
28 args = [
None,
"MatchList",
None]
32 """Get a list of suitable stars to construct a PSF."""
35 display = lsstDebug.Info(__name__).display
36 displayExposure = lsstDebug.Info(__name__).displayExposure
40 kernelSize = psfPolicy.get(
"kernelSize")
41 borderWidth = psfPolicy.get(
"borderWidth")
42 sizePsfCellX = psfPolicy.get(
"sizeCellX")
43 sizePsfCellY = psfPolicy.get(
"sizeCellY")
45 mi = exposure.getMaskedImage()
47 if display
and displayExposure:
49 ds9.mtv(mi, frame=frame, title=
"PSF candidates")
51 psfCellSet = afwMath.SpatialCellSet(mi.getBBox(), sizePsfCellX, sizePsfCellY)
55 ref, source = val[0:2]
56 if not (ref.getFlagForDetection() & measAlg.Flags.STAR)
or \
57 (source.getFlagForDetection() & measAlg.Flags.BAD):
65 if cand.getWidth() == 0:
66 cand.setBorderWidth(borderWidth)
67 cand.setWidth(kernelSize + 2*borderWidth)
68 cand.setHeight(kernelSize + 2*borderWidth)
70 im = cand.getMaskedImage().getImage()
71 max = afwMath.makeStatistics(im, afwMath.MAX).getValue()
72 if not numpy.isfinite(max):
75 psfCellSet.insertCandidate(cand)
77 if display
and displayExposure:
78 ds9.dot(
"+", source.getXAstrom() - mi.getX0(), source.getYAstrom() - mi.getY0(),
79 size=4, frame=frame, ctype=ds9.CYAN)
80 ds9.dot(
"o", source.getXAstrom() - mi.getX0(), source.getYAstrom() - mi.getY0(),
81 size=4, frame=frame, ctype=ds9.CYAN)
85 source.setFlagForDetection(source.getFlagForDetection() | measAlg.Flags.STAR)
88 return psfStars, psfCellSet
Fit spatial kernel using approximate fluxes for candidates, and solving a linear system of equations...
std::shared_ptr< PsfCandidate< PixelT > > makePsfCandidate(boost::shared_ptr< afw::table::SourceRecord > const &source, boost::shared_ptr< afw::image::Exposure< PixelT > > image)
Return a PsfCandidate of the right sort.