DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Automatize of time chanel generation

Dear All,

I have an issue with generating time channel automatically. I have data base of 4500-time channels divided into 750 groups. Each group contains channels with different length. Is there a possibility to create time channel for each group with VBA script?

0 Kudos
Message 1 of 11
(2,892 Views)

Hi KrzyFul2,

 

Yes, it is possible to create a time channel in DIAdem. The script command for this is ChnGenTime. But if you need a more detaild answer, it would be helpful getting to know more content about what the time parameters are.

 

Greetings

Walter

0 Kudos
Message 2 of 11
(2,870 Views)

Walter, thank you for the response.

I attached all the details in the .docx file. I'd deeply appreciate your assistance on this.

BR,

Krzysztof

0 Kudos
Message 3 of 11
(2,832 Views)

Hi Krzysztof,

For DIAdem it doesn’t matter how many values a channel contains. But how do you know the parameters for the time channel? The function to generate a channel is ChnLinGen.

 

Extracting a part of a channel is possible. The question is how to know where to start and where to end this cut and how to automate this via algorithm (like if the amplitude is higher then x, this is the starting point, etc.).

 

I have a question in addition, is this a job you must do frequently – with similar a number of groups and channels?

And a last hint, DIAdem 2012 is about 7 years old and only as 32-bit version available. Current DIAdem versions are 64-bit and much faster and optimized. So, it can take more time to do this calculation in 2012 than in DIAdem 2018.

Greetings

Walter

Message 4 of 11
(2,826 Views)

You can try this starter script to loop through all channel groups and create a time channel (in seconds) for each channel as well as generate peak amplitude and frequency channels for each.  You would have to change the sampling frequency at the top to the sampling frequency you used to collect the data.  It works for DIAdem 2017 so I hope it matches 2012.

Option Explicit  'Forces the explicit declaration of all the variables in a script.

' ASSUMING ALL GROUPS WITH CHANNELS ARE LOADED INTO THE DATA PORTAL

DIM SAMPLING_FQ_HZ: SAMPLING_FQ_HZ = 1000 ' DECLARE SAMPLING FREQUENCY

' Mark all the original channels
Dim aGroup, aChnl, startTime, endTime
For Each aGRoup In Data.Root.ChannelGroups
  For Each aChnl In aGroup.Channels
    Call aChnl.Properties.Add("To_Process", "Yes", DataTypeString)
  Next
Next

' Loop through all groups and through all channels in each group to process
For Each aGRoup In Data.Root.ChannelGroups
  Call aGroup.Activate()
  For Each aChnl In aGroup.Channels
    If aChnl.Properties.Exists("To_Process") Then
      startTime = 0
      endTime = (aChnl.Size / SAMPLING_FQ_HZ)
      Call ChnLinGen("/" & aChnl.Name & " - Time", startTime, endTime, aChnl.Size, "")
      FFTIndexChn      = 0
      FFTIntervUser    = "NumberStartOverl"
      FFTIntervPara(1) = 1
      FFTIntervPara(2) = aChnl.Size
      FFTIntervPara(3) = 1
      FFTIntervOverl   = 0
      FFTNoV           = 0
      FFTWndFct        = "Rectangle"
      FFTWndPara       = 10
      FFTWndChn        = "/" & aChnl.Name
      FFTWndCorrectTyp = "No"
      FFTAverageType   = "No"
      FFTAmplFirst     = "Amplitude"
      FFTAmpl          = 1
      FFTAmplType      = "Ampl.Peak"
      FFTCalc          = 0
      FFTAmplExt       = "No"
      FFTPhase         = 0
      FFTCepstrum      = 0
      Call ChnFFT1("/" & aChnl.Name & " - Time","/" & aChnl.Name)
    End If
  Next
Next
Message 5 of 11
(2,823 Views)

Thank you both for help!

a script which was prepared by gsklyr works perfectly fine!

One last thing is Extracting a part of a channel. I'd like to cut this part of the signal in which amplitude exceeds 5% of the maximum value. So if I have 100 mm/s^2 then I'd like to extract the part in which amplitude is higher than 5 mm/s^2. Could you help me with that?

 

Walter, answering your question, yes I must frequently work with a similar number of groups and channels.

0 Kudos
Message 6 of 11
(2,806 Views)

You can try this script code:

 

dim dLimit, iStartPos, iStopPos

R1        = Data.Root.ChannelGroups(1).Channels("Signal").Properties("maximum").Value * 0.05
iStartPos = find("ch(""Signal"") > R1")
iStopPos  = FindReverse("ch(""Signal"") > R1" )

msgbox iStartPos &" - "& iStopPos

call DataBlDel("Signal",1, iStartPos)
Data.Root.ChannelGroups(1).Channels("Signal").Properties("length").Value = iStopPos - iStartPos

Greetings

Walter

0 Kudos
Message 7 of 11
(2,803 Views)

Dear Walter, thank you for your response.

It works, but only for one channel. The signal in the second group stayed without any changes. 

0 Kudos
Message 8 of 11
(2,796 Views)

You can integrate it in first for loop of gsklyr's script like:

 

dim dLimit, iStartPos, iStopPos

For Each aGRoup In Data.Root.ChannelGroups
  For Each aChnl In aGroup.Channels
    R1        = aChnl.Properties("maximum").Value * 0.05
    iStartPos = find("ch(" & aChnl.GetReference(ExtendChnName) & ") > R1")
    iStopPos  = FindReverse("ch(" & aChnl.GetReference(ExtendChnName) & ") > R1" )
    call DataBlDel(aChnl.GetReference(ExtendChnName), 1, iStartPos)
    aChnl.Properties("length").Value = iStopPos - iStartPos
    Call aChnl.Properties.Add("To_Process", "Yes", DataTypeString)
  Next
Next

Greetings

Walter

Message 9 of 11
(2,792 Views)

Dear Walter, 

thank you for your response. Unfortunately, this script doesn't work.

Please find details in attachment. I am considering one more issue. Namely signal has contained values oscillating around 0 (seismic signal). So  code "R1 = aChnl.Properties("maximum").Value * 0.05" could be inappropriate, cause maximum modulus value should be taken into account. Am I right? 

0 Kudos
Message 10 of 11
(2,742 Views)