Source code for stride.optimisation.pipelines.steps.smooth_field

import scipy.ndimage

from ....core import Operator

[docs]class SmoothField(Operator): """ Apply Gaussian smoothing to a StructuredData object. Parameters ---------- sigma : float, optional Standard deviation of the Gaussian kernel, defaults to 0.25 (25% of a grid point). """ def __init__(self, **kwargs): super().__init__(*kwargs) self.sigma = kwargs.pop('sigma', 0.25)
[docs] def forward(self, field, **kwargs): sigma = kwargs.pop('sigma', self.sigma) out_field = field.alike(name='smoothed_%s' % out_field.extended_data[:] = scipy.ndimage.gaussian_filter(field.extended_data, sigma=sigma, mode='nearest') return out_field
[docs] def adjoint(self, d_field, field, **kwargs): raise NotImplementedError('No adjoint implemented for step %s' % self.__class__.__name__)