LSST Applications g044012fb7c+6976b5ec80,g04a91732dc+88a5fc122b,g07dc498a13+7e3c5f68a2,g114c6a66ad+09472d7a76,g1409bbee79+7e3c5f68a2,g1a7e361dbc+7e3c5f68a2,g1fd858c14a+3a43eabc0e,g35bb328faa+fcb1d3bbc8,g3bd4b5ce2c+2647bb081c,g4e0f332c67+5d362be553,g53246c7159+fcb1d3bbc8,g5477a8d5ce+b19c77c7ae,g58d0cdf3ff+4a2e102ff8,g60b5630c4e+09472d7a76,g623d845a50+09472d7a76,g6f0c2978f1+fcf1c0bcd6,g71fabbc107+09472d7a76,g75b6c65c88+d0b1dc44cc,g78460c75b0+2f9a1b4bcd,g786e29fd12+cf7ec2a62a,g7b71ed6315+fcb1d3bbc8,g8852436030+349c7e81d4,g89139ef638+7e3c5f68a2,g9125e01d80+fcb1d3bbc8,g95236ca021+f7a31438ed,g989de1cb63+7e3c5f68a2,g9f33ca652e+f17d666fbc,gaaedd4e678+7e3c5f68a2,gabe3b4be73+1e0a283bba,gb1101e3267+f870f33517,gb58c049af0+f03b321e39,gc99c83e5f0+76d20ab76d,gcf25f946ba+349c7e81d4,gd0fa69b896+f3a65fa83c,gd6cbbdb0b4+c8606af20c,gde0f65d7ad+5bd27d919f,ge278dab8ac+932305ba37,gfba249425e+fcb1d3bbc8,w.2025.07
LSST Data Management Base Package
Loading...
Searching...
No Matches
lsst.ip.diffim.imageDecorrelation.DecorrelateALKernelSpatialTask Class Reference
Inheritance diagram for lsst.ip.diffim.imageDecorrelation.DecorrelateALKernelSpatialTask:

Public Member Functions

 __init__ (self, *args, **kwargs)
 
 computeVarianceMean (self, exposure)
 
 run (self, scienceExposure, templateExposure, subtractedExposure, psfMatchingKernel, spatiallyVarying=True, preConvKernel=None, templateMatched=True, preConvMode=False)
 

Public Attributes

 statsControl = afwMath.StatisticsControl()
 

Static Public Attributes

 ConfigClass = DecorrelateALKernelSpatialConfig
 

Static Protected Attributes

str _DefaultName = "ip_diffim_decorrelateALKernelSpatial"
 

Detailed Description

Decorrelate the effect of convolution by Alard-Lupton matching kernel in image difference

Definition at line 779 of file imageDecorrelation.py.

Constructor & Destructor Documentation

◆ __init__()

lsst.ip.diffim.imageDecorrelation.DecorrelateALKernelSpatialTask.__init__ ( self,
* args,
** kwargs )
Create the image decorrelation Task

Parameters
----------
args :
    arguments to be passed to
    `lsst.pipe.base.task.Task.__init__`
kwargs :
    additional keyword arguments to be passed to
    `lsst.pipe.base.task.Task.__init__`

Definition at line 786 of file imageDecorrelation.py.

786 def __init__(self, *args, **kwargs):
787 """Create the image decorrelation Task
788
789 Parameters
790 ----------
791 args :
792 arguments to be passed to
793 `lsst.pipe.base.task.Task.__init__`
794 kwargs :
795 additional keyword arguments to be passed to
796 `lsst.pipe.base.task.Task.__init__`
797 """
798 pipeBase.Task.__init__(self, *args, **kwargs)
799
800 self.statsControl = afwMath.StatisticsControl()
801 self.statsControl.setNumSigmaClip(3.)
802 self.statsControl.setNumIter(3)
803 self.statsControl.setAndMask(afwImage.Mask.getPlaneBitMask(self.config.ignoreMaskPlanes))
804
Pass parameters to a Statistics object.
Definition Statistics.h:83

Member Function Documentation

◆ computeVarianceMean()

lsst.ip.diffim.imageDecorrelation.DecorrelateALKernelSpatialTask.computeVarianceMean ( self,
exposure )
Compute the mean of the variance plane of `exposure`.

Definition at line 805 of file imageDecorrelation.py.

805 def computeVarianceMean(self, exposure):
806 """Compute the mean of the variance plane of `exposure`.
807 """
808 statObj = afwMath.makeStatistics(exposure.variance,
809 exposure.mask,
810 afwMath.MEANCLIP, self.statsControl)
811 var = statObj.getValue(afwMath.MEANCLIP)
812 return var
813
Statistics makeStatistics(lsst::afw::image::Image< Pixel > const &img, lsst::afw::image::Mask< image::MaskPixel > const &msk, int const flags, StatisticsControl const &sctrl=StatisticsControl())
Handle a watered-down front-end to the constructor (no variance)
Definition Statistics.h:361

◆ run()

lsst.ip.diffim.imageDecorrelation.DecorrelateALKernelSpatialTask.run ( self,
scienceExposure,
templateExposure,
subtractedExposure,
psfMatchingKernel,
spatiallyVarying = True,
preConvKernel = None,
templateMatched = True,
preConvMode = False )
Perform decorrelation of an image difference exposure.

Decorrelates the diffim due to the convolution of the
templateExposure with the A&L psfMatchingKernel. If
`spatiallyVarying` is True, it utilizes the spatially varying
matching kernel via the `imageMapReduce` framework to perform
spatially-varying decorrelation on a grid of subExposures.

Parameters
----------
scienceExposure : `lsst.afw.image.Exposure`
   the science Exposure used for PSF matching
