maxsum scans all the daily sums and return the max value. It's useful for
figuring out queries like, "What's the rainiest day of the month?" In your
case, it would be returning the windrun for the day with the max windrun.

I'd replace your UPDATE with:

*UPDATE weewx.archive SET windrun = (windSpeed * `interval` / 60.0) where
windSpeed is not null;*

On Wed, Oct 16, 2019 at 4:10 PM Pat <[email protected]> wrote:

> I thought that sum was right and not maxsum. This is what I had it at
> before, but was told I should be using maxsum. So in my research I think I
> lost my way a little bit and started focusing on month even though the tag
> was for year. Brain fart moment I guess.
>
> On the update query; not sure on the restriction. I had shot from the hip
> based on the weewx calculation that windSpeed is not None. So I worked with
> windSpeed > 0. What would a proper query be to replace in-situ windrun?
>
> usUnits = 1 in my database.
>
> On Wednesday, October 16, 2019 at 6:59:52 PM UTC-4, Tom Keffer wrote:
>>
>> Windrun is an 'extensive' variable, which should be treated similarly to
>> the other such variables, such as rain and ET. So, it should be summed. The
>> total windrun for the year would be $year.windrun.sum.
>>
>> But, I suspect the number will still be big.
>>
>> With your UPDATE, why the restriction for windSpeed > 0? Perhaps there
>> are values where windrun is non-zero, even if windSpeed is zero?
>>
>> One more question: what unit system is your database using?
>>
>> -tk
>>
>> On Wed, Oct 16, 2019 at 3:51 PM Pat <[email protected]> wrote:
>>
>>> Unless the answer is simply that $year.windrun.maxsum is the wrong tag
>>> to be using to find the max windrun for the year.
>>>
>>> Reading this
>>> <https://github.com/weewx/weewx/blob/master/bin/weewx/manager.py#L1117>,
>>> I believe that may be the answer, however I recently changed the tag due to 
>>> the
>>> comment in this issue
>>> <https://github.com/poblabs/weewx-belchertown/issues/194#issuecomment-525017839>
>>>  in
>>> the Belchertown GitHub repo.
>>>
>>> On Wednesday, October 16, 2019 at 6:33:17 PM UTC-4, Pat wrote:
>>>>
>>>> I'm a bit lost on windrun right now and could use guidance. This is on
>>>> weewx 3.9.2
>>>>
>>>> My $year.windrun.maxsum is reporting 22617.05 miles which seems just a
>>>> little high. To the point where I thought this was a Belchertown skin
>>>> issue
>>>> <https://github.com/poblabs/weewx-belchertown/issues/194#issuecomment-541374600>.
>>>> I don't think it is because Belchertown isn't calculating windrun, just
>>>> using the Cheetah tag to display it.
>>>>
>>>> The calculation of windrun
>>>> <https://github.com/weewx/weewx/blob/master/bin/weewx/wxservices.py#L384>
>>>> seems simple. windSpeed * interval / 60.0 if windSpeed is not None.
>>>>
>>>> Exporting my database to a new MySQL database, I run this query to
>>>> reset all my windrun values in the archive table:
>>>>
>>>> UPDATE weewx.archive SET windrun = (windSpeed * `interval` / 60.0) where 
>>>> windSpeed > 0;
>>>>
>>>>
>>>> Then I dropped daily summaries and rebuilt. After doing that
>>>> my $year.windrun.maxsum is 9986.7. So there's an improvement here, but
>>>> still very high.
>>>>
>>>> According to this, my highest sum windrun is on 1452038400 (Wednesday,
>>>> January 6, 2016 12:00:00 AM)
>>>>
>>>>
>>>> MariaDB [weewx]> SELECT * FROM `archive_day_windrun` ORDER BY `sum` DESC 
>>>> LIMIT 1;
>>>> +------------+------+------------+---------------+------------+------------------+-------+------------------+---------+
>>>> | dateTime   | min  | mintime    | max           | maxtime    | sum        
>>>>       | count | wsum             | sumtime |
>>>> +------------+------+------------+---------------+------------+------------------+-------+------------------+---------+
>>>> | 1452038400 |    0 | 1452056460 | 32.6649722222 | 1452038460 | 
>>>> 9986.70872221597 |  1418 | 599202.523332966 |   85080 |
>>>> +------------+------+------------+---------------+------------+------------------+-------+------------------+---------+
>>>> 1 row in set (0.00 sec)
>>>>
>>>>
>>>> To get this day range, it's 1452038400 to 1452142799 (Wednesday,
>>>> January 6, 2016 11:59:59 PM GMT-05:00)
>>>>
>>>> So this query below takes that time range and figures out the average
>>>> wind speed, and the average windspeed across 24 hours as suggested here
>>>> <https://github.com/poblabs/weewx-belchertown/issues/194#issuecomment-542479902>
>>>> .
>>>>
>>>>
>>>> MariaDB [weewx]> select avg(windSpeed) as avg_windspeed, 
>>>> (avg(windSpeed)*24) as thisDayWindRun from archive where dateTime >= 
>>>> 1452038400 and dateTime <= 1452142799;
>>>> +---------------------+-------------------+
>>>> | avg_windspeed       | thisDayWindRun    |
>>>> +---------------------+-------------------+
>>>> | 0.09232844574780066 | 2.215882697947216 |
>>>> +---------------------+-------------------+
>>>> 1 row in set (0.00 sec)
>>>>
>>>>
>>>>
>>>> If windrun is a scalar sum
>>>> <https://github.com/weewx/weewx/issues/250#issuecomment-344936685>,
>>>> then I'm pretty sure I just add all the windspeed together to get the daily
>>>> windrun? This show's it's 157.42
>>>>
>>>>
>>>> MariaDB [weewx]> select sum(windspeed) from archive where dateTime >= 
>>>> 1452038400 and dateTime <= 1452142799;
>>>> +--------------------+
>>>> | sum(windspeed)     |
>>>> +--------------------+
>>>> | 157.42000000000013 |
>>>> +--------------------+
>>>> 1 row in set (0.00 sec)
>>>>
>>>>
>>>>
>>>>
>>>> Here's the same day's wind speed record:
>>>>
>>>> MariaDB [weewx]> SELECT * FROM `archive_day_windSpeed` where dateTime = 
>>>> 1452038400;
>>>> +------------+------+------------+------+------------+--------+-------+--------+---------+
>>>> | dateTime   | min  | mintime    | max  | maxtime    | sum    | count | 
>>>> wsum   | sumtime |
>>>> +------------+------+------------+------+------------+--------+-------+--------+---------+
>>>> | 1452038400 |    0 | 1452038460 |  3.5 | 1452098700 | 157.37 |  1419 | 
>>>> 9442.2 |   85140 |
>>>> +------------+------+------------+------+------------+--------+-------+--------+---------+
>>>> 1 row in set (0.00 sec)
>>>>
>>>>
>>>>
>>>> So I'm lost on where 9,986.7 is coming from?
>>>>
>>>>
>>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "weewx-development" 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-development/275c4b9f-b0e6-411f-acab-f62dc1bbc057%40googlegroups.com
>>> <https://groups.google.com/d/msgid/weewx-development/275c4b9f-b0e6-411f-acab-f62dc1bbc057%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>> --
> You received this message because you are subscribed to the Google Groups
> "weewx-development" 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-development/21f464e6-2c18-41aa-b1be-c6b43e9f037f%40googlegroups.com
> <https://groups.google.com/d/msgid/weewx-development/21f464e6-2c18-41aa-b1be-c6b43e9f037f%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"weewx-development" 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-development/CAPq0zEBbFz2X9y0amyGmNdVUW3pdV9SuxQN667haO0D491WHSQ%40mail.gmail.com.

Reply via email to