filters#
Filters for input field.
- boa_dask(input_field, iterations=1, axes=None, **kwargs)#
Apply BOA filter.
- Parameters:
input_field (Array) – Array to filter.
iterations (int) – Number of iterations to apply.
axes (Sequence[int] | None) – Indices of the the y/lat and x/lon axes on which to work. If None (default), the last two axes are used.
kwargs – See available kwargs for universal functions at Generalized universal function API.
- Return type:
- boa_numpy(input_field, iterations=1, axes=None, **kwargs)#
Apply BOA filter.
- Parameters:
input_field (ndarray[_Size, _DT]) – Array to filter.
iterations (int) – Number of iterations to apply.
axes (Sequence[int] | None) – Indices of the the y/lat and x/lon axes on which to work. If None (default), the last two axes are used.
kwargs – See available kwargs for universal functions at Generalized universal function API.
- Return type:
ndarray[_Size, _DT]
- boa_xarray(input_field, iterations=1, dims=None, **kwargs)#
Apply BOA filter.
- Parameters:
input_field (DataArray) – Array to filter.
iterations (int) – Number of iterations to apply.
kwargs – See available kwargs for universal functions at Generalized universal function API.
dims (Collection[Hashable] | None) – Names of the dimensions along which to apply the algorithm. Order is irrelevant, no reordering will be made between the two dimensions. If the window_size argument is given as a mapping, its keys are used instead. If not specified, is taken as module-wide variable
DEFAULT_DIMSwhich defaults to{'lat', 'lon'}.
- Return type:
- cmf_dask(input_field, window_size=3, iterations=1, axes=None, **kwargs)#
Apply contextual median filter.
This is a basic median filter where the filter is applied if and only if the central pixel of the moving window is a peak/maximum or a trough/minimum over the whole window. This is aimed at filtering anomalous values in the form of lonely spikes, without smoothing out the rest of the signal too much.
- Parameters:
input_field (DaskArray) – Array to filter.
window_size (int) – Size of the moving window. Default is 3 (ie 3x3).
iterations (int) – Number of times to apply the filter.
axes (Sequence[int] | None) – Indices of the the y/lat and x/lon axes on which to work. If None (default), the last two axes are used.
kwargs – See available kwargs for universal functions at Generalized universal function API.
- Returns:
Filtered array.
- Return type:
DaskArray
- cmf_numpy(input_field, window_size=3, iterations=1, axes=None, **kwargs)#
Apply contextual median filter.
This is a basic median filter where the filter is applied if and only if the central pixel of the moving window is a peak/maximum or a trough/minimum over the whole window. This is aimed at filtering anomalous values in the form of lonely spikes, without smoothing out the rest of the signal too much.
- Parameters:
input_field (NDArray) – Array to filter.
window_size (int) – Size of the moving window. Default is 3 (ie 3x3).
iterations (int) – Number of times to apply the filter.
axes (Sequence[int] | None) – Indices of the the y/lat and x/lon axes on which to work. If None (default), the last two axes are used.
kwargs – See available kwargs for universal functions at Generalized universal function API.
- Returns:
Filtered array.
- Return type:
NDArray
- cmf_xarray(input_field, window_size=3, iterations=1, dims=None)#
Apply contextual median filter.
This is a basic median filter where the filter is applied if and only if the central pixel of the moving window is a peak/maximum or a trough/minimum over the whole window. This is aimed at filtering anomalous values in the form of lonely spikes, without smoothing out the rest of the signal too much.
- Parameters:
input_field (DataArray) – Array to filter.
window_size (int) – Size of the moving window. Default is 3 (ie 3x3).
iterations (int) – Number of times to apply the filter.
kwargs – See available kwargs for universal functions at Generalized universal function API.
dims (Collection[Hashable] | None) – Names of the dimensions along which to apply the algorithm. Order is irrelevant, no reordering will be made between the two dimensions. If the window_size argument is given as a mapping, its keys are used instead. If not specified, is taken as module-wide variable
DEFAULT_DIMSwhich defaults to{'lat', 'lon'}.
- Returns:
Filtered array.
- Return type:
DataArray
- median_filter_dask(input_field, window_size=3, mode='constant', cval=0.0, axes=None, **kwargs)#
Apply median filter.
If the mode is constant with
cval=0and if the input array dtype isuint8,float32, orfloat64, it will use the fasterscipy.signal.medfilt2d(). Otherwise it will usescipy.ndimage.median_filter().- Parameters:
input_field (Array) – Array to filter
window_size (int | Sequence[int]) – Size of the moving window
mode (str) –
The mode parameter determines how the input array is extended beyond its boundaries. Default is ‘constant’. Behavior for each valid value is as follows:
- ‘constant’ (k k k k | a b c d | k k k k)
The input is extended by filling all values beyond the edge with the same constant value, defined by the cval parameter.
- ‘reflect’ (d c b a | a b c d | d c b a)
The input is extended by reflecting about the edge of the last pixel. This mode is also sometimes referred to as half-sample symmetric.
- ‘nearest’ (a a a a | a b c d | d d d d)
The input is extended by replicating the last pixel.
- ‘mirror’ (d c b | a b c d | c b a)
The input is extended by reflecting about the center of the last pixel. This mode is also sometimes referred to as whole-sample symmetric.
- ‘wrap’ (a b c d | a b c d | a b c d)
The input is extended by wrapping around to the opposite edge
cval (float) – Value to fill past edges of input if mode is ‘constant’. Default is 0.0.
axes (Sequence[int] | None) – Indices of the the y/lat and x/lon axes on which to work. If None (default), the last two axes are used.
kwargs – Arguments passed to either
medfilt2d()ormedian_filter().
- Returns:
Filtered array.
- Return type:
- median_filter_numpy(input_field, window_size=3, mode='constant', cval=0.0, axes=None, **kwargs)#
Apply median filter.
If the mode is constant with
cval=0and if the input array dtype isuint8,float32, orfloat64, it will use the fasterscipy.signal.medfilt2d(). Otherwise it will usescipy.ndimage.median_filter().- Parameters:
input_field (ndarray[_Size, _DT]) – Array to filter
window_size (int | Sequence[int]) – Size of the moving window
mode (str) –
The mode parameter determines how the input array is extended beyond its boundaries. Default is ‘constant’. Behavior for each valid value is as follows:
- ‘constant’ (k k k k | a b c d | k k k k)
The input is extended by filling all values beyond the edge with the same constant value, defined by the cval parameter.
- ‘reflect’ (d c b a | a b c d | d c b a)
The input is extended by reflecting about the edge of the last pixel. This mode is also sometimes referred to as half-sample symmetric.
- ‘nearest’ (a a a a | a b c d | d d d d)
The input is extended by replicating the last pixel.
- ‘mirror’ (d c b | a b c d | c b a)
The input is extended by reflecting about the center of the last pixel. This mode is also sometimes referred to as whole-sample symmetric.
- ‘wrap’ (a b c d | a b c d | a b c d)
The input is extended by wrapping around to the opposite edge
cval (float) – Value to fill past edges of input if mode is ‘constant’. Default is 0.0.
axes (Sequence[int] | None) – Indices of the the y/lat and x/lon axes on which to work. If None (default), the last two axes are used.
kwargs – Arguments passed to either
medfilt2d()ormedian_filter().
- Returns:
Filtered array.
- Return type:
ndarray[_Size, _DT]
- median_filter_xarray(input_field, window_size=3, mode='constant', cval=0.0, dims=None, **kwargs)#
Apply median filter.
If the mode is constant with
cval=0and if the input array dtype isuint8,float32, orfloat64, it will use the fasterscipy.signal.medfilt2d(). Otherwise it will usescipy.ndimage.median_filter().- Parameters:
input_field (DataArray) – Array to filter
window_size (int | Mapping[Hashable, int]) – Size of the moving window
mode (str) –
The mode parameter determines how the input array is extended beyond its boundaries. Default is ‘constant’. Behavior for each valid value is as follows:
- ‘constant’ (k k k k | a b c d | k k k k)
The input is extended by filling all values beyond the edge with the same constant value, defined by the cval parameter.
- ‘reflect’ (d c b a | a b c d | d c b a)
The input is extended by reflecting about the edge of the last pixel. This mode is also sometimes referred to as half-sample symmetric.
- ‘nearest’ (a a a a | a b c d | d d d d)
The input is extended by replicating the last pixel.
- ‘mirror’ (d c b | a b c d | c b a)
The input is extended by reflecting about the center of the last pixel. This mode is also sometimes referred to as whole-sample symmetric.
- ‘wrap’ (a b c d | a b c d | a b c d)
The input is extended by wrapping around to the opposite edge
cval (float) – Value to fill past edges of input if mode is ‘constant’. Default is 0.0.
kwargs – Arguments passed to either
medfilt2d()ormedian_filter().dims (Collection[Hashable] | None) – Names of the dimensions along which to apply the algorithm. Order is irrelevant, no reordering will be made between the two dimensions. If the window_size argument is given as a mapping, its keys are used instead. If not specified, is taken as module-wide variable
DEFAULT_DIMSwhich defaults to{'lat', 'lon'}.
- Returns:
Filtered array.
- Return type:
Modules
Belkin-O'Reilly Algorithm filter. |
|
Contextual median filter. |
|
Median filter. |