DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Average Peak Values from a large number of Yokogawa Waveforms

Solved!
Go to solution

Hello everyone: I'm still pretty new to Diadem, so please keep the suggestions to a "diadem for dummies" level.  🙂

 

I have 40 yokogawa files, each with 500 waveforms in them.  I need to find the minimum peak value for each waveform.  Then I need to report the overall maximum, average, and standard deviation of all 500 peaks.  I need to do this on all 40 files. If you have a suggestion for this, please let me know, my idea is below. 

 

 

It's a lot to do manually, so I thought about doing a script for each file.  I am so-so when it comes to VB, but I can usually figure it out, slowly. 

This is my idea:

 

  1. Have the script load the file I tell it
  2. Create a new group labeled maximums
  3. Loop 500 times to find the min peak of all waveforms
  4. combine all the peaks into one channel (can I do this?)
  5. Perform maximum, average, and st. dev. calculations on this channel. 

This seems to be the right way to do it, but i have a few questions (if you think this is a good way to do it)

  1. Since diadem loads each waveform into a new group, I would like use a loop to pass the numeric group value to chnpeakfind 500 times. So "[1]/ch1" would be replaced with "[i]/ch1" in the call to chnpeakfind in the script.  How do I pass this variable to the chnpeakfind call? 
  2. I think I know how to combine the values into a waveform, but some guidance would be helpful. 

 

 

Thanks in advance for any advice you have. 

0 Kudos
Message 1 of 5
(4,276 Views)

Hello Spark Plug,

 

Do you have a file to share so I can build an example Script?

 

You can email it to me directly using this address: otmar DOT foehner AT ni DOT com

 

I'll see if I can build an example once I have a file ...

 

    Otmar

Otmar D. Foehner
0 Kudos
Message 2 of 5
(4,273 Views)
Solution
Accepted by topic author Mr. Spark Plug

Hello Spark Plug,

 

I got the file, and this turned out to be fairly simple if I understood your steps correctly.

 

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

Dim MyFolders(), i
Call InitMyFolders
'-------------------------------------------------------------------------------
Sub InitMyFolders
  ReDim MyFolders(1)
  MyFolders(0)="C:\Temp\Data\"
End Sub
'-------------------------------------------------------------------------------

Call Data.Root.Clear()

Call FileNameGet("ANY","FileRead",, "WVF data (*.WVF),*.WVF")

Call DataFileLoad(MyFolders(0)&FileDlgFile&FileDlgExt,"Yokogawa_WVF","") '... DataFilename,FileImportFilter,ImportAction 
Call Data.Root.ChannelGroups.Add("Statistics", 501).Activate()

For i = 1 to 23
  StatSel(i)       = "No"
Next

StatSel(4)       = "Yes"
StatClipCopy     = 0
StatClipValue    = 0
StatFormat       = ""
StatResChn       = 1
StatResChnNames  = 0
StatResChnNameFormat= "NameName"

Call StatBlockCalc("Channel","1-","'[1]/CH1' - '[500]/CH2'") '... StatDirec,RowNoStr,ChnNoStr 

For i = 1 to 23
  StatSel(i)       = "No"
Next

StatSel(4)       = "Yes"
StatSel(5)       = "Yes"
StatSel(6)       = "Yes"
StatSel(14)      = "Yes"
StatClipCopy     = 0
StatClipValue    = 0
StatFormat       = ""
StatResChn       = 0
StatResChnNames  = 0
StatResChnNameFormat= "NameName"

Call StatBlockCalc("Channel","1-","[501]/Minimum") '... StatDirec,RowNoStr,ChnNoStr 

The StatBlockCalc function can actually work on multiple channels at once, so I just selected all of your channels and created a new channel called Minimum in the Group called Statistics that will contain 1000 lines, one line for each channel you have loaded with the minimum channel value for each channel you have.

 

I then run StatBlockCalc again on the new channel and calculate the maximum, average, and st. dev. of that channel. These values are stored in the properties of that channel (see screen shot below).

 

DataPortal.png

 

I hope that's what you were looking for. Let me know if you have any other questions,

 

     Otmar

Otmar D. Foehner
0 Kudos
Message 3 of 5
(4,267 Views)

That seems to work, but I have a couple of problems. 

 

First, I had to change "MyFolders(0)" to "FileDlgDir" in the following command, to get the script to find the file. Is this correct, or is there some reason you used MyFolders(0)?

DataFileLoad(MyFolders(0)&FileDlgFile&FileDlgExt,"Yokogawa_WVF","") '... DataFilename,FileImportFilter,ImportAction

 

 

Second, I need to completely ignore Ch2.  After I took the data, I found out the setup was wrong, so this data is no good.  If I could get StatBlockCalc to work on one channel, that would be good, but I don't know how.  I changed "'[1]/ch1' - '[500]/ch2'" to "'[1]/ch1' - '[500]/ch1'" but the results are the same.

 

 

Third, I commented out the second call to StatBlockCalc, but everything still works.  What does the second StatBlockCalc do? 

 

 

Fourth (and last), this is a somewhat different topic, but I tried to get the script to ignore channel 2 by simply removing the channels from the data portal with the following statement.  I'm sure this is not the best way to accomplish this, but, just for my education how do I get the call to work with a variable? 

dim i
for i= 1 to 500
     call data.root.ChannelGroups(i).Channels.Remove("CH2")
next

 

0 Kudos
Message 4 of 5
(4,198 Views)

So I got it to work. 

 

I changed the channel 2 removal loop to

dim Dat
For i=1 to 500
     Dat = Data.Root.ChannelGroups(i).Channels.Remove("CH2")
next

 

It removes all the channel 2 data and then allows your script to function on only the channel 1 information. 

 

If you have any suggestions as to better ways to do things, I would gladly listen.

 

Thank you VERY much!  🙂

0 Kudos
Message 5 of 5
(4,193 Views)