Hi Matt,
Thank you for getting back to me, I originally didn't have the constraints on the height and fwhm in my code, and they were reporting correctly. I also re-ran it and confirmed again that they report actual fit numbers when I comments them out.
My issue is that I would like to be able to constrain them in some way because I am ending up with some fits that are not finding the smaller peak or are fitting a very broad peak instead.
Here is a different data set that is not fitting the smaller peak well:
I would like to constrain the fwhm to fit the second smaller peak more similarly to the 'GoodFit.chi' in my above example. The broad green peak is not accurately fitting and I have been having a hard time feeding parameters into this type of example. Is there a way to constrain these parameters to prevent this type of fit and have the small peak fit more accurately? Or do you have any ideas how to approach this better?
I included this data file as well for reference and titled it 'BadFit.chi' and should run with the script I provided above.
Fit report for
'BadFit.chi' file (with NO constraints on fwhm and height):
[[Model]]
((Model(linear, prefix='b_') + Model(voigt, prefix='v0_')) + Model(voigt, prefix='v1_'))
[[Fit Statistics]]
# fitting method = leastsq
# function evals = 1100
# variables = 10
chi-square = 46.4462509
reduced chi-square = 1.36606620
Akaike info crit = 22.3806691
Bayesian info crit = 40.2225654
R-squared = 0.99915789
[[Variables]]
b_slope: -455.510990 +/- 853.770782 (187.43%) (init = 0)
b_intercept: 875.491181 +/- 1356.21147 (154.91%) (init = 50)
v0_amplitude: 3.36444842 +/- 0.16176741 (4.81%) (init = 5)
v0_center: 1.80921576 +/- 5.7947e-05 (0.00%) (init = 1.825)
v0_sigma: 0.00478056 +/- 3.9917e-04 (8.35%) (init = 0.005)
v0_gamma: 0.00562803 +/- 6.3554e-04 (11.29%) (init = 0.005)
v0_fwhm: 0.01843397 +/- 2.3781e-04 (1.29%) == '1.0692*v0_gamma+sqrt(0.8664*v0_gamma**2+5.545083*v0_sigma**2)'
v0_height: 134.233208 +/- 2.31161478 (1.72%) == '(v0_amplitude/(max(1e-15, v0_sigma*sqrt(2*pi))))*wofz((1j*v0_gamma)/(max(1e-15, v0_sigma*sqrt(2)))).real'
v1_amplitude: 34.2055448 +/- 143.988349 (420.95%) (init = 5)
v1_center: 1.90000000 +/- 0.06515399 (3.43%) (init = 1.8625)
v1_sigma: 0.01000000 +/- 0.10369425 (1036.94%) (init = 0.005)
v1_gamma: 0.11825431 +/- 0.16863318 (142.60%) (init = 0.005)
v1_fwhm: 0.23900002 +/- 0.29810280 (124.73%) == '1.0692*v1_gamma+sqrt(0.8664*v1_gamma**2+5.545083*v1_sigma**2)'
v1_height: 91.4276729 +/- 266.643666 (291.64%) == '(v1_amplitude/(max(1e-15, v1_sigma*sqrt(2*pi))))*wofz((1j*v1_gamma)/(max(1e-15, v1_sigma*sqrt(2)))).real'
[[Correlations]] (unreported correlations are < 0.100)
C(b_slope, b_intercept) = -1.000
C(b_slope, v1_center) = -0.997
C(b_intercept, v1_center) = 0.996
C(v1_amplitude, v1_center) = 0.994
C(b_slope, v1_amplitude) = -0.993
C(b_intercept, v1_amplitude) = 0.991
C(v1_amplitude, v1_gamma) = 0.985
C(v0_sigma, v0_gamma) = -0.968
C(v0_amplitude, v0_gamma) = 0.966
C(v1_center, v1_gamma) = 0.964
C(b_slope, v1_gamma) = -0.959
C(b_intercept, v1_gamma) = 0.955
C(v0_amplitude, v0_sigma) = -0.886
C(v1_sigma, v1_gamma) = -0.738
C(v1_amplitude, v1_sigma) = -0.623
C(b_slope, v1_sigma) = 0.547
C(v1_center, v1_sigma) = -0.541
C(b_intercept, v1_sigma) = -0.537
C(v0_amplitude, v1_gamma) = -0.535
C(v0_amplitude, v1_amplitude) = -0.461
C(v0_amplitude, v1_sigma) = 0.454
C(v0_amplitude, v1_center) = -0.429
C(v0_gamma, v1_gamma) = -0.409
C(b_slope, v0_amplitude) = 0.384
C(b_intercept, v0_amplitude) = -0.375
C(b_intercept, v0_center) = -0.367
C(b_slope, v0_center) = 0.366
C(v0_center, v1_center) = -0.363
C(v0_center, v1_amplitude) = -0.354
C(v0_gamma, v1_amplitude) = -0.345
C(v0_gamma, v1_sigma) = 0.332
C(v0_center, v1_gamma) = -0.323
C(v0_gamma, v1_center) = -0.318
C(v0_sigma, v1_gamma) = 0.313
C(b_slope, v0_gamma) = 0.276
C(b_intercept, v0_gamma) = -0.268
C(v0_sigma, v1_amplitude) = 0.258
C(v0_sigma, v1_sigma) = -0.245
C(v0_sigma, v1_center) = 0.236
C(b_slope, v0_sigma) = -0.198
C(b_intercept, v0_sigma) = 0.191
C(v0_amplitude, v0_center) = 0.142
C(v0_center, v0_gamma) = 0.112