Folding nd interpolation are techniques to align time series data to a given interval.
Folding
There are other terms used for folding such as aggregating or rolling up.
Folding time series data is the process of taking many values within a specific time range and folding them into a single representative value for the entire time range. The fold function determines how a raw history is “folded” when the history is being rolled up.
Consider the following raw history, recorded at 1minute intervals:
timestamp | My Point |
---|---|
2019-01-01 00:00 | 1 kWh |
2019-01-01 00:01 | 2 kWh |
2019-01-01 00:02 | 3 kWh |
2019-01-01 00:03 | 2 kWh |
2019-01-01 00:04 | 1 kWh |
2019-01-01 00:05 | 2 kWh |
2019-01-01 00:06 | 3 kWh |
2019-01-01 00:07 | 4 kWh |
2019-01-01 00:08 | 3 kWh |
2019-01-01 00:09 | 2 kWh |
If we were to roll this history up into 5minute intervals, we would get different results depending on how we fold the raw history. The table below shows the resulting values for fold functions of “sum”, “avg”, “min” and “max” respectively.
timestamp | Sum | Avg | Min | Max |
---|---|---|---|---|
2019-01-01 00:00 | 9 kWh | 1.8 kWh | 1 kWh | 3 kWh |
2019-01-01 00:05 | 14 kWh | 2.8 kWh | 2 kWh | 4 kWh |
The available fold functions depend of the data type.
Interpolation
Interpolating time series data could be considered the inverse of folding time series data. With folding, many values are transformed into a single value. With interpolation, two or more values are transformed into many values.
Interpolation is one method used for filling gaps in data.
Consider the following history, which has data every 5 minutes but nothing in between:
timestamp | My Point |
---|---|
2019-01-01 00:00 | 5 kWh |
2019-01-01 00:01 | |
2019-01-01 00:02 | |
2019-01-01 00:03 | |
2019-01-01 00:04 | |
2019-01-01 00:05 | 10 kWh |
2019-01-01 00:06 | |
2019-01-01 00:07 | |
2019-01-01 00:08 | |
2019-01-01 00:09 | |
2019-01-01 00:10 | 5 kWh |
There are three approaches to interpolating data. The correct approach to use depends entirely on the data in question:
-
Linear - the data is simply linearly interpolated between known values. Usually applied to sampled data such as temperature trends.
-
Change of Value - all gaps in the data are filled with the last known value. Usually applied to set point trends or boolean data
-
Apportion - the size of the gap is determined and all known data is evenly apportioned across the gap. Usually applied to consumption data such as energy usage
The table below demonstrates the three approaches:
timestamp | Original | Linear | COV | Apportion |
---|---|---|---|---|
2019-01-01 00:00 | 5 | 5 | 5 | 1 |
2019-01-01 00:01 | 6 | 5 | 1 | |
2019-01-01 00:02 | 7 | 5 | 1 | |
2019-01-01 00:03 | 8 | 5 | 1 | |
2019-01-01 00:04 | 9 | 5 | 1 | |
2019-01-01 00:05 | 10 | 10 | 10 | 2 |
2019-01-01 00:06 | 9 | 10 | 2 | |
2019-01-01 00:07 | 8 | 10 | 2 | |
2019-01-01 00:08 | 7 | 10 | 2 | |
2019-01-01 00:09 | 6 | 10 | 2 | |
2019-01-01 00:10 | 5 | 5 | 5 | 5 |