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 125 of file zogy.py.
def lsst.ip.diffim.zogy.ZogyTask.__init__ |
( |
|
self, |
|
|
|
templateExposure = None , |
|
|
|
scienceExposure = None , |
|
|
|
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 135 of file zogy.py.
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.array`s containing the values in eqs. 30 and 32 of
ZOGY (2016).
Definition at line 615 of file zogy.py.
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 427 of file zogy.py.
def lsst.ip.diffim.zogy.ZogyTask.computeDiffim |
( |
|
self, |
|
|
|
inImageSpace = None , |
|
|
|
padSize = None , |
|
|
|
returnMatchedTemplate = False , |
|
|
|
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
returnMatchedTemplate : bool
Include the PSF-matched template in the results Struct
**kwargs : `dict`
additional keyword arguments to be passed to
`computeDiffimFourierSpace` or `computeDiffimImageSpace`.
Returns
-------
An lsst.pipe.base.Struct containing:
- D : `lsst.afw.Exposure`
the proper image difference, including correct variance,
masks, and PSF
- R : `lsst.afw.Exposure`
If `returnMatchedTemplate` is True, the PSF-matched template
exposure
Definition at line 532 of file zogy.py.
def lsst.ip.diffim.zogy.ZogyTask.computeDiffimFourierSpace |
( |
|
self, |
|
|
|
debug = False , |
|
|
|
returnMatchedTemplate = 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 348 of file zogy.py.
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 463 of file zogy.py.
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 582 of file zogy.py.
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 301 of file zogy.py.
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 794 of file zogy.py.
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 668 of file zogy.py.
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.image.Exposure`, the proper image difference, including correct
variance, masks, and PSF
Definition at line 732 of file zogy.py.
def lsst.ip.diffim.zogy.ZogyTask.setup |
( |
|
self, |
|
|
|
templateExposure = None , |
|
|
|
scienceExposure = None , |
|
|
|
sig1 = None , |
|
|
|
sig2 = None , |
|
|
|
psf1 = None , |
|
|
|
psf2 = None , |
|
|
|
correctBackground = False , |
|
|
|
args, |
|
|
|
kwargs |
|
) |
| |
Set up 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`.
correctBackground : `bool`
(Optional) subtract sigma-clipped mean of exposures. Zogy doesn't correct
nonzero backgrounds (unlike AL) so subtract them here.
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 170 of file zogy.py.