# how can we align wto signals with a time lag in between?

I have two signals from two different sensors. I cropped the area i am interested in from both sensor signals. The problem is that the signals start at different time instants. I am searching for a way to align the signals just like below. It is technically just moving the blue signal to align with orange one. I tried using cross correlation but it gave a weird result. Any help please. first image: this is the result of cross correlation of two signals Second image :after applying code on cross correlation to align   • What exactly was weird about your cross correlation results ? Dec 3 '19 at 14:22
• Try removing the mean from both samples prior to doing the cross correlation Dec 3 '19 at 14:25
• I use 'lag=np.argmax(signal.correlate(x,y))' where x and y are the signals. This function typically calculates the index at which maximum cross correlation occurs. The index from what I understood is considered to be the time lag. So if I shift the signal Y by 'lag' it should be aligned with x. However the value 'lag' I get from the function is more than the length of the signal. x length 10880 y length 11035 lag i get is 11770. Dec 3 '19 at 14:41
• I've deleted my answer as I misunderstood the plots. I thought the blue and orange signals were the same but delayed, but they are actually different signals altogether! Dec 4 '19 at 19:53