This is a 1-D filter. If
x
has dimension greater than 1,
axis
determines the axis along which the filter is applied.
Parameters
:
x
array_like
The data to be filtered. If
x
is not a single or double precision
floating point array, it will be converted to type
numpy.float64
before filtering.
window_length
int
The length of the filter window (i.e., the number of coefficients).
If
mode
is ‘interp’,
window_length
must be less than or equal
to the size of
x
.
polyorder
int
The order of the polynomial used to fit the samples.
polyorder
must be less than
window_length
.
deriv
int, optional
The order of the derivative to compute. This must be a
nonnegative integer. The default is 0, which means to filter
the data without differentiating.
delta
float, optional
The spacing of the samples to which the filter will be applied.
This is only used if deriv > 0. Default is 1.0.
axis
int, optional
The axis of the array
x
along which the filter is to be applied.
Default is -1.
mode
str, optional
Must be ‘mirror’, ‘constant’, ‘nearest’, ‘wrap’ or ‘interp’. This
determines the type of extension to use for the padded signal to
which the filter is applied. When
mode
is ‘constant’, the padding
value is given by
cval
. See the Notes for more details on ‘mirror’,
‘constant’, ‘wrap’, and ‘nearest’.
When the ‘interp’ mode is selected (the default), no extension
is used. Instead, a degree
polyorder
polynomial is fit to the
last
window_length
values of the edges, and this polynomial is
used to evaluate the last
window_length // 2
output values.
cval
scalar, optional
Value to fill past the edges of the input if
mode
is ‘constant’.
Default is 0.0.
Returns
:
y
ndarray, same shape as
x
The filtered data.
‘mirror’:
Repeats the values at the edges in reverse order. The value
closest to the edge is not included.
‘nearest’:
The extension contains the nearest input value.
‘constant’:
The extension contains the value given by the
cval
argument.
‘wrap’:
The extension contains the values from the other end of the array.
For example, if the input is [1, 2, 3, 4, 5, 6, 7, 8], and
window_length
is 7, the following shows the extended data for
the various
mode
options (assuming
cval
is 0):
Note that the last five values in x are samples of a parabola, so
when mode=’interp’ (the default) is used with polyorder=2, the last
three values are unchanged. Compare that to, for example,
mode=’nearest’: