Purrrification of factory time-series
Suppose \((t, \dot{s}_{\ell}(t))\) is the time series of liquid sugar mass flow measurement in Line \(\ell\) of a certain factory. To compute the liquid sugar mass for a given interval \(t \in [t_{\rm start}, t_{\rm stop}]\), we can integrate the time series numerically: $$s(t_{\rm start}, t_{\rm stop}, \ell)=\int_{t_{\rm start}}^{t_{\rm stop}} \dot{s}_{\ell}(t)\,dt$$ For instance, the following line totalizes the liquid sugar flow in Line 1 between 11:00 am to 12:00 pm on June 29. sugar_mass('2020-6-29 11:00', '2020-6-29 12:00', 'L1_sugar_massflow') where sugar_mass is totalizer function which parse the mass flow time series into a numerical value. Suppose you are given the task to compute the total sugar metered by flowmeters in Lines 1, 2, 4, and 6 for that same interval. A quick and dirty way would be to rewrite the original code like this: start_clock A slightly better approach is to use start_clock where all_sugar is a reusable function...