def resample_1d(data, npoints, smooth = 0, periodic = False, derivative = 0):
"""Resample 1d data using n equidistant points
Arguments:
data (array): data points
npoints (int): number of points in equidistant resampling
smooth (number): smoothness factor
periodic (bool): if True assumes the curve is a closed curve
Returns:
(array): resampled data points
"""
x = np.linspace(0, 1, data.shape[0]);
dinterp = splrep(x, data, s = smooth, per = periodic);
if npoints is all:
npoints = data.shape[0];
x2 = np.linspace(0, 1, npoints);
return splev(x2, dinterp, der = derivative)
评论列表
文章目录