tidy3d.plugins.autograd.invdes.filters.AbstractFilter#

class AbstractFilter[source]#

Bases: Tidy3dBaseModel, ABC

An abstract class for creating and applying convolution filters.

Parameters:
  • kernel_size (Union[PositiveInt, tuple[PositiveInt, ...]]) – Size of the kernel in pixels for each dimension.

  • normalize (bool = True) – Whether to normalize the kernel so that it sums to 1.

  • padding (Literal['constant', 'edge', 'reflect', 'symmetric', 'wrap'] = reflect) – The padding mode to use.

Attributes

Methods

from_radius_dl(radius, dl, **kwargs)

Create a filter from radius and grid spacing.

get_kernel(size_px, normalize)

Get the kernel for the filter.

kernel_size#
normalize#
padding#
classmethod from_radius_dl(radius, dl, **kwargs)[source]#

Create a filter from radius and grid spacing.

Parameters:
  • radius (Union[float, tuple[float, ...]]) – The radius of the kernel. Can be a scalar or a tuple.

  • dl (Union[float, tuple[float, ...]]) – The grid spacing. Can be a scalar or a tuple.

  • **kwargs – Additional keyword arguments to pass to the filter constructor.

Returns:

An instance of the filter.

Return type:

AbstractFilter

abstract static get_kernel(size_px, normalize)[source]#

Get the kernel for the filter.

Parameters:
  • size_px (Iterable[int]) – Size of the kernel in pixels for each dimension.

  • normalize (bool) – Whether to normalize the kernel so that it sums to 1.

Returns:

The kernel.

Return type:

np.ndarray