This would be part of template itself?

On Tue, 16 Aug, 2022, 19:54 Tom Keffer, <[email protected]> wrote:

> Praveen,
>
> On thinking about your problem a little more, I now understand the issue
> with needing 12 different templates. However, there may be a solution using
> the #set global command, and then using #include.
>
> Briefly, it would look something like this:
>
> #for i in range(1,13
> #  set global month=$i
> #  include "Climatology.txt"
> #end for
>
> Then the file "Climatology.txt" would be very similar to what you have,
> except it would be parameterized by the variable $month.
>
>
>
> On Mon, Aug 15, 2022 at 10:00 AM Tom Keffer <[email protected]> wrote:
>
>> Last night, I did put a very brief mention of option_dict in the wiki
>> article. https://github.com/weewx/weewx/wiki/WeeWX-V4-user-defined-types
>>
>> On Mon, Aug 15, 2022 at 8:16 AM Praveen Chandrasekaran <
>> [email protected]> wrote:
>>
>>> After struggling a bit through SLE today I hav decided to go down the
>>> route of xtypes. Is there documentation for option_dict that you mentioned
>>> other day?
>>>
>>> On Mon, 15 Aug, 2022, 19:39 Tom Keffer, <[email protected]> wrote:
>>>
>>>> Nothing wrong with a search-list extension. The chief advantage of an
>>>> xtypes extension is that a new aggregation type becomes a first-class
>>>> citizen of the tag system. Indeed, all the existing aggregations are
>>>> implemented using xtypes.
>>>>
>>>> $month.outTemp.historical_month_high
>>>>
>>>> vs something like
>>>>
>>>> $historical_high(outTemp, 'month')
>>>>
>>>>
>>>>
>>>> On Sun, Aug 14, 2022 at 7:47 PM Praveen Chandrasekaran <
>>>> [email protected]> wrote:
>>>>
>>>>> Also the xtypes for monthly stats needs some more tweaks to ensure
>>>>> partial months aren't used for average computation and such.
>>>>>
>>>>> Gary's SLE in saratoga extensions already takes care of them :)
>>>>>
>>>>> Adding all that to xtypes seems beyond my noob skill level.
>>>>>
>>>>> Gary,
>>>>>
>>>>> How many seconds does the SLE for monthly stats take every record? Is
>>>>> it a big drag? If so any way to run it more infrequently?
>>>>> Also do you plan to replace it with xtypes at some point?
>>>>>
>>>>> On Mon, 15 Aug, 2022, 07:02 Praveen Chandrasekaran, <
>>>>> [email protected]> wrote:
>>>>>
>>>>>> I assume if go the Saratoga way of SLE for monthly stats all monthly
>>>>>> stats get computed every archive interval irrespective of whether reports
>>>>>> are generated every archive interval. That isn't good if so.
>>>>>>
>>>>>> Again xtypes seems better as the db fetches are done only on demand
>>>>>> there as i understand
>>>>>>
>>>>>> On Sun, 14 Aug, 2022, 23:11 Praveen Chandrasekaran, <
>>>>>> [email protected]> wrote:
>>>>>>
>>>>>>> Though i agree that xtypes will achieve this much easier instead of
>>>>>>> having to add new search lists etc.
>>>>>>>
>>>>>>> On Sun, 14 Aug, 2022, 20:09 Praveen Chandrasekaran, <
>>>>>>> [email protected]> wrote:
>>>>>>>
>>>>>>>> Thanks. On further digging i also see that sarogata skin has
>>>>>>>> function for monthly stats across years. Looks like something i can 
>>>>>>>> steak
>>>>>>>> my code from!
>>>>>>>>
>>>>>>>> On Sun, 14 Aug, 2022, 19:58 Tom Keffer, <[email protected]> wrote:
>>>>>>>>
>>>>>>>>> It's true that there is no "monthly summary" table, but that
>>>>>>>>> shouldn't stop you from doing an xtypes extension. I think all that 
>>>>>>>>> would
>>>>>>>>> be necessary is to modify the SQL queries slightly in weewx-xaggs
>>>>>>>>> <https://github.com/tkeffer/weewx-xaggs>. For example, to return
>>>>>>>>> the all time historical high for a month the query (line 45
>>>>>>>>> <https://github.com/tkeffer/weewx-xaggs/blob/master/bin/user/xaggs.py#L45>
>>>>>>>>> )
>>>>>>>>>
>>>>>>>>> "SELECT MAX(`max`) FROM {table}_day_{obs_type} "
>>>>>>>>>                   "WHERE STRFTIME('%m-%d', 
>>>>>>>>> dateTime,'unixepoch','localtime') = '{month:02d}-{day:02d}';",
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> becomes
>>>>>>>>>
>>>>>>>>> "SELECT MAX(`max`) FROM {table}_day_{obs_type} "
>>>>>>>>>                   "WHERE STRFTIME('%m', 
>>>>>>>>> dateTime,'unixepoch','localtime') = '{month:02d}';",
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> and so on. Call it something like "historical_month_max". That
>>>>>>>>> leaves the problem of where does "month" come from. In weewx-xaggs, it
>>>>>>>>> comes from the month of the date whose page is being generated. 
>>>>>>>>> However,
>>>>>>>>> you want it for a specific month, not necessarily "today." You can 
>>>>>>>>> use the
>>>>>>>>> optional parameter "option_dict" to set it (requires WeeWX V4.8 or
>>>>>>>>> greater). Then your template looks like
>>>>>>>>>
>>>>>>>>> #for month in range(1,13)
>>>>>>>>> # <p>The historical high for month $month is
>>>>>>>>> $alltime.outTemp.historical_month_max($month)</p>
>>>>>>>>> #end for
>>>>>>>>>
>>>>>>>>> Unfortunately, "option_dict" is not documented in the xtypes wiki
>>>>>>>>> <https://github.com/weewx/weewx/wiki/WeeWX-V4-user-defined-types>.
>>>>>>>>> I'll try to get around to that today. Or, perhaps Gary can do it.
>>>>>>>>>
>>>>>>>>> I realize this is a rather "stream-of-consciousness" post. Hope
>>>>>>>>> I'm making myself clear.
>>>>>>>>>
>>>>>>>>> -tk
>>>>>>>>>
>>>>>>>>> On Sun, Aug 14, 2022 at 3:30 AM Praveen Chandrasekaran <
>>>>>>>>> [email protected]> wrote:
>>>>>>>>>
>>>>>>>>>> Finally managed to get a page like what I wanted up for one month:
>>>>>>>>>>
>>>>>>>>>> http://bedi.co.in/~pcws/tabular.html?report=Climatalogy.txt
>>>>>>>>>>
>>>>>>>>>> Attached template file used for same.
>>>>>>>>>>
>>>>>>>>>> Some inputs on below would be helpful:
>>>>>>>>>>
>>>>>>>>>> 1) The way it is done now, I need to have 12 templates - one for
>>>>>>>>>> each file. With changes in just 2 lines. Looking for a way to do it
>>>>>>>>>> smarter. I see that SummaryByMonth etc creates timespans and loops. 
>>>>>>>>>> But in
>>>>>>>>>> this scenario, the timespans I am interested in are not continuous 
>>>>>>>>>> (Jan of
>>>>>>>>>> each year, Feb of each year and so on). So I dont think I can create
>>>>>>>>>> timespans for these
>>>>>>>>>> 2) xaggs may not work I think since it seems to query daily
>>>>>>>>>> summary from db. There is no monthly summary in db however as I 
>>>>>>>>>> understand
>>>>>>>>>> 3) How do I make different month templates run at different
>>>>>>>>>> times. No point in running for month off Jan daily in August for 
>>>>>>>>>> example.
>>>>>>>>>>
>>>>>>>>>> PS : I am a noob on cheetah etc. Just reading through stuff now
>>>>>>>>>> to get hang of things.
>>>>>>>>>> On Saturday, 13 August 2022 at 19:30:46 UTC+5:30 Tom Keffer wrote:
>>>>>>>>>>
>>>>>>>>>>> So you did! Here's my response:
>>>>>>>>>>>
>>>>>>>>>>> There's no explicit tag to do that. You could loop over all
>>>>>>>>>>> months, then test the date to see if it is in a particular month. 
>>>>>>>>>>> Something
>>>>>>>>>>> like (NOT TESTED):
>>>>>>>>>>>
>>>>>>>>>>> #for month in $alltime.months
>>>>>>>>>>> #  if month.start.format("%b") == 'Jun'
>>>>>>>>>>> #    <p>Max for year $month.start.format("%Y") is
>>>>>>>>>>> $month.outTemp.max</p>
>>>>>>>>>>> #  end if
>>>>>>>>>>> #end for
>>>>>>>>>>>
>>>>>>>>>>> Alternatively, you could write an xtypes extension and create a
>>>>>>>>>>> new aggregation type. Similar to the "historical_min" and 
>>>>>>>>>>> "historical_max"
>>>>>>>>>>> aggregations in the weewx-xaggs
>>>>>>>>>>> <https://github.com/tkeffer/weewx-xaggs> extension, except it
>>>>>>>>>>> would be the historical min and max for the month, instead of the 
>>>>>>>>>>> day.
>>>>>>>>>>>
>>>>>>>>>>> --
>>>>>>>>>> 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/e6b5d587-912f-41ae-b3af-0e6dbd0f5d7bn%40googlegroups.com
>>>>>>>>>> <https://groups.google.com/d/msgid/weewx-development/e6b5d587-912f-41ae-b3af-0e6dbd0f5d7bn%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/CA%2BW%3DTmW3%3D9PD637gGhsr1o8n9kuXbdG%2BY627TKn%2BboodH63-fg%40mail.gmail.com.

Reply via email to