acc_algorithm.c File Reference
#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...
 

Macro Definition Documentation

◆ DOUBLE_BUFFERING_MEAN_ABS_DEV_OUTLIER_TH

#define DOUBLE_BUFFERING_MEAN_ABS_DEV_OUTLIER_TH   5

Definition at line 17 of file acc_algorithm.c.

Function Documentation

◆ acc_algorithm_apply_filter()

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.

Parameters
[in]aDenominator of polynomial of the IIR filter
[in]filt_dataFiltered data matrix
[in]filt_rowsNumber of rows in filtered data matrix, == len(a)
[in]filt_colsNumber of columns in filtered data matrix, == data_cols
[in]bNumerator of polynomial of the IIR filter
[in]dataData matrix
[in]data_rowsNumber of rows in data matrix, == len(b)
[in]data_colsNumber of columns in data matrix, == filt_cols
[out]outputOutput filtered data array
[in]output_lengthLength of output, == data_cols and filt_cols

Definition at line 395 of file acc_algorithm.c.

◆ acc_algorithm_apply_filter_complex()

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.

Parameters
[in]aDenominator of polynomial of the IIR filter
[in]filt_dataFiltered data matrix
[in]filt_rowsNumber of rows in filtered data matrix, == len(a)
[in]filt_colsNumber of columns in filtered data matrix, == data_cols
[in]bNumerator of polynomial of the IIR filter
[in]dataData matrix
[in]data_rowsNumber of rows in data matrix, == len(b)
[in]data_colsNumber of columns in data matrix, == filt_cols
[out]outputOutput filtered data array
[in]output_lengthLength of output, == data_cols and filt_cols

Definition at line 415 of file acc_algorithm.c.

◆ acc_algorithm_argmax()

uint16_t acc_algorithm_argmax ( const float *  data,
uint16_t  data_length 
)

Find index of largest element in the array.

Parameters
[in]dataArray of data
[in]data_lengthLength of the array
Returns
Index of largest element

Definition at line 227 of file acc_algorithm.c.

◆ acc_algorithm_butter_bandpass()

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.

Parameters
[in]min_freqLow cutoff frequency
[in]max_freqHigh cutoff frequency
[in]fsSampling frequency, > 0 Hz
[out]bNumerator in polynomial of the IIR filter, length == 5
[out]aDenominator of polynomial of the IIR filter, length == 4

Definition at line 306 of file acc_algorithm.c.

◆ acc_algorithm_butter_lowpass()

void acc_algorithm_butter_lowpass ( float  freq,
float  fs,
float *  b,
float *  a 
)

Design a 2nd order digital Butterworth lowpass filter.

Parameters
[in]freqCutoff freuency
[in]fsSampling frequency, > 0 Hz
[out]bNumerator in polynomial of the IIR filter, length == 3
[out]aDenominator of polynomial of the IIR filter, length == 2

Definition at line 263 of file acc_algorithm.c.

◆ acc_algorithm_calculate_cfar()

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.

Parameters
[in]dataArray of data
[in]data_lengthLength of the data array
[in]middle_idxMiddle index
[in]cfar_win_lengthNumber of frequency bins next to the CFAR guard from which the threshold level will be calculated
[in]cfar_guard_lengthNumber of frequency bins around the point of interest that is omitted when calculating the CFAR threshold
[in]cfar_sensitivitySensitivity of the CFAR threshold
[in]idxIndex to calculate cfar for
Returns
Threshold value at index

Definition at line 844 of file acc_algorithm.c.

◆ acc_algorithm_cdiv()

float complex acc_algorithm_cdiv ( float complex  num,
float complex  denom 
)

Divide complex number num / denum.

Parameters
[in]numNumerator
[in]denomDenominator
Returns
num / denom

Definition at line 592 of file acc_algorithm.c.

◆ acc_algorithm_double_buffering_frame_filter()

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.

Parameters
[in,out]frameData frame to where the filter is applied
[in]sweeps_per_frameHow many sweeps there are in the frame
[in]num_pointsThe number of points in the frame
[in]work_bufferA work buffer for the filter, length >= (sweeps_per_frame - 2)

