Peaksandpeaks
Peaksandpeaks

Reputation: 57

Peak detection gives different results when using octave or oct2py in python

I am trying to fit a number of fixed width gaussians to a single broad peak. The only way I have been able to do this is with peakfit.m. Sample data can be downloaded here.

In octave the code I use is:

>>peakfit(data,90.5,3,3,11,0,0,0,0,[1,1,1],0,0)
ans =
  1.0000e+000  9.0012e+001  1.0185e+004  1.0000e+000  1.0749e+004
  2.0000e+000  9.0500e+001  9.3075e+003  1.0000e+000  9.9035e+003
  3.0000e+000  9.0988e+001  1.0186e+004  1.0000e+000  1.0749e+004

These are fairly close to the three peaks I used to create the initial dataset.

These are the results when I use oct2py

import oct2py as op
import numpy as np

data=np.loadtxt(file)

octave=op.Oct2Py()
octave.peakfit(data,90.5,3,3,11,0,0,0,0,[1,1,1],0,0)

#Out:
array([[    1,    91,  8873,     1, 14583],
       [    2,    88, 17314,     1,   400],
       [    3,    90, 11011,     1, 18459]])

If I fit a single peak in both cases the result is the same.

Octave

 1.0000e+000  9.0500e+001  2.0576e+004  1.4670e+000  3.2130e+004

Oct2py

array([[  1.00000000e+00,   9.05000004e+01,   2.05763986e+04,
          1.46695147e+00,   3.21304879e+04]])

Where could the differences come from?

Upvotes: 0

Views: 215

Answers (1)

Peaksandpeaks
Peaksandpeaks

Reputation: 57

I found the solution. I have to pass the arguments in oct2py as floats so

octave.peakfit(data,90.5,3.0,3.0,11.0,0.0,0.0,0.0,0.0,[1.0,1.0,1.0],0.0,0.0)

Upvotes: 1

Related Questions