smx.zones.build#

Build spectral zones directly from a single spectrum.

Functions#

building_spectral_zones(→ List[Tuple[str, Union[int, ...)

Detect local minima/maxima and build spectral cuts from a single spectrum.

Module Contents#

smx.zones.build.building_spectral_zones(spectrum: numpy.ndarray | pandas.Series | pandas.DataFrame, min_window_length: int = 7, prominence: float = 0.3, svg_smooth: bool = False, svg_window_length: int = 7, svg_polyorder: int = 3, svg_deriv: int = 1, ploting: bool = True, plotting: bool | None = None, theme: smx.plotting.theme.SMXTheme | None = None, title: str | None = None, output_path: str | Path | None = None, _show_minima: bool = False) List[Tuple[str, int | float | str, int | float | str]][source]#

Detect local minima/maxima and build spectral cuts from a single spectrum.

Parameters#

spectrumnumpy.ndarray, pandas.Series, or pandas.DataFrame

Spectrum values. If a DataFrame or a 2-D numpy array is provided, the mean spectrum (averaged over rows) is used before zone detection. If a Series or 1-D array is provided, it is used directly.

min_window_lengthint, default 7

Window length used by argrelmin to detect local minima.

prominencefloat, default 0.3

Minimum prominence for local maxima detection.

svg_smoothbool, default False

If True, apply Savitzky-Golay smoothing before peak detection.

svg_window_lengthint, default 7

Savitzky-Golay window length.

svg_polyorderint, default 3

Savitzky-Golay polynomial order.

svg_derivint, default 1

Derivative order for Savitzky-Golay filtering. Use 0 for no derivative (smoothing only), 1 for first derivative, 2 for second derivative, etc. Only used when svg_smooth=True.

plotingbool, default True

When True, plot the spectrum with zone backgrounds and identified peaks.

plottingbool, optional

Backward-compatible alias for ploting.

themeSMXTheme, optional

Optional visual theme for plotting.

titlestr, optional

Optional plot title when ploting=True.

output_pathstr or Path, optional

Optional output path for saving the plot (HTML or static image).

Returns#

list of tuples

Spectral cuts in the form (label, start, end).