lsst.ip.diffim  13.0-22-g3839dbb+23
Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions | Static Private Member Functions | Static Private Attributes | List of all members
lsst.ip.diffim.zogy.ZogyTask Class Reference
Inheritance diagram for lsst.ip.diffim.zogy.ZogyTask:
lsst.ip.diffim.zogy.ZogyMapperSubtask

Public Member Functions

def __init__ (self, templateExposure, scienceExposure, sig1=None, sig2=None, psf1=None, psf2=None, args, kwargs)
 
def computePrereqs (self, psf1=None, psf2=None, padSize=0)
 
def computeDiffimFourierSpace (self, debug=False, kwargs)
 
def computeDiffimImageSpace (self, padSize=None, debug=False, kwargs)
 
def computeDiffim (self, inImageSpace=None, padSize=None, kwargs)
 
def computeDiffimPsf (self, padSize=0, keepFourier=False, psf1=None, psf2=None)
 
def computeScorrFourierSpace (self, xVarAst=0., yVarAst=0., kwargs)
 
def computeScorrImageSpace (self, xVarAst=0., yVarAst=0., padSize=None, kwargs)
 
def computeScorr (self, xVarAst=0., yVarAst=0., inImageSpace=None, padSize=0, kwargs)
 

Public Attributes

 template
 
 science
 
 statsControl
 
 im1
 
 im2
 
 im1_var
 
 im2_var
 
 im1_psf
 
 im2_psf
 
 sig1
 
 sig2
 
 Fr
 
 Fn
 
 padSize
 

Static Public Attributes

 ConfigClass = ZogyConfig
 

Private Member Functions

def _computeVarianceMean (self, exposure)
 
def _doConvolve (self, exposure, kernel, recenterKernel=False)
 Convolve an Exposure with a decorrelation convolution kernel. More...
 
def _setNewPsf (self, exposure, psfArr)
 
def _computeVarAstGradients (self, xVarAst=0., yVarAst=0., inImageSpace=False, R_hat=None, Kr_hat=None, Kr=None, N_hat=None, Kn_hat=None, Kn=None)
 

Static Private Member Functions

def _padPsfToSize (psf, size)
 
def _padPsfToImageSize (psf, im)
 

Static Private Attributes

string _DefaultName = "ip_diffim_Zogy"
 

Detailed Description

Task to perform ZOGY proper image subtraction. See module-level documentation for
additional details.

In all methods, im1 is R (reference, or template) and im2 is N (new, or science).

Definition at line 122 of file zogy.py.

Constructor & Destructor Documentation

◆ __init__()

def lsst.ip.diffim.zogy.ZogyTask.__init__ (   self,
  templateExposure,
  scienceExposure,
  sig1 = None,
  sig2 = None,
  psf1 = None,
  psf2 = None,
  args,
  kwargs 
)
Create the ZOGY task.

Parameters
----------
templateExposure : lsst.afw.image.Exposure
    Template exposure ("Reference image" in ZOGY (2016)).
scienceExposure : lsst.afw.image.Exposure
    Science exposure ("New image" in ZOGY (2016)). Must have already been
    registered and photmetrically matched to template.
sig1 : float
    (Optional) sqrt(variance) of `templateExposure`. If `None`, it is
    computed from the sqrt(mean) of the `templateExposure` variance image.
sig2 : float
    (Optional) sqrt(variance) of `scienceExposure`. If `None`, it is
    computed from the sqrt(mean) of the `scienceExposure` variance image.
psf1 : 2D numpy.array
    (Optional) 2D array containing the PSF image for the template. If
    `None`, it is extracted from the PSF taken at the center of `templateExposure`.
psf2 : 2D numpy.array
    (Optional) 2D array containing the PSF image for the science img. If
    `None`, it is extracted from the PSF taken at the center of `scienceExposure`.
args :
    additional 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 132 of file zogy.py.

Member Function Documentation

◆ _computeVarAstGradients()

def lsst.ip.diffim.zogy.ZogyTask._computeVarAstGradients (   self,
  xVarAst = 0.,
  yVarAst = 0.,
  inImageSpace = False,
  R_hat = None,
  Kr_hat = None,
  Kr = None,
  N_hat = None,
  Kn_hat = None,
  Kn = None 
)
private
Compute the astrometric noise correction terms

