I'm trying to do a linear combination of different temperature sensors and curve it them with a strain sensor.
What I did is I can fit one temperature sensor with one strain sensor.
But I don't know how to do linear combination of different temperature sensors over one strain sensor.
Here is my attempt:
def process_data_curve_fitting(temperature, strain):
#mean_T = (temperature[[i for i in temperature.columns.tolist() if str(i)[:2] == 'TW']].mean(axis=1))
print("process data")
T1 = temperature['T1'].tolist()
T2 = temperature['T2'].tolist()
T3 = temperature['T3'].tolist()
T4 = temperature['T4'].tolist()
T5 = temperature['T5'].tolist()
T6 = temperature['T6'].tolist()
T7 = temperature['T7'].tolist()
T8 = temperature['T8'].tolist()
T9 = temperature['T9'].tolist()
T10 = temperature['T10'].tolist()
df = pd.DataFrame(list(zip(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)))
mean_T = df.mean(axis = 1)
print(mean_T)
Sensor_Names = [ 'W_A1', 'W_A2', 'W_F1', 'W_F2', 'W_F4', 'W_S1', 'W_S2', 'W_S3', 'W_S4', 'W_KF1', 'W_KF2', 'W_KF3', 'W_KF4', 'W_DB1', 'W_DB2']
ys = []
for i in range(len(strain)):
cof = np.polyfit(mean_T, strain[i], 2)
poly = np.polyval(cof, mean_T)
ys.append(poly)
print (cof)
print (poly)
for i in range(len(strain)):
fig = plt.figure()
plt.scatter(mean_T, strain[i],s=0.1)
# fig.savefig(r'c:\\ahmed\\'+Sensor_Names[i]+'.png')
plt.plot(mean_T, ys[i], color='r')
fig.savefig(r'c:\\ahmed\\'+"Curve_fitting__" + Sensor_Names[i]+'.png',dpi=300)
plt.ylabel('strain' + Sensor_Names[i])
plt.xlabel('temperature')