pyextal.larbed.peaks ==================== .. py:module:: pyextal.larbed.peaks .. autoapi-nested-parse:: 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 :func:`scipy.optimize.leastsq` is driven with here. Functions --------- .. autoapisummary:: pyextal.larbed.peaks.gaussian2D pyextal.larbed.peaks.gaussian1D pyextal.larbed.peaks.lorentzian1D pyextal.larbed.peaks.lorentzian2D pyextal.larbed.peaks.moments pyextal.larbed.peaks.fitPeak2D pyextal.larbed.peaks.fitPeak pyextal.larbed.peaks.fitPeak2DGauss Module Contents --------------- .. py:function:: gaussian2D(height, center_y, center_x, width_x) Builds a circular 2D Gaussian. :param height: Peak amplitude. :type height: float :param center_y: Centre along the first axis. :type center_y: float :param center_x: Centre along the second axis. :type center_x: float :param width_x: Standard deviation, shared by both axes. :type width_x: float :returns: ``f(x, y)`` evaluating the Gaussian. :rtype: callable .. py:function:: gaussian1D(height, center, width) Builds a 1D Gaussian. :param height: Peak amplitude. :type height: float :param center: Peak centre. :type center: float :param width: Standard deviation. :type width: float :returns: ``f(x)`` evaluating the Gaussian. :rtype: callable .. py:function:: lorentzian1D(height, center, width, y0, slope) Builds a 1D Lorentzian on a linear background. :param height: Peak amplitude. :type height: float :param center: Peak centre. :type center: float :param width: Half-width at half-maximum. :type width: float :param y0: Background offset. :type y0: float :param slope: Background slope. :type slope: float :returns: ``f(x)`` evaluating the Lorentzian plus background. :rtype: callable .. py:function:: lorentzian2D(height, center_x, center_y, width_x, a, b, c) Builds a circular 2D Lorentzian on a planar background. :param height: Peak amplitude. :type height: float :param center_x: Centre along the second axis. :type center_x: float :param center_y: Centre along the first axis. :type center_y: float :param width_x: Half-width at half-maximum. :type width_x: float :param a: Background gradient along x. :type a: float :param b: Background gradient along y. :type b: float :param c: Background offset. :type c: float :returns: ``f(y, x)`` evaluating the Lorentzian plus background. :rtype: callable .. py:function:: moments(data) Estimates Gaussian parameters of a 2D distribution from its moments. :param data: 2D image containing a single peak. :type data: np.ndarray :returns: Two ``(height, centre, width)`` triples, for the second and first axes respectively, suitable as a least-squares starting guess. :rtype: tuple .. py:function:: fitPeak2D(data, func) Fits a 7-parameter 2D peak model with a planar background. :param data: 2D image containing a single peak. :type data: np.ndarray :param func: Model factory taking 7 parameters, such as :func:`lorentzian2D`. :type func: callable :returns: The fitted parameters. :rtype: np.ndarray .. py:function:: fitPeak(data, func) Fits 1D models to the two projections of a 2D peak. :param data: 2D image containing a single peak. :type data: np.ndarray :param func: 1D model factory taking 5 parameters, such as :func:`lorentzian1D`. :type func: callable :returns: ``[xh, xc, xw, yh, yc, yw]`` — amplitude, centre, and width for each projection. :rtype: np.ndarray .. py:function:: fitPeak2DGauss(data, func) Fits a 4-parameter circular 2D Gaussian. :param data: 2D image containing a single peak. :type data: np.ndarray :param func: Model factory taking 4 parameters, normally :func:`gaussian2D`. :type func: callable :returns: ``[height, center_y, center_x, width_x]``. :rtype: np.ndarray