Definition at line 662 of file acc_algorithm.c.

◆ acc_algorithm_exp_smoothing_coefficient()

float acc_algorithm_exp_smoothing_coefficient ( float  fs,
float  tc 
)

Calculate exponential smoothing coefficient.

Parameters
[in]fsSampling frequency
[in]tcTime constant
Returns
Exponential smoothing coefficient, NAN if fs=0 or tc=0

Definition at line 577 of file acc_algorithm.c.

◆ acc_algorithm_fft()

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

Parameters
[in]dataMatrix of data
[in]data_lengthLength of data
[in]length_shiftInteger 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]outputArray for output data, must be of length N
[in]strideUsed when calculating rfft of a matrix, for an array set stride = 1

Definition at line 500 of file acc_algorithm.c.

◆ acc_algorithm_fft_matrix()

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

Parameters
[in]dataMatrix of data
[in]rowsNumber of rows in the matrix
[in]colsNumber of columns in the matrix
[in]length_shiftInteger 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]outputMatrix for output data, size = (N, cols) if axis=0 and size = (rows, N) if axis=1
[in]axisAxis over which to calculate the FFT, must be 0 or 1

Definition at line 506 of file acc_algorithm.c.

◆ acc_algorithm_fftfreq()

void acc_algorithm_fftfreq ( uint16_t  n,
float  d,
float *  freqs 
)

Calculate the Fast Fourier Transform sample frequencies.

Parameters
[in]nWindow length, > 0
[in]dSample spacing, > 0
[out]freqsSample frequencies, length >= n

Definition at line 557 of file acc_algorithm.c.

◆ acc_algorithm_fftfreq_delta()

float acc_algorithm_fftfreq_delta ( uint16_t  n,
float  d 
)

Calculate delta between frequency bins in rfft.

Parameters
[in]nWindow length, > 0
[in]dSample spacing, > 0
Returns
Delta between frequency bins

Definition at line 532 of file acc_algorithm.c.

◆ acc_algorithm_fftshift()

void acc_algorithm_fftshift ( float *  data,
uint16_t  data_length,
uint16_t  stride 
)

Shift the zero-frequency component to the center.

Parameters
[in,out]dataArray of data
[in]data_lengthLength of data
[in]strideUsed when performing fftshift on a matrix, for an array set stride = 1

Definition at line 747 of file acc_algorithm.c.

◆ acc_algorithm_fftshift_matrix()

void acc_algorithm_fftshift_matrix ( float *  data,
uint16_t  rows,
uint16_t  cols 
)

Shift the zero-frequency component to the center along row dimensions.

Parameters
[in,out]dataMatrix to be shifted
[in]rowsNumber of rows in the matrix
[in]colsNumber of cols in the matrix

Definition at line 738 of file acc_algorithm.c.

◆ acc_algorithm_find_peaks()

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.

Parameters
[in]abs_sweepAbsolute values of the mean sweep
[in]data_lengthNumber of values in the sweep
[in]threshold_checkBit array with information if peak is above or below threshold
[out]peak_idxsIndexes of found peaks
[in]peak_idxs_lengthLength of the found peaks array. To fit all possible peaks the length must be (abs_sweep_length / 2)
[out]num_peaksNumber of found peaks
Returns
true if all peaks could be found, false otherwise

Definition at line 1107 of file acc_algorithm.c.

◆ acc_algorithm_get_distance_idx()

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.

Parameters
[in]dataMatrix of data
[in]colsNumber of cols
[in]rowsNumber of rows
[in]middle_idxMiddle index
[in]half_slow_zoneHalf size of the number of frequency bins that are regarded as the slow zone
Returns
Distance index

Definition at line 900 of file acc_algorithm.c.

◆ acc_algorithm_get_distance_m()

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.

Parameters
[in]step_lengthStep length in points
[in]start_pointStart point
[in]base_step_length_mBase step length
[in]idxDistance index
Returns
Distance at index

Definition at line 1043 of file acc_algorithm.c.

