LSST Applications g06d8191974+de063e15a7,g180d380827+d0b6459378,g2079a07aa2+86d27d4dc4,g2305ad1205+f1ae3263cc,g29320951ab+5752d78b6e,g2bbee38e9b+85cf0a37e7,g337abbeb29+85cf0a37e7,g33d1c0ed96+85cf0a37e7,g3a166c0a6a+85cf0a37e7,g3ddfee87b4+b5254b9343,g48712c4677+9ea88d309d,g487adcacf7+05f7dba17f,g50ff169b8f+96c6868917,g52b1c1532d+585e252eca,g591dd9f2cf+48904e3942,g64a986408d+de063e15a7,g858d7b2824+de063e15a7,g864b0138d7+33ab2bc355,g8a8a8dda67+585e252eca,g99cad8db69+4508353287,g9c22b2923f+53520f316c,g9ddcbc5298+9a081db1e4,ga1e77700b3+15fc3df1f7,gb0e22166c9+60f28cb32d,gba4ed39666+c2a2e4ac27,gbb8dafda3b+ccb7f83a87,gc120e1dc64+6caf640b9b,gc28159a63d+85cf0a37e7,gc3e9b769f7+548c5e05a3,gcf0d15dbbd+b5254b9343,gdaeeff99f8+f9a426f77a,ge6526c86ff+515b6c9330,ge79ae78c31+85cf0a37e7,gee10cc3b42+585e252eca,gff1a9f87cc+de063e15a7,w.2024.17
LSST Data Management Base Package
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Static Public Attributes | Static Protected Attributes | List of all members
lsst.ip.diffim.subtractImages.AlardLuptonPreconvolveSubtractTask Class Reference
Inheritance diagram for lsst.ip.diffim.subtractImages.AlardLuptonPreconvolveSubtractTask:
lsst.ip.diffim.subtractImages.AlardLuptonSubtractTask

Public Member Functions

 run (self, template, science, sources, visitSummary=None)
 
 runPreconvolve (self, template, science, matchedScience, selectSources, preConvKernel)
 

Public Attributes

 log
 
 convolutionControl
 

Static Public Attributes

 ConfigClass = AlardLuptonPreconvolveSubtractConfig
 

Static Protected Attributes

str _DefaultName = "alardLuptonPreconvolveSubtract"
 

Detailed Description

Subtract a template from a science image, convolving the science image
before computing the kernel, and also convolving the template before
subtraction.

Definition at line 929 of file subtractImages.py.

Member Function Documentation

◆ run()

lsst.ip.diffim.subtractImages.AlardLuptonPreconvolveSubtractTask.run ( self,
template,
science,
sources,
visitSummary = None )
Preconvolve the science image with its own PSF,
convolve the template image with a PSF-matching kernel and subtract
from the preconvolved science image.

Parameters
----------
template : `lsst.afw.image.ExposureF`
    The template image, which has previously been warped to the science
    image. The template bbox will be padded by a few pixels compared to
    the science bbox.
science : `lsst.afw.image.ExposureF`
    The science exposure.
sources : `lsst.afw.table.SourceCatalog`
    Identified sources on the science exposure. This catalog is used to
    select sources in order to perform the AL PSF matching on stamp
    images around them.
visitSummary : `lsst.afw.table.ExposureCatalog`, optional
    Exposure catalog with complete external calibrations. Catalog uses
    the detector id for the catalog id, sorted on id for fast lookup.

Returns
-------
results : `lsst.pipe.base.Struct`
    ``scoreExposure`` : `lsst.afw.image.ExposureF`
        Result of subtracting the convolved template and science
        images. Attached PSF is that of the original science image.
    ``matchedTemplate`` : `lsst.afw.image.ExposureF`
        Warped and PSF-matched template exposure. Attached PSF is that
        of the original science image.
    ``matchedScience`` : `lsst.afw.image.ExposureF`
        The science exposure after convolving with its own PSF.
        Attached PSF is that of the original science image.
    ``backgroundModel`` : `lsst.afw.math.Function2D`
        Background model that was fit while solving for the
        PSF-matching kernel
    ``psfMatchingKernel`` : `lsst.afw.math.Kernel`
        Final kernel used to PSF-match the template to the science
        image.

Reimplemented from lsst.ip.diffim.subtractImages.AlardLuptonSubtractTask.

Definition at line 937 of file subtractImages.py.

