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!

hegdep
  • 596
  • 1
  • 6
  • 16
  • Can you explain this procedure a bit better? How are `T1` and `T2` related to each other and how exactly do you use the result of *step 1* in the rest of the calculation? The voltage values within one row of the table are not monotonous, so it might be hard to find the correct column by interpolation. – Thomas Kühn Jan 09 '18 at 12:32
  • @ThomasKühn This is a detailed calculation for the two sample points I have as an example. Step 1: Tit=(Tit_max-Tit_min)/(Vch1_max-Vch1_min)*(T1-Vch1_max)+Tit_max=(140-125)/(1.817-1.561)*(1.721-1.817)+140=134.375. Step 2:Vr_min=(Vch_max-Vch_min)/(Tit_max-Tit_min)*(Tit-Tit_max)+Vch_max=(3.616-3.608)/(140-125)*(134.375-140)+3.616=3.613; similar for Vr_max. Step 3: T_ch=(Tr_max-Tr_min)/(Vr_max-Vr_min)*(T2-Vr_max)+Tr_max=(300-250)/(4.46575-3.613)*(4.025-4.46575)+300=274.16 – hegdep Jan 09 '18 at 13:03
  • @ThomasKühn Basically,in step 2, I position between two columns based on the value of T1. Then, using T2, I try to spot for the corresponding appropriate temperature along the row labels. T1 is between 125 and 140 on the column labels and T2 lies between 250 and 300 as per the row labels. So, I interpolate between 3.608(125°C) and 3.616(140°C) to find Vr_min and between 4.402(125°C) and 4.468(140°C) to find Vr_max to find the inputs to interpolate along the row labels in step 3. – hegdep Jan 09 '18 at 13:10

1 Answers1

1

This worked for me! I'm posting an answer for anybody who might be trying to do something similar.

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])
    

Cheers!

hegdep
  • 596
  • 1
  • 6
  • 16