A left shift of t0 in a signal can be obtained by convolving it with δ(t+t0). I want to obtain this in python using discrete signals by only using the np.convolve
operator in mode='full'
. Note that I can't use np.roll
or assignment from an index like [shift:]
. It has to be obtained purely by convolution. Here's an example:
signal = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9])
shift = 3
filter = ??
shifted_signal = np.convolve(signal, filter, mode='full')
print(shifted_signal)
[4, 5, 6, 7, 8, 9, 0, 0, 0, ...
The number of zeros at the right side, or to say the length of shifted_signal
is not important. But I want the signal to start from the correct position. What should the filter
be such that I get the desired output? I need it this way because I am trying to obtain the left shift from an FFT analysis. A left shift of t0 in the time domain corresponds to a multiplication of ei2πft0 in the frequency domain. I can obtain t0 by comparing the shifted signal with the original in the frequency domain. But to check if my algorithm works, I just can't think of a filter that performs a left shift in the time domain.
I tried filter = [0, 0, 0, 1]
and filter = [1, 0, 0, 0]
but they adds zeros to the left and right of the signal. The signal itself doesn't start from the desired index. I have no idea what other filter I can use to obtain the desired result.
You can't shift signal left using standard convolution (without cutting the signal as mode 'same' does). There is no filter kernel that could accomplish that. If you could do that you could also travel back in time or foresee future.
Convolution can represent Linear System that has an input and some changed delayed (or not, but definitely not hastened) output. If it could "hasten" signals it would mean it could read future - give some information on the output about signal that hasn't yet entered input.
However, we are in digital domain, and can interpret results of the discrete convolution a bit arbitrarily. We can assume any time domain we want for the convolution kernel.
We can say that kernel (e.g. [1, 0, 0]) has time domain of [-1, 0, 1]. For simplicity signal has time domain [0, 1, 2..]. This way result of the convolution will have time domain shifted, to the beginning of kernel: [-1, 0, 1, 2..]. And we accomplished shifting signal left.
We could use any time domain we wanted for the kernel and have different result, but the one that is symmetrical around 0 seems common sense.