I have the following lists representing energy spectra that need to be subtracted from each other to produce a difference spectrum.
data1 = ToExpression@Import["http://pastebin.com/raw.php?i=VfBcE9L5", "Data"][[1]]
data2 = ToExpression@Import["http://pastebin.com/raw.php?i=dFcxfJ4j", "Data"][[1]]
This is how all the spectra look before the necessary shift (I threw a spline fit through the arrays):
The problem is that I need to preform an energy shift to the black spectrum before the subtraction so that the first peaks line up. I usually construct my difference spectrum array like this:
diffdata = Transpose[{data1[[1,;;,1]], data1[[1,;;,2]] - data2[[1,;;,2]]}]
Where the first column is energy and the second column is intensity. I want to energy shift data2
to line up with data1
(it's about a -0.35 shift), then subtract the intensity of data1
from the intensity of data2
Since the subtraction occurs based on the position of the elements within the list, any shifting I do to column 1 of data2
(the energy) will not matter to my difference array. Furthermore, the data point spacing is not homogenous within the spectrum i.e. the data points are more dense in the peak regions than in other regions; however, the point spacing between data1
and data2
are identical. Is there any way I can get around this?
My immediate attempt was to do something with Interpolation
, but I do not know how to subtract the y-values of two interpolated functions from each other. I would then input the energies of data1
(i.e. data1[[1,;;,1]]
into the interpolated difference spectrum to get the interpolated intensities of with the corresponding energies.
Any help is appreciated.