It is all good. I decided to do the averaging in my daemon - it's done over the last 30 entries which equates to less than 30 minutes but it's enough for my purposes.
I do take into account the wind direction and speed.
here's the code in javascript (nodejs) but I can port it to any language you would like to try it in.
function avg(array) {
var sum = 0;
for (i in array) {
sum += parseFloat(array[i]);
}
return sum / array.length;
}
function calc_average_wind_dir(data) {
// Store a number of U's and V's
u_comp.push(-1 * (data.windspeedms * Math.sin(data.winddir * Math.PI/180)));
v_comp.push(-1 * (data.windspeedms * Math.cos(data.winddir * Math.PI/180)));
// Store a number of wind speeds (for future use, not used atm)
ws.push(data.windspeedms);
// Dispose of any entries older than 30
while (u_comp.length > 30) {
u_comp.shift();
v_comp.shift();
ws.shift();
}
// Calculate the average u and v
var u_avg = avg(u_comp);
var v_avg = avg(v_comp);
// Calculate the average wind direction
var avg_wd;
if (u_avg > 0) {
avg_wd = 90 - 180 / Math.PI * Math.atan(v_avg / u_avg) + 180;
}
else if (u_avg < 0) {
avg_wd = 90 - 180 / Math.PI * Math.atan(v_avg / u_avg);
}
else {
if (v_avg < 0) {
avg_wd = 360;
}
else if (v_avg > 0) {
avg_wd = 180;
}
else {
avg_wd = 0;
}
}
return avg_wd
}