filter#
- Diffraction2D.filter(func, inplace=False, **kwargs)[source]#
Filters the entire dataset given some function applied to the data.
The function must take a numpy or dask array as input and return a numpy or dask array as output which has the same shape, and axes as the input.
This can be useful for adjusting the data inplace or for filtering the data using something like a Gaussian Kernel to average neighboring diffraction patterns.
- Parameters:
func (function) – Function to apply to the data. Must take a numpy or dask array as input and return a numpy or dask array as output which has the same shape as the input.
inplace (bool, optional) – If True, the data is replaced by the filtered data. If False, a new signal is returned. Default False.
**kwargs – Passed to the function.
Examples
>>> import pyxem as pxm >>> from scipy.ndimage import gaussian_filter >>> s = pxm.data.dummy_data.get_cbed_signal() >>> s_filtered = s.filter(gaussian_filter, sigma=1)