cf.Field.convolution_filter¶

Field.
convolution_filter
(weights, axis=None, mode=None, cval=None, origin=0, update_bounds=True, inplace=False, i=False, _bounds=True)[source]¶ Return the field convolved along the given axis with the specified filter.
Can be used to create running means.
See also
Parameters:  weights: sequence of numbers
Specify the window of weights to use for the filter.
 Parameter example:
An unweighted 5point moving average can be computed with
weights=[0.2, 0.2, 0.2, 0.2, 02]
Note that the
scipy.signal.windows
package has suite of window functions for creating weights for filtering. axis:
Select the domain axis over which the filter is to be applied, defined by that which would be selected by passing the given axis description to a call of the field construct’s
domain_axis
method. For example, for a value of'X'
, the domain axis construct returned byf.domain_axis('X'))
is selected. mode:
str
, optional The mode parameter determines how the input array is extended when the filter overlaps a border. The default value is
'constant'
or, if the dimension being convolved is cyclic (as ascertained by theiscyclic
method),'wrap'
. The valid values and their behaviour is as follows:mode Description Behaviour 'reflect'
The input is extended by reflecting about the edge (d c b a  a b c d  d c b a)
'constant'
The input is extended by filling all values beyond the edge with the same constant value, defined by the cval parameter. (k k k k  a b c d  k k k k)
'nearest'
The input is extended by replicating the last point. (a a a a  a b c d  d d d d)
'mirror'
The input is extended by reflecting about the center of the last point. (d c b  a b c d  c b a)
'wrap'
The input is extended by wrapping around to the opposite edge. (a b c d  a b c d  a b c d)
The position of the window can be changed by using the origin parameter.
 cval: scalar, optional
Value to fill past the edges of the array if mode is
'constant'
. Defaults toNone
, in which case the edges of the array will be filled with missing data. Parameter example:
To extend the input by filling all values beyond the edge with zero:
cval=0
 origin:
int
, optional Controls the placement of the filter. Defaults to 0, which is the centre of the window. If the window has an even number weights then then a value of 0 defines the index defined by
width/2 1
. Parameter example:
For a weighted moving average computed with a weights window of
[0.1, 0.15, 0.5, 0.15, 0.1]
, iforigin=0
then the average is centred on each point. Iforigin=2
then the average is shifted to inclued the previous four points. Iforigin=1
then the average is shifted to include the previous point and the and the next three points.
 update_bounds:
bool
, optional If False then the bounds of a dimension coordinate construct that spans the convolved axis are not altered. By default, the bounds of a dimension coordinate construct that spans the convolved axis are updated to reflect the width and origin of the window.
 inplace:
bool
, optional If True then do the operation inplace and return
None
. i: deprecated at version 3.0.0
Use the inplace parameter instead.