scipp.scipy.ndimage.gaussian_filter#

scipp.scipy.ndimage.gaussian_filter(x, /, *, sigma, order=0, **kwargs)#

Multidimensional Gaussian filter.

This is a wrapper around `scipy.ndimage.gaussian_filter()`. See there for full argument description. There are two key differences:

• This wrapper uses explicit dimension labels in the `sigma` and `order` arguments. For example, instead of `sigma=[4, 6]` use `sigma={'time':4, 'space':6}` (with appropriate dimension labels for the data).

• Coordinate values can be used (and should be preferred) for `sigma`. For example, instead of `sigma=[4, 6]` use `sigma={'time':sc.scalar(5.0, unit='ms'), 'space':sc.scalar(1.2, unit='mm')}`. In this case it is required that the corresponding coordinates exist and form a “linspace”, i.e., are evenly spaced.

Warning

If `sigma` is an integer or a mapping to integers then coordinate values are ignored. That is, the filter is applied even if the data points are not evenly spaced. The resulting filtered data may thus have no meaningful interpretation.

Parameters
Returns

`scipp.typing.VariableLike` – Filtered variable or data array

Examples

```>>> from scipp.scipy.ndimage import gaussian_filter
>>> da = sc.data.data_xy()
>>> da.plot()
```

With sigma as integer:

```>>> filtered = gaussian_filter(da, sigma=4)
>>> filtered.plot()
```

With sigma based on input coordinate values:

```>>> filtered = gaussian_filter(da, sigma=sc.scalar(0.1, unit='mm'))
>>> filtered.plot()
```

With different sigma for different dimensions:

```>>> filtered = gaussian_filter(da, sigma={'x':sc.scalar(0.01, unit='mm'),
...                                       'y':sc.scalar(1.0, unit='mm')})
>>> filtered.plot()
```