DipoleFitAlgorithm

class lsst.ip.diffim.DipoleFitAlgorithm(diffim, posImage=None, negImage=None)

Bases: object

Fit a dipole model using an image difference.

See also: DMTN-007: Dipole characterization for image differencing.

Methods Summary

displayFitResults(footprint, result)

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

fitDipole(source[, tol, rel_weight, ...])

Fit a dipole model to an input diaSource (wraps fitDipoleImpl).

fitDipoleImpl(source[, tol, rel_weight, ...])

Fit a dipole model to an input difference image.

Methods Documentation

displayFitResults(footprint, result)

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

Parameters:
footprintTODO: DM-17458

Footprint containing the dipole that was fit

resultlmfit.MinimizerResult

lmfit.MinimizerResult object returned by lmfit optimizer

Returns:
figmatplotlib.pyplot.plot
fitDipole(source, tol=1e-07, rel_weight=0.1, fitBackground=1, maxSepInSigma=5.0, separateNegParams=True, bgGradientOrder=1, verbose=False, display=False)

Fit a dipole model to an input diaSource (wraps fitDipoleImpl).

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:
sourcelsst.afw.table.SourceRecord

Record containing the (merged) dipole source footprint detected on the diffim

tolfloat, optional

Tolerance parameter for scipy.leastsq() optimization

rel_weightfloat, optional

Weighting of posImage/negImage relative to the diffim in the fit

fitBackgroundint, {0, 1, 2}, optional

How to fit linear background gradient in posImage/negImage

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

maxSepInSigmafloat, optional

Allowed window of centroid parameters relative to peak in input source footprint

separateNegParamsbool, optional

Fit separate parameters to the flux and background gradient in

bgGradientOrderint, {0, 1, 2}, optional

Desired polynomial order of background gradient

verbose: `bool`, optional

Be verbose

display

Display input data, best fit model(s) and residuals in a matplotlib window.

Returns:
resultstruct

pipeBase.Struct object containing the fit parameters and other information.

resultcallable

lmfit.MinimizerResult object for debugging and error estimation, etc.

Notes

Parameter fitBackground has three options, thus it is an integer:

fitDipoleImpl(source, tol=1e-07, rel_weight=0.5, fitBackground=1, bgGradientOrder=1, maxSepInSigma=5.0, 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.

Parameters:
sourceTODO: DM-17458

TODO: DM-17458

tolfloat, optional

TODO: DM-17458

rel_weightfloat, optional

TODO: DM-17458

fitBackgroundint, optional

TODO: DM-17458

bgGradientOrderint, optional

TODO: DM-17458

maxSepInSigmafloat, optional

TODO: DM-17458

separateNegParamsbool, optional

TODO: DM-17458

verbosebool, optional

TODO: DM-17458

Returns:
resultlmfit.MinimizerResult

return lmfit.MinimizerResult object containing the fit parameters and other information.