LSST Applications g0265f82a02+093ff98f47,g02d81e74bb+10352d6f39,g1f3e9fa97e+40b0fc677d,g2079a07aa2+14824f138e,g2bbee38e9b+093ff98f47,g337abbeb29+093ff98f47,g3ddfee87b4+064c02c7ee,g487adcacf7+7e842ebf4b,g50ff169b8f+5929b3527e,g52b1c1532d+a6fc98d2e7,g568d43a26c+1d7ac31cb0,g591dd9f2cf+fb1f69e2ea,g858d7b2824+10352d6f39,g8a8a8dda67+a6fc98d2e7,g8cdfe0ae6a+66d966b544,g99cad8db69+7ce8a7c20a,g9ddcbc5298+d4bad12328,ga1e77700b3+246acaaf9c,ga2e4dd1c03+064c02c7ee,ga8c6da7877+04f6ba86dc,gae46bcf261+093ff98f47,gb0e22166c9+3863383f4c,gba4ed39666+9664299f35,gbb8dafda3b+db40f59a7d,gbeb006f7da+e6a448e96d,gbf5cecdb8a+10352d6f39,gc0f3af6251+10a3fd39cd,gc120e1dc64+5839e50a77,gc28159a63d+093ff98f47,gcf0d15dbbd+064c02c7ee,gd2a12a3803+0c2c227a2b,gdaeeff99f8+a38ce5ea23,ge79ae78c31+093ff98f47,gee10cc3b42+a6fc98d2e7,gf1cff7945b+10352d6f39,w.2024.15
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 917 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 925 of file subtractImages.py.

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

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

Member Data Documentation

◆ _DefaultName

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

Definition at line 923 of file subtractImages.py.

◆ ConfigClass

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

Definition at line 922 of file subtractImages.py.

◆ convolutionControl

lsst.ip.diffim.subtractImages.AlardLuptonPreconvolveSubtractTask.convolutionControl

Definition at line 1040 of file subtractImages.py.

◆ log

lsst.ip.diffim.subtractImages.AlardLuptonPreconvolveSubtractTask.log

Definition at line 980 of file subtractImages.py.


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