In [2]:
%matplotlib inline
import numpy as np
import spectraplotpy as spp
import matplotlib.pyplot as plt
from IPython.display import display as pp
In [3]:
#load data
dataset = spp.CSVImporter('../sampledata/04-EPR-E500/PEP/p2801_OC_SDS_SAH.asc',).datasets[1]
spec = spp.Spectrum(dataset)
#spec.plot()
In [4]:
#use the 100 left and 100 right points
left = range(0,100)
right = range(-100,0,1)
indices = np.append(left, right)
x_base = spec.dataset.x[indices]
y_base = spec.dataset.y[indices]
#print indices
baseline = spp.get_poly_baseline(spec, indices, deg=3)
fig, ax = plt.subplots(1, 1)
ax.plot(x_base, y_base, 'r.', label="Baseline points")
baseline.plot('r-', label="Baseline")
spec.plot('b-', label="Spectrum")
corrected_spec = spec - baseline
corrected_spec.plot('black', label="Corrected")
ax.legend(loc="best")
Out[4]: