franc.filtering.uwf

Updating Wiener Filter

Classes

UpdatingWienerFilter

Updating Wiener filter implementation

Module Contents

class franc.filtering.uwf.UpdatingWienerFilter(n_channel, n_filter, idx_target, context_pre=0, context_post=0)

Bases: franc.filtering.common.FilterBase

Updating Wiener filter implementation

Parameters:
  • n_filter (int) – Length of the FIR filter (how many samples are in the input window per output sample)

  • idx_target (int) – Position of the prediction

  • n_channel (int) – Number of witness sensor channels

  • context_pre (int) – how many additional samples before the current block are used to update the filters

  • context_post (int) – how many additional samples after the current block are used to update the filters

>>> import franc as fnc
>>> n_filter = 128
>>> witness, target = fnc.evaluation.TestDataGenerator(0.1).generate(int(1e5))
>>> filt = fnc.filtering.UpdatingWienerFilter(1, n_filter, 0, context_pre=20*n_filter, context_post=20*n_filter)
>>> prediction = filt.apply(witness, target) # check on the data used for conditioning
>>> residual_rms = fnc.evaluation.rms(target-prediction)
>>> residual_rms > 0.05 and residual_rms < 0.15 # the expected RMS in this test scenario is 0.1
True
context_pre: int
context_post: int
filter_name: str = 'UWF'
filter_state: numpy.typing.NDArray | None = None
static supports_saving_loading()

Indicates whether saving and loading is supported.

Return type:

bool

condition_multi_sequence(witness, target, hide_warning=False)

Placeholder for compatibility to other filters; does nothing!

Parameters:
  • witness (collections.abc.Sequence | numpy.typing.NDArray) –

  • target (collections.abc.Sequence | numpy.typing.NDArray) –

  • hide_warning (bool) –

Return type:

None

apply(witness, target=None, pad=True, update_state=False)

Apply the filter to input data

Parameters:
  • witness (collections.abc.Sequence | numpy.typing.NDArray) – Witness sensor data

  • target (collections.abc.Sequence | numpy.typing.NDArray | None) – Target sensor data (is ignored)

  • pad (bool) – if True, apply padding zeros so that the length matches the target signal

  • update_state (bool) – ignored

Returns:

prediction, bool indicating if all WF updates had full rank

Return type:

numpy.typing.NDArray

apply_multi_sequence(witness, target, pad=True, update_state=False)

Apply the filter to multiple sequences of input data.

Similar to apply() but expects multiple sequences. First index to the given data objects indicates the sequence. The last index indicates the time within a single sequence. Sequences must not have the same length.

Parameters:
  • witness (collections.abc.Sequence | numpy.typing.NDArray) –

  • target (collections.abc.Sequence | numpy.typing.NDArray | None) –

  • pad (bool) –

  • update_state (bool) –

Return type:

collections.abc.Sequence[numpy.typing.NDArray]