Denoising a 2D Raman spectrum

In this example, we use the denoise method to remove the noise from a 2D Raman spectrum.

Import spectrochempy

import spectrochempy as scp

scp.set_loglevel("INFO")  # to see information

Load the data (should be a 2D spectrum or a list of datasets that can be merged):

dataset = scp.read("ramandata/labspec/serie190214-1.txt")

select the useful region

nd = dataset[:, 60.0:]

Basic plot

nd.plot(title="original data")
original data


Detrend the data (for a easier comparison)

nd1 = nd.detrend(title="detrended data")
nd1.plot()
plot denoising


Denoise the data using the denoise method with the default parameters i.e., ratio=99.8

nd2 = nd1.denoise()
nd2.plot(title="denoised data")
denoised data


Denoise the data using a different ratio

nd3 = nd1.denoise(ratio=95)
nd3.plot(title="denoised data")

nd4 = nd1.denoise(ratio=90)
nd4.plot(title="denoised data")
  • denoised data
  • denoised data


This example shows that denoising can be used effectively on such spectra to increase the signal-to-noise ratio. However, it apparently has a poor effect on eliminating cosmic ray peaks. For the latter, it may be useful to use despike methods as seen in another example.

This ends the basic example of denoising a 2D Raman spectrum. scp.show() # uncomment to show plot if running from a script sphinx_gallery_thumbnail_number = -1

Total running time of the script: (0 minutes 2.168 seconds)