Compute the correction for estimated astrometric noise as
proscribed in ZOGY (2016), section 3.3. All convolutions
performed either in real (image) or Fourier space.

Parameters
----------
xVarAst, yVarAst : float
   estimated astrometric noise (variance of astrometric registration errors)
inImageSpace : bool
   Perform all convolutions in real (image) space rather than Fourier space
R_hat : 2-D numpy.array
   (Optional) FFT of template image, only required if `inImageSpace=False`
Kr_hat : 2-D numpy.array
   FFT of Kr kernel (eq. 28 of ZOGY (2016)), only required if `inImageSpace=False`
Kr : 2-D numpy.array
   Kr kernel (eq. 28 of ZOGY (2016)), only required if `inImageSpace=True`.
   Kr is associated with the template (reference).
N_hat : 2-D numpy.array
   FFT of science image, only required if `inImageSpace=False`
Kn_hat : 2-D numpy.array
   FFT of Kn kernel (eq. 29 of ZOGY (2016)), only required if `inImageSpace=False`
Kn : 2-D numpy.array
   Kn kernel (eq. 29 of ZOGY (2016)), only required if `inImageSpace=True`.
   Kn is associated with the science (new) image.

Returns
-------
VastSR, VastSN : 2-D numpy.arrays containing the values in eqs. 30 and 32 of
   ZOGY (2016).

Definition at line 551 of file zogy.py.

◆ _computeVarianceMean()

def lsst.ip.diffim.zogy.ZogyTask._computeVarianceMean (   self,
  exposure 
)
private
Compute the sigma-clipped mean of the variance image of `exposure`.

Definition at line 206 of file zogy.py.

◆ _doConvolve()

def lsst.ip.diffim.zogy.ZogyTask._doConvolve (   self,
  exposure,
  kernel,
  recenterKernel = False 
)
private

Convolve an Exposure with a decorrelation convolution kernel.

Parameters

exposure : lsst.afw.image.Exposure to be convolved. kernel : 2D numpy.array to convolve the image with

Returns

A new lsst.afw.image.Exposure with the convolved pixels and the (possibly re-centered) kernel.

Notes

  • We optionally re-center the kernel if necessary and return the possibly re-centered kernel

Definition at line 381 of file zogy.py.

◆ _padPsfToImageSize()

def lsst.ip.diffim.zogy.ZogyTask._padPsfToImageSize (   psf,
  im 
)
staticprivate
Zero-pad `psf` to same dimensions as im.

Parameters
----------
psf : 2D numpy.array
    Input psf to be padded
im : lsst.afw.Image, MaskedImage or Exposure
    Dimensions of this image are used to set the PSF pad dimensions

Returns
-------
psf : 2D numpy.array
    The padded copy of the input `psf`.

Definition at line 244 of file zogy.py.

◆ _padPsfToSize()

def lsst.ip.diffim.zogy.ZogyTask._padPsfToSize (   psf,
  size 
)
staticprivate
Zero-pad `psf` to the dimensions given by `size`.

Parameters
----------
psf : 2D numpy.array
    Input psf to be padded
size : list
    Two element list containing the dimensions to pad the `psf` to

Returns
-------
psf : 2D numpy.array
    The padded copy of the input `psf`.

Definition at line 216 of file zogy.py.

◆ _setNewPsf()

def lsst.ip.diffim.zogy.ZogyTask._setNewPsf (   self,
  exposure,
  psfArr 
)
private
Utility method to set an exposure's PSF when provided as a 2-d numpy.array

Definition at line 472 of file zogy.py.

◆ computeDiffim()

def lsst.ip.diffim.zogy.ZogyTask.computeDiffim (   self,
  inImageSpace = None,
  padSize = None,
  kwargs 
)
Wrapper method to compute ZOGY proper diffim

This method should be used as the public interface for
computing the ZOGY diffim.

Parameters
----------
inImageSpace : bool
   Override config `inImageSpace` parameter
padSize : int
   Override config `padSize` parameter
**kwargs : dict
    additional keyword arguments to be passed to
    `computeDiffimFourierSpace` or `computeDiffimImageSpace`.

Returns
-------
D : lsst.afw.Exposure
   the proper image difference, including correct variance,
   masks, and PSF

Definition at line 482 of file zogy.py.

◆ computeDiffimFourierSpace()

def lsst.ip.diffim.zogy.ZogyTask.computeDiffimFourierSpace (   self,
  debug = False,
  kwargs 
)
Compute ZOGY diffim `D` as proscribed in ZOGY (2016) manuscript

