def cwt_time(data, wavelet, widths, dt, axis):
# wavelets can be complex so output is complex
output = np.zeros((len(widths),) + data.shape, dtype=np.complex)
# compute in time
slices = [None for _ in data.shape]
slices[axis] = slice(None)
for ind, width in enumerate(widths):
# number of points needed to capture wavelet
M = 10 * width / dt
# times to use, centred at zero
t = np.arange((-M + 1) / 2., (M + 1) / 2.) * dt
# sample wavelet and normalise
norm = (dt / width) ** .5
wavelet_data = norm * wavelet(t, width)
output[ind, :] = scipy.signal.fftconvolve(data,
wavelet_data[slices],
mode='same')
return output
评论列表
文章目录