◆ acc_algorithm_get_fwhm()

float acc_algorithm_get_fwhm ( acc_config_profile_t  profile)

Get the envelope Full Width Half Maximum in meters given a profile.

Parameters
[in]profileThe profile to get envelope FWHM for
Returns
The envelope FWHM in meters or 0.0 if profile is not valid.

Definition at line 632 of file acc_algorithm.c.

◆ acc_algorithm_get_peak_velocity()

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.

Parameters
[in]velocitiesArray of velocities
[in]energiesArray of energies
[in]peak_idxsIndices of identified peaks
[in]num_peaksNumber of identified peaks
[in]limitSlow zone limit
Returns
Peak velocity

Definition at line 927 of file acc_algorithm.c.

◆ acc_algorithm_hamming()

void acc_algorithm_hamming ( uint16_t  n,
float *  window 
)

Calculate hamming window for a specified number of points.

Parameters
[in]nNumber of points
[out]windowReturned hamming window, length = n

Definition at line 606 of file acc_algorithm.c.

◆ acc_algorithm_hann()

void acc_algorithm_hann ( uint16_t  n,
float *  window 
)

Calculate non-symmetrical hann window for a specified number of points.

Parameters
[in]nNumber of points
[out]windowReturned hann window, length = n

Definition at line 619 of file acc_algorithm.c.

◆ acc_algorithm_interpolate_peaks()

float acc_algorithm_interpolate_peaks ( const float *  y,
const float *  x 
)

Interpolate peak.

Parameters
[in]yAmplitudes of frequency peaks
[in]xFrequencies
Returns
Interpolated frequency

Definition at line 245 of file acc_algorithm.c.

◆ acc_algorithm_interpolate_peaks_equidistant()

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.

Parameters
[in]yY values to interpolate
[in]x_startStart value of X-axis
[in]x_deltaDelta between values on X-axis
[in]peak_idxIdx of peak
Returns
Interpolated X-values

Definition at line 255 of file acc_algorithm.c.

◆ acc_algorithm_lfilter()

void acc_algorithm_lfilter ( const float *  b,
const float *  a,
float *  data,
uint16_t  data_length 
)

Filter data with a digital filter.

Parameters
[in]bNumerator in polynomial of the IIR filter, length == 5
[in]aDenominator of polynomial of the IIR filter, length == 4
[in,out]dataData array to filter
[in]data_lengthLength of the array

Definition at line 375 of file acc_algorithm.c.

◆ acc_algorithm_lfilter_matrix()

void acc_algorithm_lfilter_matrix ( const float *  b,
const float *  a,
float *  data,
uint16_t  rows,
uint16_t  cols 
)

Filter data along row dimension.

Parameters
[in]bNumerator in polynomial of the IIR filter, length == 5
[in]aDenominator of polynomial of the IIR filter, length == 4
[in,out]dataMatrix to filter
[in]rowsNumber of rows in the matrix
[in]colsNumber of columns in the matrix

Definition at line 386 of file acc_algorithm.c.

◆ acc_algorithm_mean_sweep()

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.

Parameters
[in]frameFrame to calculate mean sweep for
[in]num_pointsNumber of points in a sweep
[in]sweeps_per_frameNumber of sweeps in the frame
[in]start_pointStart point of mean sweep, if 0 will be same start point as for sweeps in frame
[in]end_pointEnd point of mean sweep, if num_points will be same end point as for sweeps in frame
[out]sweepMean sweep returned from calculation, length >= (end_point - start_point)

Definition at line 441 of file acc_algorithm.c.

◆ acc_algorithm_merge_peaks()

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.

Parameters
[in]max_peak_separationThe greatest distance (in meters) between peaks that will result in a merge
[in]velocitiesThe velocities to merge
[in]energiesThe energies to merge
[in]peak_idxsIndices of identified peaks
[in]num_peaksNumber of peaks in the peak_idxs array, if 0 nothing will happen
[out]merged_velocitiesOutput array for the merged velocities
[out]merged_energiesOutput array for the merged energies
[in]merged_peaks_lengthThe length of the merged_velocities and merged_energies arrays
[out]num_merged_peaksThe number of peaks that were merged
Returns
true if successful, false otherwise

