add main
This commit is contained in:
79
arg_fit.py
79
arg_fit.py
@@ -89,43 +89,48 @@ def data_process(path):
|
||||
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])
|
||||
return data0
|
||||
plt.figure(figsize=(25, 15))
|
||||
paths=['./data1','./data2','./data3','./data4']
|
||||
datas=[]
|
||||
num=241
|
||||
threshold=int(input('threshold set(recommend start from 250):\n请输入阈值设置(默认推荐250):\n'))
|
||||
try:
|
||||
def main():
|
||||
plt.figure(figsize=(25, 15))
|
||||
paths=['./data1','./data2','./data3','./data4']
|
||||
datas=[]
|
||||
num=241
|
||||
threshold=int(input('threshold set(recommend start from 250):\n请输入阈值设置(默认推荐250):\n'))
|
||||
try:
|
||||
for path in paths:
|
||||
plt.subplot(num)
|
||||
num+=1
|
||||
datas.append(data_process(path))
|
||||
except:
|
||||
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]
|
||||
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)
|
||||
num+=1
|
||||
datas.append(data_process(path))
|
||||
except:
|
||||
print("please make sure you have move the 4 data file to IDM folder\n请确认你有把4个文件拷到IDM文件夹内")
|
||||
#反向求值
|
||||
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]
|
||||
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)
|
||||
num+=1
|
||||
data=[]
|
||||
file_path = path # 替换为你的文件路径
|
||||
with open(file_path, 'r') as file:
|
||||
# 逐行读取文件内容
|
||||
lines = file.readlines()
|
||||
# 遍历每行内容
|
||||
for line in lines:
|
||||
data.append(line.split(','))
|
||||
file.close()
|
||||
full_data=pd.DataFrame(data[1:-1],columns=data[0])
|
||||
temp=np.array(full_data['temp']).astype(np.float32)
|
||||
freq=np.array(full_data['freq']).astype(np.float32)
|
||||
freq=freq[::100]
|
||||
temp=temp[::100]
|
||||
result0=[]
|
||||
for i in range(len(temp)):
|
||||
result0.append(model.compensate(freq[i],temp[i],20.66))
|
||||
plt.plot(temp[10:],result0[10:])
|
||||
plt.savefig('fit.png')
|
||||
print('fit result:')
|
||||
print('tc_tcc:'+str(params[0])+'\ntc_tcfl:'+str(params[1])+'\ntc_tctl:'+str(params[2]))
|
||||
data=[]
|
||||
file_path = path # 替换为你的文件路径
|
||||
with open(file_path, 'r') as file:
|
||||
# 逐行读取文件内容
|
||||
lines = file.readlines()
|
||||
# 遍历每行内容
|
||||
for line in lines:
|
||||
data.append(line.split(','))
|
||||
file.close()
|
||||
full_data=pd.DataFrame(data[1:-1],columns=data[0])
|
||||
temp=np.array(full_data['temp']).astype(np.float32)
|
||||
freq=np.array(full_data['freq']).astype(np.float32)
|
||||
freq=freq[::100]
|
||||
temp=temp[::100]
|
||||
result0=[]
|
||||
for i in range(len(temp)):
|
||||
result0.append(model.compensate(freq[i],temp[i],20.66))
|
||||
plt.plot(temp[10:],result0[10:])
|
||||
plt.savefig('fit.png')
|
||||
print('fit result:')
|
||||
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