一、二维的插值方法:
原始数据(x,y)
先对横坐标x进行扩充数据量,采用linspace。【如下面例子,由7个值扩充到300个】
采用scipy.interpolate中的spline来对纵坐标数据y进行插值【也由7个扩充到300个】。
画图
import matplotlib.pyplot as plt
import numpy as np
#数据
T = np.array([6, 7, 8, 9, 10, 11, 12])
power = np.array([1.53E+03, 5.92E+02, 2.04E+02, 7.24E+01, 2.72E+01, 1.10E+01, 4.70E+00])
#插值
from scipy.interpolate import spline
xnew = np.linspace(T.min(),T.max(),300) #300 represents number of points to make between T.min and T.max
power_smooth = spline(T,power,xnew)
print(xnew.shape) #(300,)
print(power_smooth.shape) #(300,)
#画图
plt.plot(xnew,power_smooth)
plt.show()
二、三维平滑图---插值:
1、数据:
x = [0.1,0.2,……,0.9] (shape = (9))
y = [0.1,0.2,……,0.9] (shape = (9))
z = 【81个数据】(shape = (81))
生成数据:
x = np.linspace(0.1,0.9,9)
y = np.linspace(0.1,0.9,9)
z = np.random.rand(81)<