Source: GitHub
Signature¶
def sdynpy.signal_processing.sdynpy_harmonic.vold_kalman_filter_generator(sample_rate, num_orders, block_size, overlap, filter_order=None, bandwidth=None, method=None, plot_results=False, verbose=False)Extracts sinusoidal information using a Vold-Kalman Filter
This uses an windowed-overlap-and-add process to solve for the signal while removing start and end effects of the filter. Each time the generator is called, it will yield a further section of the results up until the overlap section.
Parameters¶
sample_rate : float The sample rate of the signal in Hz.
num_orders : int The number of orders that will be found in the signal
block_size : int The size of the blocks used in the analysis.
overlap : float, optional Fraction of the block size to overlap when computing the results. If not specified, it will default to 0.15.
filter_order : int, optional The order of the VK filter, which should be 1, 2, or 3. The default is 2. The low-pass filter roll-off is approximately -40 dB per times the filter order.
bandwidth : ndarray, optional The prescribed bandwidth of the filter. This is related to the filter selectivity parameter
rin the literature. This will be broadcast to the same shape as theargumentsargument. The default is the sample rate divided by 1000.method : str, optional Can be set to either ‘single’ or ‘multi’. In a ‘single’ solution, each sinusoidal component will be solved independently without any coupling. This can be more efficient, but will result in errors if the frequencies of the sine waves cross. The ‘multi’ solution will solve for all sinusoidal components simultaneously, resulting in a better estimate of crossing frequencies. The default is ‘multi’.
plot_results : bool If True, will plot the data at multiple steps for diagnostics
Yields¶
reconstructed_signals : ndarray Returns a time history the same size as
signalfor each of the sinusoidal components solved for.reconstructed_amplitudes : ndarray Returns the amplitude over time for each of the sinusoidal components solved for. Only returned if return_amp_phs is True.
reconstructed_phases : ndarray Returns the phase over time for each of the sinusoidal components solved for. Only returned if return_amp_phs is True.
Raises¶
ValueError
If arguments are not the correct size or values.
ValueError
If data is provided subsequently to specifying last_signal = True
Sends¶
xi : iterable
The next block of the signal to be filtered. This should be a 1D
signal containing sinusoidal components that need to be extracted.
argsi : iterable
A 2D array consisting of the arguments to the sinusoidal components of
the form exp(1jargsi). This is the integral over time of the
angular frequency, which can be approximated as
2np.pi*scipy.integrate.cumulative_trapezoid(frequencies,timesteps,initial=0)
if frequencies is the frequency at each time step in Hz timesteps is
the vector of time steps in seconds. This is a 2D array where the
number of rows is the
number of different sinusoidal components that are desired to be
extracted, and the number of columns are the number of time steps in
the signal argument.
last_signal : bool
If True, the remainder of the data will be returned and the
overlap-and-add process will be finished.