Saturday, 22 October 2022

Synchronizing two noisy sinusoids out of phase

I currently have two noisy sinusoids which are out of phase and I am looking for a solution to set them in phase. Firstly, I was trying to just adjust the sinusoids via finding the zero-crossing values with an upward trend, however, as there is some noise in the signal, this solution is not suitable. I made a small mock-up example:

time = np.arange(0, 60, 0.005)
amp = 2
F = 0.25
signal1 = amp*np.sin(2*np.pi*F*time + np.pi)
signal2 = amp*np.sin(2*np.pi*F*time + np.pi/3)

mu, sigma = 0.2, 0.1 # mean and standard deviation
noise1 = np.random.normal(mu, sigma, len(signal1))
noise2 = np.random.normal(mu, sigma, len(signal2))


noisy_signal1 = signal1 + noise1
noisy_signal2 = signal2 + noise2

plt.figure()
plt.plot(time, noisy_signal1)
plt.plot(time, noisy_signal2)
plt.show()

Of course that in reality, I don't know which is the phase shift, but I do know the amplitude and the frequency of each sinusoidal beforehand. What I want to achieve, is to go from the plots you can see when running the code, to this: enter image description here

EDIT1: Using the correlation function might be a suitable solution. However, you will have the problem that since the signal is noisy, the maximum correlation could be found in several periods ahead of one of the signals, and therefore, losing a lot of data points when doing the shift. I am looking specially for a solution in which I am identifying the phase and just shifting one of the sinuoids.



from Synchronizing two noisy sinusoids out of phase

No comments:

Post a Comment