LSST Applications 24.1.5,g02d81e74bb+fa3a7a026e,g180d380827+a53a32eff8,g2079a07aa2+86d27d4dc4,g2305ad1205+c0501b3732,g295015adf3+7d3e92f0ec,g2bbee38e9b+0e5473021a,g337abbeb29+0e5473021a,g33d1c0ed96+0e5473021a,g3a166c0a6a+0e5473021a,g3ddfee87b4+5dd1654d75,g48712c4677+3bf1020dcb,g487adcacf7+065c13d9cf,g50ff169b8f+96c6868917,g52b1c1532d+585e252eca,g591dd9f2cf+d7ac436cfb,g5a732f18d5+53520f316c,g64a986408d+fa3a7a026e,g858d7b2824+fa3a7a026e,g8a8a8dda67+585e252eca,g99cad8db69+a5a909b84f,g9ddcbc5298+9a081db1e4,ga1e77700b3+15fc3df1f7,ga8c6da7877+4cf350ccb2,gb0e22166c9+60f28cb32d,gba4ed39666+c2a2e4ac27,gbb8dafda3b+f991a0b59f,gc120e1dc64+9ccbfdb8be,gc28159a63d+0e5473021a,gcf0d15dbbd+5dd1654d75,gd96a1ce819+42fd0ee607,gdaeeff99f8+f9a426f77a,ge6526c86ff+0d71447b4b,ge79ae78c31+0e5473021a,gee10cc3b42+585e252eca,gff1a9f87cc+fa3a7a026e
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.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
 

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 775 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 782 of file imageDecorrelation.py.

782 def __init__(self, *args, **kwargs):
783 """Create the image decorrelation Task
784
785 Parameters
786 ----------
787 args :
788 arguments to be passed to
789 `lsst.pipe.base.task.Task.__init__`
790 kwargs :
791 additional keyword arguments to be passed to
792 `lsst.pipe.base.task.Task.__init__`
793 """
794 pipeBase.Task.__init__(self, *args, **kwargs)
795
796 self.statsControl = afwMath.StatisticsControl()
797 self.statsControl.setNumSigmaClip(3.)
798 self.statsControl.setNumIter(3)
799 self.statsControl.setAndMask(afwImage.Mask.getPlaneBitMask(self.config.ignoreMaskPlanes))
800
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 801 of file imageDecorrelation.py.

801 def computeVarianceMean(self, exposure):
802 """Compute the mean of the variance plane of `exposure`.
803 """
804 statObj = afwMath.makeStatistics(exposure.variance,
805 exposure.mask,
806 afwMath.MEANCLIP, self.statsControl)
807 var = statObj.getValue(afwMath.MEANCLIP)
808 return var
809
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 810 of file imageDecorrelation.py.

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

Member Data Documentation

◆ _DefaultName

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

Definition at line 780 of file imageDecorrelation.py.

◆ ConfigClass

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

Definition at line 779 of file imageDecorrelation.py.

◆ statsControl

lsst.ip.diffim.imageDecorrelation.DecorrelateALKernelSpatialTask.statsControl

Definition at line 796 of file imageDecorrelation.py.


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