I'm having second thoughts about how we are using __init__ and __call__ in the zgr child classes.
The parent Zgr knows about jpk, but it doesn't do any computationally expensive stuff when it is initialized.
I.e., I don't think there's any advantage in initializing the class only once. I also think it is easier to do:
ds.domcfg.sco(jpk=31, **kwargs)
rather than
ds.domcfg.jpk = 31
ds.domcfg.sco(**kwargs)
I suggest we move __call__ in Zgr, where call does not have any argument and returns the final object with all z3 and e3.
The parent __init__ can stay as it is: __init__(obj, jpk).
Childs' __init__ would just add arguments to the parent __init__.
Finally, compute_z3 should be an abstract method in the parent class (Zgr), and that abstract method should be used by the parent class to generate z3 needed to compute e3.
Recap:
- Child classes should look like this:
Zco(obj, jpk, ...). Child classes initialize additional arguments and their __init__ end with super().__init__(obj, jpk)
- The only constraint for child classes is that they have a method that computes and return
z3. How they do it, it's not Zgr business.
- Direct call of classes looks like this
ds_out = Zco(ds_in, jpk, **kwargs)()
- The public API looks like this:
ds_out = ds_in.domcfg.zco(jpk, **kwargs)
I'm having second thoughts about how we are using
__init__and__call__in thezgrchild classes.The parent
Zgrknows aboutjpk, but it doesn't do any computationally expensive stuff when it is initialized.I.e., I don't think there's any advantage in initializing the class only once. I also think it is easier to do:
rather than
I suggest we move
__call__inZgr, where call does not have any argument and returns the final object with all z3 and e3.The parent
__init__can stay as it is:__init__(obj, jpk).Childs'
__init__would just add arguments to the parent__init__.Finally,
compute_z3should be an abstract method in the parent class (Zgr), and that abstract method should be used by the parent class to generatez3needed to computee3.Recap:
Zco(obj, jpk, ...). Child classes initialize additional arguments and their__init__end withsuper().__init__(obj, jpk)z3. How they do it, it's notZgrbusiness.ds_out = Zco(ds_in, jpk, **kwargs)()ds_out = ds_in.domcfg.zco(jpk, **kwargs)