Flux support interpolating between data points. I have timeseries data with data points at every whole hour by default, but this can change due to intermittency issues or because someone specified a different cadence for the sensor. I need to have the “best approximation” of this series at time X where X can be at any instant. I have used the “interpolate” function but I have stumbled on this issue: You absolutely need to catch data points on both sides of the target time.
This means I need to enlarge the data retrieval period by at least more than the cadence (e.g. 1 hour) on bother sides of the target time. I need to round off the target time to something like a minute and then interpolate every minute. This will get me a good value.
However. If one side is missing (before or after X) I can’t get an approximation. So my question is: why can’t we have a function “extrapolate” as well as interpolate? Or why can’t interpolate be made to adjust to the underlying data so it just gets the first data point before the requested range and the first data point after the requested range?
I realize Flux is in maintenance mode, which is a pity. But I feel this functionality is still missing.
@donker I’m wondering if there may be a way to do this with Flux today. Can you give me an example of what your raw data looks like and how you would want query results work and/or be structured?
And now I’d like to know the best estimate at the time 2025-04-01T16:30:00Z. Extrapolating from the values you’d get to 970 (we have a climb of 1 per minute in that first segment).
How would you calculate the rate of change before 2025-04-01T17:00:00Z? The rate of change between 2025-04-01T17:00:00Z and 2025-04-01T18:00:00Z (60/min) is different than the rate change between 2025-04-01T18:00:00Z and 2025-04-01T19:00:00Z (40/min)? Does that rate of change stay the same if the time is reversed? Is the rate of change linear, exponential, logarithmic? I know you say it should be 970, but how do you get that?
Well, similarly to (linear) interpolate. AFAIK the interpolate function in Flux does it this way. It just takes the surrounding two values and calculates a straight line between these two points. My use case doesn’t demand anything more fancy. A simple continuation of the line would be fine. Obviously you can’t use this to calculate over a large time difference so we limit this to 3 hours max (the change rates are also smaller in real life).
So to answer your question: the third value is ignored in this calculation.