DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

How to merge two channels with different time channels

Hello,

 

I'm looking for a way to merge two channels from different channel groups.

The channel groups have their own date/time channel.

 

Example of two channelsExample of two channels

 

 

 

 

 

 

 

 

 

 

 

 

Here is a example of those two channels.

How can I merge them into one channel by time/date?

In Python with pandas you can achieve this with a join, is this also possible in DIAdem?

 

Thank you!

 

 

 

0 Kudos
Message 1 of 7
(1,447 Views)

Hi blume,

 

As far as I know, the JOIN method is only applicable for strings. DIAdem channels do not provide such a function.

With such a question one must distinguish different conditions, in order to calculate the data physically correctly.

 

  • If the channels have the same sampling rate and a same start and the irrelevant values in both channels are 0, then the channels can simply be added.
  • If the sampling rate is different, one of the two channels must be mapped to the other sampling rate (linear mapping or resampling).
  • If the start is different, only the common time domain may be considered.
  • If the non-relevant values are not equal to 0 or if the relevant values overlap, it must be clarified which channel has priority.

However, this can only be clarified exactly with the data itself.

 

Greetings

Walter

0 Kudos
Message 2 of 7
(1,416 Views)

Hi Walter,

 

thanks for your response.

To clarify which conditions must be distinguished, I attached a example file containing two channel groups.

Can you help me merge these two channels?

 

Greetings

blume

 

 

 

0 Kudos
Message 3 of 7
(1,411 Views)

Hi blume,

 

Here is a very fast script to join both channel pairs.

 

dim oGroupChns, oChnX1, oChnX2, oChnY1, oChnY2, oResultChnX, oResultChnY
dim iStartPos1,iStartPos2, iStopPos1, iStopPos2

' declare channel values
set oGroupChns = Data.Root.ChannelGroups(1).Channels
set oChnX1     = oGroupChns("Zeit")
set oChnX2     = oGroupChns("Zeit1")
set oChnY1     = oGroupChns("ComGM_Motorspeed")
set oChnY2     = oGroupChns("ComGM_Motorspeed1")

' extract relevant values for the first channel pair 
ChnEventList1 = ChnEventDetectionWindow(oChnX1, oChnY1, 1, 500000, 0, 0)
Call ChnEventCreateFilteredTrueChn(oChnX1, ChnEventList1, oChnX1, NOVALUE)
Call ChnEventCreateFilteredTrueChn(oChnY1, ChnEventList1, oChnY1, NOVALUE)
Call ChnNovHandle(oChnX1, oChnY1, "Delete", "XY", True, False, 0)

' extract relevant values for the second channel pair 
ChnEventList1 = ChnEventDetectionWindow(oChnX2, oChnY2, 1, 500000, 0, 0)
Call ChnEventCreateFilteredTrueChn(oChnX2, ChnEventList1, oChnX2, NOVALUE)
Call ChnEventCreateFilteredTrueChn(oChnY2, ChnEventList1, oChnY2, NOVALUE)
Call ChnNovHandle(oChnX2, oChnY2, "Delete", "XY", True, False, 0)

' concatenate both X channels
Set oResultChnX = ChnConcatenateChannels(oChnX1, oChnX2, False, False, False)
' concatenate both Y channels
Set oResultChnY = ChnConcatenateChannels(oChnY1, oChnY2, False, False, False)
oResultChnX(1).Name = "JoinedChnX"
oResultChnY(1).Name = "JoinedChnY"
' sort both channels time related
call ChnMultipleSortExt(oResultChnX(1), oResultChnY(1), "Up", "UpperCase", true)

 

Greetings

Walter

0 Kudos
Message 4 of 7
(1,399 Views)

Hi Walter,

 

thank you very much for your response.

I'm sorry to bother you again, but how can I use this script when I have more y-channels?

I attached another example.csv file with more y-channels.

 

Sorry and thank you again!

 

Greetings 

blume

 

0 Kudos
Message 5 of 7
(1,390 Views)

Hi blume,

 

here is my suggestion for this.

 

dim oGroupChns, oChnX1, oChnX2, oChnY1, oChnY2, oResultChnX, oResultChnY
dim iStartPos1,iStartPos2, iStopPos1, iStopPos2
dim oResGroup, oResGroupChns, oResChnX1, oResChnX2, oResChnY1, oResChnY2

' declare channel values
set oGroupChns    = Data.Root.ChannelGroups(1).Channels

