Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

Averaging wind direction in RTMC


Clayton Dec 13, 2010 08:31 PM

Does anyone know of a way to average wind direction in RTMC? I would like to be able to average five minutes worth of one minute data without creating a value in the datalogger program? An expression like WindVector("Server:CR10X.101.Wind_Dir",5) would be mighty handy, but there isn't one. I've tried to think of a way to write an expression which converts each one minute datapoint into a radian, takes the sine and cosine of each, averages these sines and cosines of the past five minutes, uses ATAN2 to turn that back into a wind direction in radians, coverts that back into degrees, and finally runs an IF statement to add 360 if the result is negative. If this is possible, so far I haven't figured out how to do it.


tmecham Dec 14, 2010 03:23 PM

For a simple running avg you can do this...

StartRelativeToNewest(5*nSecPerMin, OrderCollected); Alias(W, "Server:CR1000.MINUTE.Wind_Deg"); AvgRunOverTime(W, Timestamp(W), 4 * nSecPerMin)


For Wind Vector Average this should work ...

StartRelativeToNewest(5 * nSecPerMin, OrderCollected); Alias(W, "Server:CR1000.MINUTE.Wind_Deg"); IIF((ATN2(AvgRunOverTime(sin(W * PI/180), Timestamp(W), 4 * nSecPerMin), AvgRunOverTime(cos(W * PI/180), Timestamp(W), 4 * nSecPerMin)) * 180 / PI) > 0, (ATN2(AvgRunOverTime(sin(W * PI/180), Timestamp(W), 4 * nSecPerMin), AvgRunOverTime(cos(W * PI/180), Timestamp(W), 4 * nSecPerMin)) * 180 / PI), 360 + (ATN2(AvgRunOverTime(sin(W * PI/180), Timestamp(W), 4 * nSecPerMin), AvgRunOverTime(cos(W * PI/180), Timestamp(W), 4 * nSecPerMin)) * 180 / PI))

* Last updated by: tmecham on 12/14/2010 @ 10:15 AM *


Clayton Dec 14, 2010 06:29 PM

Thanks tmecham, that wind vector average is exactly what I'm looking for. I assume the simple average would get screwy when the wind is blowing out of the North. Could you explain why you use 5 minutes for the StartRelativeToNewest, but only 4 minutes for the rest of the expression?


tmecham Dec 14, 2010 07:14 PM

Yes, the simple average gets messed up by the North value.

The AverageRunOverTime is a closed closed interval or [CurrentTime - interval, CurrentTime]. So if you specify 5 minutes in the AverageRunOverTime, you end up with 6 data points. If you want the AverageRunOverTime to be based on 5 data points, then the 4 minute interval takes care of this.

Log in or register to post/reply in the forum.