Definition at line 967 of file acc_algorithm.c.

◆ acc_algorithm_rfft()

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

Parameters
[in]dataArray of data
[in]data_lengthLength of data
[in]length_shiftInteger that specifies the transform length N in accordance with N = (1 << length_shift) and N >= data_length
[out]outputArray for output data, length >= (data_length / 2) + 1
[in]strideUsed when calculating rfft of a matrix, for an array set stride = 1

Definition at line 463 of file acc_algorithm.c.

◆ acc_algorithm_rfft_matrix()

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

Parameters
[in]dataMatrix of data
[in]rowsNumber of rows in the matrix
[in]colsNumber of columns in the matrix
[in]length_shiftInteger 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]outputMatrix for output data, size = ((rows / 2) + 1, cols) if axis=0 and size = (rows, (cols / 2) + 1) if axis=1
[in]axisAxis over which to calculate the FFT, must be 0 or 1

Definition at line 474 of file acc_algorithm.c.

◆ acc_algorithm_rfftfreq()

void acc_algorithm_rfftfreq ( uint16_t  n,
float  d,
float *  freqs 
)

Calculate the real Fast Fourier Transform sample frequencies.

Parameters
[in]nWindow length, > 0
[in]dSample spacing, > 0
[out]freqsSample frequencies, length >= (n / 2) + 1

Definition at line 545 of file acc_algorithm.c.

◆ acc_algorithm_roll_and_push()

void acc_algorithm_roll_and_push ( float *  data,
uint16_t  data_length,
float  element 
)

Roll array elements and push new element last.

Parameters
[in,out]dataArray to be rolled
[in]data_lengthLength of the array
[in]elementThe new element

Definition at line 122 of file acc_algorithm.c.

◆ acc_algorithm_roll_and_push_f32_complex_matrix()

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.

Parameters
[in,out]dataMatrix to be rolled of size rows*cols
[in]rowsNumber of rows in the matrix
[in]colsNumber of cols in the matrix
[in]columnThe new column
[in]pos_shiftIf 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.

◆ acc_algorithm_roll_and_push_f32_matrix()

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.

Parameters
[in,out]dataMatrix to be rolled of size rows*cols
[in]rowsNumber of rows in the matrix
[in]colsNumber of cols in the matrix
[in]columnThe new column
[in]pos_shiftIf 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_algorithm_select_prf()

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.

Parameters
[in]breakpointA base step, relative to start_point = 0
[in]profileThe profile at breakpoint
[in]base_step_lengthThe base step length
Returns
A suitable PRF

Definition at line 1071 of file acc_algorithm.c.

◆ acc_algorithm_select_profile()

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.

Parameters
[in]start_pointStart point
[in]base_step_lengthbase_step_length
Returns
A suitable profile

Definition at line 1051 of file acc_algorithm.c.

◆ acc_algorithm_unwrap()

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.

Parameters
[in,out]dataArray with signal data
[in]data_lengthLength of the array

Definition at line 204 of file acc_algorithm.c.

◆ acc_algorithm_welch()

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.

Parameters
[in]dataArray of data
[in]data_lengthLength of data
[in]segment_lengthLength of each segment
[in]data_bufferBuffer used for calculations, length = segment_length
[out]fft_outArray for fft output data, length = segment_length
[out]psdArray for output data, length = segment_length
[in]windowDesired window to use, length = segment_length
[in]length_shiftInteger that specifies the transform length N in accordance with N = 1 << length_shift and N >= segment_length
[in]fsSampling frequency
[in]strideUsed when calculating psd of a matrix, for an array set stride = 1

Definition at line 784 of file acc_algorithm.c.

◆ acc_algorithm_welch_matrix()

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

