elasticai.preprocessor.filter.filtering#
Module Contents#
Classes#
Dataclass with filter coefficients Attributes: a: List with filter coefficients a b: List with filter coefficients b |
|
Configuration class for defining the filter processor Attributes: gain: Integer with applied amplification factor [V/V] fs: Sampling rate [Hz] n_order: Integer with number of filter order or delay values in FIR-allpass f_filt: List with filter frequencies [Hz] (low/high-pass: only one value - rest: two values) type: String with selected filter algorithm [‘iir’, ‘fir’] f_type: String with selected filter structure [‘butter’, ‘cheby1’, ‘cheby2’, ‘ellip’, ‘bessel’] b_type: String with selected filter type [‘lowpass’, ‘highpass’, ‘bandpass’, ‘bandstop’, ‘notch’, ‘allpass’, ‘simple_low’] |
|
Data#
API#
- class elasticai.preprocessor.filter.filtering.FilterCoeffs[source]#
Dataclass with filter coefficients Attributes: a: List with filter coefficients a b: List with filter coefficients b
- a: list#
None
- b: list#
None
- class elasticai.preprocessor.filter.filtering.SettingsFilter[source]#
Configuration class for defining the filter processor Attributes: gain: Integer with applied amplification factor [V/V] fs: Sampling rate [Hz] n_order: Integer with number of filter order or delay values in FIR-allpass f_filt: List with filter frequencies [Hz] (low/high-pass: only one value - rest: two values) type: String with selected filter algorithm [‘iir’, ‘fir’] f_type: String with selected filter structure [‘butter’, ‘cheby1’, ‘cheby2’, ‘ellip’, ‘bessel’] b_type: String with selected filter type [‘lowpass’, ‘highpass’, ‘bandpass’, ‘bandstop’, ‘notch’, ‘allpass’, ‘simple_low’]
- gain: float#
None
- fs: float#
None
- n_order: int#
None
- f_filt: list#
None
- type: str#
None
- f_type: str#
None
- b_type: str#
None
- elasticai.preprocessor.filter.filtering.DefaultSettingsFilter#
‘SettingsFilter(…)’
- class elasticai.preprocessor.filter.filtering.Filtering(setting: elasticai.preprocessor.filter.filtering.SettingsFilter, use_filtfilt: bool = False)[source]#
Bases:
elasticai.preprocessor._common_func.CommonDigitalFunctionsInitialization
Class for Emulating Digital Signal Processing on FPGA
- Parameters:
setting – Class for handling the filter stage (using SettingsFilter)
use_filtfilt – Boolean for applying zero-phase filtering
- Returns:
None
- get_coeffs() elasticai.preprocessor.filter.filtering.FilterCoeffs[source]#
Getting the filter coefficients
- Returns:
dataclass FilterCoeffs with filter coefficients
- get_coeffs_quantized(bit_size: int) tuple[elasticai.preprocessor.filter.filtering.FilterCoeffs, elasticai.preprocessor.filter.filtering.FilterCoeffs][source]#
Quantize the coefficients with given bit fraction for adding into hardware designs
- Parameters:
bit_size – Integer with total bitwidth
- Returns:
dataclass FilterCoeffs with quantized filter coefficients
- filt(xin: numpy.ndarray) numpy.ndarray[source]#
Apply filter structure on transient input data
- Parameters:
xin – Numpy array with transient input data
- Returns:
Numpy array with filtered data
- filt_quantized(xin: numpy.ndarray, total_bitwidth: int, fraction_width: int, is_signed: bool = True) numpy.ndarray[source]#
Apply filter structure on transient input data
- Parameters:
xin – Numpy array with transient data
total_bitwidth – Integer with total bitwidth
fraction_width – Integer with fraction width
is_signed – Boolean with whether to sign the coefficients
- Returns:
Numpy array with filtered and quantized data
- plot_freq_response(num_points: int = 1001, show_plot: bool = True, path2save: str = '') None[source]#
Function for plotting the frequency response of desired filter type
- Parameters:
num_points – Number of points to plot
show_plot – Boolean for showing plot
path2save – Path to save figure
- plot_grp_delay(num_points: int = 1001, show_plot: bool = False) None[source]#
Plotting the Group Delay of filter
- Parameters:
num_points – Number of points to plot
show_plot – Boolean for showing plot
- Returns:
None
- create_design(target: str, bitwidth: int, id: str, path2save: pathlib.Path, signed: bool = True) None[source]#
Creating the hardware design for executing on specific target
- Parameters:
target – String with target name [“mcu”, “pc”, “fpga”]
bitwidth – Integer with total bitwidth
id – String with unique identifier of device (appended to the name)
path2save – Path to save the hardware files
signed – Whether generated C designs use a signed integer data type
- Returns:
None