saftig.filtering.wf¶
Classical static Wiener filter
Classes¶
Satic Wiener filter implementation |
Functions¶
|
estimate the cross-correlation between A and B |
|
caluclate the FIR coefficients for a wiener filter |
|
apply the WF to witness data |
Module Contents¶
- saftig.filtering.wf.mean_cross_correlation_offset(A, B, N, offset)¶
estimate the cross-correlation between A and B :param A: First input array :param B: Second input array :param N: Number of steps to test. Defines length of output :param offset: Offset for the cross correlation
- Parameters:
A (collections.abc.Sequence | numpy.typing.NDArray) –
B (collections.abc.Sequence | numpy.typing.NDArray) –
N (int) –
offset (int) –
- Return type:
numpy.typing.NDArray
- saftig.filtering.wf.wf_calculate(witness, target, n_filter, idx_target=0)¶
caluclate the FIR coefficients for a wiener filter
- Parameters:
witness (collections.abc.Sequence | numpy.typing.NDArray) – Witness sensor data
witness – Target sensor data
n_filter (int) – Length of the FIR filter (how many samples are in the input window per output sample)
idx_target (int) – offset of the prediction relative to the end of the array
target (collections.abc.Sequence | numpy.typing.NDArray) –
- Returns:
filter coefficients, full_rank (bool)
- Return type:
tuple[numpy.typing.NDArray, bool]
- saftig.filtering.wf.wf_apply(WFC, witness)¶
apply the WF to witness data
- Parameters:
witness (collections.abc.Sequence | numpy.typing.NDArray) – Witness sensor data
target – Target sensor data
WFC (collections.abc.Sequence | numpy.typing.NDArray) –
- Returns:
prediction
- Return type:
numpy.typing.NDArray
- class saftig.filtering.wf.WienerFilter(n_filter, idx_target, n_channel=1)¶
Bases:
saftig.filtering.common.FilterBaseSatic 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
>>> import saftig as sg >>> n_filter = 128 >>> witness, target = sg.evaluation.TestDataGenerator(0.1).generate(int(1e5)) >>> filt = sg.filtering.WienerFilter(n_filter, 0, 1) >>> _coefficients, full_rank = filt.condition(witness, target) >>> full_rank True >>> prediction = filt.apply(witness, target) # check on the data used for conditioning >>> residual_rms = sg.evaluation.rms(target-prediction) >>> residual_rms > 0.05 and residual_rms < 0.15 # the expected RMS in this test scenario is 0.1 True
- filter_state: numpy.typing.NDArray | None = None¶
- filter_name: str = 'WF'¶
- requires_apply_target = False¶
- condition_multi_sequence(witness, target)¶
Use an input dataset to condition the filter
- Parameters:
witness (collections.abc.Sequence | collections.abc.Sequence[collections.abc.Sequence] | numpy.typing.NDArray) – Witness sensor data
target (collections.abc.Sequence | numpy.typing.NDArray) – Target sensor data
- Return type:
tuple[numpy.typing.NDArray, bool]
- apply_multi_sequence(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
- Return type:
list[numpy.typing.NDArray]