Average wind direction

106 views
Skip to first unread message

Phil D

unread,
Aug 10, 2023, 11:58:31 PM8/10/23
to weewx-user
Hello everyone,

I am trying to create an sql query from the archive_day_xxx tables to find the daily and monthly values ​​of the average wind direction that we retrieve in the variables $day.wind.vecdir and $month.wind.vecdir.
I tried several things from the archive_day_wind and archive_day_winDir tables but without finding the exact values.
Anyone know how to find them?
sorry for the google translate
Thanks in advance
Phil

michael.k...@gmx.at

unread,
Aug 11, 2023, 1:15:39 AM8/11/23
to weewx-user
There is no average direction, what you are looking for is the direction of a vector, the resulting vector (speed, direction) of all measuerements of a given timespan. I am not too familiar with all database tables and entries, but I thinking of the parts I know, I doubt that you can retrieve the vector an it's direction by a query (at least with a considerable simple one). 

What is your use case and why can't you use the provided variables you have mentioned?

Tom Keffer

unread,
Aug 11, 2023, 6:47:34 AM8/11/23
to weewx...@googlegroups.com
The query is 

"SELECT SUM(xsum),SUM(ysum) FROM %(table_name)s_day_%(obs_key)s WHERE dateTime >= %(start)s AND dateTime < %(stop)s;"


deg = 90.0 - math.degrees(math.atan2(row[1], row[0]))
value = deg if deg >= 0 else deg + 360.0

But, like Michael, I'm curious what you plan on doing with it.

--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/0d856397-4479-439e-80ee-e7bfbd799285n%40googlegroups.com.

Phil D

unread,
Aug 11, 2023, 9:45:52 AM8/11/23
to weewx-user
Thank you for your answers.
I have a website that displays monthly and annual comparisons from weewx tables. All the data comes from sql queries except for the direction column which comes from an html template then encoded in json. I would like to be able to use only sql queries

The web page in question (in French) https://www.cyclotropic.re/noaa.php

Tom Keffer

unread,
Aug 11, 2023, 11:41:00 AM8/11/23
to weewx...@googlegroups.com
In that case, you must also be sure to check for null values. The Python code is in function weewx.xtypes.DailySummaries.get_aggregate()

Reply all
Reply to author
Forward
0 new messages