OnEarth
OnEarth

Reputation: 49

Generate impulse train in python

I want to generate a train of impulses. I can generate one impulse by below code:

imp = signal.unit_impulse(200, 'mid')
plt.plot(np.arange(0, 200), imp)

After I create the impulse train I want to convolve one wavelet to it. For one impulse I can do it like below:

imp = signal.unit_impulse(200, 'mid')
points = 200 # number of samples per seconds
a = 22
c = signal.ricker(points, a)
co=np.convolve (imp,c)
plt.plot(np.arange(0, 399), co)

But I need to do this for a long period of time. So at first I need a trian of pulses. Then I will convolve the wavelet to the train. Please give me your idea about this.

Upvotes: 0

Views: 5398

Answers (1)

Sheldon
Sheldon

Reputation: 4643

You can actually use unit_impulse to create multiple impulses: instead of 'mid', simply specify a list containing the locations of the different pulses, for instance:

import scipy.signal as signal
imp = signal.unit_impulse(200, [10,40,50])

The code above will yield the following figure:

enter image description here

Upvotes: 3

Related Questions