Peak search function#

This module provides a peak search function and tools related to peak analysis.

Find peaks in a curve.

Parameters:
  • y (numpy.ndarray) – Data array

  • fwhm – Estimated full width at half maximum of the typical peaks we are interested in (expressed in number of samples)

  • sensitivity – Threshold factor used for peak detection. Only peaks with amplitudes higher than σ * sensitivity - where σ is the standard deviation of the noise - qualify as peaks.

  • begin_index – Index of the first sample of the region of interest in the y array. If None, start from the first sample.

  • end_index – Index of the last sample of the region of interest in the y array. If None, process until the last sample.

  • debug – If True, print debug messages. Default: False

  • relevance_info – If True, add a second dimension with relevance information to the output array. Default: False

Returns:

1D sequence with indices of peaks in the data if relevance_info is False. Else, sequence of (peak_index, peak_relevance) tuples (one tuple per peak). WARNING: Peak indices are returned as float64.

Raise:

IndexError if the number of peaks is too large to fit in the output array.

guess_fwhm(y)#

Return the full-width at half maximum for the largest peak in the data array.

The algorithm removes the background, then finds a global maximum and its corresponding FWHM.

This value can be used as an initial fit parameter, used as input for an iterative fit function.

Parameters:

y – Data to be used for guessing the fwhm.

Returns:

Estimation of full-width at half maximum, based on fwhm of the global maximum.