lsst.ip.diffim  16.0-14-g8a3b804
Public Member Functions | Public Attributes | List of all members
lsst.ip.diffim.dipoleFitTask.DipoleModel Class Reference

Lightweight class containing methods for generating a dipole model for fitting to sources in diffims, used by DipoleFitAlgorithm. More...

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

Public Member Functions

def __init__ (self)
 
def makeBackgroundModel (self, in_x, pars=None)
 Generate gradient model (2-d array) with up to 2nd-order polynomial. More...
 
def fitFootprintBackground (self, source, posImage, order=1)
 Fit a linear (polynomial) model of given order (max 2) to the background of a footprint. More...
 
def makeStarModel (self, bbox, psf, xcen, ycen, flux)
 Generate model (2-d Image) of a 'star' (single PSF) centered at given coordinates. More...
 
def makeModel (self, x, flux, xcenPos, ycenPos, xcenNeg, ycenNeg, fluxNeg=None, b=None, x1=None, y1=None, xy=None, x2=None, y2=None, bNeg=None, x1Neg=None, y1Neg=None, xyNeg=None, x2Neg=None, y2Neg=None, kwargs)
 Generate dipole model with given parameters. More...
 

Public Attributes

 debug
 
 log
 

Detailed Description

Lightweight class containing methods for generating a dipole model for fitting to sources in diffims, used by DipoleFitAlgorithm.

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

Definition at line 174 of file dipoleFitTask.py.

Constructor & Destructor Documentation

◆ __init__()

def lsst.ip.diffim.dipoleFitTask.DipoleModel.__init__ (   self)

Definition at line 181 of file dipoleFitTask.py.

Member Function Documentation

◆ fitFootprintBackground()

def lsst.ip.diffim.dipoleFitTask.DipoleModel.fitFootprintBackground (   self,
  source,
  posImage,
  order = 1 
)

Fit a linear (polynomial) model of given order (max 2) to the background of a footprint.

Only fit the pixels OUTSIDE of the footprint, but within its bounding box.

Parameters
sourceSourceRecord, the footprint of which is to be fit
posImageThe exposure from which to extract the footprint subimage
orderPolynomial order of background gradient to fit.
Returns
pars tuple of length (1 if order==0; 3 if order==1; 6 if order == 2), containing the resulting fit parameters
Todo:
look into whether to use afwMath background methods – see http://lsst-web.ncsa.illinois.edu/doxygen/x_masterDoxyDoc/_background_example.html

Definition at line 255 of file dipoleFitTask.py.

◆ makeBackgroundModel()

def lsst.ip.diffim.dipoleFitTask.DipoleModel.makeBackgroundModel (   self,
  in_x,
  pars = None 
)

Generate gradient model (2-d array) with up to 2nd-order polynomial.

Parameters
in_x(2, w, h)-dimensional numpy.array, containing the input x,y meshgrid providing the coordinates upon which to compute the gradient. This will typically be generated via _generateXYGrid(). w and h correspond to the width and height of the desired grid.
parsUp to 6 floats for up to 6 2nd-order 2-d polynomial gradient parameters, in the following order: (intercept, x, y, xy, x**2, y**2). If pars is emtpy or None, do nothing and return None (for speed).
Returns
None, or 2-d numpy.array of width/height matching input bbox, containing computed gradient values.

Definition at line 186 of file dipoleFitTask.py.

◆ makeModel()

def lsst.ip.diffim.dipoleFitTask.DipoleModel.makeModel (   self,
  x,
  flux,
  xcenPos,
  ycenPos,
  xcenNeg,
  ycenNeg,
  fluxNeg = None,
  b = None,
  x1 = None,
  y1 = None,
  xy = None,
  x2 = None,
  y2 = None,
  bNeg = None,
  x1Neg = None,
  y1Neg = None,
  xyNeg = None,
  x2Neg = None,
  y2Neg = None,
  kwargs 
)

Generate dipole model with given parameters.

This is the function whose sum-of-squared difference from data is minimized by lmfit.

Parameters
xInput independent variable. Used here as the grid on which to compute the background gradient model.
fluxDesired flux of the positive lobe of the dipole
xcenPosDesired x-centroid of the positive lobe of the dipole
ycenPosDesired y-centroid of the positive lobe of the dipole
xcenNegDesired x-centroid of the negative lobe of the dipole
ycenNegDesired y-centroid of the negative lobe of the dipole
fluxNegDesired flux of the negative lobe of the dipole, set to 'flux' if None
b,x1,y1,xy,x2,y2Gradient parameters for positive lobe.
bNeg,x1Neg,y1Neg,xyNeg,x2Neg,y2NegGradient parameters for negative lobe. They are set to the corresponding positive values if None.
**kwargsKeyword arguments passed through lmfit and used by this function. These must include:
  • psf Psf model used to generate the 'star'
  • rel_weight Used to signify least-squares weighting of posImage/negImage relative to diffim. If rel_weight == 0 then posImage/negImage are ignored.
  • bbox Bounding box containing region to be modelled
See also
makeBackgroundModel for further parameter descriptions.
Returns
numpy.array of width/height matching input bbox, containing dipole model with given centroids and flux(es). If rel_weight = 0, this is a 2-d array with dimensions matching those of bbox; otherwise a stack of three such arrays, representing the dipole (diffim), positive and negative images respectively.

Definition at line 342 of file dipoleFitTask.py.

◆ makeStarModel()

def lsst.ip.diffim.dipoleFitTask.DipoleModel.makeStarModel (   self,
  bbox,
  psf,
  xcen,
  ycen,
  flux 
)

Generate model (2-d Image) of a 'star' (single PSF) centered at given coordinates.

Parameters
bboxBounding box marking pixel coordinates for generated model
psfPsf model used to generate the 'star'
xcenDesired x-centroid of the 'star'
ycenDesired y-centroid of the 'star'
fluxDesired flux of the 'star'
Returns
2-d stellar afwImage.Image of width/height matching input bbox, containing PSF with given centroid and flux

Definition at line 306 of file dipoleFitTask.py.

Member Data Documentation

◆ debug

lsst.ip.diffim.dipoleFitTask.DipoleModel.debug

Definition at line 183 of file dipoleFitTask.py.

◆ log

lsst.ip.diffim.dipoleFitTask.DipoleModel.log

Definition at line 184 of file dipoleFitTask.py.


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