Extract Channels Sections in DIAdem Script

Updated Jun 27, 2023

Reported In

Software

  • DIAdem

Issue Details

I need to extract a specific section of a channel, loaded into Data Portal, to copy it into a new channel and be able to run analysis function only on this section.
I know that I can create a 2D Axis System in VIEW panel, plot my channel, add a band cursor to select the desired range and then use Flag functions to copy the selected data points into a new channel.

How can I perform this operation automatically in a DIAdem script? Which script functions should I use?

 

Solution

In a DIAdem script, you have different options to achieve this implement this task:
  • use Block operations
  • call GetValuesBlock method for Channel class to retrieve an array of values from the original channel and SetValuesBlock method to insert this array into a new channel
  • implement and Event search to search for specific events in the original channel and copy the found events into new channels. You can find an example called Searching for Events in Channels in DIAdem clicking on Help » Examples

Additional Information

Here you can find an extract of an example of the second options described above. You have to declare all variables with Dim operator. P1 and Pn variables should be assigned to the indexes of the section of the original channel you need to copy in a new channel. Time and Vibration are the two original channels, TimeCopy and VibrationCopy are the newly created channels.
Set oOldChns = Data.Root.ActiveChannelGroup.Channels
Set oNewChnTime = oNewChnGrp.Channels.Add("TimeCopy",DataTypeFloat64)
Set oNewChnVibr = oNewChnGrp.Channels.Add("VibrationCopy",DataTypeFloat64)
aMyArray = oOldChns("Time").GetValuesBlock(P1,Pn)
Call oNewChnTime.SetValuesBlock(aMyArray, 1, eValueBlockValueOverwrite)  
aMyArray = oOldChns("Vibration").GetValuesBlock(P1,Pn)
Call oNewChnVibr.SetValuesBlock(aMyArray, 1, eValueBlockValueOverwrite)