I have this 7 quasi-lorentzian curves which are fitted to my data.
and I would like to join them, to make one connected curved line. Do You have any ideas how to do this? I've read about ComposingModel at lmfit documentation, but it's not clear how to do this.
Here is a sample of my code of two fitted curves.
for dataset in [Bxfft]: dataset = np.asarray(dataset) freqs, psd = signal.welch(dataset, fs=266336/300, window='hamming', nperseg=16192, scaling='spectrum') plt.semilogy(freqs[0:-7000], psd[0:-7000]/dataset.size**0, color='r', label='Bx') x = freqs[100:-7900] y = psd[100:-7900] # 8 Hz model = Model(lorentzian) params = model.make_params(amp=6, cen=5, sig=1, e=0) result = model.fit(y, params, x=x) final_fit = result.best_fit print "8 Hz mode" print(result.fit_report(min_correl=0.25)) plt.plot(x, final_fit, 'k-', linewidth=2) # 14 Hz x2 = freqs[220:-7780] y2 = psd[220:-7780] model2 = Model(lorentzian) pars2 = model2.make_params(amp=6, cen=10, sig=3, e=0) pars2['amp'].value = 6 result2 = model2.fit(y2, pars2, x=x2) final_fit2 = result2.best_fit print "14 Hz mode" print(result2.fit_report(min_correl=0.25)) plt.plot(x2, final_fit2, 'k-', linewidth=2)
What I desire is something like this.