LSST Applications g034a557a3c+dd8dd8f11d,g0afe43252f+b86e4b8053,g11f7dcd041+017865fdd3,g1cd03abf6b+8446defddb,g1ce3e0751c+f991eae79d,g28da252d5a+ca8a1a9fb3,g2bbee38e9b+b6588ad223,g2bc492864f+b6588ad223,g2cdde0e794+8523d0dbb4,g347aa1857d+b6588ad223,g35bb328faa+b86e4b8053,g3a166c0a6a+b6588ad223,g461a3dce89+b86e4b8053,g52b1c1532d+b86e4b8053,g7f3b0d46df+ad13c1b82d,g80478fca09+f29c5d6c70,g858d7b2824+293f439f82,g8cd86fa7b1+af721d2595,g965a9036f2+293f439f82,g979bb04a14+51ed57f74c,g9ddcbc5298+f24b38b85a,gae0086650b+b86e4b8053,gbb886bcc26+b97e247655,gc28159a63d+b6588ad223,gc30aee3386+a2f0f6cab9,gcaf7e4fdec+293f439f82,gcd45df26be+293f439f82,gcdd4ae20e8+70b5def7e6,gce08ada175+da9c58a417,gcf0d15dbbd+70b5def7e6,gdaeeff99f8+006e14e809,gdbce86181e+6a170ce272,ge3d4d395c2+224150c836,ge5f7162a3a+bb2241c923,ge6cb8fbbf7+d119aed356,ge79ae78c31+b6588ad223,gf048a9a2f4+40ffced2b8,gf0baf85859+b4cca3d10f,w.2024.30
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 990 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 998 of file subtractImages.py.

998 def run(self, template, science, sources, visitSummary=None):
999 """Preconvolve the science image with its own PSF,
1000 convolve the template image with a PSF-matching kernel and subtract
1001 from the preconvolved science image.
1002
1003 Parameters
1004 ----------
1005 template : `lsst.afw.image.ExposureF`
1006 The template image, which has previously been warped to the science
1007 image. The template bbox will be padded by a few pixels compared to
1008 the science bbox.
1009 science : `lsst.afw.image.ExposureF`
1010 The science exposure.
1011 sources : `lsst.afw.table.SourceCatalog`
1012 Identified sources on the science exposure. This catalog is used to
1013 select sources in order to perform the AL PSF matching on stamp
1014 images around them.
1015 visitSummary : `lsst.afw.table.ExposureCatalog`, optional
1016 Exposure catalog with complete external calibrations. Catalog uses
1017 the detector id for the catalog id, sorted on id for fast lookup.
1018
1019 Returns
1020 -------
1021 results : `lsst.pipe.base.Struct`
1022 ``scoreExposure`` : `lsst.afw.image.ExposureF`
1023 Result of subtracting the convolved template and science
1024 images. Attached PSF is that of the original science image.
1025 ``matchedTemplate`` : `lsst.afw.image.ExposureF`
1026 Warped and PSF-matched template exposure. Attached PSF is that
1027 of the original science image.
1028 ``matchedScience`` : `lsst.afw.image.ExposureF`
1029 The science exposure after convolving with its own PSF.
1030 Attached PSF is that of the original science image.
1031 ``backgroundModel`` : `lsst.afw.math.Function2D`
1032 Background model that was fit while solving for the
1033 PSF-matching kernel
1034 ``psfMatchingKernel`` : `lsst.afw.math.Kernel`
1035 Final kernel used to PSF-match the template to the science
1036 image.
1037 """
1038 self._prepareInputs(template, science, visitSummary=visitSummary)
1039
1040 # TODO: DM-37212 we need to mirror the kernel in order to get correct cross correlation
1041 scienceKernel = science.psf.getKernel()
1042 matchedScience = self._convolveExposure(science, scienceKernel, self.convolutionControl,
1043 interpolateBadMaskPlanes=True)
1044 self.metadata.add("convolvedExposure", "Preconvolution")
1045 try:
1046 selectSources = self._sourceSelector(sources, matchedScience.mask)
1047 subtractResults = self.runPreconvolve(template, science, matchedScience,
1048 selectSources, scienceKernel)
1049
1050 except (RuntimeError, lsst.pex.exceptions.Exception) as e:
1051 self.log.warning("Failed to match template. Checking coverage")
1052 # Raise NoWorkFound if template fraction is insufficient
1053 checkTemplateIsSufficient(template[science.getBBox()], self.log,
1054 self.config.minTemplateFractionForExpectedSuccess,
1055 exceptionMessage="Template coverage lower than expected to succeed."
1056 f" Failure is tolerable: {e}")
1057 # checkTemplateIsSufficient did not raise NoWorkFound, so raise original exception
1058 raise e
1059
1060 return subtractResults
1061
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 1062 of file subtractImages.py.

