Smoothing¶
- datkit.moving_average(times, values, w=None, t=None)¶
Applies a moving average filter to
v
, using a window of either widthw
or a width derived from the durationt
.If
w
is given, it must be a strictly positive and odd integer. Ift
is given, the used width will be the nearest odd integer tot
over the sampling interval. Seewindow_size()
for details.Returns a new time series
x, y
of lengthlen(times) - w + 1
.
- datkit.gaussian_smoothing(times, values, w=None, t=None)¶
Applies a Gaussian smoothing filter to
v
, using a window of either widthw
or a width derived from the durationt
.If
w
is given, it must be a strictly positive and odd integer. Ift
is given, the used width will be the nearest odd integer tot
over the sampling interval. Seewindow_size()
for details.The Gaussian kernel is determined as
np.exp(-x**2)
, wherex
ranges from -2 to +2 in the window.
- datkit.window_size(times, w=None, t=None)¶
Returns a window size of either
w
samples or widtht
.If
w
is given, it must be a strictly positive odd integer.If
t
is given, the used width will be the nearest odd integer tot / dt
, wheredt
is the sampling interval. The nearest odd integer is defined as1 + 2 * ((t / dt) // 2)
.
- datkit.haar_downsample(times, values, repeats=1)¶
Returns a downsampled signal created by successive averaging of adjacent samples, similar to a Haar wavelet.
In each pass:
If the signal length is odd, the final sample is omitted
The first two samples are averaged, then the next two, etc.
Returns a new and downsampled time series
(times_2, values_2)
.