Parameters
[in]dataMatrix of data
[in]rowsNumber of rows in the matrix
[in]colsNumber of cols in the matrix
[in]segment_lengthLength of each segment
[in]data_bufferBuffer used for calculations, length = segment_length
[out]fft_outArray for fft output data, length = segment_length
[out]psdsMatrix for output data, size = (cols, segment_length)
[in]windowDesired window to use, length = segment_length
[in]length_shiftInteger that specifies the transform length N in accordance with N = 1 << length_shift and N >= segment_length
[in]fsSampling frequency

Definition at line 765 of file acc_algorithm.c.

◆ double_buffering_interpolate()

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 
)
static

Interpolate function for Double buffering.

This function will calculate the interpolated value from the sweep before and the sweep two positions ahead.

Parameters
[in,out]frameData frame to where the filter is applied
[in]sweeps_per_frameHow many sweeps there are in the frame
[in]num_pointsThe number of points in the frame
[in]sweepThe sweep to generate with interpolatation
[in]pointThe point to generate with interpolatation

Definition at line 1527 of file acc_algorithm.c.

◆ double_buffering_median_filter()

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 
)
static

Median function for Double buffering.

This function will calculate the median value of four complex values.

Parameters
[in,out]frameData frame to where the filter is applied
[in]num_pointsThe number of points in the frame
[in]sweepThe sweep to generate with median filter
[in]pointThe point to generate with median filter
[in]median_start_sweepThe start sweep for the median calculation

Definition at line 1462 of file acc_algorithm.c.

◆ filter_inplace_apply()

static void filter_inplace_apply ( uint16_t  sample_idx,
const float *  b,
const float *  a,
float  state[5],
float *  data 
)
static

Definition at line 1207 of file acc_algorithm.c.

◆ get_data_padded_f32_complex()

static float complex get_data_padded_f32_complex ( const float complex *  data,
uint16_t  data_length,
uint16_t  index,
uint16_t  stride 
)
static

Definition at line 1249 of file acc_algorithm.c.

◆ get_data_padded_f32_to_f32_complex()

static float complex get_data_padded_f32_to_f32_complex ( const float *  data,
uint16_t  data_length,
uint16_t  index,
uint16_t  stride 
)
static

Definition at line 1227 of file acc_algorithm.c.

◆ get_profile()

static acc_config_profile_t get_profile ( uint16_t  value)
static

Get profile by value

Parameters
[in]valueInteger value that corresponds to an ACC_CONFIG_PROFILE enum
Returns
An ACC_CONFIG_PROFILE enum

Definition at line 1623 of file acc_algorithm.c.

◆ max_measurable_dist()

static float max_measurable_dist ( acc_config_prf_t  prf)
static

Get max measurable distance for some PRF.

Parameters
[in]prfPulse repetition frequency (PRF)
Returns
Max measurable distance in meters

Definition at line 1590 of file acc_algorithm.c.

◆ merge_peak_cluster()

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 
)
static

Merge peak cluster.

Parameters
[in]start_idxStart index
[in]num_peaksNumber of peaks to merge
[in]velocitiesVelocities array
[in]energiesEnergies array
[in]peak_idxsPeak indexes array
[out]merged_velocitiesMerged velocities array
[out]merged_energiesMerged energies array
[in]cluster_countCluster count

Definition at line 1560 of file acc_algorithm.c.

◆ small_fft()

static void small_fft ( const float complex *  data,
uint16_t  data_length,
uint16_t  length_shift,
float complex *  output,
uint16_t  stride 
)
static

Definition at line 1316 of file acc_algorithm.c.

◆ small_fft_transformation()

static void small_fft_transformation ( uint16_t  length_shift,
float complex *  output,
uint16_t  stride 
)
static

Definition at line 1368 of file acc_algorithm.c.

◆ small_rfft()

static void small_rfft ( const float *  data,
uint16_t  data_length,
uint16_t  length_shift,
float complex *  output,
uint16_t  stride 
)
static

Definition at line 1262 of file acc_algorithm.c.

◆ small_rfft_real_symmetry_conversion()

static void small_rfft_real_symmetry_conversion ( float complex *  output,
uint16_t  length_shift,
uint16_t  stride 
)
static

Definition at line 1418 of file acc_algorithm.c.