def plotPsfCandidates(cellSet, showBadCandidates=False, frame=1): import lsst.afw.display.utils as displayUtils stamps = [] for cell in cellSet.getCellList(): for cand in cell.begin(not showBadCandidates): # maybe include bad candidates try: im = cand.getMaskedImage() chi2 = cand.getChi2() if chi2 < 1e100: chi2 = "%.1f" % chi2 else: chi2 = float("nan") stamps.append((im, "%d%s" % (maUtils.splitId(cand.getSource().getId(), True)["objId"], chi2), cand.getStatus())) except Exception: continue mos = displayUtils.Mosaic() for im, label, status in stamps: im = type(im)(im, True) try: im /= afwMath.makeStatistics(im, afwMath.MAX).getValue() except NotImplementedError: pass mos.append(im, label, ds9.GREEN if status == afwMath.SpatialCellCandidate.GOOD else ds9.YELLOW if status == afwMath.SpatialCellCandidate.UNKNOWN else ds9.RED) if mos.images: mos.makeMosaic(frame=frame, title="Psf Candidates")
def plotPsfCandidates(cellSet, showBadCandidates=False, frame=1): stamps = [] for cell in cellSet.getCellList(): for cand in cell.begin(not showBadCandidates): # maybe include bad candidates try: im = cand.getMaskedImage() chi2 = cand.getChi2() if chi2 < 1e100: chi2 = "%.1f" % chi2 else: chi2 = float("nan") stamps.append((im, "%d%s" % (maUtils.splitId(cand.getSource().getId(), True)["objId"], chi2), cand.getStatus())) except Exception: continue mos = afwDisplay.utils.Mosaic() disp = afwDisplay.Display(frame=frame) for im, label, status in stamps: im = type(im)(im, True) try: im /= afwMath.makeStatistics(im, afwMath.MAX).getValue() except NotImplementedError: pass mos.append(im, label, afwDisplay.GREEN if status == afwMath.SpatialCellCandidate.GOOD else afwDisplay.YELLOW if status == afwMath.SpatialCellCandidate.UNKNOWN else afwDisplay.RED) if mos.images: disp.mtv(mos.makeMosaic(), title="Psf Candidates")
def plotPsfCandidates(cellSet, showBadCandidates=False, frame=1): import lsst.afw.display.utils as displayUtils stamps = [] for cell in cellSet.getCellList(): for cand in cell.begin(not showBadCandidates): # maybe include bad candidates cand = measAlg.cast_PsfCandidateF(cand) try: im = cand.getMaskedImage() chi2 = cand.getChi2() if chi2 < 1e100: chi2 = "%.1f" % chi2 else: chi2 = numpy.nan stamps.append((im, "%d%s" % (maUtils.splitId(cand.getSource().getId(), True)["objId"], chi2), cand.getStatus())) except Exception, e: continue