且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用scipy.signal.resample重新采样的时间

更新时间:2023-02-26 17:00:01

即使您提供x坐标(与t参数相对应),也会

Even when you give the x coordinates (which corresponds to the t argument), resample assumes that the sampling is uniform.

请考虑在 scipy.interpolate 中使用单变量插值器之一.

Consider using one of the univariate interpolators in scipy.interpolate.

例如,此脚本:

import numpy as np
from scipy import interpolate
import matplotlib.pyplot as plt

x = np.array([0,1,2,3,4,5,6,6.5,7,7.5,8,8.5,9])
y = np.cos(-x**2/4.0)

f = interpolate.interp1d(x, y)

num = 50
xx = np.linspace(x[0], x[-1], num)
yy = f(xx)

plt.plot(x,y, 'bo-')
plt.plot(xx,yy, 'g.-')
plt.show()

生成此图:

检查 interp1d 的文档字符串>用于控制插值的选项,并查看其他插值类.

Check the docstring of interp1d for options to control the interpolation, and also check out the other interpolation classes.