0

Reference Table I want to interpolate values two voltage signals using this table and convert them into corresponding temperature values. It isn't a direct bilinear interpolation I want to perform.

for example: T1: 1.721 V T2: 4.025 V

Step 1: Interpolate T1 over Internal Temp. Ch1 I end up with 134.375 °C.

Step 2: From T2, determine the possible row of the expected value (between 250-300 °C) under Referenz and T1 lies between 125 °C and 140 °C) on the columns. This gives me the following grid: 3.608 3.616 4.462 4.468 Now, I would like to calculate the corresponding voltages by interpolation(max and min). I end up with 3.613 V and 4.46575 V.

Step 3: Using the two voltage values calculated in Step 2, interpolate along the rows. i.e. between 250-300 °C and 3.613 V -4.46575 V to find the temperature in °C corresponding to T2=4.025 V.

Is there any way of doing this by directly reading in a table like this as a data frame?

I've been able to do this on excel using index and match and a lengthier way of doing this is reading in series from the table. For example, a code like this to achieve Step 1:

internal=ref_table.loc[['Internal Temp. (Ch1)'],:].squeeze()
y=[20,85,100,125,140,150,160,170,180]
tit_p1=[]
for i in raw_data['T1 Intern']:
    j=np.interp(i,internal,y)
    tit_p1.append(j)
print(tit_p1)

However, I have many tables to deal with and it would be a lot easier if I can somehow convert the voltage values into temperature by using the table as a mesh grid.

Any help would be appreciated! Thanks!

4

1 回答 1

1

这对我有用!我正在为任何可能试图做类似事情的人发布答案。

import numpy as np
import pandas as pd
ref_table=pd.read_csv('Voltage Temp conversion_1.csv',encoding='ISO-8859-1',sep=';',index_col='Referenz')
ref_table=ref_table.dropna(how='all',axis=1)
ref_table=ref_table.dropna(how='all',axis=0)
print(ref_table)

T1=value
T2=value_2

ref_1=[]
for i in ref_table.iloc[2,:]:
    ref_1.append(i)
ref_1[:] = [value - x for x in ref_1]
idx=ref_1.index(min(i for i in ref_1 if i > 0))
T_it=np.interp(value,ref_table.iloc[2,idx:idx+2],ref_table.columns[idx:idx+2].astype(int))
ref_choose=ref_table.iloc[3:,idx:idx+2]
ref_2=[]
for i in ref_choose.iloc[:,0]:
     ref_2.append(i)
ref_2[:] = [value_2 - x for x in ref_2]
idx_2=ref_2.index(min(i for i in ref_2 if i > 0))
ref_fgrid=ref_choose.iloc[idx_2:idx_2+2,:]
Vr_min=np.interp(T_it,ref_fgrid.columns.astype(int),ref_fgrid.iloc[0,:])
Vr_max=np.interp(T_it,ref_fgrid.columns.astype(int),ref_fgrid.iloc[1,:])
T_ch=np.interp(value_2,[Vr_min,Vr_max],ref_choose.index.astype(int)[idx_2:idx_2+2])
    

干杯!

于 2018-01-18T13:46:14.790 回答