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.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: