Tom,
I run almost everything WeeWX out of github. Either checking out tags or 
running at HEAD (or close to it), so my development environment is 
currently at head. My specialized get_aggregate and get_series catch any 
CannotCalculate and return None. I had one CannotCalculate that is now 
handled at startup by checking the configuration. All makes sense now and 
is working well. I guess now I don’t actually have to catch it.
I think my AQI XType is now working well. It was a fairly simple one 
because it only depends on particulate matter. Only the ‘avg’ aggregate 
requires calculating all values in the series and averaging. ‘min’, ‘max;, 
‘first’, ‘last’ can just retrieve the single particulate matter and 
calculate the AQI.
I’m now experimenting with the Nowcast algorithm. One could argue why… 
Because? It uses up to the last 12 hour readings, so I think any 
aggregation period less than a day makes no sense. So I will probably need 
to handle that somehow.  We’ll see what I learn from this.
- rich

On Monday 4 March 2024 at 12:11:17 UTC-5 Tom Keffer wrote:

> Rich,
>
> Going back to your post in this thread, one thing I forgot to mention: You 
> and I talked about how the XTypes system is not very rigorous on when a 
> function should or should not raise weewx.CannotCalculate.  HEAD has 
> tightened this up and now has a few changes that prevent get_aggregate() 
> and get_series() from raising weewx.CannotCalculate. Instead, they return 
> None. 
>
> However, get_scalar() can still raise CannotCalculate.
>
> The XTypes wiki <https://github.com/weewx/weewx/wiki/xtypes> has been 
> revised to clarify this 
>
> -tk
>
> On Mon, Mar 4, 2024 at 8:53 AM bell...@gmail.com <bell...@gmail.com> 
> wrote:
>
>> Tom,
>> Thanks for the example. I did the same thing, just not as elegant. When I 
>> have time, I will try this out.
>> I also did it for ‘not_null’ since it is called when ‘has_data’ is 
>> called. For most people, probably not necessary, but I had a sensor offline 
>> recently, so the default get_aggregate of ‘not_null’ had to iterate until a 
>> time when the sensor was online. 
>> Again, thanks!
>> rich
>> On Monday 4 March 2024 at 10:41:39 UTC-5 Tom Keffer wrote:
>>
>>> I've added an optimized version of get_aggregate(). This version 
>>> recognizes the monotonic relationship between temperature and vapor 
>>> pressure, so it can use the daily summaries to find the min, max, mintime, 
>>> and maxtime of vapor pressure. It would not work for the average value.
>>>
>>> See 
>>> https://github.com/weewx/weewx/wiki/XTypes-performance#optimized-version-of-get_aggregate
>>>
>>> On Sat, Mar 2, 2024 at 6:52 PM John Kline <jo...@johnkline.com> wrote:
>>>
>>>> It looks like I specialized get_aggregate() for my weewx-purple 
>>>> extension in July of 2020.  AQI isn’t in the database, but pm2_5 is, which 
>>>> makes things efficient.
>>>>
>>>> I don’t know if get_aggregate was actually called in v4 (since I update 
>>>> my skin pages on every loop record, the values initially generated in 
>>>> reports aren’t interesting).
>>>>
>>>> I do know that reporting got slower in v5.
>>>>
>>>> And this simple change dramatically speeded things up:
>>>> - weewx.xtypes.xtypes.append(AQI())
>>>> + weewx.xtypes.xtypes.insert(0, AQI())
>>>> I’m glad I finally paid attention to this subject.  Thanks, Tom and 
>>>> others.
>>>>
>>>> On Mar 2, 2024, at 5:16 PM, Tom Keffer <tke...@gmail.com> wrote:
>>>>
>>>> 
>>>> On Sat, Mar 2, 2024 at 9:38 AM Karen K <kk44...@gmail.com> wrote:
>>>>
>>>>>
>>>>> First is the ArchiveTable class. It calls the general get_aggregate 
>>>>> function and thus also your XType. If you want ArchiveTable handle 
>>>>> get_series aggregations for your XType, you have to insert your XType 
>>>>> after 
>>>>> ArchiveTable. But if you implemented aggregations and do not want 
>>>>> XTypeTable handle those aggregations, then you need to insert your XTypes 
>>>>> before XTypeTable. That is, between ArchiveTable and XTypeTable.
>>>>>
>>>>
>>>> I guess I'm not seeing that. If ArchiveTable.get_series() calls 
>>>> xtypes.get_aggregate(), it will run down the list of xtypes. It won't use 
>>>> the one in ArchiveTable because it doesn't know about your new type. It 
>>>> keeps going until it gets to your xtype extension. 
>>>>  
>>>>
>>>>> If your users want to speed up something and include your XTypes into 
>>>>> the database, they surely want the DailySummaries class handle 
>>>>> aggregations. But that does not mean that you want XTypeTable handle the 
>>>>> aggegations of your XType in the other case. You may have provided your 
>>>>> own 
>>>>> implementation of the aggregations. That means you have to insert your 
>>>>> XType after DailySummaries but before XTypeTable.
>>>>>
>>>>
>>>> If the XType is in the database, it will be handled like any other 
>>>> type. There is no longer anything special about it. There is no reason for 
>>>> XTypeTable to come into play. I also don't know why you'd want your own 
>>>> implementation of get_aggregate() if the type is in the database.
>>>>
>>>> So I guess if you want your XType to behave in an intuitive way and you 
>>>>> have implemented the aggregations, then you will have to insert it after 
>>>>> ArchiveTable and DailySummaries, but before XTypeTable.
>>>>>
>>>>
>>>> Respectively disagree. New XTypes can be appended or prepended to the 
>>>> list --- the only time it matters is a straight optimization of 
>>>> get_aggregate(). Then it must appear at the beginning of the list so it 
>>>> appears before XTypeTable.get_aggregate().
>>>>
>>>> See the new wiki article on xtypes performance 
>>>> <https://github.com/weewx/weewx/wiki/XTypes-performance>. It explains 
>>>> some of this.
>>>>
>>>> -tk
>>>>
>>>> -- 
>>>> 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 weewx-developm...@googlegroups.com.
>>>> To view this discussion on the web visit 
>>>> https://groups.google.com/d/msgid/weewx-development/CAPq0zEA8h_DYLP6%2BrTB4VeEo46%2B9ySXsfasExohbptVuk8peSw%40mail.gmail.com
>>>>  
>>>> <https://groups.google.com/d/msgid/weewx-development/CAPq0zEA8h_DYLP6%2BrTB4VeEo46%2B9ySXsfasExohbptVuk8peSw%40mail.gmail.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 weewx-developm...@googlegroups.com.
>>
> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/weewx-development/c1b54377-63b9-4261-89f6-af80ce29779cn%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/weewx-development/c1b54377-63b9-4261-89f6-af80ce29779cn%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 weewx-development+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-development/bb3a9229-e346-42fe-8c3e-d1d9285cb112n%40googlegroups.com.

Reply via email to