我需要插入两个大小不同的列表

时间:2019-05-31 19:28:55

标签: python-3.x

我需要对两个大小不同的列表进行插值,然后将结果与另一个大小不同的列表求和

我已经尝试过循环,但可能不是功能强大或高效的循环     从scipy.interpolate导入interp1d

import numpy as np
V_correction= (np.array([-7.73, -7.76, -8.32,80]))
Temp_Unit = (np.array([25.5,50,80]))
calibration_Temp_Drift = interp1d(Temp_Unit,V_correction)

temp_at_sensor = np.array([65, 66, 67, 71, 70, 56])
rawV_at_sensor = np.array([95, 56, 105, 400, 20])

V_correction_Temp_Drift = calibration_Temp_Drift(temp_at_sensor)

no_drift_V = rawV_at_sensor+V_correction_Temp_Drift

print(no_drift_V)


U_correction = (np.array([100,200,300]))
V_volts = (np.array([.34,.38,.4]))

calibration_Units_Drift = interp1d(U_correction,V_volts)

U_correction_W_Drift = calibration_Units_Drift(no_drift_V)

print(U_correction_W_Drift)

错误消息如下:

line 7, in <module>
calibration_Temp_Drift = interp1d(Temp_Unit,V_correction)
line 431, in __init__
_Interpolator1D.__init__(self, x, y, axis=axis)
line 60, in __init__
self._set_yi(yi, xi=xi, axis=axis)
line 125, in _set_yi
raise ValueError("x and y arrays must be equal in length along "
ValueError: x and y arrays must be equal in length along interpolation axis.

0 个答案:

没有答案