Calculate average wind direction
While it's not quite meaningless to average the direction of the wind, it's ill-defined in many cases (imagine that you have a perfect east wind and a perfect west wind and you want to find the direction of their average!), and probably not really what you're after. Assuming that you have velocity data for the wind as well as directional data, you're best off turning the velocity+direction into a vector, adding those vectors, and then if you need a direction in the end, taking the direction of the result. In the case where your wind always has the same speed (or at least can be assumed to have constant speed), this is better than the mechanism you suggest: for instance, in your method an east wind ($\theta_0=0^{\circ}$) and a north wind ($\theta_1=90^{\circ}$) will give $s_0 = \sin(0^{\circ}) = 0$ and $s_1 = \sin(90^{\circ}) = 1$, so $s_{avg} = 0.5$ and $\theta_{avg} = \sin^{-1}(s_{avg}) = 30^{\circ}$, whereas the average-of-vectors method yields $v_0 = (\cos(\theta_0),\sin(\theta_0)) = (1,0), v_1 = (0,1), v_{avg} = (0.5, 0.5)$ and $\theta_{avg} = 45^{\circ}$. It also has the advantage that it's rotationally invariant; rotating the entire assemblage by any constant value (for instance, making your north wind a northeast wind and your east wind a southeast wind) will give an average that's the average of the initial data rotated by that amount. Note that in the case where the average is ill-defined, this method will yield a zero vector for the combined wind's direction, and so it (correctly) breaks down when trying to find an angle from that result.
Assuming you use the standard meterological convention that wind direction is the source direction of winds (i.e. 270º means blowing west → "here"):
Given two arrays containing wind speed (WS
) and wind direction (WD
, in degrees) observations, the vector mean wind direction is calculated as follows:
V_east[i] = mean(WS[i] * sin(WD[i] * pi/180))
V_north[i] = mean(WS[i] * cos(WD[i] * pi/180))
mean_WD = arctan2(V_east, V_north)) * 180/pi
mean_WD = (360 + mean_WD) % 360
The final line remaps the range ($-\pi$ to $\pi$) ($-$180 to 180) → (0 to 359).
Alternately, the unit vector mean wind direction can be calculated by omitting the wind speed components. The unit vector mean wind direction is often a good approximation to the scalar mean wind direction (which is a more involved calculation).
u_east = mean(sin(WD * pi/180))
u_north = mean(cos(WD * pi/180))
unit_WD = arctan2(u_east, u_north) * 180/pi
unit_WD = (360 + unit_WD) % 360
N.B. The implementation of the
arctan2
oratan2
function is important: most programming languages respect theatan2(y, x)
convention but spreadsheets tend to reverse the arguments asatan2(x, y)
.
Edited to clarify array computation. Thanks comments!
Question is old, but I found this in Wikipedia, which might be the "average of sin" stuff you wrote in your question:
"A simple way to calculate the mean of a series of angles (in the interval [0°, 360°)) is to calculate the mean of the cosines and sines of each angle, and obtain the angle by calculating the inverse tangent. Consider the following three angles as an example: 10, 20, and 30 degrees. Intuitively, calculating the mean would involve adding these three angles together and dividing by 3, in this case indeed resulting in a correct mean angle of 20 degrees. By rotating this system anticlockwise through 15 degrees the three angles become 355 degrees, 5 degrees and 15 degrees. The naive mean is now 125 degrees, which is the wrong answer, as it should be 5 degrees."
http://en.wikipedia.org/wiki/Directional_statistics#The_fundamental_difference_between_linear_and_circular_statistics