Skip to content

Subtracting background spectra from sample spectra #731

Answered by atravert
phoebe-sch asked this question in Q&A
Discussion options

You must be logged in to vote

Hello,

Yes it is perefectly doable using the subtraction. For instance, if your sample spectra and background have been recorded in distinct files, you could do:

import spectrochempy as scp

A = scp.read("mydata/sample_spectra.spg")
B = scp.read("mydata/background_spectrum.spa")

A_corr = A - B
A_corr.plot()

or if all your spectra are in a dataset A where the background spectrum is the first one (index 0):

A = scp.read("mydata/all_spectra.spg")
A_corr = A[1:] - A[0]
A_corr.plot()

You can test this directly with one of the sample datasets in spectrochempy. In this case the reference spectrum is the last one (index -1):

import spectrochempy as scp

A = scp.read("irdata/nh4y-activation.spg")
A.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by atravert
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants