add main
This commit is contained in:
35
arg_fit.py
35
arg_fit.py
@@ -89,23 +89,25 @@ def data_process(path):
|
|||||||
plt.plot(temp,line_fit(temp,linear_params[0],linear_params[1],linear_params[2]))
|
plt.plot(temp,line_fit(temp,linear_params[0],linear_params[1],linear_params[2]))
|
||||||
data0=line_fit(np.arange(5,80,0.01),linear_params[0],linear_params[1],linear_params[2])
|
data0=line_fit(np.arange(5,80,0.01),linear_params[0],linear_params[1],linear_params[2])
|
||||||
return data0
|
return data0
|
||||||
plt.figure(figsize=(25, 15))
|
def main():
|
||||||
paths=['./data1','./data2','./data3','./data4']
|
plt.figure(figsize=(25, 15))
|
||||||
datas=[]
|
paths=['./data1','./data2','./data3','./data4']
|
||||||
num=241
|
datas=[]
|
||||||
threshold=int(input('threshold set(recommend start from 250):\n请输入阈值设置(默认推荐250):\n'))
|
num=241
|
||||||
try:
|
threshold=int(input('threshold set(recommend start from 250):\n请输入阈值设置(默认推荐250):\n'))
|
||||||
|
try:
|
||||||
for path in paths:
|
for path in paths:
|
||||||
plt.subplot(num)
|
plt.subplot(num)
|
||||||
num+=1
|
num+=1
|
||||||
datas.append(data_process(path))
|
datas.append(data_process(path))
|
||||||
except:
|
except:
|
||||||
print("please make sure you have move the 4 data file to IDM folder\n请确认你有把4个文件拷到IDM文件夹内")
|
print("please make sure you have move the 4 data file to IDM folder\n请确认你有把4个文件拷到IDM文件夹内")
|
||||||
#反向求值
|
return
|
||||||
model=TempModel(1,-2.1429828e-05,-1.8980091e-10,3.6738370e-16,2943053.84,20.33)
|
#反向求值
|
||||||
p0=[-2.1429828e-05,-1.8980091e-10,3.6738370e-16]
|
model=TempModel(1,-2.1429828e-05,-1.8980091e-10,3.6738370e-16,2943053.84,20.33)
|
||||||
params, params_covariance = curve_fit(fit,np.arange(5,80,0.01),np.hstack(datas),p0=p0,maxfev=1000000,ftol=1e-10,xtol=1e-10)
|
p0=[-2.1429828e-05,-1.8980091e-10,3.6738370e-16]
|
||||||
for path in paths:
|
params, params_covariance = curve_fit(fit,np.arange(5,80,0.01),np.hstack(datas),p0=p0,maxfev=1000000,ftol=1e-10,xtol=1e-10)
|
||||||
|
for path in paths:
|
||||||
plt.subplot(num)
|
plt.subplot(num)
|
||||||
num+=1
|
num+=1
|
||||||
data=[]
|
data=[]
|
||||||
@@ -126,6 +128,9 @@ for path in paths:
|
|||||||
for i in range(len(temp)):
|
for i in range(len(temp)):
|
||||||
result0.append(model.compensate(freq[i],temp[i],20.66))
|
result0.append(model.compensate(freq[i],temp[i],20.66))
|
||||||
plt.plot(temp[10:],result0[10:])
|
plt.plot(temp[10:],result0[10:])
|
||||||
plt.savefig('fit.png')
|
plt.savefig('fit.png')
|
||||||
print('fit result:')
|
print('fit result:')
|
||||||
print('tc_tcc:'+str(params[0])+'\ntc_tcfl:'+str(params[1])+'\ntc_tctl:'+str(params[2]))
|
print('tc_tcc:'+str(params[0])+'\ntc_tcfl:'+str(params[1])+'\ntc_tctl:'+str(params[2]))
|
||||||
|
|
||||||
|
if __name__== "__main__" :
|
||||||
|
main()
|
||||||
Reference in New Issue
Block a user