xoa.filter.convolve

xoa.filter.convolve(data, kernel, normalize=False)[source]

N-dimensional convolution that takes care of nans

Parameters
Returns

xarray.DataArray – The filtered array with the same shape, attributes and coordinates as the input array.

Example

In [1]: data = xr.DataArray(np.random.normal(size=(50, 70)), dims=('y', 'x'))

In [2]: data[10:20, 10:20] = np.nan # introduce missing data

In [3]: kernel = dict(x=[1, 2, 5, 2, 1], y=[1, 2, 1])

In [4]: datac = convolve(data, kernel, normalize=True)

In [5]: fig, (ax0, ax1) = plt.subplots(ncols=2, figsize=(7, 3))

In [6]: kw = dict(vmin=data.min(), vmax=data.max())

In [7]: data.plot.pcolormesh(ax=ax0, **kw)
Out[7]: <matplotlib.collections.QuadMesh at 0x7f1715feddf0>

In [8]: datac.plot.pcolormesh(ax=ax1, **kw)
Out[8]: <matplotlib.collections.QuadMesh at 0x7f17170e3550>