This commit is contained in:
Sgr A* VMT
2023-11-26 23:06:44 +08:00
parent 18a8397de5
commit ac40d56e10

View File

@@ -89,43 +89,48 @@ 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:
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: for path in paths:
plt.subplot(num) plt.subplot(num)
num+=1 num+=1
datas.append(data_process(path)) data=[]
except: file_path = path # 替换为你的文件路径
print("please make sure you have move the 4 data file to IDM folder\n请确认你有把4个文件拷到IDM文件夹内") with open(file_path, 'r') as file:
#反向求值 # 逐行读取文件内容
model=TempModel(1,-2.1429828e-05,-1.8980091e-10,3.6738370e-16,2943053.84,20.33) lines = file.readlines()
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 line in lines:
for path in paths: data.append(line.split(','))
plt.subplot(num) file.close()
num+=1 full_data=pd.DataFrame(data[1:-1],columns=data[0])
data=[] temp=np.array(full_data['temp']).astype(np.float32)
file_path = path # 替换为你的文件路径 freq=np.array(full_data['freq']).astype(np.float32)
with open(file_path, 'r') as file: freq=freq[::100]
# 逐行读取文件内容 temp=temp[::100]
lines = file.readlines() result0=[]
# 遍历每行内容 for i in range(len(temp)):
for line in lines: result0.append(model.compensate(freq[i],temp[i],20.66))
data.append(line.split(',')) plt.plot(temp[10:],result0[10:])
file.close() plt.savefig('fit.png')
full_data=pd.DataFrame(data[1:-1],columns=data[0]) print('fit result:')
temp=np.array(full_data['temp']).astype(np.float32) print('tc_tcc:'+str(params[0])+'\ntc_tcfl:'+str(params[1])+'\ntc_tctl:'+str(params[2]))
freq=np.array(full_data['freq']).astype(np.float32)
freq=freq[::100] if __name__== "__main__" :
temp=temp[::100] main()
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]))