pymoto.FilterConv

class pymoto.FilterConv(domain: VoxelDomain, radius: float = None, relative_units: bool = True, weights: ndarray = None, xmin_bc='symmetric', xmax_bc='symmetric', ymin_bc='symmetric', ymax_bc='symmetric', zmin_bc='symmetric', zmax_bc='symmetric')

Density filter based on convolution

\(y_{i,j,k} = W \ast x_{i,j,k} = \sum_{p,q,r} W_{p,q,r} x_{i-p,j-q,k-r}\)

Input Signal:
  • x: The unfiltered field \(\mathbf{x}\)

Output Signal:
  • y: Filtered field \(\mathbf{y}\)

References

[Wikipedia](https://en.wikipedia.org/wiki/Kernel_(image_processing))

__init__(domain: VoxelDomain, radius: float = None, relative_units: bool = True, weights: ndarray = None, xmin_bc='symmetric', xmax_bc='symmetric', ymin_bc='symmetric', ymax_bc='symmetric', zmin_bc='symmetric', zmax_bc='symmetric')

Initialize density filter module based on convolution

Either the argument filter radius (radius) or a filtering kernel weights needs to be provided. If a filter radius is passed, the standard linear density filter will be used (see pymoto.DensityFilter).

For the boundaries, a padded effect can be selected from the following options:

‘symmetric’ (default)

Pads with the reflection of the vector mirrored along the edge of the array.

value (e.g. 1.0 or 0.0)

Pads with a constant value.

‘edge’

Pads with the edge values of array.

‘wrap’

Pads with the wrap of the vector along the axis. The first values are used to pad the end and the end values are used to pad the beginning.

Parameters:
  • domain (pymoto.VoxelDomain) – The (finite-element) domain

  • radius (float, optional) – Filter radius. If this is not provided, the filtering kernel weights must be defined

  • relative_units (bool, optional) – Indicate if the filter radius is in relative units with respect to the element-size or is given as an absolute geometry using element size. Defaults to True.

  • weights (np.ndarray, optional) – Use a custom filtering kernel (2D or 3D array). Alternatively, the filter radius can be provided to have the kernel initialized automatically.

  • xmin_bc (str, optional) – Boundary condition for the boundary at minimum x-value. Defaults to “symmetric”.

  • xmax_bc (str, optional) – Boundary condition for the boundary at maximum x-value. Defaults to “symmetric”.

  • ymin_bc (str, optional) – Boundary condition at minimum y. Defaults to “symmetric”.

  • ymax_bc (str, optional) – Boundary condition at maximum y. Defaults to “symmetric”.

  • zmin_bc (str, optional) – Boundary condition at minimum z (only in 3D). Defaults to “symmetric”.

  • zmax_bc (str, optional) – Bounadry condition at maximum z (only in 3D). Defaults to “symmetric”.

Methods

__init__(domain[, radius, relative_units, ...])

Initialize density filter module based on convolution

connect(sig_in[, sig_out])

Connect without automatic adding to a function network

get_input_sensitivities([as_list])

get_input_states([as_list])

get_output_sensitivities([as_list])

get_output_states([as_list])

get_padded_vector(x)

override_padded_values(index, value)

override_values(index, value)

reset()

Reset the state of the sensitivities (they are set to zero or to None)

response()

Calculate the response from sig_in and output this to sig_out

sensitivity()

Calculate sensitivities using backpropagation

set_filter_radius(radius[, relative_units])

Attributes

n_in

Get the number of input signals

n_out

Get the number of output signals

padded_domain

sig_in

sig_out

property padded_domain
override_padded_values(index, value)
override_values(index, value)
get_padded_vector(x)
set_filter_radius(radius: float, relative_units: bool = True)
connect(sig_in: Signal | Iterable[Signal], sig_out: Signal | Iterable[Signal] = None)

Connect without automatic adding to a function network

get_input_sensitivities(as_list=False)
get_input_states(as_list=False)
get_output_sensitivities(as_list=False)
get_output_states(as_list=False)
property n_in: int

Get the number of input signals

property n_out: int

Get the number of output signals

Note: Cannot be used in the initial __call__()

reset()

Reset the state of the sensitivities (they are set to zero or to None)

response()

Calculate the response from sig_in and output this to sig_out

sensitivity()

Calculate sensitivities using backpropagation

Based on the sensitivity we get from sig_out, reverse the process and output the new sensitivities to sig_in

sig_in: List = None
sig_out: List = None