Align or sync time series data

Hello. I am relatively new to Igor and I am looking to align two waves in the time scale. I have responses of two instruments against the time. Due to their inherent response time , they are offset by about a minute.

I have a two waves, wave0 and wave1 (for simplicity) and a time wave. For further data analysis, I need to first align the two waves. Both the responses are different so I would like to sync the waves by the minima/maxima. I know that all I have to do is to find the time lag and do the necessary alignment but I am not sure how to proceed in calculating the lag time. I could do it manually by deleting the points but in the near future I will have lots of data and would prefer a code to do it. I know this might be trivial but I would appreciate any help.

Thanks.
Align.pxp
Hello,

I have a question: why do you have only one time wave and 2 data waves (with shifted data)?
Is there a reasonable specialty in your setup that forces you to use this format (like two detectors on a delay line)?

With the given information I would suggest that you check if you can synchronize your data acquisition or at least use two time waves (one for each data wave)?
Is the different delta in your waves an artifact or is it intentionally set (since you use "vs" different delta do not make much sense)?

My guess would be that an automatic correction is error prone. At least you should manually verify the result.
A first attempt to solve this might be to use the v_maxloc information from wavestats and delete data points to match the maxima. In your example it should work, but it's close to a fail.
Maybe you can calculate the delay between the two data sets by correlation? I did not test this.

displayhelptopic "wavestats"
displayhelptopic "correlate"
Hello,

The reason I have one time wave and two data sets is because I am using a data-logging software to log the data of the two instruments simultaneously. My setup is fixed and is such that the flow to the instruments are in parallel to each other, although one flow 'leg' is longer than the other. Another reason for this lag might be due to the inherent response time of these instruments, which I have no control over. It is okay as long as the lag is under 5 seconds. I know I have to shift one of the waves by a certain number of points, but the only issue is how to arrive at that number.

Thanks for the help on wavestats and correlate. I will work on this and see if I come up with anything relevant.
Hello

considering your time wave you will run into trouble if the "inherent response time" is longer than two seconds (effects depend on your system).

Do I get you right? You want to compensate in Igor for a time delay due to the different lengths of the legs in your setup. And of course you want to vary the flow and the delay is not constant.

Maybe the solution is a semi-automated procedure:
- Display both wave like in your example
- Add cursors on both waves
- Manually select corresponding peaks
- Use a programmable hotkey to run a procedure that calculates the "point-distance" between the cursors and deletes these data points from one weave
- Maybe run this in a loop
Have a look at "Programing with Cursors" and "pcsr" for this.

I assume you write the start of a sample in the time wave start the two sampling procedures and put the result in the data waves (since it has a 2 sec spacing)? In this case the inherent time does not show up.
Writing two time stamps after the acquisition might be better but will not solve your specific issue.

HJ
You could also use the Wave Arithmetic package. To learn more about it, see the demo experiment: File->Example Experiments->Analysis->Wave Arithmetic Panel Demo.

While I was trying it out, I discovered what I think is an Igor bug. To do what you want, you need to re-make the graph with two X waves. So, first make a duplicate of the time wave:
Duplicate Date_Time, Date_Time1
and then make a new graph with wave0 vs Date_Time and wave1 vs Date_Time1

Now you can choose Analysis->Packages->Wave Arithmetic, put the cursors on peaks that you think should be in the same place, then use the X Shift tab in the panel to have one or both of the Date_Time waves altered so that the cursors are at the same X value.

I actually thought about this problem, and Wave Arithmetic will make the duplicate X wave for you, and it will try to replace the X wave on the relevant trace with the duplicate. But the ReplaceWave operation appears to be doing the wrong thing. I will file a bug...

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
OK, I thought about what ReplaceWave is doing, and at some twisted level it is working "as expected". But it seems wrong. But, either

1) It's a bug, but it's going to be really hard to fix,

or

2) It's not bug, just a misfeature :)

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
Hello.

The X shift worked like a charm! Thank you so much for all the help!