An Inexpensive APRS Weather Station

FAQs

What is consensus averaging?
Why is 16 points for wind direction enough?
How accurate is our wind direction data??

WHAT IS CONSENSUS AVERAGING?
This is an explanation of the averaging of 1-Wire Weather Station wind direction data. The averaging used here is called consensus averaging, because only the subset of data that is in consensus is used in the averaging process. Consensus averaging is very useful for averaging widely separated data as can occur from a wind vane in turbulent atmospheric flow. Consensus averaging also simplifies the north crossover problem where data suddenly jumps from 359 to zero.

In our weather station, an individual data period is about 5 seconds and the averaging time is 5 minutes. For the direction data, each 5 second data period results in one of 16 numbers which represent the state of the reed switches closed by a moving magnetic connected to the wind vane. Each of the 16 numbers represent a section of azimuth. The numbers 0, 2, 4, 6, 8, 10, 12, 14 represent 45 degree sections centered on the N, NE, E, SE, S, SW, W, NW directions. The odd numbers 1, 3, 5, 7, 9, 11, 13, 15 represent 22.5 degree sections centered between the directions represented by even numbers. In 5 minutes, we will get about 60 counts total in the 16 different azimuth bins. It is convenient to let the units of azimuth be half degrees, so that in a complete rotation of the wind vane it goes through 720 units or half degrees.

Assume that the center of rotation of the wind vane is directly north of the support point. If this is not the case, a software input allows you to enter the offset so that the wind vane can be oriented in any direction.

We start with 16 bins numbered i = 0, 1, 2, ... , 15 where increasing i implies clockwise rotation and each bin has a number n(i) indicating the number of counts that were in that azimuth bin during the 5 minute period. Then add 4 more bins with numbers as shown below.

```	Bin        Number        Direction
0            n(0)        N
1            n(1)        NNE
2            n(2)        NE
3            n(3)        ENE
4            n(4)        E
5            n(5)        ESE
6            n(6)        SE
7            n(7)        SSE
8            n(8)        S
9	    n(9)         SSW
10          n(10)        SW
11          n(11)        WSW
12          n(12)        W
13          n(13)        WNW
14          n(14)        NW
15          n(15)        NNW
16          n(16)        = n(0)
17          n(17)        = n(1)
18          n(18)        = n(2)
19          n(19)        = n(3)
```
Next set up a pointer that starts at bin 0 and goes to bin 15. The purpose of this is to find which set of five adjacent bins has the most total counts. When the pointer is at bin i, form this sum,
```	sum =  n(i) + n(i+1) + n(i+2) + n(i+3) + n(i+4).
```
Then find which i = 0,...,15 has the largest sum (call that bin I) and what this maximum sum is (call it S) and save both. The number of half degrees from north to the region we will start the averaging is I * 45.

Next, do the actual averaging by forming this weighted sum,

```	W = ( n(I+1) + 2 * n(I+2) + 3 * n(I+3) + 4 * n(I+4) ) * 45 / S
```
Note that we don't have to include 0 * n(I) since it is always zero. The division here (which should be done last) can be integer division.

Then form the term, D = I * 45 + W, which is the direction in half degrees. This could exceed 720, so check to see if D > 720 and if so then subtract 720. Next, to convert to degrees, divide by 2 and the result is the average direction in degrees.

Why are 16 points for wind direction enough?
With only 16 points for wind direction data, it is natural to be concerned if that is enough points to be able to report wind direction with any decent kind of accuracy. Russ and I had the same concerns when we first evaluated the Dallas weather station too. After a lot of thinking (and a lot of math for Russ), we feel that 16 points is indeed enough. Two things work in our favor. First, the wind direction is very "noisy" data. Even with a consistent wind direction, the weather vane wiggles a LOT around the average position. This is due to lots of localized turbulence. This is normal, and unavoidable. The second thing in our favor is that we do lots of averaging (60 samples per 5-minute window). This has two very nice effects. The first is to get a more accurate picture of the average wind direction. In doing so, we also greatly enhance the accuracy of our samples beyond the level of the basic sensor themselves. This can be explained better with a few examples:

Imagine our sensor had only 45-degree accuracy and average wind direction was 22.5 degrees. When the wind vane wobbles around, half the time it would be read as 45 degrees, and the other half, it would read 0 degrees. The average of all those readings (1/2 at 0, 1/2 at 45) will be 22.5. If the average wind direction was 34 degrees (3/4ths between 0 and 45), then as the wind vane wobbled around that average direction, ¼ of the samples would be 0 and 3/4 would be 45.

HOW ACCURATE IS OUR WIND DIRECTION DATA?
A reasonable question is "what is the error for this type of averaging on a quantized measurement like the wind direction in the 1-Wire weather station?" To answer this question, a simulation with mean wind direction over a 45 degree sector was perturbed by adding white noise to the true wind. The consensus averaging technique was used to average the noisy wind direction data. This simulation was done at 1 degree increments from 270 degrees 315 degrees. This is from the W reed relay switch to the adjacent NW reed relay switch. There is a boundary in the quantization scheme at 285 degrees and another one at 300 degrees. In between 285 and 300 degrees, both the W and NW reed relay switches are closed. Each 5 seconds a new measurement is obtained and these were averaged for 5 minutes to arrive at an averaged value of the wind direction. Since the simulated wind direction was known, the error (absolute value of the difference between the simulated direction and the averaged direction) can be found. This procedure was repeated 1000 times for each degree and the average error is the average over those 1000 trials. The maximum error is the maximum that occurred in those 1000 trials. These results, in degrees, are given in the list below as a function of angle.
```          Angle      Average Error   Maximum Error
270            .04            .38
271            .96            1.4
272            1.9            2.2
273            2.8            3.2
274            3.7            4.2
275            4.5            5.0
276            5.2            6.0
277            5.8            7.0
278            6.2            7.8
279            6.4            8.2
280            6.4            8.3
281            6.2            9.1
282            5.8            9.0
283            5.2            7.9
284            4.5            7.8
285            3.8            7.3
286            2.9            6.1
287            2.1            5.0
288            1.6            4.9
289            1.2            3.8
290            .86            3.5
291            .69            3.2
292            .62            2.7
293            .62            2.7
294            .69            3.4
295            .84            3.7
296            1.1            4.4
297            1.6            4.5
298            2.2            5.2
299            3.0            7.4
300            3.7            7.1
301            4.5            8.0
302            5.2            8.3
303            5.7            8.4
304            6.2            8.9
305            6.4            8.5
306            6.4            8.3
307            6.1            7.6
308            5.8            7.0
309            5.2            6.0
310            4.5            5.0
311            3.7            4.2
312            2.8            3.2
313            1.9            2.2
314            .96            1.4
315            .04            .56
```
The small scale turbulence effect on the wind vane was modeled as a zero mean white Gaussian random process with standard deviation of about 5 degrees. If you were looking at the wind vane, you would see a random motion over a range of about 15 degrees with rare excursions outside this range and with the wind vane pointing in the mean direction of the wind more than in any other direction. Wind in the lower atmosphere is always accompanied by small scale turbulence which causes random motion of a wind vane. If there is no wind or extremely light winds, there may be little motion of the wind vane, but in that case the direction is unimportant. The simulation here is for the case where there is enough wind speed so that the wind direction is important. So, we can use average error or maximum error as the measure of "goodness" of this averaging technique for wind vane output. The list above shows the relationship between the two for the conditions given. Similar results would be obtained for all other directions.
Back to the top