Example #1
0
def run(args):
    #
    # Create the Config and use sum of gaussian basis
    #
    config = ImagePsfMatchTask.ConfigClass()
    config.kernel.name = "AL"
    config.kernel.active.fitForBackground = True
    config.kernel.active.spatialKernelOrder = 1
    config.kernel.active.spatialBgOrder = 0

    # Run the requested method of the Task
    if args.template is not None and args.science is not None:
        if not os.path.isfile(args.template):
            raise Exception, "Template image %s does not exist" % (
                args.template)
        if not os.path.isfile(args.science):
            raise Exception, "Science image %s does not exist" % (args.science)

        try:
            templateExp = afwImage.ExposureF(args.template)
        except pexExcept.LsstCppException, e:
            raise Exception, "Cannot read template image %s" % (args.template)
        try:
            scienceExp = afwImage.ExposureF(args.science)
        except pexExcept.LsstCppException, e:
            raise Exception, "Cannot read science image %s" % (args.science)
Example #2
0
def run(args):
    #
    # Create the Config and use sum of gaussian basis
    #
    config = ImagePsfMatchTask.ConfigClass()
    config.kernel.name = "AL"
    config.kernel.active.fitForBackground = True
    config.kernel.active.spatialKernelOrder = 1
    config.kernel.active.spatialBgOrder = 0

    # Run the requested method of the Task
    if args.template is not None and args.science is not None:
        if not os.path.isfile(args.template):
            raise FileNotFoundError("Template image %s does not exist" %
                                    (args.template))
        if not os.path.isfile(args.science):
            raise FileNotFoundError("Science image %s does not exist" %
                                    (args.science))

        try:
            templateExp = afwImage.ExposureF(args.template)
        except Exception:
            raise RuntimeError("Cannot read template image %s" %
                               (args.template))
        try:
            scienceExp = afwImage.ExposureF(args.science)
        except Exception:
            raise RuntimeError("Cannot read science image %s" % (args.science))
    else:
        templateExp, scienceExp = generateFakeImages()
        config.kernel.active.sizeCellX = 128
        config.kernel.active.sizeCellY = 128

    if args.debug:
        afwDisplay.Display(frame=1).mtv(templateExp,
                                        title="Example script: Input Template")
        afwDisplay.Display(frame=2).mtv(
            scienceExp, title="Example script: Input Science Image")

    # Create the Task
    psfMatchTask = MyImagePsfMatchTask(config=config)

    # Run the Task
    result = psfMatchTask.run(templateExp, scienceExp, args.mode)

    if args.debug:
        # See if the LSST debug has incremented the frame number; if not start with frame 3
        try:
            frame = debug.lsstDebug.frame + 1
        except Exception:
            frame = 3
        afwDisplay.Display(frame=frame).mtv(
            result.matchedExposure,
            title="Example script: Matched Template Image")
        if "subtractedExposure" in result.getDict():
            afwDisplay.Display(frame=frame + 1).mtv(
                result.subtractedExposure,
                title="Example script: Subtracted Image")
 def __init__(self, *args, **kwargs):
     ImagePsfMatchTask.__init__(self, *args, **kwargs)
 def __init__(self, *args, **kwargs):
     ImagePsfMatchTask.__init__(self, *args, **kwargs)