|
#include <complex.h>
#include <math.h>
#include <stdint.h>
#include <stdlib.h>
#include "acc_alg_basic_utils.h"
#include "acc_algorithm.h"
#include "acc_definitions_a121.h"
#include "acc_definitions_common.h"
Go to the source code of this file.
Macros | |
#define | DOUBLE_BUFFERING_MEAN_ABS_DEV_OUTLIER_TH 5 |
Functions | |
static void | filter_inplace_apply (uint16_t sample_idx, const float *b, const float *a, float state[5], float *data) |
static float complex | get_data_padded_f32_to_f32_complex (const float *data, uint16_t data_length, uint16_t index, uint16_t stride) |
static float complex | get_data_padded_f32_complex (const float complex *data, uint16_t data_length, uint16_t index, uint16_t stride) |
static void | small_rfft (const float *data, uint16_t data_length, uint16_t length_shift, float complex *output, uint16_t stride) |
static void | small_fft (const float complex *data, uint16_t data_length, uint16_t length_shift, float complex *output, uint16_t stride) |
static void | small_fft_transformation (uint16_t length_shift, float complex *output, uint16_t stride) |
static void | small_rfft_real_symmetry_conversion (float complex *output, uint16_t length_shift, uint16_t stride) |
static void | double_buffering_interpolate (acc_int16_complex_t *frame, const uint16_t sweeps_per_frame, const uint16_t num_points, const uint16_t sweep, const uint16_t point) |
Interpolate function for Double buffering. More... | |
static void | double_buffering_median_filter (acc_int16_complex_t *frame, const uint16_t num_points, const uint16_t sweep, const uint16_t point, const uint16_t median_start_sweep) |
Median function for Double buffering. More... | |
static void | merge_peak_cluster (uint16_t start_idx, uint16_t num_peaks, const float *velocities, const float *energies, const uint16_t *peak_idxs, float *merged_velocities, float *merged_energies, uint16_t cluster_count) |
Merge peak cluster. More... | |
static float | max_measurable_dist (acc_config_prf_t prf) |
Get max measurable distance for some PRF. More... | |
static acc_config_profile_t | get_profile (uint16_t value) |
void | acc_algorithm_roll_and_push (float *data, uint16_t data_length, float element) |
Roll array elements and push new element last. More... | |
void | acc_algorithm_roll_and_push_f32_matrix (float *data, uint16_t rows, uint16_t cols, const float *column, bool pos_shift) |
Roll row elements and push a new column. More... | |
void | acc_algorithm_roll_and_push_f32_complex_matrix (float complex *data, uint16_t rows, uint16_t cols, const float complex *column, bool pos_shift) |
Roll row elements and push a new column. More... | |
void | acc_algorithm_unwrap (float *data, uint16_t data_length) |
Unwraps a signal by changing elements which have an absolute difference from their predecessor of more than 2*pi to their period-complementary values. More... | |
uint16_t | acc_algorithm_argmax (const float *data, uint16_t data_length) |
Find index of largest element in the array. More... | |
float | acc_algorithm_interpolate_peaks (const float *y, const float *x) |
Interpolate peak. More... | |
float | acc_algorithm_interpolate_peaks_equidistant (const float *y, float x_start, float x_delta, uint16_t peak_idx) |
Interpolate equidistant peaks. More... | |
void | acc_algorithm_butter_lowpass (float freq, float fs, float *b, float *a) |
Design a 2nd order digital Butterworth lowpass filter. More... | |
void | acc_algorithm_butter_bandpass (float min_freq, float max_freq, float fs, float *b, float *a) |
Design a 2nd order digital Butterworth bandpass filter. More... | |
void | acc_algorithm_lfilter (const float *b, const float *a, float *data, uint16_t data_length) |
Filter data with a digital filter. More... | |
void | acc_algorithm_lfilter_matrix (const float *b, const float *a, float *data, uint16_t rows, uint16_t cols) |
Filter data along row dimension. More... | |
void | acc_algorithm_apply_filter (const float *a, const float *filt_data, uint16_t filt_rows, uint16_t filt_cols, const float *b, const float *data, uint16_t data_rows, uint16_t data_cols, float *output, uint16_t output_length) |
Apply filter coefficients to filtered data matrix and data matrix. More... | |
void | acc_algorithm_apply_filter_complex (const float *a, const float complex *filt_data, uint16_t filt_rows, uint16_t filt_cols, const float *b, const float complex *data, uint16_t data_rows, uint16_t data_cols, float complex *output, uint16_t output_length) |
Apply filter coefficients to filtered data matrix and data matrix. More... | |
void | acc_algorithm_mean_sweep (const acc_int16_complex_t *frame, uint16_t num_points, uint16_t sweeps_per_frame, uint16_t start_point, uint16_t end_point, float complex *sweep) |
Calculate mean sweep of a frame from start_point to end_point. More... | |
void | acc_algorithm_rfft (const float *data, uint16_t data_length, uint16_t length_shift, float complex *output, uint16_t stride) |
1D Fast Fourier Transform for real input More... | |
void | acc_algorithm_rfft_matrix (const float *data, uint16_t rows, uint16_t cols, uint16_t length_shift, float complex *output, uint16_t axis) |
1D Fast Fourier Transform for real input matrix More... | |
void | acc_algorithm_fft (const float complex *data, uint16_t data_length, uint16_t length_shift, float complex *output, uint16_t stride) |
1D Fast Fourier Transform for complex input More... | |
void | acc_algorithm_fft_matrix (const float complex *data, uint16_t rows, uint16_t cols, uint16_t length_shift, float complex *output, uint16_t axis) |
1D Fast Fourier Transform for input matrix More... | |
float | acc_algorithm_fftfreq_delta (uint16_t n, float d) |
Calculate delta between frequency bins in rfft. More... | |
void | acc_algorithm_rfftfreq (uint16_t n, float d, float *freqs) |
Calculate the real Fast Fourier Transform sample frequencies. More... | |
void | acc_algorithm_fftfreq (uint16_t n, float d, float *freqs) |
Calculate the Fast Fourier Transform sample frequencies. More... | |
float | acc_algorithm_exp_smoothing_coefficient (float fs, float tc) |
Calculate exponential smoothing coefficient. More... | |
float complex | acc_algorithm_cdiv (float complex num, float complex denom) |
Divide complex number num / denum. More... | |
void | acc_algorithm_hamming (uint16_t n, float *window) |
Calculate hamming window for a specified number of points. More... | |
void | acc_algorithm_hann (uint16_t n, float *window) |
Calculate non-symmetrical hann window for a specified number of points. More... | |
float | acc_algorithm_get_fwhm (acc_config_profile_t profile) |
Get the envelope Full Width Half Maximum in meters given a profile. More... | |
void | acc_algorithm_double_buffering_frame_filter (acc_int16_complex_t *frame, const uint16_t sweeps_per_frame, const uint16_t num_points, int32_t *work_buffer) |
Double buffering frame filter. More... | |
void | acc_algorithm_fftshift_matrix (float *data, uint16_t rows, uint16_t cols) |
Shift the zero-frequency component to the center along row dimensions. More... | |
void | acc_algorithm_fftshift (float *data, uint16_t data_length, uint16_t stride) |
Shift the zero-frequency component to the center. More... | |
void | acc_algorithm_welch_matrix (const float complex *data, uint16_t rows, uint16_t cols, uint16_t segment_length, float complex *data_buffer, float complex *fft_out, float *psds, const float *window, uint16_t length_shift, float fs) |
Estimate power spectral density (PSD) using Welch’s method along row dimensions. More... | |
void | acc_algorithm_welch (const float complex *data, uint16_t data_length, uint16_t segment_length, float complex *data_buffer, float complex *fft_out, float *psd, const float *window, uint16_t length_shift, float fs, uint16_t stride) |
Estimate power spectral density using Welch’s method. More... | |
float | acc_algorithm_calculate_cfar (const float *data, uint16_t data_length, uint16_t middle_idx, uint16_t cfar_win_length, uint16_t cfar_guard_length, float cfar_sensitivity, uint16_t idx) |
Calculate CFAR threshold. More... | |
uint16_t | acc_algorithm_get_distance_idx (const float *data, uint16_t cols, uint16_t rows, uint16_t middle_idx, uint16_t half_slow_zone) |
Find the index of the distance column containing the largest amplitude, disregarding amplitudes present in the slow zone. More... | |
float | acc_algorithm_get_peak_velocity (const float *velocities, const float *energies, const uint16_t *peak_idxs, uint16_t num_peaks, float limit) |
Find the velocity of the peak with the largest amplitude, prioritizing peaks with a velocity over the slow zone limit. More... | |
bool | acc_algorithm_merge_peaks (float max_peak_separation, const float *velocities, const float *energies, const uint16_t *peak_idxs, uint16_t num_peaks, float *merged_velocities, float *merged_energies, uint16_t merged_peaks_length, uint16_t *num_merged_peaks) |
Merges peaks. More... | |
float | acc_algorithm_get_distance_m (uint16_t step_length, uint16_t start_point, float base_step_length_m, uint16_t idx) |
Calculate distance for a point at an index. More... | |
acc_config_profile_t | acc_algorithm_select_profile (int32_t start_point, float base_step_length) |
Select the highest possible profile without interference of direct leakage. More... | |
acc_config_prf_t | acc_algorithm_select_prf (int16_t breakpoint, acc_config_profile_t profile, float base_step_length) |
Select a suitable PRF given a breakpoint and profile. More... | |
bool | acc_algorithm_find_peaks (const float *abs_sweep, const uint16_t data_length, const uint32_t *threshold_check, uint16_t *peak_idxs, uint16_t peak_idxs_length, uint16_t *num_peaks) |
Find peaks above threshold. More... | |
#define DOUBLE_BUFFERING_MEAN_ABS_DEV_OUTLIER_TH 5 |
Definition at line 17 of file acc_algorithm.c.
void acc_algorithm_apply_filter | ( | const float * | a, |
const float * | filt_data, | ||
uint16_t | filt_rows, | ||
uint16_t | filt_cols, | ||
const float * | b, | ||
const float * | data, | ||
uint16_t | data_rows, | ||
uint16_t | data_cols, | ||
float * | output, | ||
uint16_t | output_length | ||
) |
Apply filter coefficients to filtered data matrix and data matrix.
[in] | a | Denominator of polynomial of the IIR filter |
[in] | filt_data | Filtered data matrix |
[in] | filt_rows | Number of rows in filtered data matrix, == len(a) |
[in] | filt_cols | Number of columns in filtered data matrix, == data_cols |
[in] | b | Numerator of polynomial of the IIR filter |
[in] | data | Data matrix |
[in] | data_rows | Number of rows in data matrix, == len(b) |
[in] | data_cols | Number of columns in data matrix, == filt_cols |
[out] | output | Output filtered data array |
[in] | output_length | Length of output, == data_cols and filt_cols |
Definition at line 395 of file acc_algorithm.c.
void acc_algorithm_apply_filter_complex | ( | const float * | a, |
const float complex * | filt_data, | ||
uint16_t | filt_rows, | ||
uint16_t | filt_cols, | ||
const float * | b, | ||
const float complex * | data, | ||
uint16_t | data_rows, | ||
uint16_t | data_cols, | ||
float complex * | output, | ||
uint16_t | output_length | ||
) |
Apply filter coefficients to filtered data matrix and data matrix.
[in] | a | Denominator of polynomial of the IIR filter |
[in] | filt_data | Filtered data matrix |
[in] | filt_rows | Number of rows in filtered data matrix, == len(a) |
[in] | filt_cols | Number of columns in filtered data matrix, == data_cols |
[in] | b | Numerator of polynomial of the IIR filter |
[in] | data | Data matrix |
[in] | data_rows | Number of rows in data matrix, == len(b) |
[in] | data_cols | Number of columns in data matrix, == filt_cols |
[out] | output | Output filtered data array |
[in] | output_length | Length of output, == data_cols and filt_cols |
Definition at line 415 of file acc_algorithm.c.
uint16_t acc_algorithm_argmax | ( | const float * | data, |
uint16_t | data_length | ||
) |
Find index of largest element in the array.
[in] | data | Array of data |
[in] | data_length | Length of the array |
Definition at line 227 of file acc_algorithm.c.
void acc_algorithm_butter_bandpass | ( | float | min_freq, |
float | max_freq, | ||
float | fs, | ||
float * | b, | ||
float * | a | ||
) |
Design a 2nd order digital Butterworth bandpass filter.
[in] | min_freq | Low cutoff frequency |
[in] | max_freq | High cutoff frequency |
[in] | fs | Sampling frequency, > 0 Hz |
[out] | b | Numerator in polynomial of the IIR filter, length == 5 |
[out] | a | Denominator of polynomial of the IIR filter, length == 4 |
Definition at line 306 of file acc_algorithm.c.
void acc_algorithm_butter_lowpass | ( | float | freq, |
float | fs, | ||
float * | b, | ||
float * | a | ||
) |
Design a 2nd order digital Butterworth lowpass filter.
[in] | freq | Cutoff freuency |
[in] | fs | Sampling frequency, > 0 Hz |
[out] | b | Numerator in polynomial of the IIR filter, length == 3 |
[out] | a | Denominator of polynomial of the IIR filter, length == 2 |
Definition at line 263 of file acc_algorithm.c.
float acc_algorithm_calculate_cfar | ( | const float * | data, |
uint16_t | data_length, | ||
uint16_t | middle_idx, | ||
uint16_t | cfar_win_length, | ||
uint16_t | cfar_guard_length, | ||
float | cfar_sensitivity, | ||
uint16_t | idx | ||
) |
Calculate CFAR threshold.
[in] | data | Array of data |
[in] | data_length | Length of the data array |
[in] | middle_idx | Middle index |
[in] | cfar_win_length | Number of frequency bins next to the CFAR guard from which the threshold level will be calculated |
[in] | cfar_guard_length | Number of frequency bins around the point of interest that is omitted when calculating the CFAR threshold |
[in] | cfar_sensitivity | Sensitivity of the CFAR threshold |
[in] | idx | Index to calculate cfar for |
Definition at line 844 of file acc_algorithm.c.
float complex acc_algorithm_cdiv | ( | float complex | num, |
float complex | denom | ||
) |
Divide complex number num / denum.
[in] | num | Numerator |
[in] | denom | Denominator |
Definition at line 592 of file acc_algorithm.c.
void acc_algorithm_double_buffering_frame_filter | ( | acc_int16_complex_t * | frame, |
const uint16_t | sweeps_per_frame, | ||
const uint16_t | num_points, | ||
int32_t * | work_buffer | ||
) |
Double buffering frame filter.
Detects and removes outliers in data that appear when the double buffering mode is enabled, and returns the filtered frame.
Outliers are detected along the sweep dimension using the second order difference. For reliable outlier detection, the filter is applied only when there are 32 or more sweeps per frame.
The disturbance caused by enabling the double buffering mode can appear in multiple sweeps but, according to observations, is limited to a maximum of two consecutive sweeps. Therefore, the function removes outliers by interpolating between the sample before and the sample two positions ahead.
The function does not correct disturbances that may appear in the initial or final sweeps.
[in,out] | frame | Data frame to where the filter is applied |
[in] | sweeps_per_frame | How many sweeps there are in the frame |
[in] | num_points | The number of points in the frame |
[in] | work_buffer | A work buffer for the filter, length >= (sweeps_per_frame - 2) |
Definition at line 662 of file acc_algorithm.c.
float acc_algorithm_exp_smoothing_coefficient | ( | float | fs, |
float | tc | ||
) |
Calculate exponential smoothing coefficient.
[in] | fs | Sampling frequency |
[in] | tc | Time constant |
Definition at line 577 of file acc_algorithm.c.
void acc_algorithm_fft | ( | const float complex * | data, |
uint16_t | data_length, | ||
uint16_t | length_shift, | ||
float complex * | output, | ||
uint16_t | stride | ||
) |
1D Fast Fourier Transform for complex input
[in] | data | Matrix of data |
[in] | data_length | Length of data |
[in] | length_shift | Integer that specifies the transform length N in accordance with N = (1 << length_shift) and N >= rows if axis == 0 or N >= cols if axis == 1 |
[out] | output | Array for output data, must be of length N |
[in] | stride | Used when calculating rfft of a matrix, for an array set stride = 1 |
Definition at line 500 of file acc_algorithm.c.
void acc_algorithm_fft_matrix | ( | const float complex * | data, |
uint16_t | rows, | ||
uint16_t | cols, | ||
uint16_t | length_shift, | ||
float complex * | output, | ||
uint16_t | axis | ||
) |
1D Fast Fourier Transform for input matrix
[in] | data | Matrix of data |
[in] | rows | Number of rows in the matrix |
[in] | cols | Number of columns in the matrix |
[in] | length_shift | Integer that specifies the transform length N in accordance with N = (1 << length_shift) and N >= rows if axis == 0 or N >= cols if axis == 1 |
[out] | output | Matrix for output data, size = (N, cols) if axis=0 and size = (rows, N) if axis=1 |
[in] | axis | Axis over which to calculate the FFT, must be 0 or 1 |
Definition at line 506 of file acc_algorithm.c.
void acc_algorithm_fftfreq | ( | uint16_t | n, |
float | d, | ||
float * | freqs | ||
) |
Calculate the Fast Fourier Transform sample frequencies.
[in] | n | Window length, > 0 |
[in] | d | Sample spacing, > 0 |
[out] | freqs | Sample frequencies, length >= n |
Definition at line 557 of file acc_algorithm.c.
float acc_algorithm_fftfreq_delta | ( | uint16_t | n, |
float | d | ||
) |
Calculate delta between frequency bins in rfft.
[in] | n | Window length, > 0 |
[in] | d | Sample spacing, > 0 |
Definition at line 532 of file acc_algorithm.c.
void acc_algorithm_fftshift | ( | float * | data, |
uint16_t | data_length, | ||
uint16_t | stride | ||
) |
Shift the zero-frequency component to the center.
[in,out] | data | Array of data |
[in] | data_length | Length of data |
[in] | stride | Used when performing fftshift on a matrix, for an array set stride = 1 |
Definition at line 747 of file acc_algorithm.c.
void acc_algorithm_fftshift_matrix | ( | float * | data, |
uint16_t | rows, | ||
uint16_t | cols | ||
) |
Shift the zero-frequency component to the center along row dimensions.
[in,out] | data | Matrix to be shifted |
[in] | rows | Number of rows in the matrix |
[in] | cols | Number of cols in the matrix |
Definition at line 738 of file acc_algorithm.c.
bool acc_algorithm_find_peaks | ( | const float * | abs_sweep, |
const uint16_t | data_length, | ||
const uint32_t * | threshold_check, | ||
uint16_t * | peak_idxs, | ||
uint16_t | peak_idxs_length, | ||
uint16_t * | num_peaks | ||
) |
Find peaks above threshold.
A peak is defined as a point with greater value than its two neighbouring points and all three points are above the threshold.
[in] | abs_sweep | Absolute values of the mean sweep |
[in] | data_length | Number of values in the sweep |
[in] | threshold_check | Bit array with information if peak is above or below threshold |
[out] | peak_idxs | Indexes of found peaks |
[in] | peak_idxs_length | Length of the found peaks array. To fit all possible peaks the length must be (abs_sweep_length / 2) |
[out] | num_peaks | Number of found peaks |
Definition at line 1107 of file acc_algorithm.c.
uint16_t acc_algorithm_get_distance_idx | ( | const float * | data, |
uint16_t | cols, | ||
uint16_t | rows, | ||
uint16_t | middle_idx, | ||
uint16_t | half_slow_zone | ||
) |
Find the index of the distance column containing the largest amplitude, disregarding amplitudes present in the slow zone.
[in] | data | Matrix of data |
[in] | cols | Number of cols |
[in] | rows | Number of rows |
[in] | middle_idx | Middle index |
[in] | half_slow_zone | Half size of the number of frequency bins that are regarded as the slow zone |
Definition at line 900 of file acc_algorithm.c.
float acc_algorithm_get_distance_m | ( | uint16_t | step_length, |
uint16_t | start_point, | ||
float | base_step_length_m, | ||
uint16_t | idx | ||
) |
Calculate distance for a point at an index.
[in] | step_length | Step length in points |
[in] | start_point | Start point |
[in] | base_step_length_m | Base step length |
[in] | idx | Distance index |
Definition at line 1043 of file acc_algorithm.c.
float acc_algorithm_get_fwhm | ( | acc_config_profile_t | profile | ) |
Get the envelope Full Width Half Maximum in meters given a profile.
[in] | profile | The profile to get envelope FWHM for |
Definition at line 632 of file acc_algorithm.c.
float acc_algorithm_get_peak_velocity | ( | const float * | velocities, |
const float * | energies, | ||
const uint16_t * | peak_idxs, | ||
uint16_t | num_peaks, | ||
float | limit | ||
) |
Find the velocity of the peak with the largest amplitude, prioritizing peaks with a velocity over the slow zone limit.
[in] | velocities | Array of velocities |
[in] | energies | Array of energies |
[in] | peak_idxs | Indices of identified peaks |
[in] | num_peaks | Number of identified peaks |
[in] | limit | Slow zone limit |
Definition at line 927 of file acc_algorithm.c.
void acc_algorithm_hamming | ( | uint16_t | n, |
float * | window | ||
) |
Calculate hamming window for a specified number of points.
[in] | n | Number of points |
[out] | window | Returned hamming window, length = n |
Definition at line 606 of file acc_algorithm.c.
void acc_algorithm_hann | ( | uint16_t | n, |
float * | window | ||
) |
Calculate non-symmetrical hann window for a specified number of points.
[in] | n | Number of points |
[out] | window | Returned hann window, length = n |
Definition at line 619 of file acc_algorithm.c.
float acc_algorithm_interpolate_peaks | ( | const float * | y, |
const float * | x | ||
) |
Interpolate peak.
[in] | y | Amplitudes of frequency peaks |
[in] | x | Frequencies |
Definition at line 245 of file acc_algorithm.c.
float acc_algorithm_interpolate_peaks_equidistant | ( | const float * | y, |
float | x_start, | ||
float | x_delta, | ||
uint16_t | peak_idx | ||
) |
Interpolate equidistant peaks.
The function fits a second degree polynomial to three consecutive amplitude values where the second element is expected to contain the maximum measured amplitude. The function then finds the position of the maximum amplitude of the polynomial. The position is normalized.
[in] | y | Y values to interpolate |
[in] | x_start | Start value of X-axis |
[in] | x_delta | Delta between values on X-axis |
[in] | peak_idx | Idx of peak |
Definition at line 255 of file acc_algorithm.c.
void acc_algorithm_lfilter | ( | const float * | b, |
const float * | a, | ||
float * | data, | ||
uint16_t | data_length | ||
) |
Filter data with a digital filter.
[in] | b | Numerator in polynomial of the IIR filter, length == 5 |
[in] | a | Denominator of polynomial of the IIR filter, length == 4 |
[in,out] | data | Data array to filter |
[in] | data_length | Length of the array |
Definition at line 375 of file acc_algorithm.c.
void acc_algorithm_lfilter_matrix | ( | const float * | b, |
const float * | a, | ||
float * | data, | ||
uint16_t | rows, | ||
uint16_t | cols | ||
) |
Filter data along row dimension.
[in] | b | Numerator in polynomial of the IIR filter, length == 5 |
[in] | a | Denominator of polynomial of the IIR filter, length == 4 |
[in,out] | data | Matrix to filter |
[in] | rows | Number of rows in the matrix |
[in] | cols | Number of columns in the matrix |
Definition at line 386 of file acc_algorithm.c.
void acc_algorithm_mean_sweep | ( | const acc_int16_complex_t * | frame, |
uint16_t | num_points, | ||
uint16_t | sweeps_per_frame, | ||
uint16_t | start_point, | ||
uint16_t | end_point, | ||
float complex * | sweep | ||
) |
Calculate mean sweep of a frame from start_point to end_point.
[in] | frame | Frame to calculate mean sweep for |
[in] | num_points | Number of points in a sweep |
[in] | sweeps_per_frame | Number of sweeps in the frame |
[in] | start_point | Start point of mean sweep, if 0 will be same start point as for sweeps in frame |
[in] | end_point | End point of mean sweep, if num_points will be same end point as for sweeps in frame |
[out] | sweep | Mean sweep returned from calculation, length >= (end_point - start_point) |
Definition at line 441 of file acc_algorithm.c.
bool acc_algorithm_merge_peaks | ( | float | max_peak_separation, |
const float * | velocities, | ||
const float * | energies, | ||
const uint16_t * | peak_idxs, | ||
uint16_t | num_peaks, | ||
float * | merged_velocities, | ||
float * | merged_energies, | ||
uint16_t | merged_peaks_length, | ||
uint16_t * | num_merged_peaks | ||
) |
Merges peaks.
[in] | max_peak_separation | The greatest distance (in meters) between peaks that will result in a merge |
[in] | velocities | The velocities to merge |
[in] | energies | The energies to merge |
[in] | peak_idxs | Indices of identified peaks |
[in] | num_peaks | Number of peaks in the peak_idxs array, if 0 nothing will happen |
[out] | merged_velocities | Output array for the merged velocities |
[out] | merged_energies | Output array for the merged energies |
[in] | merged_peaks_length | The length of the merged_velocities and merged_energies arrays |
[out] | num_merged_peaks | The number of peaks that were merged |
Definition at line 967 of file acc_algorithm.c.
void acc_algorithm_rfft | ( | const float * | data, |
uint16_t | data_length, | ||
uint16_t | length_shift, | ||
float complex * | output, | ||
uint16_t | stride | ||
) |
1D Fast Fourier Transform for real input
[in] | data | Array of data |
[in] | data_length | Length of data |
[in] | length_shift | Integer that specifies the transform length N in accordance with N = (1 << length_shift) and N >= data_length |
[out] | output | Array for output data, length >= (data_length / 2) + 1 |
[in] | stride | Used when calculating rfft of a matrix, for an array set stride = 1 |
Definition at line 463 of file acc_algorithm.c.
void acc_algorithm_rfft_matrix | ( | const float * | data, |
uint16_t | rows, | ||
uint16_t | cols, | ||
uint16_t | length_shift, | ||
float complex * | output, | ||
uint16_t | axis | ||
) |
1D Fast Fourier Transform for real input matrix
[in] | data | Matrix of data |
[in] | rows | Number of rows in the matrix |
[in] | cols | Number of columns in the matrix |
[in] | length_shift | Integer that specifies the transform length N in accordance with N = (1 << length_shift) and N >= rows if axis == 0 or N >= cols if axis == 1 |
[out] | output | Matrix for output data, size = ((rows / 2) + 1, cols) if axis=0 and size = (rows, (cols / 2) + 1) if axis=1 |
[in] | axis | Axis over which to calculate the FFT, must be 0 or 1 |
Definition at line 474 of file acc_algorithm.c.
void acc_algorithm_rfftfreq | ( | uint16_t | n, |
float | d, | ||
float * | freqs | ||
) |
Calculate the real Fast Fourier Transform sample frequencies.
[in] | n | Window length, > 0 |
[in] | d | Sample spacing, > 0 |
[out] | freqs | Sample frequencies, length >= (n / 2) + 1 |
Definition at line 545 of file acc_algorithm.c.
void acc_algorithm_roll_and_push | ( | float * | data, |
uint16_t | data_length, | ||
float | element | ||
) |
Roll array elements and push new element last.
[in,out] | data | Array to be rolled |
[in] | data_length | Length of the array |
[in] | element | The new element |
Definition at line 122 of file acc_algorithm.c.
void acc_algorithm_roll_and_push_f32_complex_matrix | ( | float complex * | data, |
uint16_t | rows, | ||
uint16_t | cols, | ||
const float complex * | column, | ||
bool | pos_shift | ||
) |
Roll row elements and push a new column.
[in,out] | data | Matrix to be rolled of size rows*cols |
[in] | rows | Number of rows in the matrix |
[in] | cols | Number of cols in the matrix |
[in] | column | The new column |
[in] | pos_shift | If true will be the same as shift=1 in np.roll, otherwise the same as shift=-1 |
Definition at line 168 of file acc_algorithm.c.
void acc_algorithm_roll_and_push_f32_matrix | ( | float * | data, |
uint16_t | rows, | ||
uint16_t | cols, | ||
const float * | column, | ||
bool | pos_shift | ||
) |
Roll row elements and push a new column.
[in,out] | data | Matrix to be rolled of size rows*cols |
[in] | rows | Number of rows in the matrix |
[in] | cols | Number of cols in the matrix |
[in] | column | The new column |
[in] | pos_shift | If true will be the same as shift=1 in np.roll, otherwise the same as shift=-1 |
Definition at line 133 of file acc_algorithm.c.
acc_config_prf_t acc_algorithm_select_prf | ( | int16_t | breakpoint, |
acc_config_profile_t | profile, | ||
float | base_step_length | ||
) |
Select a suitable PRF given a breakpoint and profile.
[in] | breakpoint | A base step, relative to start_point = 0 |
[in] | profile | The profile at breakpoint |
[in] | base_step_length | The base step length |
Definition at line 1071 of file acc_algorithm.c.
acc_config_profile_t acc_algorithm_select_profile | ( | int32_t | start_point, |
float | base_step_length | ||
) |
Select the highest possible profile without interference of direct leakage.
[in] | start_point | Start point |
[in] | base_step_length | base_step_length |
Definition at line 1051 of file acc_algorithm.c.
void acc_algorithm_unwrap | ( | float * | data, |
uint16_t | data_length | ||
) |
Unwraps a signal by changing elements which have an absolute difference from their predecessor of more than 2*pi to their period-complementary values.
[in,out] | data | Array with signal data |
[in] | data_length | Length of the array |
Definition at line 204 of file acc_algorithm.c.
void acc_algorithm_welch | ( | const float complex * | data, |
uint16_t | data_length, | ||
uint16_t | segment_length, | ||
float complex * | data_buffer, | ||
float complex * | fft_out, | ||
float * | psd, | ||
const float * | window, | ||
uint16_t | length_shift, | ||
float | fs, | ||
uint16_t | stride | ||
) |
Estimate power spectral density using Welch’s method.
Computes an estimate of the PSD by dividing the data into non-overlapping segments, computing a periodogram for each segment and averaging the periodograms.
[in] | data | Array of data |
[in] | data_length | Length of data |
[in] | segment_length | Length of each segment |
[in] | data_buffer | Buffer used for calculations, length = segment_length |
[out] | fft_out | Array for fft output data, length = segment_length |
[out] | psd | Array for output data, length = segment_length |
[in] | window | Desired window to use, length = segment_length |
[in] | length_shift | Integer that specifies the transform length N in accordance with N = 1 << length_shift and N >= segment_length |
[in] | fs | Sampling frequency |
[in] | stride | Used when calculating psd of a matrix, for an array set stride = 1 |
Definition at line 784 of file acc_algorithm.c.
void acc_algorithm_welch_matrix | ( | const float complex * | data, |
uint16_t | rows, | ||
uint16_t | cols, | ||
uint16_t | segment_length, | ||
float complex * | data_buffer, | ||
float complex * | fft_out, | ||
float * | psds, | ||
const float * | window, | ||
uint16_t | length_shift, | ||
float | fs | ||
) |
Estimate power spectral density (PSD) using Welch’s method along row dimensions.
See acc_algorithm_welch for more details
[in] | data | Matrix of data |
[in] | rows | Number of rows in the matrix |
[in] | cols | Number of cols in the matrix |
[in] | segment_length | Length of each segment |
[in] | data_buffer | Buffer used for calculations, length = segment_length |
[out] | fft_out | Array for fft output data, length = segment_length |
[out] | psds | Matrix for output data, size = (cols, segment_length) |
[in] | window | Desired window to use, length = segment_length |
[in] | length_shift | Integer that specifies the transform length N in accordance with N = 1 << length_shift and N >= segment_length |
[in] | fs | Sampling frequency |
Definition at line 765 of file acc_algorithm.c.
|
static |
Interpolate function for Double buffering.
This function will calculate the interpolated value from the sweep before and the sweep two positions ahead.
[in,out] | frame | Data frame to where the filter is applied |
[in] | sweeps_per_frame | How many sweeps there are in the frame |
[in] | num_points | The number of points in the frame |
[in] | sweep | The sweep to generate with interpolatation |
[in] | point | The point to generate with interpolatation |
Definition at line 1527 of file acc_algorithm.c.
|
static |
Median function for Double buffering.
This function will calculate the median value of four complex values.
[in,out] | frame | Data frame to where the filter is applied |
[in] | num_points | The number of points in the frame |
[in] | sweep | The sweep to generate with median filter |
[in] | point | The point to generate with median filter |
[in] | median_start_sweep | The start sweep for the median calculation |
Definition at line 1462 of file acc_algorithm.c.
|
static |
Definition at line 1207 of file acc_algorithm.c.
|
static |
Definition at line 1249 of file acc_algorithm.c.
|
static |
Definition at line 1227 of file acc_algorithm.c.
|
static |
Get profile by value
[in] | value | Integer value that corresponds to an ACC_CONFIG_PROFILE enum |
Definition at line 1623 of file acc_algorithm.c.
|
static |
Get max measurable distance for some PRF.
[in] | prf | Pulse repetition frequency (PRF) |
Definition at line 1590 of file acc_algorithm.c.
|
static |
Merge peak cluster.
[in] | start_idx | Start index |
[in] | num_peaks | Number of peaks to merge |
[in] | velocities | Velocities array |
[in] | energies | Energies array |
[in] | peak_idxs | Peak indexes array |
[out] | merged_velocities | Merged velocities array |
[out] | merged_energies | Merged energies array |
[in] | cluster_count | Cluster count |
Definition at line 1560 of file acc_algorithm.c.
|
static |
Definition at line 1316 of file acc_algorithm.c.
|
static |
Definition at line 1368 of file acc_algorithm.c.
|
static |
Definition at line 1262 of file acc_algorithm.c.
|
static |
Definition at line 1418 of file acc_algorithm.c.