Пример #1
0
    def show_diff(self, sensorRef, display):

        subtractedExposure = sensorRef.get("deepDiff_differenceExp", immediate=True)
        diaSources = sensorRef.get("deepDiff_diaSrc", immediate=True)

        print(display._defaultMaskPlaneColor)
        display.mtv(subtractedExposure)

        mi = subtractedExposure.getMaskedImage()
        x0, y0 = mi.getX0(), mi.getY0()
        for s in diaSources:
            x, y = s.getX() - x0, s.getY() - y0
            # Measurement is currently a hodge-podge, and I don't know what flags are
            # working and which are not. Skipping this and displaying all sources.
            if False:
                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"
            else:
                ptype = "x"

            display.dot(ptype, x, y, size=15)

        # This is broken, not sure if showDiaSources() is functional.
        if False:
            #flagChecker   = SourceFlagChecker(diaSources)
            #isFlagged     = [flagChecker(x) for x in diaSources]
            isFlagged = [False for x in diaSources]
            #isDipole      = [x.get("classification.dipole") for x in diaSources]
            isDipole = [False for x in diaSources]
            diUtils.showDiaSources(diaSources, diff_exposure, isFlagged, isDipole,
                                   frame=2)
Пример #2
0
    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
Пример #3
0
    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