LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Calculating averages of data bins

Hello,

For a project, I am collecting wind data (speed + direction). I take 10 minute averages of these data.
Now I wish to plot a histogram and a radar plot of the total average wind speed for each direction (bins of 10°). How should I proceed to efficiently calculate these averages?
I have currently tried with a case structure containing a case for every bin of direction. If a case is true, it adds the 10-min average speed to the specific array for that case/direction and then calculates the total average speed for that direction (by calculating the average of that array). Of course, this leaves me with 36 cases and arrays.

Also, because this is a long test run and the PC running the software could be rebooted (i.e. after a power loss), it needs to be able to start again where it left off. The averages need to be stored and reused after the reboot. I have currently not found any easy way to do this.

Any ideas?

 

Rgrds,

0 Kudos
Message 1 of 10
(8,578 Views)

It seems to be that Histogram VI is what you needed, isn't?

 

Histo.png 

 

Andrey.

0 Kudos
Message 2 of 10
(8,557 Views)
If only it were that simple. While the histogram VI is indeed required for the histogram of wind speeds, I also need to make speed averages of every direction bin. This would look like the histogram, but the X-axis would be made up of all the direction bins (10° intervals) and the Y-axis of the average wind speed in that bin.
0 Kudos
Message 3 of 10
(8,550 Views)

Take the median number between each bin, multiply it by the current representation (%) of each bin, and take the sum of the results.

 

example:

 

If my data set is:

 

Degrees

 

0-10*

11-20*

21-30*

31-40*

0 Kudos
Message 4 of 10
(8,531 Views)

Take the median number between each bin, multiply it by the current representation (%) of each bin, and take the sum of the results.

 

example:

 

If the true data set is for example (5,7,6,4,8,6,2,3,7,6) with a true average of 5 but I see a histogram distribution of:

 

Bin             Obs.           %ofTotalObs.           Bin Median      %ofTotalObs.*Bin Median                    

 

0-2            1                10%                        2                    .2

3-4            2                20%                        3                    .6

5-6            4                40%                        5                    2

7-8            3                30%                        7                    2.1

9-10          0                0%                          9                    0

Sum(for average)                                                              4.9

 

******Rounded                                                                5

 

Some rules: Thye more obs. you have the tighter the bin sizes you my need: for the above example I would hav gotten similair results if my bins were just 0- and 6-10 since my sample size was so small but if my sample size is quite large (over 200) i may need tighter bins or i risk accuracy. But if all you have is bins then ma.

0 Kudos
Message 5 of 10
(8,527 Views)

The problem is that I dont have to count observations but have to arrange and average pairs of data. For example, my data set is:

(direction, speed): (270,5);(260,10),(130,15);(270,8);(340,2);(130,10)

These are 10-minute averages, so every 10 minutes a new pair of data comes available.

 

My X-bin size is 10. I need to calculate the average speed (average Y-values) of every X-bin as data comes available. In this example it would be:

bin     avg

130   12,5

260   10

270   6,5

340   2

 

Not all bins are yet filled with data, but because it's a very long measurement (weeks) they will be at the end of the measurement.

0 Kudos
Message 6 of 10
(8,496 Views)

Hi JLE,

 

I would use an array of cluster of array. That way you can have different length arrays for each direction bin...

 

In each cluster the values for one direction bin are collected. As you need 36 bins you use an array of clusters. So your program reduces to a simple index calculation instead of 36 cases with 36 different arrays...

wind-bins.png

Message Edited by GerdW on 02-07-2010 06:31 PM
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 7 of 10
(8,494 Views)

Thank you GerdW, your suggestion is very helpful. However, I'm quite at a loss at how to setup my array of clusters of array. I'm guessing that each index of the primary array is a speed bin, so I will have an array containing 36 clusters, each with an array containing an arbitrary number of speed samples. Is this the correct assumption?

 

windbins_clustered.png

The above is part of my Labview program. The case is executed when the array of direction and speed samples contains 10 minutes of information. It takes the average of the array and then resets it. The average data is then used in your solution. However, it isn't being processed quite well. I figure I need to format the array of clusters beforehand?

 

 windbins_front.png

 

Thanks for your help.

Message Edited by JLE on 02-08-2010 05:15 AM
0 Kudos
Message 8 of 10
(8,458 Views)

Hi JLE,

 

can you attach your VI instead of a picture?

 

And why (the hell) you are writing to an indicator and then read from a local of the same indicator instead of directly wiring? And why do you do this two times?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 10
(8,429 Views)

Hi GerdW,

 

I use the indicator to provide a visible feedback of the contents of the array on the frontpanel . I had to use the control to initialise (setup) my array, otherwise the data type kept being void.

 

I've included a cutout picture of my program. It consists of a while loop in which every second a pair (direction, speed) of samples is taken from a DAQ device, processed and stored in a buffer (array). If the array has 10 minutes worth of data (600 pairs of samples) it enables the case structure in which a pair of averages is calculated (average direction, average speed) and the buffer is reset. The speed averages need to be sorted by direction, so every resulting average speed needs to be added to the array belonging to the coupled average direction of that pair.

 

Then finally (not implemented yet) I want to calculate the average speed of every array of direction and plot it on a radar plot. That way I can make a 360° map of the average speed in every direction (10° resolution) and have it updated every time a new pair of average data comes available.

 

I'm using shift registers to maintain my data between loops. When i did not include the array control, the data type would remain void. 

 

program_cutout.png

 

I have currently solved it like above. I use an array control to initialise my array of clusters of array and then the loop takes over and stores every average value like it should.

 

Of course, I'm open to suggestions if there is a better way to obtain this result.

 

Regards,

0 Kudos
Message 10 of 10
(8,407 Views)