33 """Get a list of suitable stars to construct a PSF."""
41 kernelSize = psfPolicy.get(
"kernelSize")
42 borderWidth = psfPolicy.get(
"borderWidth")
43 sizePsfCellX = psfPolicy.get(
"sizeCellX")
44 sizePsfCellY = psfPolicy.get(
"sizeCellY")
46 mi = exposure.getMaskedImage()
48 if display
and displayExposure:
49 disp = afwDisplay.Display(frame=0)
50 disp.mtv(mi, title=
"PSF candidates")
52 psfCellSet = afwMath.SpatialCellSet(mi.getBBox(), sizePsfCellX, sizePsfCellY)
56 ref, source = val[0:2]
57 if not (ref.getFlagForDetection() & measAlg.Flags.STAR)
or \
58 (source.getFlagForDetection() & measAlg.Flags.BAD):
62 cand = measAlg.makePsfCandidate(source, mi)
66 if cand.getWidth() == 0:
67 cand.setBorderWidth(borderWidth)
68 cand.setWidth(kernelSize + 2*borderWidth)
69 cand.setHeight(kernelSize + 2*borderWidth)
71 im = cand.getMaskedImage().getImage()
72 max = afwMath.makeStatistics(im, afwMath.MAX).getValue()
73 if not np.isfinite(max):
76 psfCellSet.insertCandidate(cand)
78 if display
and displayExposure:
79 disp.dot(
"+", source.getXAstrom() - mi.getX0(), source.getYAstrom() - mi.getY0(),
80 size=4, ctype=afwDisplay.CYAN)
81 disp.dot(
"o", source.getXAstrom() - mi.getX0(), source.getYAstrom() - mi.getY0(),
82 size=4, ctype=afwDisplay.CYAN)
86 source.setFlagForDetection(source.getFlagForDetection() | measAlg.Flags.STAR)
89 return psfStars, psfCellSet