ramanlib.analysis

Analysis routines for Raman spectral data. This focuses on single-spectrum analysis methods or methods that don’t require heavy grouping or metadata management.

This module currently provides a Classical Least Squares (CLS) unmixing routine that decomposes a query spectrum into a linear combination of reference (component) spectra using linear regression. Outputs include the fitted coefficients, the residual spectrum, and the scaled component spectra that best fit the query under a least-squares criterion.

See also

ramanspy.Spectrum

RamanSPy spectrum class used throughout.

sklearn.linear_model.LinearRegression

Estimator used to obtain CLS coefficients.

Functions

CLS(query_spec, components_spec, component_names)

Classical Least Squares (CLS) spectral unmixing.

ramanlib.analysis.CLS(query_spec, components_spec, component_names, plot=True, verbose=True)[source]

Classical Least Squares (CLS) spectral unmixing.

Parameters:
  • query_spec (rp.Spectrum)

  • components_spec (list[rp.Spectrum])

  • component_names (list[str])

  • plot (bool, optional) – If True, plot query, residual, and fitted component spectra. Default True.

  • verbose (bool, optional) – If True, print component names and coefficients. Default True.

Returns:

  • cs (numpy.ndarray)

  • res_spec (rp.Spectrum)

  • fitted_components_spec (list[rp.Spectrum])