set oChnX1        = oGroupChns("Zeit")
set oChnY1        = oGroupChns("ComGM_Motorspeed")
set oChnX2        = oGroupChns("Zeit_1")
set oChnY2        = oGroupChns("ComGM_Motorspeed_1")
set oResGroup     = Data.Root.ChannelGroups.Add("Result_" & oChnY1.Name)
set oResGroupChns = oResGroup.Channels
set oResChnX1     = oResGroupChns.AddChannel(oChnX1)
set oResChnY1     = oResGroupChns.AddChannel(oChnY1)
set oResChnX2     = oResGroupChns.AddChannel(oChnX2)
set oResChnY2     = oResGroupChns.AddChannel(oChnY2)
call oResGroup.Activate
call JoinChannels(oResChnX1, oResChnX2, oResChnY1, oResChnY2)

set oChnY1        = oGroupChns("ComGM_AbsSollDrehzahl")
set oChnY2        = oGroupChns("ComGM_AbsSollDrehzahl_1")
set oResGroup     = Data.Root.ChannelGroups.Add("Result_" & oChnY1.Name)
set oResGroupChns = oResGroup.Channels
set oResChnX1     = oResGroupChns.AddChannel(oChnX1)
set oResChnY1     = oResGroupChns.AddChannel(oChnY1)
set oResChnX2     = oResGroupChns.AddChannel(oChnX2)
set oResChnY2     = oResGroupChns.AddChannel(oChnY2)
call oResGroup.Activate
call JoinChannels(oResChnX1, oResChnX2, oResChnY1, oResChnY2)

set oChnY1        = oGroupChns("ComGM_BattVolt")
set oChnY2        = oGroupChns("ComGM_BattVolt_1")
set oResGroup     = Data.Root.ChannelGroups.Add("Result_" & oChnY1.Name)
set oResGroupChns = oResGroup.Channels
set oResChnX1     = oResGroupChns.AddChannel(oChnX1)
set oResChnY1     = oResGroupChns.AddChannel(oChnY1)
set oResChnX2     = oResGroupChns.AddChannel(oChnX2)
set oResChnY2     = oResGroupChns.AddChannel(oChnY2)
call oResGroup.Activate
call JoinChannels(oResChnX1, oResChnX2, oResChnY1, oResChnY2)

'-------------------------------------------------------------------------------
'-------------------------------------------------------------------------------
'-------------------------------------------------------------------------------
sub JoinChannels(oChnX1, oChnX2, oChnY1, oChnY2)
  ' extract relevant values for the first channel pair 
  ChnEventList1 = ChnEventDetectionWindow(oChnX1, oChnY1, 1, 500000, 0, 0)
  Call ChnEventCreateFilteredTrueChn(oChnX1, ChnEventList1, oChnX1, NOVALUE)
  Call ChnEventCreateFilteredTrueChn(oChnY1, ChnEventList1, oChnY1, NOVALUE)
  Call ChnNovHandle(oChnX1, oChnY1, "Delete", "XY", True, False, 0)
  
  ' extract relevant values for the second channel pair 
  ChnEventList1 = ChnEventDetectionWindow(oChnX2, oChnY2, 1, 500000, 0, 0)
  Call ChnEventCreateFilteredTrueChn(oChnX2, ChnEventList1, oChnX2, NOVALUE)
  Call ChnEventCreateFilteredTrueChn(oChnY2, ChnEventList1, oChnY2, NOVALUE)
  Call ChnNovHandle(oChnX2, oChnY2, "Delete", "XY", True, False, 0)
  
  ' concatenate both X channels
  Set oResultChnX = ChnConcatenateChannels(oChnX1, oChnX2, False, False, False)
  ' concatenate both Y channels
  Set oResultChnY = ChnConcatenateChannels(oChnY1, oChnY2, False, False, False)
  oResultChnX(1).Name = "Joined_" & oChnY1.Name & "_Time"
  oResultChnY(1).Name = "Joined_" & oChnY1.Name
  ' sort both channels time related
  call ChnMultipleSortExt(oResultChnX(1), oResultChnY(1), "Up", "UpperCase", true)
end sub

 

Greetings

Walter

0 Kudos
Message 6 of 7
(1,384 Views)

Hi Walter,

 

In your solution, each newly created joined channel has its own time channel.

Is it possible to get only one time channel for all joined channels?

 

Greetings 

blume

0 Kudos
Message 7 of 7
(1,377 Views)