Peak Analysis¶
spectrakit.peaks.peaks_find ¶
peaks_find(
intensities: ndarray,
wavenumbers: ndarray | None = None,
height: float | None = None,
distance: int = DEFAULT_DISTANCE,
prominence: float | None = None,
) -> PeakResult
Find peaks in a 1-D spectrum.
Wraps scipy.signal.find_peaks with spectroscopy-friendly
defaults and returns a structured result.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
intensities
|
ndarray
|
Spectral intensities, shape |
required |
wavenumbers
|
ndarray | None
|
Wavenumber axis, shape |
None
|
height
|
float | None
|
Minimum peak height. If |
None
|
distance
|
int
|
Minimum number of points between peaks. |
DEFAULT_DISTANCE
|
prominence
|
float | None
|
Minimum peak prominence. If |
None
|
Returns:
| Type | Description |
|---|---|
PeakResult
|
|
Raises:
| Type | Description |
|---|---|
SpectrumShapeError
|
If input is not 1-D. |
Source code in src/spectrakit/peaks/find.py
spectrakit.peaks.PeakResult
dataclass
¶
Container for peak detection results.
Attributes:
| Name | Type | Description |
|---|---|---|
indices |
ndarray
|
Array of peak indices, shape |
heights |
ndarray
|
Peak heights at the detected positions, shape |
wavenumbers |
ndarray | None
|
Peak wavenumber positions if wavenumbers were
provided, shape |
Source code in src/spectrakit/peaks/find.py
spectrakit.peaks.peaks_integrate ¶
peaks_integrate(
intensities: ndarray,
wavenumbers: ndarray | None = None,
ranges: list[tuple[float, float]] | None = None,
) -> np.ndarray | float
Integrate peak areas over specified wavenumber ranges.
If ranges is provided, computes the trapezoidal integral for
each range. Otherwise, integrates the entire spectrum.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
intensities
|
ndarray
|
Spectral intensities, shape |
required |
wavenumbers
|
ndarray | None
|
Wavenumber axis, shape |
None
|
ranges
|
list[tuple[float, float]] | None
|
List of |
None
|
Returns:
| Type | Description |
|---|---|
ndarray | float
|
If |
ndarray | float
|
is provided, an array of shape |
ndarray | float
|
for each range. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If ranges is specified but wavenumbers is |