10
$\begingroup$

What is the best way to average wind direction? I have found many conflicting suggestions elsewhere. Best one I saw is to average SINs of all angles in radians and take inverse SIN of the result.

This is to be used to produce a windrose where the input must have one record per hour, but the data provided has several records per hour.

$\endgroup$
1
  • 3
    $\begingroup$ The real questions, I think, are 1) what do you mean by an average direction? 2) what do you want to use this for? $\endgroup$ Jun 10, 2011 at 19:08

4 Answers 4

15
$\begingroup$

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.

$\endgroup$
3
  • $\begingroup$ You are right, the sine method is plain wrong. Thank you for the vector suggestion. +1 $\endgroup$
    – Kopernik
    Jun 11, 2011 at 1:36
  • $\begingroup$ I know this is late but the method of decomposing the directions into u and v components is correct, although the best thing would be to work with complex numbers, since it is way simpler (automatic, actually). $\endgroup$
    – TomCho
    May 15, 2015 at 16:31
  • $\begingroup$ TomCho that sounds intriguing - do you care to elaborate, please? $\endgroup$
    – Kopernik
    Apr 13, 2016 at 21:43
7
$\begingroup$

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 or atan2 function is important: most programming languages respect the atan2(y, x) convention but spreadsheets tend to reverse the arguments as atan2(x, y).

Edited to clarify array computation. Thanks comments!

$\endgroup$
4
  • 3
    $\begingroup$ Why doesn't the mean take into account WS? Shouldn't the mean be weighted by the wind speeds, with the wind speeds inside the mean()? $\endgroup$
    – AF7
    Jun 14, 2018 at 10:51
  • 1
    $\begingroup$ I added subscripts to clarify the array computation. Thanks @AF7 $\endgroup$ Sep 25, 2019 at 21:12
  • $\begingroup$ @patricktokeeffe Would it be possible to show how to create the wind function using ATAN not ATAN2 ? I'm trying to implement this on a device that doesn't have an ATAN2 function. Thanks $\endgroup$
    – James
    Jan 27, 2020 at 1:40
  • $\begingroup$ @James ATAN2 was motivated by the challenges of ATAN! If you understand the difference you can accomplish the same with ATAN and sign comparison, but it's out-of-scope for this answer (sorry) $\endgroup$ Jan 31, 2020 at 19:17
6
$\begingroup$

Averaging the sines of the inputs and taking the inverse sine of the result can't give you a sensible answer, since the range of the inverse sine function is $180^\circ$ rather than $360^\circ$.

You probably want to take the magnitude of the wind into account. For example, if you have a wind blowing to the east (at $0^\circ$) at 10 mph for half the time and to the north (at $90^\circ$) at 2 mph half the time, the average probably shouldn't be $45^\circ$ but something much closer to $0^\circ$.

A good solution would be to take the vectors of wind direction, add them all together and divide by the number of samples. For example, in the above case the average speed would be

$$\frac{(10,0) + (0,2)}{2} = (5,1)$$

which, if we plug it into the atan2 function gives a wind direction of $11.31^\circ$, or just slightly north of east. This method also has the nice property that it generalizes easily to higher dimensions which, though it might not be relevant for your work, is often an indicator that you're on the right track.

$\endgroup$
5
$\begingroup$

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

$\endgroup$
1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .