Using DIAdem to Synchronize Data From Different Files

Updated Nov 17, 2022

Environment

Software

  • DIAdem

This article demonstrates how to use the Synchronize Data from Different Files function in DIAdem™ to shift the x-axis of multiple channels so that they become synchronized. This function is useful for removing time offsets between channels and to visually compare channels.

The steps below indicate how this can be accomplished manually and automatically. Optionally, download the attached example files to follow along with the tutorial.

For demonstration purposes, this article refers to the files in the attached .zip folder. Namely:

  • test set1.TDM
  • test set2.TDM
  • Synchronize Channels script.VBS
 

Manually Synchronizing Channels

1. Load the two data files ("test set1.TDM" and "test set2.TDM" in the example) into DIAdem's Data Portal. 2. If using Waveform Channels, convert them into Numeric Channels. Note: It is possible to synchronize Waveform Channels. However, both channels must have the same Waveform x-offset and Waveform x-step width property values.
  • On the ANALYSIS Panel, navigate to Channel Functions >> Numeric Channels <-> Waveform Channels...
  • In the pop-up window, set the following options:
    • Conversion mode to Waveform channels <-> Numeric channels.
    • X-part to Generate numeric channel (relative time reference).
    • Click the "..." button next to Channels to select multiple Waveform Channels to convert.
    • Click OK.
  • Complete this step for both TDM data files.
 Convert waveform to numeric.png

3. The Data Portal will now list Numeric Channels (indicated by the "XY" symbol) along with a new channel that represents the x-axis of the converted channels (titled "NoName" and "x" for each Channel Group in the example).
  • Note: if two or more x-axis Numeric Channels are generated within a single Channel Group, verify that all y-axis channels reference the corresponding x-axis by following these steps:
    • Navigate to Channel Functions >> Channels <-> XY-Channels in the ANALYSIS Panel.
    • In the pop-up window, set the Conversion mode to Create channel reference.
    • Select the y-axis channel(s) that require re-referencing and specify an x-axis channel to be referenced. 
    • At this point, any unused x-axis channels can be deleted.
    • Verify that each y-axis channel within a Channel Group is referencing the same x-axis channel by checking the X-Channel reference property, as shown below.

Data Portal after both groups converted.png

4. If the newly generated x-axis channels do not have a value for Source file, Source file path and Data source type properties, follow the steps below:
  • Select the x-axis channel in the Data Portal and expand the Origin properties section.
  • Modify the Source file, Source file path and Data source type properties to match the y-axis channels, as highlighted in the image below.
  • Repeat this for all x-axis channels.
Channel origin properties completre.png

Note: The Channels <-> XY-Channels function mentioned in step 3 can also be used if your data channels were already Numeric Channels and you did not had to convert them from Waveform Channels, this will create a reference between the y-axis channels and their corresponding x-axis channel.

5. In the ANALYSIS Panel, click Channel Functions >> Synchronize Data from Different Files.
6. In the pop-up window, choose the following configuration:
  • Synchronization Channels to the channels that require synchronizing.
    • This is "[1]/U+ (rms)" and "[2]/U_pos_pu" in the example.
  • X-Offset Correction to Automatic and Calculate in frequency domain.
  • Click OK.
  • The ANALYSIS Panel will populate with the following message upon successful completion:
"Mapping onto the new x-area was successful. All channels requiring modification were replaced."

Synchronize channels function.png

7. Navigate to the VIEW Panel and plot the synchronized channels.
 

Automatically Synchronizing Channels

The code in this section executes the steps above inside a VB Script (.VBS file). From the DIAdem SCRIPT Panel, open "Synchronize Channels script.vbs" from the example files.
Alternatively, select File >> New VBS from the SCRIPT Panel and paste in the following code.

Note: Modify the bolded line in the code below to load the TDM data files from the local directory on your PC.

'-------------------------------------------------------------------------------
'-- VBS script file
'-- Created on 03/22/2022 16:00:27
'-- Author: NI
'-- Comment: Demonstration of how to use the Synchronize Data from Different Files function
'-------------------------------------------------------------------------------
Option Explicit  'Forces the explicit declaration of all the variables in a script.
Dim i, j, mySheet, myArea, myGraph, myCurve

'--Load in the 2 files. NOTE: you will have to change this directory for your PC --'
Data.Root.Clear()
Call DataFileLoad("C:\Downloads\test set1.TDM|C:\Downloads\test set2.TDM", "TDM", "Load|ChnXYRelation")


'--Display unsynchronized channels --'
Call MsgBoxDisp("Channels before synchronization:")

Call View.NewLayout
Set mySheet = View.Sheets(1)
Set myArea = mySheet.Areas(1)
myArea.DisplayObjType = "CurveChart2D"
Set myGraph = myArea.DisplayObj
Call myGraph.Curves2D.RemoveAll
myGraph.YScaling = "n axes [phys.]"
Set myCurve = myGraph.Curves2D.Add("","[1]/U+ (rms)")
Set myCurve = myGraph.Curves2D.Add("","[2]/U_pos_pu")

WndShow("VIEW")



'--Change some channel properties to make looping easier later on --'
For i = 1 to data.Root.ChannelGroups.Count
  For j = 1 to data.Root.ChannelGroups.Count
    Data.Root.ChannelGroups(i).Channels(j).Properties("wf_xname").Value = "x"
   Next
Next

'-- Convert the first waveform channel in each Group to numeric. This generates a new Numeric x axis channel --'
Set ChnResult = ChnConvertWaveformToNumeric("[1]/[1]", False, "WfXRelative")
Set ChnResult = ChnConvertWaveformToNumeric("[2]/[1]", False, "WfXRelative")

'-- Rename the newly generated numeric X axis channel to Time --'
Data.Root.ChannelGroups(1).Channels("x").Name = "Time"
Data.Root.ChannelGroups(2).Channels("x").Name = "Time"

'-- Convert the other waveform channels into numeric, but remember to relate every Y channel to the numeric X channel generated in line 22. --'
For i = 1 to data.Root.ChannelGroups.Count
  For j = 3 to data.Root.ChannelGroups(1).Channels.Count
    Set ChnResult = ChnConvertWaveformToNumeric("["&i&"]/["&j&"]", False, "WfXRelative")
    Set Data.GetChannel("["&i&"]/["&j&"]").xRelation = Data.GetChannel("["&i&"]/Time")
    
    If Data.Root.channelgroups(i).Channels.Exists("NoName") Then
      Call Data.Root.ChannelGroups(i).Channels.Remove("NoName")
    ElseIf data.Root.channelgroups(i).Channels.Exists("x") Then
      Call Data.Root.ChannelGroups(i).Channels.Remove("x")
  End If
  
  Next
Next

'-- Use the Synchronize Data from Different Files function --'
Call ChnResampleFreqBasedXOffsetCalc2("[1]/Time","[1]/U+ (rms)","'[1]/Time', '[1]/U+ (rms)', '[1]/I+ (rms)', '[1]/P (W)'",0,"[2]/Time","[2]/U_pos_pu","'[2]/Time', '[2]/U_pos_pu', '[2]/P', '[2]/I_pos_pu'",-2.1818909,1,"Automatic",2000,"Automatic",0,0,"TimeDomain",10)

Call MsgBoxDisp("Channels after synchronization:")