Welcome to the Cumulus Support forum.

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

Cumulus MX V4 beta test release 4.0.0 (build 4018) - 28 March 2024

Legacy Cumulus 1 release v1.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

Rolling Weekly Data - Displaying data on website

Other discussion about creating web sites for Cumulus that doesn't have a specific subforum

Moderator: daj

AndyKF650
Posts: 704
Joined: Thu 20 Aug 2020 8:35 am
Weather Station: Davis VP2 Plus
Operating System: RPiv4 64bit Linux 12 Bookworm
Location: Jersey Channel Islands
Contact:

Re: Rolling Weekly Data - Displaying data on website

Post by AndyKF650 »

Hi everyone

Thanks for all your help and comments on this task. Obviously what I thought was a simple task of just a simple average was a way under estimate, scalar averaging just does not work.

This left vector averaging which was something I was completely unused to. The degree values are converted into radians, and I worked out the u East and u North components with sin and cos functions of each data point, and averaged the results. This result is then run through the atan2 function and converted back to radians.

The above calculation then was turned into php instruction to get the final result as seem on my web site. For those who are interested the final php code is attached.
You do not have the required permissions to view the files attached to this post.
User avatar
mcrossley
Posts: 12694
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Rolling Weekly Data - Displaying data on website

Post by mcrossley »

Hi Andy, that is not quite how CMX does it for either the daily dominant direction of current average direction.
You are averaging the direction X and Y components to avoid the 360->0 issue (ie the scalar average).
CMX also multiplies each X/Y value by the speed giving a vector average.
In practice I do not know how much of a difference it makes, and it also comes down to how you define the average direction.
User avatar
mcrossley
Posts: 12694
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Rolling Weekly Data - Displaying data on website

Post by mcrossley »

HansR wrote: Mon 15 Aug 2022 7:41 am
mcrossley wrote: Sun 14 Aug 2022 8:41 pm Well it's a vector as I understand it, averaging each direction and speed (a vector) in the calculation.
Afaics it does not average the speed as a vector.
Current average uses both speed and direction...

Code: Select all

			WindVec[nextwindvec].X = calibratedgust * Math.Sin(DegToRad(Bearing));
			WindVec[nextwindvec].Y = calibratedgust * Math.Cos(DegToRad(Bearing));
Dominant direction uses both speed and direction...

Code: Select all

			DominantWindBearingX += (minutes * averageSpeed * Math.Sin(DegToRad(averageBearing)));
			DominantWindBearingY += (minutes * averageSpeed * Math.Cos(DegToRad(averageBearing)));
			DominantWindBearingMinutes += minutes;
And yes @sfws, Steve's code is unchanged.
User avatar
HansR
Posts: 5871
Joined: Sat 20 Oct 2012 6:53 am
Weather Station: GW1100 (WS80/WH40)
Operating System: Raspberry OS/Bullseye
Location: Wagenborgen (NL)
Contact:

Re: Rolling Weekly Data - Displaying data on website

Post by HansR »

sfws wrote: Mon 15 Aug 2022 8:55 am AndyK's post refers to his Dominant wind direction line on his rolling data report, asking for pointer towards calculation that he could use to show something in 7-day average column and therefore the subsequent trend column. All data for that report is taken from the daily summary database table. That sets a very limited context.
It is unclear from Andy's original question (I refer to this post) that he only wants the dominant wind direction.
sfws wrote: Mon 15 Aug 2022 8:55 am [...] I did not waste my time reading the whole linked article, simply checked it had some relevant details that could help Andy fill in his empty table cell.
You should have wasted your time differently iso posting this confusing article. Even Steve said (your reference):
[...] it does make my head hurt[...]
so you could have known it was not an all easy subject.
sfws wrote: Mon 15 Aug 2022 8:55 am I suggested that somewhere in forum there would be a post saying how Cumulus did it, now found at viewtopic.php?p=111741#p111741. Andy can now decide between use of the discussion in the article I linked or use of the bare bones in Steve's post. Before you say that refers to Steve's original beta Cumulus MX, it does, but I doubt if "dominant wind direction" calculation has been changed.
That indeed is an interesting reference.
sfws wrote: Mon 15 Aug 2022 8:55 am In several posts in this thread you seem to be conducting a campaign against me. Resist that temptation to launch personal attacks, also resist the making of interpretations outside context of individual posts!
Campaign is your interpretation.

But I must admit that over the two days following your publication of that link an increasing irritation came over me, that somebody who contributes so much to the Wiki, just flings in this reference which has no validity from the pov of CMX (and just claimed he saw it as a waste of time to read it).

You initiated this discussion. I am responsible for my content, not your interpretation. Yes, you irritate me, this sentence adds to that.
sfws wrote: Mon 15 Aug 2022 8:55 am Only your posts discuss wind speed averaging.
It is not only my posts discussing wind speed averaging, it is your linked article - meant as a help for Andy wanting to average direction, claiming in the same breath he did not search well - which treats wind speed and wind direction averaging as a vector, stating that CMX uses that method. Almost everything in that sentence is untrue.

That is very confusing and everybody using that article as a reference would get confused.
Last edited by HansR on Mon 15 Aug 2022 5:48 pm, edited 2 times in total.
Hans

https://meteo-wagenborgen.nl
CMX build 4017+ ● RPi 3B+ ● Raspbian Linux 6.1.21-v7+ armv7l ● dotnet 8.0.3
User avatar
HansR
Posts: 5871
Joined: Sat 20 Oct 2012 6:53 am
Weather Station: GW1100 (WS80/WH40)
Operating System: Raspberry OS/Bullseye
Location: Wagenborgen (NL)
Contact:

Re: Rolling Weekly Data - Displaying data on website

Post by HansR »

mcrossley wrote: Mon 15 Aug 2022 10:33 am Current average uses both speed and direction...

Code: Select all

			WindVec[nextwindvec].X = calibratedgust * Math.Sin(DegToRad(Bearing));
			WindVec[nextwindvec].Y = calibratedgust * Math.Cos(DegToRad(Bearing));
Dominant direction uses both speed and direction...

Code: Select all

			DominantWindBearingX += (minutes * averageSpeed * Math.Sin(DegToRad(averageBearing)));
			DominantWindBearingY += (minutes * averageSpeed * Math.Cos(DegToRad(averageBearing)));
			DominantWindBearingMinutes += minutes;
Only to weigh the direction, not to modify the speed which is inherently different from what the vector calculation is in both the article referenced by @sfws and the Copernicus article referenced by me.

I think I finish my contribution to this thread here unless a very convincing argument comes along.
If I can't convince you then so be it.
Hans

https://meteo-wagenborgen.nl
CMX build 4017+ ● RPi 3B+ ● Raspbian Linux 6.1.21-v7+ armv7l ● dotnet 8.0.3
Post Reply