I have a signal containing a variation of digital ASK type on-off keyed sine wave among which some stochastic irrelevant harmonic waves occur, like you can see on this figure:
In its current form each pulse duration is the same, but it's not always the case.
I'd like to calculate each pulse duration. To do that, I was thinking of converting this signal to a square wave signal like this:
I'm not sure of the different steps needed for this conversion but I have some leads:
- Remove the noise => Low pass filter I presume?
- To have the signal between 0 and the amplitude, I multiply the signal by itself
- I apply a magic filter to convert the signal to square signal.
So my questions are:
- Do I need a low pass filter to remove the noise?
- What kind of filter do I need to convert the signal to square signal? Is it possible?
For information, I'm using Python and Numpy.
If there is any other method to calculate the duration of each pulse in the sequence, I'm open to all ideas.
Thanks!
Edit: Here's my signal:
freq = 1000000
fs = int(2*freq) # sample rate
x = np.linspace(0, 10, fs)
noise1 = 0.01*np.sin(2*np.pi * 1*x) + 0.05*np.sin(2*np.pi * 1.5*x) + 0.04*np.sin(2*np.pi * 0.2*x)
noise2 = 0.1*np.sin(2*np.pi * 0.1*x) + 0.2*np.sin(2*np.pi * 1.8*x) + 0.1*np.sin(2*np.pi * 0.4*x)
realSignal = 2*np.sin(2*np.pi * freq*x)
sig = noise1
sig = np.append(sig, [realSignal, noise2, realSignal, noise1*noise2])