Note
Go to the end to download the full example code
Chemometric preprocessing
This example demonstrates the standard preprocessing operations available in SpectroChemPy: normalization, mean-centering, autoscaling, Standard Normal Variate (SNV), and Multiplicative Scatter Correction (MSC).
import spectrochempy as scp
Load the dataset
dataset = scp.read_omnic("irdata/nh4y-activation.spg")
region = dataset[:, 4000.0:2000.0]
Normalization
Scales each spectrum. The default is method='max':

Mean-centering
Subtracts the mean along a chosen dimension:
centered = region.center(dim="x")
_ = centered.plot(title="Mean-centered per spectrum")

Autoscaling
Mean-centers and divides by the standard deviation (z-score):
scaled = region.autoscale(dim="x")
_ = scaled.plot(title="Autoscaled (z-score) per spectrum")

SNV and MSC
Standard Normal Variate (SNV) — equivalent to autoscale(dim='x'):

Multiplicative Scatter Correction (MSC):

This ends the example. Uncomment the next line to display the figures when running the script directly with Python.
# scp.show()
Total running time of the script: ( 0 minutes 1.148 seconds)