def runDebug(self, exposure, subtractRes, selectSources, kernelSources, diaSources): """@todo Test and update for current debug display and slot names """ import lsstDebug display = lsstDebug.Info(__name__).display showSubtracted = lsstDebug.Info(__name__).showSubtracted showPixelResiduals = lsstDebug.Info(__name__).showPixelResiduals showDiaSources = lsstDebug.Info(__name__).showDiaSources showDipoles = lsstDebug.Info(__name__).showDipoles maskTransparency = lsstDebug.Info(__name__).maskTransparency if display: import lsst.afw.display.ds9 as ds9 if not maskTransparency: maskTransparency = 0 ds9.setMaskTransparency(maskTransparency) if display and showSubtracted: ds9.mtv(subtractRes.subtractedExposure, frame=lsstDebug.frame, title="Subtracted image") mi = subtractRes.subtractedExposure.getMaskedImage() x0, y0 = mi.getX0(), mi.getY0() with ds9.Buffering(): for s in diaSources: x, y = s.getX() - x0, s.getY() - y0 ctype = "red" if s.get("flags.negative") else "yellow" if (s.get("flags.pixel.interpolated.center") or s.get("flags.pixel.saturated.center") or s.get("flags.pixel.cr.center")): ptype = "x" elif (s.get("flags.pixel.interpolated.any") or s.get("flags.pixel.saturated.any") or s.get("flags.pixel.cr.any")): ptype = "+" else: ptype = "o" ds9.dot(ptype, x, y, size=4, frame=lsstDebug.frame, ctype=ctype) lsstDebug.frame += 1 if display and showPixelResiduals and selectSources: nonKernelSources = [] for source in selectSources: if source not in kernelSources: nonKernelSources.append(source) diUtils.plotPixelResiduals( exposure, subtractRes.warpedExposure, subtractRes.subtractedExposure, subtractRes.kernelCellSet, subtractRes.psfMatchingKernel, subtractRes.backgroundModel, nonKernelSources, self.subtract.config.kernel.active.detectionConfig, origVariance=False) diUtils.plotPixelResiduals( exposure, subtractRes.warpedExposure, subtractRes.subtractedExposure, subtractRes.kernelCellSet, subtractRes.psfMatchingKernel, subtractRes.backgroundModel, nonKernelSources, self.subtract.config.kernel.active.detectionConfig, origVariance=True) if display and showDiaSources: flagChecker = SourceFlagChecker(diaSources) isFlagged = [flagChecker(x) for x in diaSources] isDipole = [x.get("classification.dipole") for x in diaSources] diUtils.showDiaSources(diaSources, subtractRes.subtractedExposure, isFlagged, isDipole, frame=lsstDebug.frame) lsstDebug.frame += 1 if display and showDipoles: DipoleAnalysis().displayDipoles(subtractRes.subtractedExposure, diaSources, frame=lsstDebug.frame) lsstDebug.frame += 1
def runDebug(self, exposure, subtractRes, selectSources, kernelSources, diaSources): """@todo Test and update for current debug display and slot names """ import lsstDebug display = lsstDebug.Info(__name__).display showSubtracted = lsstDebug.Info(__name__).showSubtracted showPixelResiduals = lsstDebug.Info(__name__).showPixelResiduals showDiaSources = lsstDebug.Info(__name__).showDiaSources showDipoles = lsstDebug.Info(__name__).showDipoles maskTransparency = lsstDebug.Info(__name__).maskTransparency if display: import lsst.afw.display.ds9 as ds9 if not maskTransparency: maskTransparency = 0 ds9.setMaskTransparency(maskTransparency) if display and showSubtracted: ds9.mtv(subtractRes.subtractedExposure, frame=lsstDebug.frame, title="Subtracted image") mi = subtractRes.subtractedExposure.getMaskedImage() x0, y0 = mi.getX0(), mi.getY0() with ds9.Buffering(): for s in diaSources: x, y = s.getX() - x0, s.getY() - y0 ctype = "red" if s.get("flags.negative") else "yellow" if (s.get("flags.pixel.interpolated.center") or s.get("flags.pixel.saturated.center") or s.get("flags.pixel.cr.center")): ptype = "x" elif (s.get("flags.pixel.interpolated.any") or s.get("flags.pixel.saturated.any") or s.get("flags.pixel.cr.any")): ptype = "+" else: ptype = "o" ds9.dot(ptype, x, y, size=4, frame=lsstDebug.frame, ctype=ctype) lsstDebug.frame += 1 if display and showPixelResiduals and selectSources: nonKernelSources = [] for source in selectSources: if not source in kernelSources: nonKernelSources.append(source) diUtils.plotPixelResiduals(exposure, subtractRes.warpedExposure, subtractRes.subtractedExposure, subtractRes.kernelCellSet, subtractRes.psfMatchingKernel, subtractRes.backgroundModel, nonKernelSources, self.subtract.config.kernel.active.detectionConfig, origVariance=False) diUtils.plotPixelResiduals(exposure, subtractRes.warpedExposure, subtractRes.subtractedExposure, subtractRes.kernelCellSet, subtractRes.psfMatchingKernel, subtractRes.backgroundModel, nonKernelSources, self.subtract.config.kernel.active.detectionConfig, origVariance=True) if display and showDiaSources: flagChecker = SourceFlagChecker(diaSources) isFlagged = [flagChecker(x) for x in diaSources] isDipole = [x.get("classification.dipole") for x in diaSources] diUtils.showDiaSources(diaSources, subtractRes.subtractedExposure, isFlagged, isDipole, frame=lsstDebug.frame) lsstDebug.frame += 1 if display and showDipoles: DipoleAnalysis().displayDipoles(subtractRes.subtractedExposure, diaSources, frame=lsstDebug.frame) lsstDebug.frame += 1