Compute the ZOGY eqn. (13):
$$
\widehat{D} = \frac{Fr\widehat{Pr}\widehat{N} -
F_n\widehat{Pn}\widehat{R}}{\sqrt{\sigma_n^2 Fr^2
|\widehat{Pr}|^2 + \sigma_r^2 F_n^2 |\widehat{Pn}|^2}}
$$
where $D$ is the optimal difference image, $R$ and $N$ are the
reference and "new" image, respectively, $Pr$ and $P_n$ are their
PSFs, $Fr$ and $Fn$ are their flux-based zero-points (which we
will set to one here), $\sigma_r^2$ and $\sigma_n^2$ are their
variance, and $\widehat{D}$ denotes the FT of $D$.

Returns
-------
A lsst.pipe.base.Struct containing:
- D : 2D numpy.array, the proper image difference
- D_var : 2D numpy.array, the variance image for `D`

Definition at line 309 of file zogy.py.

◆ computeDiffimImageSpace()

def lsst.ip.diffim.zogy.ZogyTask.computeDiffimImageSpace (   self,
  padSize = None,
  debug = False,
  kwargs 
)
Compute ZOGY diffim `D` using image-space convlutions

This method is still being debugged as it results in artifacts
when the PSFs are noisy (see module-level docstring). Thus
there are several options still enabled by the `debug` flag,
which are disabled by defult.

Parameters
----------
padSize : int, the amount to pad the PSFs by
debug : bool, flag to enable debugging tests and options

Returns
-------
D : lsst.afw.Exposure
   the proper image difference, including correct variance,
   masks, and PSF

Definition at line 417 of file zogy.py.

◆ computeDiffimPsf()

def lsst.ip.diffim.zogy.ZogyTask.computeDiffimPsf (   self,
  padSize = 0,
  keepFourier = False,
  psf1 = None,
  psf2 = None 
)
Compute the ZOGY diffim PSF (ZOGY manuscript eq. 14)

Parameters
----------
padSize : int
   Override config `padSize` parameter
keepFourier : bool
   Return the FFT of the diffim PSF (do not inverse-FFT it)
psf1 : 2D numpy.array
    (Optional) Input psf of template, override if already padded
psf2 : 2D numpy.array
    (Optional) Input psf of science image, override if already padded

Returns
-------
Pd : 2D numpy.array, the diffim PSF (or FFT of PSF if `keepFourier=True`)

Definition at line 518 of file zogy.py.

◆ computePrereqs()

def lsst.ip.diffim.zogy.ZogyTask.computePrereqs (   self,
  psf1 = None,
  psf2 = None,
  padSize = 0 
)
Compute standard ZOGY quantities used by (nearly) all methods.

