In that case, you must also be sure to check for null values. The Python
code is in function weewx.xtypes.DailySummaries.get_aggregate()
<https://github.com/weewx/weewx/blob/26bbcc56b5939d3e7e102ba21e9e656074714f67/bin/weewx/xtypes.py#L496>

On Fri, Aug 11, 2023 at 6:45 AM Phil D <[email protected]> wrote:

> 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
>
> Le vendredi 11 août 2023 à 14:47:34 UTC+4, Tom Keffer a écrit :
>
>> The query
>> <https://github.com/weewx/weewx/blob/26bbcc56b5939d3e7e102ba21e9e656074714f67/bin/weewx/xtypes.py#L491C19-L492C73>
>> is
>>
>> "SELECT SUM(xsum),SUM(ysum) FROM %(table_name)s_day_%(obs_key)s WHERE
>> dateTime >= %(start)s AND dateTime < %(stop)s;"
>>
>> Then
>> <https://github.com/weewx/weewx/blob/26bbcc56b5939d3e7e102ba21e9e656074714f67/bin/weewx/xtypes.py#L581>
>> ,
>>
>> 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.
>>
>> On Thu, Aug 10, 2023 at 10:15 PM [email protected] <[email protected]>
>> wrote:
>>
>>> 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?
>>>
>>> Phil D schrieb am Freitag, 11. August 2023 um 05:58:31 UTC+2:
>>>
>>>> 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
>>>
>>> --
>>> 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 [email protected].
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/weewx-user/0d856397-4479-439e-80ee-e7bfbd799285n%40googlegroups.com
>>> <https://groups.google.com/d/msgid/weewx-user/0d856397-4479-439e-80ee-e7bfbd799285n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>> --
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/weewx-user/a30788fa-8b45-4132-b793-d60a79d0cd02n%40googlegroups.com
> <https://groups.google.com/d/msgid/weewx-user/a30788fa-8b45-4132-b793-d60a79d0cd02n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-user/CAPq0zEA6Z%2BTk_4O-mJRR%2BnXhB4PcVB1mDwBouJFBuVLFWsR6eQ%40mail.gmail.com.

Reply via email to