试图为这样的一些数据拟合一个峰值:
import scipy
from lmfit.models import GaussianModel
x = shm.PTR_P
y = shm.PORE_V_P
mod = LorentzianModel()
pars = mod.guess(y, x=x)
out = mod.fit(y, pars, x=x)
print(out.fit_report(min_correl=0.25))
虽然如果我生成数据,我可以做到这一点,但如果我尝试从另一个来源读取它们,它就不起作用了。我不太擅长这一点,也不知道问题是什么。这是输出:
[x,y] [(34.145490000000002, 3.4599999999999999e-08), (29.286449999999999, 4.8399999999999997e-08), (25.118860000000002, 0.026773140000000001), (21.544350000000001, 0.068791409999999997), (18.4785, 0.083200979999999994), (15.848929999999999, 0.02123179), (11.659139999999999 , 0.01551077), (10.0, 0.084493879999999993), (6.3095739999999996, 2.0899999999999998e-07), (5.4116949999999999, 0.045209140000000002), (4.6415889999999997, 0.054789360000000002), (3.4145489999999996, 8.9399999999999993e-08), (2.9286449999999999, 0.01100814), (2.5118860000000001, 0.088990659999999999 ), (1.84785, 3.5799999999999995e-07), (1.5848930000000001, 0.099999009999999999), (1.359356, 0.075139280000000003), (1.1659139999999999, 0.167379), (1.0, 0.57693050000000001), (0.85769590000000007, 1.8658159999999999), (0.73564230000000008, 8.4961369999999992), (0.6309574, 25.299099999999999), (0.54116949999999997, 21.413350000000001), (0.46415889999999999, 13.408829999999998), (0.39810719999999999, 8.3584750000000003), (0.34145490000000006, 5.3982010000000002), (0.29286440000000002, 3.7518540000000002), (0.25118859999999998, 2.5325389999999999), (0.21544349999999998, 1.7722470000000001), (0.18478499999999998, 1.445808), (0.15848929999999997, 1.182083), (0.13593559999999999, 0.94957730000000007), (0.1165914, 0.67620849999999999), (0.10000000000000001, 0.46631620000000001), (0.085769590000000007, 0.41001890000000002), (0.07356422, 0.30625920000000001), (0.063095730000000003, 0.24040219999999998) , (0.054116949999999997, 0.1942596), (0.046415890000000001, 0.11306760000000002), (0.039810720000000001, 0.099998470000000006), (0.034145490000000001, 0.099998470000000006), (0.029286449999999999, 0.02246857), (0.025118870007940001999)]