# Filtering data with timestamps

How to apply filter to data that was sampled in certain moments of time? Examples from documentation deal only with uniformly sampled data:

data = Table[SquareWave[i/100] + RandomReal[{-0.1, 0.1}], {i, 225}];
GraphicsRow[ListLinePlot /@ {data, LowpassFilter[data, .5]}]


I.e. time is not included in the array. How to apply similar filter to the case when sampling times are explicitly stated? The following fails:

data = Table[{i/100, SquareWave[i/100] + RandomReal[{-0.1, 0.1}]}, {i,225}];
GraphicsRow[ListLinePlot /@ {data, LowpassFilter[data, .5]}]

• @kglr this won't work for non uniform sampling time: data = Table[{(i/100)^2, SquareWave[(i/100)^2] + RandomReal[{-0.1, 0.1}]}, {i, 525}]; May 3 '18 at 19:39
• @kglr this works, thank you May 3 '18 at 19:55

Just apply TemporalData or TimeSeries to your data:

data = TemporalData[Table[{i/100, SquareWave[i/100] + RandomReal[{-0.1, 0.1}]}, {i,225}]];
ListLinePlot[{data, LowpassFilter[data, 60]}] You can use Timeseries objects essentially like a InterpolatingFunction:

data0 = Table[{i/100 + RandomReal[{-0.005, 0.005}],
SquareWave[i/100] + RandomReal[{-0.1, 0.1}]}, {i, 225}];
f = TimeSeries[data0,
"ResamplingMethod" -> {"Interpolation", InterpolationOrder -> 0}];
g = TimeSeries[data0,
"ResamplingMethod" -> {"Interpolation", InterpolationOrder -> 1}];
h = TimeSeries[data0,
"ResamplingMethod" -> {"Interpolation", InterpolationOrder -> 3}];
Plot[{f[t], g[t], h[t]}, {t, f["Times"][], f["Times"][[-1]]}] The default resampling method is of order 1 (piecewise-linear interpolation). You can get the InterpolatingFunction with g["PathFunction"].

Also interesting for you might be to inspect other properties with g["Properties"] (this works also for TemporalData objects.

• Is there any difference between TimeSeries and TemporalData? May 3 '18 at 20:12
• How do I plot TimeSeries like a usual function? May 3 '18 at 20:42
• This proved to work much faster than Timeseries. Jul 1 '18 at 23:04
data = Table[{(i/100)^2, SquareWave[(i/100)^2] + RandomReal[{-0.1, 0.1}]}, {i, 180}];
GraphicsRow[ListLinePlot /@ {data, LowpassFilter[TimeSeries@data, Quantity[5, "Hertz"]]}] 