Welcome to the Cumulus Support forum.

Latest Cumulus MX V4 release 4.4.2 (build 4085) - 12 March 2025

Latest Cumulus MX V3 release 3.28.6 (build 3283) - 21 March 2024

Legacy Cumulus 1 release 1.9.4 (build 1099) - 28 November 2014
(a patch is available for 1.9.4 build 1099 that extends the date range of drop-down menus to 2030)

Download the Software (Cumulus MX / Cumulus 1 and other related items) from the Wiki

If you are posting a new Topic about an error or if you need help PLEASE read this first viewtopic.php?p=164080#p164080

How is dominant wind direction calculated by MX?

Topics about the Beta trials up to Build 3043, the last build by Cumulus's founder Steve Loft. It was by this time way out of Beta but Steve wanted to keep it that way until he made a decision on his and Cumulus's future.

Moderator: mcrossley

Locked
freddie
Posts: 2870
Joined: Wed 08 Jun 2011 11:19 am
Weather Station: Davis Vantage Pro 2 + Ecowitt
Operating System: GNU/Linux Ubuntu 24.04 LXC
Location: Alcaston, Shropshire, UK
Contact:

How is dominant wind direction calculated by MX?

Post by freddie »

I ask the question because my "yesterday" stats (http://www.hosiene.co.uk/weather-test/yesterday.htm) say the dominant direction was NNE'ly. Using MK1 eyeball on the wind direction chart (http://www.hosiene.co.uk/weather-test/trends.htm) suggests that it would be a tricky call to make,considering the variability of the direction on that day, but the strongest winds were from a southerly direction and the most persistent direction was west-south-west. Hence my question in the topic title :-)
Freddie
Image
User avatar
steve
Cumulus Author
Posts: 26672
Joined: Mon 02 Jun 2008 6:49 pm
Weather Station: None
Operating System: None
Location: Vienne, France
Contact:

Re: How is dominant wind direction calculated by MX?

Post by steve »

It's very similar to how it calculates the average bearing. the daily figure is basically an average of all of those averages. Once a minute, it takes the current average speed and average bearing, and calculates the X and Y components of a vector using those figures. It maintains a running total of those during the day, like this:

Code: Select all

DominantWindBearingX += (minutes*averageSpeed*Math.Sin(DegToRad(averageBearing)));
DominantWindBearingY += (minutes*averageSpeed*Math.Cos(DegToRad(averageBearing)));
During normal running, 'minutes' will have the value 1.

It then computes the bearing of the vector with those X and Y components, like this:

Code: Select all

private int calcavgbear(double x, double y)
{
    var avg = 90 - (int) (RadToDeg(Math.Atan2(y, x)));
    if (avg < 0)
    {
        avg = 360 + avg;
    }

     return avg;
}
Your figure for yesterday does look odd, given your graph, so perhaps there's a bug in the calculation - maybe I'm using the result of atan2() incorrectly - it does make my head hurt, and I was unable to find a definitive solution on the web. But today so far looks reasonable, yes? It could be that there's a bug in the saving and restoring of the counters over a restart - did you you restart MX at all yesterday? Or today?

Are you generating NOAA-style reports? If so, what does that show for the dominant wind bearing for yesterday? That's done in a similar way, but using only the entries in the log file.
Steve
freddie
Posts: 2870
Joined: Wed 08 Jun 2011 11:19 am
Weather Station: Davis Vantage Pro 2 + Ecowitt
Operating System: GNU/Linux Ubuntu 24.04 LXC
Location: Alcaston, Shropshire, UK
Contact:

Re: How is dominant wind direction calculated by MX?

Post by freddie »

Thanks for the explanation - that's useful.
steve wrote:But today so far looks reasonable, yes?
Yes, today looks spot on.
steve wrote:It could be that there's a bug in the saving and restoring of the counters over a restart - did you you restart MX at all yesterday?
Yes, the connection to the station dropped around 1103 (when I was away from home - it is always well timed!!) and I performed a re-start at around 2230 last night when I got home. You might be on to something there.
steve wrote:Are you generating NOAA-style reports?
No, I'm not.

Thanks as ever for the speedy response.
Freddie
Image
User avatar
steve
Cumulus Author
Posts: 26672
Joined: Mon 02 Jun 2008 6:49 pm
Weather Station: None
Operating System: None
Location: Vienne, France
Contact:

Re: How is dominant wind direction calculated by MX?

Post by steve »

I've tested the code, going around the compass, and it seems to produce the correct results (I'm pretty sure I did the same when I first wrote it). I had a quick look at the save/restore code and it looked OK. As you had it stopped for most of the day I now think the most likely explanation is that it goes wrong when logger data is used - I'll check that.
Steve
User avatar
steve
Cumulus Author
Posts: 26672
Joined: Mon 02 Jun 2008 6:49 pm
Weather Station: None
Operating System: None
Location: Vienne, France
Contact:

Re: How is dominant wind direction calculated by MX?

Post by steve »

That didn't take much finding, once I knew where to look. The bearing stored in logger entries is only supplied as an integer from 0 to 15, representing N to NNW, rather than a full bearing as with live data. I was using the integer directly in the dominant direction calculation rather than multiplying it by 22.5. This skews the result towards N. I'll fix it in the next build.
Steve
freddie
Posts: 2870
Joined: Wed 08 Jun 2011 11:19 am
Weather Station: Davis Vantage Pro 2 + Ecowitt
Operating System: GNU/Linux Ubuntu 24.04 LXC
Location: Alcaston, Shropshire, UK
Contact:

Re: How is dominant wind direction calculated by MX?

Post by freddie »

steve wrote:That didn't take much finding, once I knew where to look. The bearing stored in logger entries is only supplied as an integer from 0 to 15, representing N to NNW, rather than a full bearing as with live data. I was using the integer directly in the dominant direction calculation rather than multiplying it by 22.5. This skews the result towards N. I'll fix it in the next build.
Good detective work! Thanks Steve :-)
Freddie
Image
Locked