Note
Go to the end to download the full example code.
Removing cosmic ray spikes from a Raman spectrum
In this example, we use the despike method to remove the noise from a Raman
spectrum.
import spectrochempy as scp
Load and prepare the data
Keep one spectrum and select the useful region:
Apply a fast SNIP baseline correction:
prefs = scp.preferences
prefs.figure.figsize = (8, 4)
_ = X1.plot()

Despike with the default method
The despike method has two key parameters: size (Savitzky-Golay filter
width) and delta (detection threshold in standard deviation units):

Despike with the Whitaker method

The importance of parameter tuning
Poorly chosen parameters may remove valid peaks:

This ends the example ! The following line can be uncommented if no plot shows when running the .py script with python
# scp.show()
Total running time of the script: (0 minutes 0.767 seconds)