doc_model_loadmodelresult2.pyΒΆ

model loadmodelresult2
[[Model]]
    ((Model(gaussian, prefix='g1_') + Model(gaussian, prefix='g2_')) + Model(exponential, prefix='exp_'))
[[Fit Statistics]]
    # fitting method   = leastsq
    # function evals   = 46
    # data points      = 250
    # variables        = 8
    chi-square         = 1247.52821
    reduced chi-square = 5.15507524
    Akaike info crit   = 417.864631
    Bayesian info crit = 446.036318
    R-squared          = 0.99648654
[[Variables]]
    exp_amplitude:  99.0183278 +/- 0.53748593 (0.54%) (init = 162.2102)
    exp_decay:      90.9508853 +/- 1.10310778 (1.21%) (init = 93.24905)
    g1_amplitude:   4257.77360 +/- 42.3836478 (1.00%) (init = 2000)
    g1_center:      107.030956 +/- 0.15006851 (0.14%) (init = 105)
    g1_sigma:       16.6725772 +/- 0.16048381 (0.96%) (init = 15)
    g1_fwhm:        39.2609181 +/- 0.37791049 (0.96%) == '2.3548200*g1_sigma'
    g1_height:      101.880230 +/- 0.59217173 (0.58%) == '0.3989423*g1_amplitude/max(1e-15, g1_sigma)'
    g2_amplitude:   2493.41735 +/- 36.1697789 (1.45%) (init = 2000)
    g2_center:      153.270102 +/- 0.19466802 (0.13%) (init = 155)
    g2_sigma:       13.8069464 +/- 0.18679695 (1.35%) (init = 15)
    g2_fwhm:        32.5128735 +/- 0.43987320 (1.35%) == '2.3548200*g2_sigma'
    g2_height:      72.0455941 +/- 0.61722243 (0.86%) == '0.3989423*g2_amplitude/max(1e-15, g2_sigma)'
[[Correlations]] (unreported correlations are < 0.100)
    C(g1_amplitude, g1_sigma)      = +0.8243
    C(g2_amplitude, g2_sigma)      = +0.8154
    C(exp_amplitude, exp_decay)    = -0.6946
    C(g1_sigma, g2_center)         = +0.6842
    C(g1_center, g2_amplitude)     = -0.6689
    C(g1_center, g2_sigma)         = -0.6520
    C(g1_amplitude, g2_center)     = +0.6477
    C(g1_center, g2_center)        = +0.6205
    C(g1_center, g1_sigma)         = +0.5075
    C(exp_decay, g1_amplitude)     = -0.5074
    C(g1_sigma, g2_amplitude)      = -0.4915
    C(g2_center, g2_sigma)         = -0.4889
    C(g1_sigma, g2_sigma)          = -0.4826
    C(g2_amplitude, g2_center)     = -0.4763
    C(exp_decay, g2_amplitude)     = -0.4270
    C(g1_amplitude, g1_center)     = +0.4183
    C(g1_amplitude, g2_sigma)      = -0.4010
    C(g1_amplitude, g2_amplitude)  = -0.3071
    C(exp_amplitude, g2_amplitude) = +0.2821
    C(exp_decay, g1_sigma)         = -0.2520
    C(exp_decay, g2_sigma)         = -0.2329
    C(exp_amplitude, g2_sigma)     = +0.1714
    C(exp_decay, g2_center)        = -0.1514
    C(exp_amplitude, g1_amplitude) = +0.1478
    C(exp_decay, g1_center)        = +0.1055

# <examples/doc_model_loadmodelresult2.py>
import os
import sys

import matplotlib.pyplot as plt
import numpy as np

from lmfit.model import load_modelresult

if not os.path.exists('nistgauss_modelresult.sav'):
    os.system(f"{sys.executable} doc_model_savemodelresult2.py")

dat = np.loadtxt('NIST_Gauss2.dat')
x = dat[:, 1]
y = dat[:, 0]

result = load_modelresult('nistgauss_modelresult.sav')
print(result.fit_report())

plt.plot(x, y, 'o')
plt.plot(x, result.best_fit, '-')
plt.show()
# <end examples/doc_model_loadmodelresult2.py>

Total running time of the script: (0 minutes 0.169 seconds)

Gallery generated by Sphinx-Gallery