DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Time Aligning Two Datasets

Solved!
Go to solution

Hi All,

 

Searching on the NI Forums to find a way of aligning two datasets didn't give me what I required, so to detail the issue:

  • I have two sets of data.
  • Both datasets have the same measurement channels
  • I want to plot the datasets against each other.
  • The datasets have different recording lengths so there is an offset in the X-Axis time period.
  • I want to try to align the datasets to overlay specific sections that are identical to each other.
  • I wish to do this using either a time-based X-axis or a logpoint-based X-axis.

Other programs such as Bosch MDA and Uniplot have this feature built in where data alignment is done with a simple, easy drag and drop on the X-axis. I'm surprised that Diadem does not have this.

0 Kudos
Message 1 of 8
(257 Views)

You can generate a time or numeric channel in DIAdem to use as your X axis.  It is under ANALYSIS-> Channel Functions-> Generate numeric/time channel.  You can post an example of your data if you want an example solution/script

0 Kudos
Message 2 of 8
(225 Views)

Hi gsklyr,

 

Thank you very much for your reply. I have cut down some data to as an example and attached two files for your perusal.

 

0 Kudos
Message 3 of 8
(118 Views)
Highlighted

Upon loading the files, applying an offset to the shorter time channel will enable you to plot and compare the two groups (each channel needs to be plotted against its own group time channel).  Just run this:

Call Calculate("ch(""Dataset 2 EXAMPLE/Time"") = ch(""Dataset 2 EXAMPLE/Time"") + 2209")

In this case I arbitrarily assigned the offset to be +2209 on the shorter time channel so that both groups end at the same time.  So you must know what offset to apply to each channel because you dont have absolute time.

Is that the sort of direction you were looking for?

Capture.JPG

0 Kudos
Message 4 of 8
(99 Views)

Hi gsklyr

Thank you for investigating this.

The method is similar to what I require but I wanted to apply it to all channels rather than just each individual channel. Is there a script for that?

0 Kudos
Message 5 of 8
(61 Views)
Solution
Accepted by Uttam_Bhoobun

Hi Uttam_Bhoobun,

 

The solution gskylr offered scales the Time channel values in the File2 group to match the Time channel values in the File1 group.  That DOES effectively apply the X axis offset to all the channels in that File2 group.

 

I'm including a VBScript I wrote a while back to allow you to perform this type of X axis scaling interactively in VIEW with the crosshair cursor.  I also created a quick DataPlugin which I used to load your *.txt file, which I'm including as well, in case that's helpful.

 

So, first load these 2 *.txt files into an empty Data Portal in DIAdem.  Then Plot the "Engine Speed vs. Time" curves from the File1 group and the File2 group on the same VIEW graph.  Then position the crosshair cursor to X = 470 and Y = 2450.  The vertical line of the curve cursor defines where the attached VBScript starts looking (left to right).  Where the horizontal line of the curve cursor first intersects a curve is the rising edge that will be forced to match between the File1 and File2 curves.  Now run the attached script "Time Align Curves.VBS".  You will see the green curve jump to the right to overlap similar features of both curves.  This is done by forcing the first value of the green curve intersected (to the right of its vertical line) by the horizontal line of the crosshair cursor to have the same X value as the first value of the red curve intersected.  It only truly matches all the features to the extend that there is just one constant X axis offset.  The math is the same as in gskylr's VBScript.

 

Brad Turpin

DIAdem Product support Engineer

National Instruments

Message 6 of 8
(51 Views)

Oh,

 

I forgot to mention, the first time you run the attached VBScript, it adds a new "Time Align Curves" icon on the right side of the top icon bar in the VIEW panel.  You can click that icon to re-run the VBScript without having to leave the VIEW panel.

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 7 of 8
(49 Views)

Hi Brad,

 

This worked really well; thank you for posting this and also for creating the toolbar icon too; that was really useful.

 

 

 

0 Kudos
Message 8 of 8
(28 Views)