Filters

Filer design

pyvib.filter.blinddeconvolution(z, L, part=1.0, k=4.0, maxIter=1000, maxMu=2.0, stopCrit=0.01, debug=False)

Iteratively identifies a filter g that deconvolves the filter h originally applied to z to return the deconvolved signal x. The iterator tries to maximize the kurtosis (impulsivity) of the deconvolved signal. The deconvolution is afterwards performed using: x = pyvib.signal.fftwconvolve(z, gNew, ‘valid’)

Parameters
  • z (float 1D array) – Signal to deconvolve

  • L (int) – Length of filter

  • part (float, optional) – Percentage of the data to train the filter on. Must be within <0, 1>

  • float (k -) – Exponent of the objective. 4 gives kurtosis

  • optional – Exponent of the objective. 4 gives kurtosis

  • maxIter (int, optional) – Maximum number of iterations to run

  • maxMu (float, optional) – Maximum training coefficient

  • stopCrit (float, optional) – Stopping criterion

  • debug (boolean, optional) – Print progression if true

Returns

gNew – Filter kernel that deconvolves the signal

Return type

float 1D array

pyvib.filter.cpw(x)

Removes synchronous parts of a signal using Cepstrum Pre-Whitening

Parameters
xfloat 1D array

Signal

Returns
xPWfloat 1D array

Whitened signal

pyvib.filter.filterbank_compose(xbank, f0, f1, xsizes)

Recompose the filter bank to a single signal

Parameters
  • xbank (float 1D array) – The filterbank

  • f0 (float 1D arrays) – The filter kernels

  • f1 (float 1D arrays) – The filter kernels

  • xsizes (list of list of ints) – The sizes of signals before decomposing

Returns

  • x_hat (float array) – The recomposed signal. Should be close to the original signal x after applying the lag

  • lag (int) – The lag of the recomposed signal Should ideally use x_hat[lag:-lag] after recomposition x_hat[lag:-lag] approximates x[0:-lag*2]

pyvib.filter.filterdesign(Yh, M, plot=True)

Design a FIR filter that matches a frequency response

Parameters
  • Yh (float 1D array) – The amplitude specrum to match

  • M (int) – Number of coefficients to use in the filter

  • plot (boolean, optional) – Whether the resulting filter should be plotted

  • Resturns

  • --------

  • h (float 1D array) – The designed FIR filter kernel

pyvib.filter.get_decimatelist(desireddecimation, maxdec=12, step=- 1)

Generate a decimation list for using the decimate function

Parameters
  • desireddecimation (int) – Desired decimation factor in total Going from a sample frequency of 50 kHz to 10 kHz is a factor of 5

  • maxdec (int, optional) – Maximum decimation per iteration Defaults to 12

  • direction (int, optional) – Step to make if a decimation factor is not suitable

Returns

decimatelist – Decimation factors to follow per decimation iteration.

Return type

list

See also

decimate

pyvib.filter.get_filterbankfilters(N, fc=0.25)

Make filters for filterbank decomposition and recomposition These are even order FIR filters

Parameters
  • N (int) – The filter length. Must be even number

  • fc (float) – Normalized cutoff frequency <0.0, 0.5>

Returns

f0, f1, h0, h1 – The filter kernels

Return type

arrays of float

pyvib.filter.get_filterbankfilters_kurtogram(N=16)

Acquire the filterbank filters used in: Antoni, Jerome. “Fast computation of the kurtogram for the detection of transient faults.” Mechanical Systems and Signal Processing 21.1 (2007): 108-124.

Parameters

N (int) – Number of filterbank coefficients

Returns

  • h (float 1D array) – Lowpass filter

  • g (float 1D array) – Highpass filter

pyvib.filter.waveletfilter(f0, sigma, Fs, N)

Constructs the frequency transformed wavelet filter. Can be used to filter a frequency transformed signal by taking Y*Ksi.

Parameters
  • f0 (float) – The center frequency for the bandpass filter in Hz

  • sigma (float) – The width of the filter in Hz

  • Fs (float) – The sampling frequency of the signal in Hz

  • N (int) – The number of samples in the signal in Hz

Returns

Ksi – Filter in the frequency domain.

Return type

float 1D array