![](/profiles/wavemetrics/themes/wavemetrics/logo.png)
Aligning multiple waves to the same timescale
![](/sites/default/files/styles/thumbnail/public/krediger/profile-images/2024-07/Headshot_KLR.jpg?itok=xETNxDpu)
I have data that is on an exact one-second timescale. Then I have another set of data that's a bit messier...
1. its not on exact one-second timescale (ie. 1:00:01.34589, 1:00:02.47638, 1:00:03.69284, etc)
2. the time is no continuous- there is missing time when the instrument was down. (ie: skips from 01:00:04.0936 to 05:00:00.1836)
My goal is to get the 2nd, "messy" data spread out on a continuous timescale (with -9999 replacing where there's no data) that counts up by exactly one second so that I can run a correlation of the first and second datasets as a function of time.
So far, I have (1) identified the missing times and added in the correct number of missing points and (2) tried using "round", "floor" and "ceil" to get the timescale into exact seconds. The problem is that this sometimes results in double-counting of seconds based off which rounding mechanism I use (ie: 1:00:01.5673 and 1:00:02.1346 both round to 1:00:02). I have put the code as it stands below (sorry it's a bit messy).
![Code for the process described above](/sites/default/files/styles/content_body/public/2024-07/Screenshot%202024-07-23%20095619.png?itok=Gmzf8ZVe)
i think you want > rather than >> in your code.
Have you considered using interpolate to clean up your data?
Look under Analysis - Interpolate... for the interpolate dialog. If you have a wave containing the 'clean' times, interpolate can fill in corresponding values from the messy readings.
July 23, 2024 at 09:53 am - Permalink
The Interpolate2 operation with /I=3 might be useful in this case.
For background information, execute:
DisplayHelpTopic "The Interpolate2 Operation"
For details on /I=3:
DisplayHelpTopic "Destination X Coordinates from Destination Wave"
In 2012 (how time flies:) Tony posted a worked out snippet which does not use /I=3 here: https://www.wavemetrics.com/code-snippet/interpolate-path-equal-steps
July 23, 2024 at 11:36 am - Permalink
In reply to The Interpolate2 operation… by hrodstein
I think that code snippet from 2012 aims to do something slightly different. It was a workaround for producing an interpolated path where the distances between successive points in the x-y plane are equal. Here I think the desire is for interpolation where x-coordinates are taken from a 'cleaned-up' wave, so Interpolate2 with the /I=3 flag is appropriate.
If you're using the Interpolate dialog you should choose 'from Dest Wave' in the 'Dest X Coordinates' dropdown menu, or, as Howard wrote, use the /I=3 flag in the coded version.
July 24, 2024 at 02:41 am - Permalink