Data Gap Filling
Time series queries can add extra data points into the gaps between entries. These data points get values extrapolated from the entries on either side of the gap. This is called interpolation.
There are two interpolation methods available:
- Nearest - add values equal to the value of the nearest entry.
- Linear - place the data points on a straight line between the entries on either side.
In this page:
To add interpolation to a time series query, start by grouping the data by some
For example, suppose you have a time series with an entry for every hour, but several hours are missing (1am, 3pm, etc.), and you want to fill those gaps. You will want to group by 1 hour.
Or suppose you have a time series with an entry for every hour, and you want to fill in the gap with one data point per minute: you will group by 1 minute.
See here to learn about aggregation in queries.
- For RQL queries:
The two interpolation modes are:
Nearest: add entries with values equal to the closest time series entry before or after this data point. If the data point is exactly in the middle between two entries, the data point gets the value of the earlier entry.
Linear: the data point is placed on a projected line between two entries. For example, if the entry for 1:00 PM has a value 100, and the entry for 2:00 PM has a value 130, the interpolated data point for 1:40 PM will have the value 120.
One data point is added for each aggregated time unit that does not contain any values. When time series entries have multiple values, an interpolation will add one data point for each pair of values found on both sides of the gap.
const query = session.advanced.rawQuery( "from People\n" + "select timeseries(\n" + " from HeartRates\n" + " group by 1 second\n" + " with interpolation(liner)\n" + ")", TimeSeriesAggregationResult );