templateExposure : `lsst.afw.image.Exposure`
   the template Exposure used for PSF matching
subtractedExposure : `lsst.afw.image.Exposure`
   the subtracted Exposure produced by `ip_diffim.ImagePsfMatchTask.subtractExposures()`
psfMatchingKernel : an (optionally spatially-varying) PSF matching kernel produced
   by `ip_diffim.ImagePsfMatchTask.subtractExposures()`
spatiallyVarying : `bool`
   if True, perform the spatially-varying operation
preConvKernel : `lsst.meas.algorithms.Psf`
   if not none, the scienceExposure has been pre-filtered with this kernel. (Currently
   this option is experimental.)
templateMatched : `bool`, optional
   If True, the template exposure was matched (convolved) to the science exposure.
preConvMode : `bool`, optional
    If True, ``subtractedExposure`` is assumed to be a likelihood difference image
    and will be noise corrected as a likelihood image.

Returns
-------
results : `lsst.pipe.base.Struct`
    a structure containing:
    - ``correctedExposure`` : the decorrelated diffim

Definition at line 814 of file imageDecorrelation.py.

815 spatiallyVarying=True, preConvKernel=None, templateMatched=True, preConvMode=False):
816 """Perform decorrelation of an image difference exposure.
817
818 Decorrelates the diffim due to the convolution of the
819 templateExposure with the A&L psfMatchingKernel. If
820 `spatiallyVarying` is True, it utilizes the spatially varying
821 matching kernel via the `imageMapReduce` framework to perform
822 spatially-varying decorrelation on a grid of subExposures.
823
824 Parameters
825 ----------
826 scienceExposure : `lsst.afw.image.Exposure`
827 the science Exposure used for PSF matching
828 templateExposure : `lsst.afw.image.Exposure`
829 the template Exposure used for PSF matching
830 subtractedExposure : `lsst.afw.image.Exposure`
831 the subtracted Exposure produced by `ip_diffim.ImagePsfMatchTask.subtractExposures()`
832 psfMatchingKernel : an (optionally spatially-varying) PSF matching kernel produced
833 by `ip_diffim.ImagePsfMatchTask.subtractExposures()`
834 spatiallyVarying : `bool`
835 if True, perform the spatially-varying operation
836 preConvKernel : `lsst.meas.algorithms.Psf`
837 if not none, the scienceExposure has been pre-filtered with this kernel. (Currently
838 this option is experimental.)
839 templateMatched : `bool`, optional
840 If True, the template exposure was matched (convolved) to the science exposure.
841 preConvMode : `bool`, optional
842 If True, ``subtractedExposure`` is assumed to be a likelihood difference image
843 and will be noise corrected as a likelihood image.
844
845 Returns
846 -------
847 results : `lsst.pipe.base.Struct`
848 a structure containing:
849 - ``correctedExposure`` : the decorrelated diffim
850 """
851 self.log.info('Running A&L decorrelation: spatiallyVarying=%r', spatiallyVarying)
852
853 svar = self.computeVarianceMean(scienceExposure)
854 tvar = self.computeVarianceMean(templateExposure)
855 if np.isnan(svar) or np.isnan(tvar): # Should not happen unless entire image has been masked.
856 # Double check that one of the exposures is all NaNs
857 if (np.all(np.isnan(scienceExposure.image.array))
858 or np.all(np.isnan(templateExposure.image.array))):
859 self.log.warning('Template or science image is entirely NaNs: skipping decorrelation.')
860 if np.isnan(svar):
861 svar = 1e-9
862 if np.isnan(tvar):
863 tvar = 1e-9
864
865 var = self.computeVarianceMean(subtractedExposure)
866
867 if spatiallyVarying:
868 self.log.info("Variance (science, template): (%f, %f)", svar, tvar)
869 self.log.info("Variance (uncorrected diffim): %f", var)
870 config = self.config.decorrelateMapReduceConfig
871 task = ImageMapReduceTask(config=config)
872 results = task.run(subtractedExposure, science=scienceExposure,
873 template=templateExposure, psfMatchingKernel=psfMatchingKernel,
874 preConvKernel=preConvKernel, forceEvenSized=True,
875 templateMatched=templateMatched, preConvMode=preConvMode)
876 results.correctedExposure = results.exposure
877
878 # Make sure masks of input image are propagated to diffim
879 def gm(exp):
880 return exp.mask
881 gm(results.correctedExposure)[:, :] = gm(subtractedExposure)
882
883 var = self.computeVarianceMean(results.correctedExposure)
884 self.log.info("Variance (corrected diffim): %f", var)
885
886 else:
887 config = self.config.decorrelateConfig
888 task = DecorrelateALKernelTask(config=config)
889 results = task.run(scienceExposure, templateExposure,
890 subtractedExposure, psfMatchingKernel, preConvKernel=preConvKernel,
891 templateMatched=templateMatched, preConvMode=preConvMode)
892
893 return results

Member Data Documentation

◆ _DefaultName

str lsst.ip.diffim.imageDecorrelation.DecorrelateALKernelSpatialTask._DefaultName = "ip_diffim_decorrelateALKernelSpatial"
staticprotected

Definition at line 784 of file imageDecorrelation.py.

◆ ConfigClass

lsst.ip.diffim.imageDecorrelation.DecorrelateALKernelSpatialTask.ConfigClass = DecorrelateALKernelSpatialConfig
static

Definition at line 783 of file imageDecorrelation.py.

◆ statsControl

lsst.ip.diffim.imageDecorrelation.DecorrelateALKernelSpatialTask.statsControl = afwMath.StatisticsControl()

Definition at line 800 of file imageDecorrelation.py.


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