You're on the right track. If you pass in a parameter to an aggregation, it
appears in "option_dict" in the corresponding get_aggregate() call. If you
don't name that parameter, it shows up as key "val". So, in your example,

$day.outTemp.rolling_avg_years(10)


would result in a call to get_aggregate() that looks like:

get_aggregate('outTemp', timespan, 'rolling_avg_years', db_manager, val=10)


The value 'val' will contain the appropriate number of years to do the
rolling average.

Hope that helps.

-tk

On Sun, Oct 9, 2022 at 5:54 AM [email protected] <[email protected]>
wrote:

> Hello,
>
> I am writing a Xtype extension providing  a new aggregate type that
> calculates a rolling average of a parameter over years.
>
> I started by defining several different aggregate type for different
> number of years, such as :
>
> *rolling_avg_years1*
>
> *rolling_avg_years5*
>
> *rolling_avg_years10*
>
> *rolling_avg_years15*
>
> For exemple :  *$day.outTemp.rolling_avg_years10* returns the average
> temperature of the last 3650 days (i.e. 10 years).
>
> And it works.
>
> But, to allow more flexibility,  I would prefer, if possible,  to have the
> number of years as parameter, such as
>
> *rolling_avg_years(10)*
>
> but I don't know how I could retrieve the parameter in the get_aggregate
> function of my extension.
> Any help is appreciated,
> Thanks
>
> --
> 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/c17fbd97-4547-4a36-bfc0-35b10aa3b68bn%40googlegroups.com
> <https://groups.google.com/d/msgid/weewx-development/c17fbd97-4547-4a36-bfc0-35b10aa3b68bn%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/CAPq0zECGbOo6rT7mNdRFvRQAq6TNmWKZO6NZ7evDA6mvUz925g%40mail.gmail.com.

Reply via email to