spectrochempy.mscο
- msc(dataset, reference=None, dim='y', inplace=False)[source]ο
Multiplicative Scatter Correction (MSC).
MSC corrects for multiplicative and additive effects caused by light-scattering or path-length variations. Each observation is linearly regressed against a reference spectrum and corrected as:
\[x_i^\prime = \frac{x_i - a_i}{b_i}\]where \(a_i\) and \(b_i\) are the intercept and slope of the least-squares fit of observation \(i\) to the reference. The same reference can be reused through
MSCTransformeronly for datasets with compatible spectral geometry.- Parameters:
dataset (
NDDataset) β The input data (2-D: observations Γ features).reference (
NDDatasetor array-like, optional) β 1-D reference spectrum. IfNone, the mean spectrum is used.dim (
strorint, optional, default:βyβ) β Dimension that identifies individual observations (spectra).inplace (
bool, optional, default:False) β IfTrue, MSC is performed in place.
- Returns:
NDDatasetβ The MSC-corrected dataset.- Raises:
SpectroChemPyError β If the dataset is not 2-D, the reference is incompatible, a spectrum has too few valid paired points, the effective reference is constant, or the local slope is zero.
Examples
>>> dataset = scp.read("irdata/nh4.spg") >>> nd = dataset.msc()