pyextal.larbed.peaks¶
Least-squares peak fitting used to locate the direct beam on the detector.
Each model function is a factory: it takes the model parameters and returns a
callable evaluated on pixel index arrays, which is what
scipy.optimize.leastsq() is driven with here.
Functions¶
|
Builds a circular 2D Gaussian. |
|
Builds a 1D Gaussian. |
|
Builds a 1D Lorentzian on a linear background. |
|
Builds a circular 2D Lorentzian on a planar background. |
|
Estimates Gaussian parameters of a 2D distribution from its moments. |
|
Fits a 7-parameter 2D peak model with a planar background. |
|
Fits 1D models to the two projections of a 2D peak. |
|
Fits a 4-parameter circular 2D Gaussian. |
Module Contents¶
- pyextal.larbed.peaks.gaussian2D(height, center_y, center_x, width_x)¶
Builds a circular 2D Gaussian.
- Parameters:
height (float) – Peak amplitude.
center_y (float) – Centre along the first axis.
center_x (float) – Centre along the second axis.
width_x (float) – Standard deviation, shared by both axes.
- Returns:
f(x, y)evaluating the Gaussian.- Return type:
callable
- pyextal.larbed.peaks.gaussian1D(height, center, width)¶
Builds a 1D Gaussian.
- Parameters:
height (float) – Peak amplitude.
center (float) – Peak centre.
width (float) – Standard deviation.
- Returns:
f(x)evaluating the Gaussian.- Return type:
callable
- pyextal.larbed.peaks.lorentzian1D(height, center, width, y0, slope)¶
Builds a 1D Lorentzian on a linear background.
- Parameters:
height (float) – Peak amplitude.
center (float) – Peak centre.
width (float) – Half-width at half-maximum.
y0 (float) – Background offset.
slope (float) – Background slope.
- Returns:
f(x)evaluating the Lorentzian plus background.- Return type:
callable
- pyextal.larbed.peaks.lorentzian2D(height, center_x, center_y, width_x, a, b, c)¶
Builds a circular 2D Lorentzian on a planar background.
- Parameters:
height (float) – Peak amplitude.
center_x (float) – Centre along the second axis.
center_y (float) – Centre along the first axis.
width_x (float) – Half-width at half-maximum.
a (float) – Background gradient along x.
b (float) – Background gradient along y.
c (float) – Background offset.
- Returns:
f(y, x)evaluating the Lorentzian plus background.- Return type:
callable
- pyextal.larbed.peaks.moments(data)¶
Estimates Gaussian parameters of a 2D distribution from its moments.
- Parameters:
data (np.ndarray) – 2D image containing a single peak.
- Returns:
Two
(height, centre, width)triples, for the second and first axes respectively, suitable as a least-squares starting guess.- Return type:
tuple
- pyextal.larbed.peaks.fitPeak2D(data, func)¶
Fits a 7-parameter 2D peak model with a planar background.
- Parameters:
data (np.ndarray) – 2D image containing a single peak.
func (callable) – Model factory taking 7 parameters, such as
lorentzian2D().
- Returns:
The fitted parameters.
- Return type:
np.ndarray
- pyextal.larbed.peaks.fitPeak(data, func)¶
Fits 1D models to the two projections of a 2D peak.
- Parameters:
data (np.ndarray) – 2D image containing a single peak.
func (callable) – 1D model factory taking 5 parameters, such as
lorentzian1D().
- Returns:
[xh, xc, xw, yh, yc, yw]— amplitude, centre, and width for each projection.- Return type:
np.ndarray
- pyextal.larbed.peaks.fitPeak2DGauss(data, func)¶
Fits a 4-parameter circular 2D Gaussian.
- Parameters:
data (np.ndarray) – 2D image containing a single peak.
func (callable) – Model factory taking 4 parameters, normally
gaussian2D().
- Returns:
[height, center_y, center_x, width_x].- Return type:
np.ndarray