Many of the ZOGY calculations require similar quantities, including
FFTs of the PSFs, and the "denominator" term (e.g. in eq. 13 of
ZOGY manuscript (2016). This function consolidates many of those
operations.

Parameters
----------
psf1 : 2D numpy.array
    (Optional) Input psf of template, override if already padded
psf2 : 2D numpy.array
    (Optional) Input psf of science image, override if already padded

Returns
-------
A lsst.pipe.base.Struct containing:
- Pr : 2D numpy.array, the (possibly zero-padded) template PSF
- Pn : 2D numpy.array, the (possibly zero-padded) science PSF
- Pr_hat : 2D numpy.array, the FFT of `Pr`
- Pn_hat : 2D numpy.array, the FFT of `Pn`
- denom : 2D numpy.array, the denominator of equation (13) in ZOGY (2016) manuscript
- Fd : float, the relative flux scaling factor between science and template

Definition at line 262 of file zogy.py.

◆ computeScorr()

def lsst.ip.diffim.zogy.ZogyTask.computeScorr (   self,
  xVarAst = 0.,
  yVarAst = 0.,
  inImageSpace = None,
  padSize = 0,
  kwargs 
)
Wrapper method to compute ZOGY corrected likelihood image, optimal for
source detection

This method should be used as the public interface for
computing the ZOGY S_corr.

Parameters
----------
xVarAst, yVarAst : float
   estimated astrometric noise (variance of astrometric registration errors)
inImageSpace : bool
   Override config `inImageSpace` parameter
padSize : int
   Override config `padSize` parameter

Returns
-------
S : lsst.afw.image.Exposure, the likelihood exposure S (eq. 12 of ZOGY (2016)),
    including corrected variance, masks, and PSF

Definition at line 729 of file zogy.py.

◆ computeScorrFourierSpace()

def lsst.ip.diffim.zogy.ZogyTask.computeScorrFourierSpace (   self,
  xVarAst = 0.,
  yVarAst = 0.,
  kwargs 
)
Compute corrected likelihood image, optimal for source detection

Compute ZOGY S_corr image. This image can be thresholded for
detection without optimal filtering, and the variance image is
corrected to account for astrometric noise (errors in
astrometric registration whether systematic or due to effects
such as DCR). The calculations here are all performed in
Fourier space, as proscribed in ZOGY (2016).

Parameters
----------
xVarAst, yVarAst : float
   estimated astrometric noise (variance of astrometric registration errors)

Returns
-------
A lsst.pipe.base.Struct containing:
- S : numpy.array, the likelihood image S (eq. 12 of ZOGY (2016))
- S_var : the corrected variance image (denominator of eq. 25 of ZOGY (2016))
- Dpsf : the PSF of the diffim D, likely never to be used.

Definition at line 604 of file zogy.py.

◆ computeScorrImageSpace()

def lsst.ip.diffim.zogy.ZogyTask.computeScorrImageSpace (   self,
  xVarAst = 0.,
  yVarAst = 0.,
  padSize = None,
  kwargs 
)
Compute corrected likelihood image, optimal for source detection

Compute ZOGY S_corr image. This image can be thresholded for
detection without optimal filtering, and the variance image is
corrected to account for astrometric noise (errors in
astrometric registration whether systematic or due to effects
such as DCR). The calculations here are all performed in
Real (image) space.

Parameters
----------
xVarAst, yVarAst : float
   estimated astrometric noise (variance of astrometric registration errors)

Returns
-------
a tuple containing:
- S : lsst.afw.image.Exposure, the likelihood exposure S (eq. 12 of ZOGY (2016)),
    including corrected variance, masks, and PSF
- D : lsst.afw.Exposure, the proper image difference, including correct
    variance, masks, and PSF

Definition at line 668 of file zogy.py.

Member Data Documentation

◆ _DefaultName

string lsst.ip.diffim.zogy.ZogyTask._DefaultName = "ip_diffim_Zogy"
staticprivate

Definition at line 129 of file zogy.py.

◆ ConfigClass

lsst.ip.diffim.zogy.ZogyTask.ConfigClass = ZogyConfig
static

Definition at line 128 of file zogy.py.

◆ Fn

lsst.ip.diffim.zogy.ZogyTask.Fn

Definition at line 203 of file zogy.py.

◆ Fr

lsst.ip.diffim.zogy.ZogyTask.Fr

Definition at line 202 of file zogy.py.

◆ im1

lsst.ip.diffim.zogy.ZogyTask.im1

Definition at line 172 of file zogy.py.

◆ im1_psf

lsst.ip.diffim.zogy.ZogyTask.im1_psf

Definition at line 186 of file zogy.py.

◆ im1_var

lsst.ip.diffim.zogy.ZogyTask.im1_var

Definition at line 174 of file zogy.py.

◆ im2

lsst.ip.diffim.zogy.ZogyTask.im2

Definition at line 173 of file zogy.py.

◆ im2_psf

lsst.ip.diffim.zogy.ZogyTask.im2_psf

Definition at line 187 of file zogy.py.

◆ im2_var

lsst.ip.diffim.zogy.ZogyTask.im2_var

Definition at line 175 of file zogy.py.

◆ padSize

lsst.ip.diffim.zogy.ZogyTask.padSize

Definition at line 204 of file zogy.py.

◆ science

lsst.ip.diffim.zogy.ZogyTask.science

Definition at line 164 of file zogy.py.

◆ sig1

lsst.ip.diffim.zogy.ZogyTask.sig1

Definition at line 199 of file zogy.py.

◆ sig2

lsst.ip.diffim.zogy.ZogyTask.sig2

Definition at line 200 of file zogy.py.

◆ statsControl

lsst.ip.diffim.zogy.ZogyTask.statsControl

Definition at line 166 of file zogy.py.

◆ template

lsst.ip.diffim.zogy.ZogyTask.template

Definition at line 163 of file zogy.py.


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