02-05-2010 04:56 AM
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,
02-05-2010 07:39 AM
It seems to be that Histogram VI is what you needed, isn't?
Andrey.
02-05-2010 08:37 AM
02-05-2010 01:17 PM
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*
02-05-2010 01:29 PM
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.
02-07-2010 11:16 AM
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.
02-07-2010 11:24 AM - edited 02-07-2010 11:31 AM
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...
02-08-2010 05:14 AM - edited 02-08-2010 05:15 AM
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?
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?
Thanks for your help.
02-08-2010 03:51 PM
02-09-2010 09:50 AM
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.
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,