spectrochempy.find_peaks
- find_peaks(dataset, height=None, window_length=3, threshold=None, distance=None, prominence=None, width=None, wlen=None, rel_height=0.5, plateau_size=None, use_coord=True)[source]
- Find and analyze peaks in spectroscopic data with advanced filtering options. - This function extends scipy.signal.find_peaks by adding spectroscopy-specific features like coordinate system awareness and unit handling. It performs peak detection through local maxima analysis and supports various filtering criteria to identify significant peaks. - Parameters:
- dataset (NDDataset) – Input dataset containing spectral data. Must be 1D or 2D with len(X.y) == 1. 
- height (float or array-like, optional) – Minimum and/or maximum peak height criteria. Can be specified as: - Single value for minimum height - Tuple (min, max) for height range - Array matching x for position-dependent criteria 
- window_length (int, default: 3) – Window size for peak interpolation. Must be odd. Larger values provide smoother interpolation but may miss narrow peaks. 
- threshold (float or array-like, optional) – Minimum height difference between peak and neighboring points. Useful for filtering out noise-related peaks. 
- distance (float, optional) – Minimum separation between peaks. Peaks closer than this are filtered based on their prominence. 
- prominence (float or array-like, optional) – Required prominence (height above surrounding baseline) of peaks. 
- width (float or array-like, optional) – Required width of peaks. Interpreted as coordinate units if use_coord=True, otherwise as number of points. 
- wlen (int or float, optional) – Window length for prominence calculation. Affects computation speed for large datasets. 
- rel_height (float, default: 0.5) – Relative height for width calculation (0-1 range). 
- plateau_size (float or array-like, optional) – Required size of peak plateau (flat top). 
- use_coord (bool, default: True) – Whether to use coordinate system units instead of array indices. 
 
- Returns:
- peaks (NDDataset) – Dataset containing identified peaks with interpolated positions and heights. 
- properties (dict) – Peak properties including heights, widths, prominences, and more. All values use appropriate units when use_coord=True. 
 
 - Notes - Peak positions are refined using quadratic interpolation when window_length > 1 
- The function handles units automatically when use_coord=True 
- For noisy data, consider preprocessing with smoothing functions 
 - Examples - Basic peak finding with height threshold: >>> dataset = scp.read(“irdata/nh4y-activation.spg”) >>> X = dataset[0, 1800.0:1300.0] >>> peaks, props = X.find_peaks(height=1.5) - Find well-separated peaks with minimum width: >>> peaks, props = X.find_peaks(distance=50.0, width=10.0) - Complex filtering with multiple criteria: >>> peaks, props = X.find_peaks( … height=1.5, … distance=50.0, … prominence=0.5, … width=20.0 … )