1062 def runPreconvolve(self, template, science, matchedScience, selectSources, preConvKernel):
1063 """Convolve the science image with its own PSF, then convolve the
1064 template with a matching kernel and subtract to form the Score
1065 exposure.
1066
1067 Parameters
1068 ----------
1069 template : `lsst.afw.image.ExposureF`
1070 Template exposure, warped to match the science exposure.
1071 science : `lsst.afw.image.ExposureF`
1072 Science exposure to subtract from the template.
1073 matchedScience : `lsst.afw.image.ExposureF`
1074 The science exposure, convolved with the reflection of its own PSF.
1075 selectSources : `lsst.afw.table.SourceCatalog`
1076 Identified sources on the science exposure. This catalog is used to
1077 select sources in order to perform the AL PSF matching on stamp
1078 images around them.
1079 preConvKernel : `lsst.afw.math.Kernel`
1080 The reflection of the kernel that was used to preconvolve the
1081 `science` exposure. Must be normalized to sum to 1.
1082
1083 Returns
1084 -------
1085 results : `lsst.pipe.base.Struct`
1086
1087 ``scoreExposure`` : `lsst.afw.image.ExposureF`
1088 Result of subtracting the convolved template and science
1089 images. Attached PSF is that of the original science image.
1090 ``matchedTemplate`` : `lsst.afw.image.ExposureF`
1091 Warped and PSF-matched template exposure. Attached PSF is that
1092 of the original science image.
1093 ``matchedScience`` : `lsst.afw.image.ExposureF`
1094 The science exposure after convolving with its own PSF.
1095 Attached PSF is that of the original science image.
1096 ``backgroundModel`` : `lsst.afw.math.Function2D`
1097 Background model that was fit while solving for the
1098 PSF-matching kernel
1099 ``psfMatchingKernel`` : `lsst.afw.math.Kernel`
1100 Final kernel used to PSF-match the template to the science
1101 image.
1102 """
1103 bbox = science.getBBox()
1104 innerBBox = preConvKernel.shrinkBBox(bbox)
1105
1106 kernelSources = self.makeKernel.selectKernelSources(template[innerBBox], matchedScience[innerBBox],
1107 candidateList=selectSources,
1108 preconvolved=True)
1109 kernelResult = self.makeKernel.run(template[innerBBox], matchedScience[innerBBox], kernelSources,
1110 preconvolved=True)
1111
1112 matchedTemplate = self._convolveExposure(template, kernelResult.psfMatchingKernel,
1113 self.convolutionControl,
1114 bbox=bbox,
1115 psf=science.psf,
1116 interpolateBadMaskPlanes=True,
1117 photoCalib=science.photoCalib)
1118 score = _subtractImages(matchedScience, matchedTemplate,
1119 backgroundModel=(kernelResult.backgroundModel
1120 if self.config.doSubtractBackground else None))
1121 correctedScore = self.finalize(template[bbox], science, score,
1122 kernelResult.psfMatchingKernel,
1123 templateMatched=True, preConvMode=True,
1124 preConvKernel=preConvKernel)
1125
1126 return lsst.pipe.base.Struct(scoreExposure=correctedScore,
1127 matchedTemplate=matchedTemplate,
1128 matchedScience=matchedScience,
1129 backgroundModel=kernelResult.backgroundModel,
1130 psfMatchingKernel=kernelResult.psfMatchingKernel)
1131
1132

Member Data Documentation

◆ _DefaultName

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

Definition at line 996 of file subtractImages.py.

◆ ConfigClass

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

Definition at line 995 of file subtractImages.py.

◆ convolutionControl

lsst.ip.diffim.subtractImages.AlardLuptonPreconvolveSubtractTask.convolutionControl

Definition at line 1113 of file subtractImages.py.

◆ log

lsst.ip.diffim.subtractImages.AlardLuptonPreconvolveSubtractTask.log

Definition at line 1053 of file subtractImages.py.


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