DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

average Y values iff they have the same X value

Hi,

I want to avergage some Y values if they have the same X value and create two new channels by that.

A little more detail:

I got 2 data channels out of a Citadel 5 Database (recorded with DSC Tag Engine from FieldPoint). Every data channel has it's own time channel. I want to create a chart with data2(data1).

First I do a ChnMapLinCalc to get data points at the same time for data1 and data2.

But as the data is, I get more then one point in data2 for every data1 point. Now I want to average all points in data2, iff data1 is the same.

Writing this in a VBS loop is quite easy, but as my channels can be pretty large and I want to process more than one channel I'm looking for a more performant solution.

Any
ideas out there?

Thanks,
Carsten
0 Kudos
Message 1 of 4
(4,065 Views)
Unfortunately there is no native DIAdem command for a calculation like this. You will have to write a VBS doing the job for you.
Keep in mind that there is a fast and a slow way to access the data matrix. If you are using the CHD Variable to examine your channels the script will be rather slow, you should use ChDX instead. Depending on how frequently the x channel changes you might furtherly improve the performance if you make use of the FIND command to search for a values inside the channel. This command delivers row-numbers which you can use as interval borders to calculate the average of the y channel.
Refer to the DIAdem online help for further information on these commands and variables.

Hope this helps.

Ingo Schumacher
National Instruments
0 Kudos
Message 2 of 4
(4,065 Views)
Hi cs42,

Have you tried importing the channels from Citadel with a particular delta time? You can specify in the Data Storage properties for your Citadel connection that you want the data to be imported with a constant delta time, and you can also specify the way to handle points that don't map 1 to 1, i.e. with averaging, interpolating, etc.

If this works for you, the performance should be superior to doing the same thing after importing into DIAdem using a VBScript.

Cheers,
Brad Turpin
DIAdem Product Support Engineer
National Instruments
0 Kudos
Message 3 of 4
(4,065 Views)
Hi Brad,

no, I haven't tested this yet. It sounds like a good idea, though this will just spare MapLinCalc and the problem with the multiple Y-values to each/some X-value remains. Unfortunately I'll have no time to test for the next fortnight.

And there's another issue to make this comfortable: I'd like to select the time span I want and the channels for which I want to do this in DIAdem-VIEW.

What I'm thinking about is similar to the "copy" function in VIEW. I select the channels I want and the timespan being interesting and then reimport these channels into a new group. But by that I need to know of which database the data came originally from...

To map the data to a constant delta time, so that I'm able to plot Data1(Data2), is always a difficult i
ssue for me because basically all data in the database are steps. But if I have data constantly changing over some time (a ramp for instance) an analogue mapping/interpolation leeds to better/nicer (even more realistic) plots. On the other hand we have data which doesn't change over a long time so the tag engine writes the value just each 10 minutes to the database (we chose 10 minutes to see something on MAX in realtime for these data too). Some of these data may change quite fast. E.g. the changes of some mass flow controllers are too fast to give more than a step with FieldPoint (we don't need a higher resolution anyway). And doing an analogue mapping there will lead to wrong results definetly (in the worst case it will look like the flow changed for 9 minutes and 59 seconds!). But that's just a general problem we'll always have...

Thanks for your suggestions.

Cheers,
Carsten
0 Kudos
Message 4 of 4
(4,065 Views)