06-22-2011 02:50 PM
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:
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)
Thanks in advance for any advice you have.
Solved! Go to Solution.
06-22-2011 03:03 PM
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
06-22-2011 03:57 PM
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).
I hope that's what you were looking for. Let me know if you have any other questions,
Otmar
06-22-2011 05:29 PM
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
06-22-2011 07:06 PM
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! 🙂