937 def run(self, template, science, sources, visitSummary=None):
938 """Preconvolve the science image with its own PSF,
939 convolve the template image with a PSF-matching kernel and subtract
940 from the preconvolved science image.
941
942 Parameters
943 ----------
944 template : `lsst.afw.image.ExposureF`
945 The template image, which has previously been warped to the science
946 image. The template bbox will be padded by a few pixels compared to
947 the science bbox.
948 science : `lsst.afw.image.ExposureF`
949 The science exposure.
950 sources : `lsst.afw.table.SourceCatalog`
951 Identified sources on the science exposure. This catalog is used to
952 select sources in order to perform the AL PSF matching on stamp
953 images around them.
954 visitSummary : `lsst.afw.table.ExposureCatalog`, optional
955 Exposure catalog with complete external calibrations. Catalog uses
956 the detector id for the catalog id, sorted on id for fast lookup.
957
958 Returns
959 -------
960 results : `lsst.pipe.base.Struct`
961 ``scoreExposure`` : `lsst.afw.image.ExposureF`
962 Result of subtracting the convolved template and science
963 images. Attached PSF is that of the original science image.
964 ``matchedTemplate`` : `lsst.afw.image.ExposureF`
965 Warped and PSF-matched template exposure. Attached PSF is that
966 of the original science image.
967 ``matchedScience`` : `lsst.afw.image.ExposureF`
968 The science exposure after convolving with its own PSF.
969 Attached PSF is that of the original science image.
970 ``backgroundModel`` : `lsst.afw.math.Function2D`
971 Background model that was fit while solving for the
972 PSF-matching kernel
973 ``psfMatchingKernel`` : `lsst.afw.math.Kernel`
974 Final kernel used to PSF-match the template to the science
975 image.
976 """
977 self._prepareInputs(template, science, visitSummary=visitSummary)
978
979 # TODO: DM-37212 we need to mirror the kernel in order to get correct cross correlation
980 scienceKernel = science.psf.getKernel()
981 matchedScience = self._convolveExposure(science, scienceKernel, self.convolutionControl,
982 interpolateBadMaskPlanes=True)
983 self.metadata.add("convolvedExposure", "Preconvolution")
984 try:
985 selectSources = self._sourceSelector(sources, matchedScience.mask)
986 subtractResults = self.runPreconvolve(template, science, matchedScience,
987 selectSources, scienceKernel)
988
989 except (RuntimeError, lsst.pex.exceptions.Exception) as e:
990 self.log.warning("Failed to match template. Checking coverage")
991 # Raise NoWorkFound if template fraction is insufficient
992 checkTemplateIsSufficient(template[science.getBBox()], self.log,
993 self.config.minTemplateFractionForExpectedSuccess,
994 exceptionMessage="Template coverage lower than expected to succeed."
995 f" Failure is tolerable: {e}")
996 # checkTemplateIsSufficient did not raise NoWorkFound, so raise original exception
997 raise e
998
999 return subtractResults
1000
Provides consistent interface for LSST exceptions.
Definition Exception.h:107

◆ runPreconvolve()

lsst.ip.diffim.subtractImages.AlardLuptonPreconvolveSubtractTask.runPreconvolve ( self,
template,
science,
matchedScience,
selectSources,
preConvKernel )
Convolve the science image with its own PSF, then convolve the
template with a matching kernel and subtract to form the Score
exposure.

Parameters
----------
template : `lsst.afw.image.ExposureF`
    Template exposure, warped to match the science exposure.
science : `lsst.afw.image.ExposureF`
    Science exposure to subtract from the template.
matchedScience : `lsst.afw.image.ExposureF`
    The science exposure, convolved with the reflection of its own PSF.
selectSources : `lsst.afw.table.SourceCatalog`
    Identified sources on the science exposure. This catalog is used to
    select sources in order to perform the AL PSF matching on stamp
    images around them.
preConvKernel : `lsst.afw.math.Kernel`
    The reflection of the kernel that was used to preconvolve the
    `science` exposure. Must be normalized to sum to 1.

Returns
-------
results : `lsst.pipe.base.Struct`

    ``scoreExposure`` : `lsst.afw.image.ExposureF`
        Result of subtracting the convolved template and science
        images. Attached PSF is that of the original science image.
    ``matchedTemplate`` : `lsst.afw.image.ExposureF`
        Warped and PSF-matched template exposure. Attached PSF is that
        of the original science image.
    ``matchedScience`` : `lsst.afw.image.ExposureF`
        The science exposure after convolving with its own PSF.
        Attached PSF is that of the original science image.
    ``backgroundModel`` : `lsst.afw.math.Function2D`
        Background model that was fit while solving for the
        PSF-matching kernel
    ``psfMatchingKernel`` : `lsst.afw.math.Kernel`
        Final kernel used to PSF-match the template to the science
        image.

