As we used to say in my company, "Still confused, but at a higher level."
Something to keep in mind is that for an expression $f($x, $y, $z) the function $f() can actually be a "functor" --- an object that defines __call__(). While functors look like functions, they are actually objects. Because they are objects, they can have attributes, which can be your hidden, model-dependent, parameters. class Model(object): def __init__(self, secret_j, secret_k): self.secret_j = secret_j self.secret_k = secret_k ... def __call__(self, x, y, z): result = do_some_calculation(x, y, self.secret_j, self.secret_k) return result You create the Model object in a search list extension: class ModelSLE(SearchList): def __init__(self, generator): SearchList.__init__(self, generator) self.model = Model(secret_j=12.2, secret_k=-2.1) Now you can do things like: #def result = $model('moth', 'spring') <p>The result for species 'moth' is $result, using parameters $result.secret_j, $result.secret_k</p> This is very similar to how the tag $almanac works. Needless to say, this is not tested, and there is ample room for improvement. My intention is to show how functors work. It's also entirely possible that I've completely misunderstood the problem you're trying to solve! -tk On Sat, Dec 12, 2020 at 9:17 PM Chuck Rhode <charlescurtisrh...@gmail.com> wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > On Fri, 11 Dec 2020 04:51:05 -0800 > Tom Keffer <tkef...@gmail.com> wrote: > > > I'm not understanding what you are asking. I gather you want to use an > > expression like > > > $f($x, $y, $z). > > > in a Cheetah template, where f() is your model, and x, y, and z are > > parameters? If so, what's to stop you from simply using $x, $y, and > > $z in the template? > > Thanks for your reply to my rather muddled query. > > I'm writing a WeeWX extension that lets the User choose from a suite of > models. There are too many to calculate, so I want to calculate only > those of interest. > > I'm struggling to explain this to myself, too, and my conceptualization > of the problem is evolving, so I apologize for inconsistency with my > previous posts. > > The models don't really have parameters. There are underlying > parameterized calculations, but the choice of the model dictates the > choice of the parameters. I expect the User to choose a handful of > models. I'll make each chosen model *name* the *name* of an XType > variable and ignore the models that are not chosen. > > I'll provide a Cheetah template for a standard HTML report that > includes group breaks for each temperature development model and lines > for daily min/max temperatures, growing-degree-days, cumulative > degree-days, and development event horizons. In the model headers I'd > like to show the actual calculation parameters used by the model. > These are not in the User-defined part of the config, but in the > model-definition part of the config, which I'd rather the User kept his > paws out of, so I need to walk the various configs in the template in > the same way that I walk the same configs in the XType instantiation > code to look up parameters by model *name* ... unless there's a way to > get an XType variable to cough up metadata in addition to numerical > series. > > I've settled on a solution, though. I'll include my Python XType > instantiation module in my Cheetah template and reference the same > config-walking code (a non-User-oriented class) in both places. (The > config-walking code should not need to be run on each evaluation of the > XType variable but only at instantiation. It will need to be run on > every Cheetah report generation.) Upon sober reflection, it doesn't > seem that that is too often or too expensive. > > - -- > .. Be Seeing You, > .. Chuck Rhode, Sheboygan, WI, USA > .. Weather: http://LacusVeris.com/WX > .. 30° — Wind NNW 9 mph — Sky overcast. > > -----BEGIN PGP SIGNATURE----- > > iF0EARECAB0WIQT+MY/5I/LMPSswTbVg2/xipKOWUgUCX9Wj7QAKCRBg2/xipKOW > UqnVAJ98hay31xSFw1mKDKQboCYRIu/+uwCfTKHWIicOQvbatTk8DebdznaU6D4= > =wqlq > -----END PGP SIGNATURE----- > > -- > 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 weewx-user+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/weewx-user/20201212231732.189fae62%40wealthy > . > -- 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 weewx-user+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/CAPq0zEBf48Rsimsbm9XNiDX5oEd1Hi3DVg8v3LwN_Btz-pDthw%40mail.gmail.com.