lsst.ip.diffim  14.0-9-g330837b
Public Member Functions | Public Attributes | Static Private Attributes | List of all members
lsst.ip.diffim.dipoleFitTask.DipoleFitAlgorithm Class Reference

Lightweight class containing methods for fitting a dipole model in a diffim, used by DipoleFitPlugin. More...

Inheritance diagram for lsst.ip.diffim.dipoleFitTask.DipoleFitAlgorithm:

Public Member Functions

def __init__ (self, diffim, posImage=None, negImage=None)
 Algorithm to run dipole measurement on a diaSource. More...
 
def fitDipoleImpl (self, source, tol=1e-7, rel_weight=0.5, fitBackground=1, bgGradientOrder=1, maxSepInSigma=5., separateNegParams=True, verbose=False)
 Fit a dipole model to an input difference image. More...
 
def fitDipole (self, source, tol=1e-7, rel_weight=0.1, fitBackground=1, maxSepInSigma=5., separateNegParams=True, bgGradientOrder=1, verbose=False, display=False)
 Wrapper around fitDipoleImpl() which performs the fit of a dipole model to an input diaSource. More...
 
def displayFitResults (self, footprint, result)
 Display data, model fits and residuals (currently uses matplotlib display functions). More...
 

Public Attributes

 diffim
 
 posImage
 
 negImage
 
 psfSigma
 
 log
 
 debug
 

Static Private Attributes

string _private_version_ = '0.0.5'
 

Detailed Description

Lightweight class containing methods for fitting a dipole model in a diffim, used by DipoleFitPlugin.

This code is documented in DMTN-007 (http://dmtn-007.lsst.io).

Below is a (somewhat incomplete) list of improvements that would be worth investigating, given the time:

Todo:
  1. evaluate necessity for separate parameters for pos- and neg- images

2. only fit background OUTSIDE footprint (DONE) and dipole params INSIDE footprint (NOT DONE)?

3. correct normalization of least-squares weights based on variance planes

4. account for PSFs that vary across the exposures (should be happening by default?)

5. correctly account for NA/masks (i.e., ignore!)

6. better exception handling in the plugin

7. better classification of dipoles (e.g. by comparing chi2 fit vs. monopole?)

8. (DONE) Initial fast estimate of background gradient(s) params – perhaps using numpy.lstsq

9. (NOT NEEDED - see (2)) Initial fast test whether a background gradient needs to be fit

10. (DONE) better initial estimate for flux when there's a strong gradient

11. (DONE) requires a new package lmfit – investiate others? (astropy/scipy/iminuit?)

Definition at line 432 of file dipoleFitTask.py.

Constructor & Destructor Documentation

◆ __init__()

def lsst.ip.diffim.dipoleFitTask.DipoleFitAlgorithm.__init__ (   self,
  diffim,
  posImage = None,
  negImage = None 
)

Algorithm to run dipole measurement on a diaSource.

Parameters
diffimExposure on which the diaSources were detected
posImage"Positive" exposure from which the template was subtracted
negImage"Negative" exposure which was subtracted from the posImage

Definition at line 458 of file dipoleFitTask.py.

Member Function Documentation

◆ displayFitResults()

def lsst.ip.diffim.dipoleFitTask.DipoleFitAlgorithm.displayFitResults (   self,
  footprint,
  result 
)

Display data, model fits and residuals (currently uses matplotlib display functions).

Parameters
footprintFootprint containing the dipole that was fit
resultlmfit.MinimizerResult object returned by lmfit optimizer

Definition at line 794 of file dipoleFitTask.py.

◆ fitDipole()

def lsst.ip.diffim.dipoleFitTask.DipoleFitAlgorithm.fitDipole (   self,
  source,
  tol = 1e-7,
  rel_weight = 0.1,
  fitBackground = 1,
  maxSepInSigma = 5.,
  separateNegParams = True,
  bgGradientOrder = 1,
  verbose = False,
  display = False 
)

Wrapper around fitDipoleImpl() which performs the fit of a dipole model to an input diaSource.

Actually, fits the subimage bounded by the input source's footprint) and optionally constrain the fit using the pre-subtraction images self.posImage (science) and self.negImage (template). Wraps the output into a pipeBase.Struct named tuple after computing additional statistics such as orientation and SNR.

Parameters
sourceRecord containing the (merged) dipole source footprint detected on the diffim
tolTolerance parameter for scipy.leastsq() optimization
rel_weightWeighting of posImage/negImage relative to the diffim in the fit
fitBackgroundHow to fit linear background gradient in posImage/negImage (see notes)
bgGradientOrderDesired polynomial order of background gradient (allowed are [0,1,2])
maxSepInSigmaAllowed window of centroid parameters relative to peak in input source footprint
separateNegParamsFit separate parameters to the flux and background gradient in the negative images? If true, this adds a separate parameter for the negative flux, and [1, 3, or 6] additional parameters to fit for the background gradient in the negImage. Otherwise, the flux and gradient parameters are constrained to be exactly equal in the fit.
verboseBe verbose
displayDisplay input data, best fit model(s) and residuals in a matplotlib window.
Returns
pipeBase.Struct object containing the fit parameters and other information.
lmfit.MinimizerResult object for debugging and error estimation, etc.
Note
Parameter fitBackground has three options, thus it is an integer:
  • 0: do not fit background at all
  • 1 (default): pre-fit the background using linear least squares and then do not fit it as part of the dipole fitting optimization
  • 2: pre-fit the background using linear least squares (as in 1), and use the parameter estimates from that fit as starting parameters for an integrated "re-fit" of the background as part of the overall dipole fitting optimization.

Definition at line 699 of file dipoleFitTask.py.

◆ fitDipoleImpl()

def lsst.ip.diffim.dipoleFitTask.DipoleFitAlgorithm.fitDipoleImpl (   self,
  source,
  tol = 1e-7,
  rel_weight = 0.5,
  fitBackground = 1,
  bgGradientOrder = 1,
  maxSepInSigma = 5.,
  separateNegParams = True,
  verbose = False 
)

Fit a dipole model to an input difference image.

Actually, fits the subimage bounded by the input source's footprint) and optionally constrain the fit using the pre-subtraction images posImage and negImage.

Returns
lmfit.MinimizerResult object containing the fit parameters and other information.
See also
fitDipole()

Definition at line 480 of file dipoleFitTask.py.

Member Data Documentation

◆ _private_version_

string lsst.ip.diffim.dipoleFitTask.DipoleFitAlgorithm._private_version_ = '0.0.5'
staticprivate

Definition at line 456 of file dipoleFitTask.py.

◆ debug

lsst.ip.diffim.dipoleFitTask.DipoleFitAlgorithm.debug

Definition at line 476 of file dipoleFitTask.py.

◆ diffim

lsst.ip.diffim.dipoleFitTask.DipoleFitAlgorithm.diffim

Definition at line 466 of file dipoleFitTask.py.

◆ log

lsst.ip.diffim.dipoleFitTask.DipoleFitAlgorithm.log

Definition at line 473 of file dipoleFitTask.py.

◆ negImage

lsst.ip.diffim.dipoleFitTask.DipoleFitAlgorithm.negImage

Definition at line 468 of file dipoleFitTask.py.

◆ posImage

lsst.ip.diffim.dipoleFitTask.DipoleFitAlgorithm.posImage

Definition at line 467 of file dipoleFitTask.py.

◆ psfSigma

lsst.ip.diffim.dipoleFitTask.DipoleFitAlgorithm.psfSigma

Definition at line 469 of file dipoleFitTask.py.


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