the sql to do what I want would be
select avg(outtemp) from archive
where strftime("%m-%d %H", datetime,'unixepoch')=strftime('%m-%d %H','now')
where I could put that query?
El sábado, 23 de octubre de 2021 a las 16:29:40 UTC+2, [email protected]
escribió:
> To be sure, it is an expensive calculation because the whole database
> would have to be searched. The daily summaries cannot be used because they
> are aggregates over a day.
>
> Precalculating would speed things up.
>
> -tk
>
> On Sat, Oct 23, 2021 at 6:25 AM p q <[email protected]> wrote:
>
>> Maybe it would be better to precompute the one hour (good enough? Or one
>> minute?) historical averages and store it in the database rather than
>> calculate it on the fly.
>>
>> On Sat, Oct 23, 2021, 5:35 AM Tom Keffer <[email protected]> wrote:
>>
>>> If I understand you correctly, you want to graph the day's temperature,
>>> along with the average historical temperature for the same time of day.
>>>
>>> The extension that Peter is referring to is the XAggs extension
>>> <https://github.com/tkeffer/weewx-xaggs>, but it does something
>>> slightly different. It calculates historical data (high, low, average,
>>> etc.) for the *whole day*, not just a particular time. It does this by
>>> offering new aggregation types, such as historical_avg, so you can
>>> request something like *$day.outTemp.historical_avg* and get the
>>> average temperature for today. That's not quite what you want, because you
>>> want the average for a particular time.
>>>
>>> Not sure how to handle that. Perhaps by defining a new type, call it
>>> outTemp_avg? Think of it as a new column in the database. although the
>>> XTypes <https://github.com/weewx/weewx/wiki/WeeWX-V4-user-defined-types>
>>> system allows you to define new types virtually, so you don't have to
>>> actually put it in the database. Then it could be specified like any other
>>> type:
>>>
>>> [[day_images]]
>>> ...
>>> [[[dayhistorical]]]
>>> [[[[outTemp]]]]
>>> [[[[outTemp_avg]]]]
>>>
>>> I think you can get away with just defining the XTypes function
>>> get_scalar(). Schematically, this would look something like this:
>>>
>>> class HistoricalAvg(weewx.xtypes.XType):
>>> def get_scalar(self, obs_type, record, db_manage):
>>> if obs_type != 'outTemp_avg':
>>> raise weewx.UnknownType(obs_type)
>>> ... Get the time of day for this record ...
>>> ... Look through the database for the average temperature for
>>> that time ...
>>> ... return it as a ValueTuple...
>>>
>>> As you can see, I've left out a lot of details! Read through the XTypes
>>> documentation
>>> <https://github.com/weewx/weewx/wiki/WeeWX-V4-user-defined-types> and
>>> see if you want to tackle this project.
>>>
>>> -tk
>>>
>>> On Sat, Oct 23, 2021 at 3:38 AM [email protected] <[email protected]>
>>> wrote:
>>>
>>>> What is that extension?
>>>> What I want is a graph that has the current temperature and the average
>>>> temperature that corresponds to all the records in the database with the
>>>> same day and time.
>>>>
>>>> El viernes, 22 de octubre de 2021 a las 15:58:20 UTC+2,
>>>> [email protected] escribió:
>>>>
>>>>> Someone wrote a search extension for "on this date" that would allow
>>>>> you to pull up the stats for a given date over time. I use it to show the
>>>>> high/low/rain for today's date for the years that I have data. Search
>>>>> this
>>>>> forum for it, if that's what you're looking for.
>>>>>
>>>>> On This Day
>>>>> Oct 22 2016
>>>>> H: 83.8°F L: 51.0°F
>>>>> 2017
>>>>> H: 77.2°F L: 47.6°F
>>>>> 2018
>>>>> H: 76.9°F L: 49.4°F
>>>>> 2019
>>>>> H: 86.2°F L: 49.8°F
>>>>> 2020
>>>>> H: 82.6°F L: 52.4°F
>>>>>
>>>>> On Fri, Oct 22, 2021 at 6:27 AM [email protected] <[email protected]>
>>>>> wrote:
>>>>>
>>>>>> Would it be possible to make a graph with the historical temperature
>>>>>> of that same day at that same time with all the data in the database?
>>>>>> And another would be the temperature anomaly with the current moment.
>>>>>> Thank you.
>>>>>>
>>>>>> --
>>>>>> 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/61df7337-1936-43eb-b4e0-46ffaae5a6c1n%40googlegroups.com
>>>>>>
>>>>>> <https://groups.google.com/d/msgid/weewx-user/61df7337-1936-43eb-b4e0-46ffaae5a6c1n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>>> .
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Peter Quinn
>>>>> (415)794-2264 <(415)%20794-2264>
>>>>>
>>>> --
>>>> 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/08e13c07-0811-4abe-a12d-4ff54f593211n%40googlegroups.com
>>>>
>>>> <https://groups.google.com/d/msgid/weewx-user/08e13c07-0811-4abe-a12d-4ff54f593211n%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/CAPq0zEBJ2dgEWwKbyj70aFXZ9-FLD%3Du%2BrY51%2BY6dS-b9oHF4aw%40mail.gmail.com
>>>
>>> <https://groups.google.com/d/msgid/weewx-user/CAPq0zEBJ2dgEWwKbyj70aFXZ9-FLD%3Du%2BrY51%2BY6dS-b9oHF4aw%40mail.gmail.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/CAA1SM23F_HuUvKN62S61sdx-nEFFMBXKV9nTGYDNbHWg6VTUvA%40mail.gmail.com
>>
>> <https://groups.google.com/d/msgid/weewx-user/CAA1SM23F_HuUvKN62S61sdx-nEFFMBXKV9nTGYDNbHWg6VTUvA%40mail.gmail.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/71827464-91a0-46ca-9e2d-aec015c5ca6cn%40googlegroups.com.