Not quite sure what this is trying to fit, but seems to be some kind of line spectrum


In [4]:
%matplotlib inline
import matplotlib.pyplot as plt
import sys
import os
sys.path.append('..')
sys.path.append('../../spc')
import spectra, spc

In [7]:
raw_d = spc.File(os.path.join("../../data/data_spc/MERC.SPC"))
x = raw_d.x
y = raw_d.sub[0].y


gx-y(1)

In [8]:
plt.plot(x,y,'r-')


Out[8]:
[<matplotlib.lines.Line2D at 0x7feb38e9efd0>]

In [9]:
from spectra import find_peaks

In [10]:
?find_peaks

In [11]:
pos = find_peaks(x, y)
plt.plot(x, y, 'r-', x[pos], y[pos], 'ro')


Out[11]:
[<matplotlib.lines.Line2D at 0x7feb36e39650>,
 <matplotlib.lines.Line2D at 0x7feb36e39850>]

In [14]:
from spectra import fit_data, output_results
out1 = fit_data(x, y, pos)

In [15]:
output_results(out1)


Out[15]:
array([['bg_c0', '3.87653755648', '233943.018976'],
       ['bg_c1', '0.00020601605431', '25.326649287'],
       ['bg_c2', '1.0861551729e-08', '0.000684269317086'],
       ['p0_x0', '18332.0030291', '0.0358266312728'],
       ['p0_amp', '1535367.77695', '25072.0780391'],
       ['p0_fwhm', '-7.93392650316', '2.11885751307e-10'],
       ['p1_x0', '17350.0044034', '0.088153481767'],
       ['p1_amp', '618317.109215', '25079.5529077'],
       ['p1_fwhm', '-1.00370345476', '4.95710309091e-10'],
       ['p2_x0', '17287.0046894', '0.0928228049013'],
       ['p2_amp', '587227.318528', '25082.9061698'],
       ['p2_fwhm', '-7.99175660451', '4.96764596227e-10']], 
      dtype='|S17')

In [28]:
plt.semilogy(x, y, 'r-', x, out1.best_fit, 'b--')
#plt.xlim(18000, 18500)


Out[28]:
[<matplotlib.lines.Line2D at 0x7feb3660b490>,
 <matplotlib.lines.Line2D at 0x7feb3651b7d0>]

In [ ]: