lsst.ip.diffim  20.0.0
Classes | Functions
lsst.ip.diffim.diffimTools Namespace Reference

Classes

class  NbasisEvaluator
 

Functions

def makeFlatNoiseImage (mi, seedStat=afwMath.MAX)
 Add noise. More...
 
def makePoissonNoiseImage (im)
 
def fakeCoeffs ()
 Make fake images for testing; one is a delta function (or narrow gaussian) and the other is a convolution of this with a spatially varying kernel. More...
 
def makeFakeKernelSet (sizeCell=128, nCell=3, deltaFunctionCounts=1.e4, tGaussianWidth=1.0, addNoise=True, bgValue=100., display=False)
 
def backgroundSubtract (config, maskedImages)
 Background subtraction for ip_diffim. More...
 
def writeKernelCellSet (kernelCellSet, psfMatchingKernel, backgroundModel, outdir)
 More coarse debugging. More...
 
def sourceToFootprintList (candidateInList, templateExposure, scienceExposure, kernelSize, config, log)
 Converting types. More...
 
def sourceTableToCandidateList (sourceTable, templateExposure, scienceExposure, kConfig, dConfig, log, basisList, doBuild=False)
 

Function Documentation

◆ backgroundSubtract()

def lsst.ip.diffim.diffimTools.backgroundSubtract (   config,
  maskedImages 
)

Background subtraction for ip_diffim.

Subtract the background from masked images.

Parameters
----------
config : TODO: DM-17458
    TODO: DM-17458
maskedImages : `list` of `lsst.afw.image.MaskedImage`
    TODO: DM-17458

Returns
-------
TODO: DM-17458
    TODO: DM-17458

Definition at line 289 of file diffimTools.py.

◆ fakeCoeffs()

def lsst.ip.diffim.diffimTools.fakeCoeffs ( )

Make fake images for testing; one is a delta function (or narrow gaussian) and the other is a convolution of this with a spatially varying kernel.

Definition at line 99 of file diffimTools.py.

◆ makeFakeKernelSet()

def lsst.ip.diffim.diffimTools.makeFakeKernelSet (   sizeCell = 128,
  nCell = 3,
  deltaFunctionCounts = 1.e4,
  tGaussianWidth = 1.0,
  addNoise = True,
  bgValue = 100.,
  display = False 
)
Generate test template and science images with sources.

Parameters
----------
sizeCell : `int`, optional
    Size of the square spatial cells in pixels.
nCell : `int`, optional
    Number of adjacent spatial cells in both direction in both images.
deltaFunctionCounts : `float`, optional
    Flux value for the template image sources.
tGaussianWidth : `float`, optional
    Sigma of the generated Gaussian PSF sources in the template image.
addNoise : `bool`, optional
    If `True`, Poisson noise is added to both the generated template
    and science images.
bgValue : `float`, optional
    Background level to be added to the generated science image.
display : `bool`, optional
    If `True` displays the generated template and science images by
    `lsst.afw.display.Display`.

Notes
-----
- The generated images consist of adjacent ``nCell x nCell`` cells, each
  of pixel size ``sizeCell x sizeCell``.
- The sources in the science image are generated by convolving the
  template by ``sKernel``. ``sKernel`` is a spatial `LinearCombinationKernel`
  of hard wired kernel bases functions. The linear combination has first
  order polynomial spatial dependence with polynomial parameters from ``fakeCoeffs()``.
- The template image sources are generated in the center of each spatial
  cell from one pixel, set to `deltaFunctionCounts` counts, then convolved
  by a 2D Gaussian with sigma of `tGaussianWidth` along each axis.
- The sources are also returned in ``kernelCellSet`` each source is "detected"
  exactly at the center of a cell.

Returns
-------
tMi : `lsst.afw.image.MaskedImage`
    Generated template image.
sMi : `lsst.afw.image.MaskedImage`
    Generated science image.
sKernel : `lsst.afw.math.LinearCombinationKernel`
    The spatial kernel used to generate the sources in the science image.
kernelCellSet : `lsst.afw.math.SpatialCellSet`
    Cell grid of `lsst.afw.math.SpatialCell` instances, containing
    `lsst.ip.diffim.KernelCandidate` instances around all the generated sources
    in the science image.
configFake : `lsst.ip.diffim.ImagePsfMatchConfig`
    Config instance used in the image generation.

Definition at line 109 of file diffimTools.py.

◆ makeFlatNoiseImage()

def lsst.ip.diffim.diffimTools.makeFlatNoiseImage (   mi,
  seedStat = afwMath.MAX 
)

Add noise.

Definition at line 52 of file diffimTools.py.

◆ makePoissonNoiseImage()

def lsst.ip.diffim.diffimTools.makePoissonNoiseImage (   im)
Return a Poisson noise image based on im

Parameters
----------
im : `lsst.afw.image.Image`
    image; the output image has the same dtype, dimensions, and shape
    and its expectation value is the value of ``im`` at each pixel

Returns
-------
noiseIm : `lsst.afw.image.Image`
    Newly constructed image instance, same type as ``im``.

Notes
-----
- Warning: This uses an undocumented numpy API (the documented API
    uses a single float expectation value instead of an array).

- Uses numpy.random; you may wish to call numpy.random.seed first.

Definition at line 61 of file diffimTools.py.

◆ sourceTableToCandidateList()

def lsst.ip.diffim.diffimTools.sourceTableToCandidateList (   sourceTable,
  templateExposure,
  scienceExposure,
  kConfig,
  dConfig,
  log,
  basisList,
  doBuild = False 
)
Convert a list of Sources into KernelCandidates.

The KernelCandidates are used for fitting the Psf-matching kernel.

Parameters
----------
sourceTable : TODO: DM-17458
    TODO: DM-17458
templateExposure : TODO: DM-17458
    TODO: DM-17458
scienceExposure : TODO: DM-17458
    TODO: DM-17458
kConfig : TODO: DM-17458
    TODO: DM-17458
dConfig : TODO: DM-17458
    TODO: DM-17458
log : TODO: DM-17458
    TODO: DM-17458
basisList : TODO: DM-17458
    TODO: DM-17458
doBuild : `bool`, optional
    TODO: DM-17458

Returns
-------
TODO: DM-17458
    TODO: DM-17458

Definition at line 472 of file diffimTools.py.

◆ sourceToFootprintList()

def lsst.ip.diffim.diffimTools.sourceToFootprintList (   candidateInList,
  templateExposure,
  scienceExposure,
  kernelSize,
  config,
  log 
)

Converting types.

Convert a list of sources for the PSF-matching Kernel to Footprints.

Parameters
----------
candidateInList : TODO: DM-17458
    Input list of Sources
templateExposure : TODO: DM-17458
    Template image, to be checked for Mask bits in Source Footprint
scienceExposure : TODO: DM-17458
    Science image, to be checked for Mask bits in Source Footprint
kernelSize : TODO: DM-17458
    TODO: DM-17458
config : TODO: DM-17458
    Config that defines the Mask planes that indicate an invalid Source and Bbox grow radius
log : TODO: DM-17458
    Log for output

Returns
-------
candidateOutList : `list`
    a list of dicts having a "source" and "footprint" field, to be used for Psf-matching

Raises
------
RuntimeError
    TODO: DM-17458

Notes
-----
Takes an input list of Sources that were selected to constrain
the Psf-matching Kernel and turns them into a List of Footprints,
which are used to seed a set of KernelCandidates.  The function
checks both the template and science image for masked pixels,
rejecting the Source if certain Mask bits (defined in config) are
set within the Footprint.

Definition at line 372 of file diffimTools.py.

◆ writeKernelCellSet()

def lsst.ip.diffim.diffimTools.writeKernelCellSet (   kernelCellSet,
  psfMatchingKernel,
  backgroundModel,
  outdir 
)

More coarse debugging.

TODO: DM-17458

Parameters
----------
kernelCellSet : TODO: DM-17458
    TODO: DM-17458
psfMatchingKernel : TODO: DM-17458
    TODO: DM-17458
backgroundModel : TODO: DM-17458
    TODO: DM-17458
outdir : TODO: DM-17458
    TODO: DM-17458

Definition at line 331 of file diffimTools.py.