Definition at line 1001 of file subtractImages.py.

1001 def runPreconvolve(self, template, science, matchedScience, selectSources, preConvKernel):
1002 """Convolve the science image with its own PSF, then convolve the
1003 template with a matching kernel and subtract to form the Score
1004 exposure.
1005
1006 Parameters
1007 ----------
1008 template : `lsst.afw.image.ExposureF`
1009 Template exposure, warped to match the science exposure.
1010 science : `lsst.afw.image.ExposureF`
1011 Science exposure to subtract from the template.
1012 matchedScience : `lsst.afw.image.ExposureF`
1013 The science exposure, convolved with the reflection of its own PSF.
1014 selectSources : `lsst.afw.table.SourceCatalog`
1015 Identified sources on the science exposure. This catalog is used to
1016 select sources in order to perform the AL PSF matching on stamp
1017 images around them.
1018 preConvKernel : `lsst.afw.math.Kernel`
1019 The reflection of the kernel that was used to preconvolve the
1020 `science` exposure. Must be normalized to sum to 1.
1021
1022 Returns
1023 -------
1024 results : `lsst.pipe.base.Struct`
1025
1026 ``scoreExposure`` : `lsst.afw.image.ExposureF`
1027 Result of subtracting the convolved template and science
1028 images. Attached PSF is that of the original science image.
1029 ``matchedTemplate`` : `lsst.afw.image.ExposureF`
1030 Warped and PSF-matched template exposure. Attached PSF is that
1031 of the original science image.
1032 ``matchedScience`` : `lsst.afw.image.ExposureF`
1033 The science exposure after convolving with its own PSF.
1034 Attached PSF is that of the original science image.
1035 ``backgroundModel`` : `lsst.afw.math.Function2D`
1036 Background model that was fit while solving for the
1037 PSF-matching kernel
1038 ``psfMatchingKernel`` : `lsst.afw.math.Kernel`
1039 Final kernel used to PSF-match the template to the science
1040 image.
1041 """
1042 bbox = science.getBBox()
1043 innerBBox = preConvKernel.shrinkBBox(bbox)
1044
1045 kernelSources = self.makeKernel.selectKernelSources(template[innerBBox], matchedScience[innerBBox],
1046 candidateList=selectSources,
1047 preconvolved=True)
1048 kernelResult = self.makeKernel.run(template[innerBBox], matchedScience[innerBBox], kernelSources,
1049 preconvolved=True)
1050
1051 matchedTemplate = self._convolveExposure(template, kernelResult.psfMatchingKernel,
1052 self.convolutionControl,
1053 bbox=bbox,
1054 psf=science.psf,
1055 interpolateBadMaskPlanes=True,
1056 photoCalib=science.photoCalib)
1057 score = _subtractImages(matchedScience, matchedTemplate,
1058 backgroundModel=(kernelResult.backgroundModel
1059 if self.config.doSubtractBackground else None))
1060 correctedScore = self.finalize(template[bbox], science, score,
1061 kernelResult.psfMatchingKernel,
1062 templateMatched=True, preConvMode=True,
1063 preConvKernel=preConvKernel)
1064
1065 return lsst.pipe.base.Struct(scoreExposure=correctedScore,
1066 matchedTemplate=matchedTemplate,
1067 matchedScience=matchedScience,
1068 backgroundModel=kernelResult.backgroundModel,
1069 psfMatchingKernel=kernelResult.psfMatchingKernel)
1070
1071

Member Data Documentation

◆ _DefaultName

str lsst.ip.diffim.subtractImages.AlardLuptonPreconvolveSubtractTask._DefaultName = "alardLuptonPreconvolveSubtract"
staticprotected

Definition at line 935 of file subtractImages.py.

◆ ConfigClass

lsst.ip.diffim.subtractImages.AlardLuptonPreconvolveSubtractTask.ConfigClass = AlardLuptonPreconvolveSubtractConfig
static

Definition at line 934 of file subtractImages.py.

◆ convolutionControl

lsst.ip.diffim.subtractImages.AlardLuptonPreconvolveSubtractTask.convolutionControl

Definition at line 1052 of file subtractImages.py.

◆ log

lsst.ip.diffim.subtractImages.AlardLuptonPreconvolveSubtractTask.log

Definition at line 992 of file subtractImages.py.


The documentation for this class was generated from the following file: