e15190.utilities.peak_finder.PeakFinderGaus1D

class e15190.utilities.peak_finder.PeakFinderGaus1D(x, hist_range, hist_bins)

Functions

__init__(x, hist_range, hist_bins)

param x

x-values of the data

gaus(t, amplt, mean, sigma)

get_highest_peak([fit_range])

__init__(x, hist_range, hist_bins)
Parameters
  • x (list-like of float) – x-values of the data

  • hist_range (2-tuple of float) – Range of the histogram.

  • hist_bins (int) – Number of bins of the histogram.

static _get_convoluted_y(y, kernel_range, ngrids, sigma=None) → numpy.ndarray
Parameters
  • y (np.ndarray) – The histogram counts to convolute.

  • kernel_range (2-tuple of floats) – The range of the kernel. This should match the range of the histogram. Notice that the x of histogram is not an input of this function.

  • ngrids (int) – The number of grids to use in the convolution. This should be less than or equal to the number of bins in the histogram.

  • sigma (float, default None) – Standard deviation of the Gaussian kernel. If None, the bin width is used.

Returns

y_conv – The convoluted histogram counts.

Return type

np.ndarray

static _find_highest_peak(x, y, fit_range=None, kw_rough=None, kw_fine=None, error=False) → Union[numpy.ndarray, Tuple[numpy.ndarray, numpy.ndarray]]

Returns Gaussian parameters of the highest peak in the histogram.

Parameters
  • x (np.ndarray) – The x-values of the histogram.

  • y (np.ndarray) – The y-values of the histogram.

  • fit_range (2-tuple of float, default None) – The range of the histogram to fit. If None, the entire histogram is fit.

  • kw_rough (dict, default None) – Keyword arguments for the rough fit supplied to scipy.optimize.curve_fit.

  • kw_fine (dict, default None) – Keyword arguments for the fine fit supplied to scipy.optimize.curve_fit.

  • error (bool, default False) – If True, return the errors of the fit too.

Returns

pars – The Gaussian parameters of the highest peak, [amplt, mean, sigma]. If error is True, the errors of the parameters are returned as well.

Return type

np.ndarray of size 3 or 2-tuple of np.ndarray both of sizes 3