For fun and learning.

I have posted Friday night quizes in the past

Friday night is a good night because there is little activity and there is the whole weekend to work on the problem.
There weren't many players. I can think of all sorts of problems but most are too difficult.

Here is a good one though and not too difficult, calculate the average wind direction when sampling every minute. Most of the time it will be easy because the wind will not come from the north but if it does it will come from 355 degrees some times and 05 degrees other times and the average is 180 which isn't right.

Should the direciton be weighted by the wind speed? How would you do that?
 
Interesting problem!

Firstly with average direction only - you have 2 possible answers if the wind swings 180 degrees. This depends upon what rule you apply to get round the problem stated (averaging between 5 and 355 degrees).
For example, if the wind hovers around 10 degrees and then 190 degrees, each for the same amount of time you could end up with an average of either 100 degrees or 280 degrees; which answer is correct?

Taking wind speed into account raises even more problems; the obvious idea is to treat the speed/direction as a vector. The average of 2 vectors is easy but how would you go about averaging more than 2 vectors?
 
You are a very evil Man Peter roflamo!!!!!!!!!!!!!!!!. I seem to recall how intense the math was on this problem. You need to calculate the standard deviation of the horizontal wind component which has two components the scalar wind speed, and the harmonic wind speed. this is part of the speed computations. Then you will need to convert the degrees to a valid mean value. What Peter described above is called standard wind direction and harmonic wind direction. I'll PM Peter the solutions as I've already looked into this problem for a previous project.
 
I think that it would be to the mid-point of a line joining the ends of the 2 vectors. Can be found with some simple trig (not so simple in my case as i'm a bit rusty!)

edit: or add the 2 vectors and divide the resulting vector by 2
 
Last edited:
I am not evil, here, I am simply doing what SMOKE requested.

You are a very evil Man Peter roflamo!!!!!!!!!!!!!!!!. I seem to recall how intense the math was on this problem.
Yes, it does require a little math but you should have had this in high school.

You need to calculate the standard deviation of the horizontal wind component which has two components the scalar wind speed, and the harmonic wind speed. this is part of the speed computations.
There is no standard deviations or harmonics involved.

Then you will need to convert the degrees to a valid mean value.
Yes, that is the problem.
 
1. Maintain 2 FIFO queues of the x and y components of the wind direction (sin & cos). Insert a new reading into each FIFO every minute.

2. Every n minutes, calculate ARCTAN(y_avg/x_avg)). [atan2, in excel], where y_avg is the average of the values in the Y_FIFO, and x_avg is the average of the values in the X_FIFO.

You can distinguish which quadrant the angle belongs in based on the signs of y_avg and x_avg.

Here's the wikipedia entry on atan2.
 
Quote:
You need to calculate the standard deviation of the horizontal wind component which has two components the scalar wind speed, and the harmonic wind speed. this is part of the speed computations.


your right on this part I re-read your post and you only mentioned the speed element
 
Here is my take on it:

Split the wind measurement, wind speed and direction, into north-south and east-west coordinates.
Then do an average of both north-south and east-west.
Use the average values to convert back to an averaged speed and direction average.

edit: I am too slow. But I dont see why a FIFO is needed.
 
x = average cosine
y = average sine

ARCTAN(y_avg/x_avg))

Do me a favor try 120 120 120 90 0 270 240 240 240 as a data set. If I'm not mistaken the resultant will be 180 degrees

I added how to calculate x and Y
 
Mordred is raising a challenge.

Mordred has sent me a solution that works too. In this case it is a matter of the definition of what works. Mordred has some test data which is very contrived but it makes a point. Mordred's solution is basically an incremental one. I can see Mordred's point. In some ways Mordred's solution seems more natural to me because I think in terms of incremental encoders and how to handle the rollover. However, Mordred's solution can't be scaled on the wind speed. If the wind vane is left point east but the wind is not blowing should we average in 270 for each minute the wind isn't blowing? I don't think so.
I think I can improve on Mordred's method to be both incremental AND take into account the wind speed.

Yes, a FIFO would be needed for a rolling average.
What about exponential averaging?
AverageWindDirection:=K*AverageWindDirection+(1-K)*NewWindDirection?
I think there is some possibilities with the exponential averaging of wind direction too.
 

Similar Topics

I found this code today in a running machine. This routine executes but the bit to call it is only written to inside this same routine... so how...
Replies
7
Views
2,009
Ok simple one let's start counting with pictures thread as a bit of Fun. Rules - Picture must be +1 higher than the previous picture -...
Replies
41
Views
11,095
I recently came across a scale slot car drag racing track used for $4500. The racer in me was like cooool. The programmer in me was like, I can...
Replies
6
Views
2,686
I believe I posted something about this last year but here it is again. This Spud Gun has a removable breech that holds the igniter, which is...
Replies
3
Views
2,174
I received my Alexa Echo yesterday and I'm looking forward to automating the home. But I wondered just what other amazing things I can do with...
Replies
36
Views
9,648
Back
Top Bottom