mmwave.dsp.cfar

mmwave.dsp.cfar.ca(x, *argv, **kwargs)

Detects peaks in signal using Cell-Averaging CFAR (CA-CFAR).

Parameters:
  • x (ndarray) – Signal.
  • *argv – See mmwave.dsp.cfar.ca_
  • **kwargs – See mmwave.dsp.cfar.ca_
Returns:

Boolean array of detected peaks in x.

Return type:

ndarray

Examples

>>> signal = np.random.randint(100, size=10)
>>> signal
    array([41, 76, 95, 28, 25, 53, 10, 93, 54, 85])
>>> det = mm.dsp.ca(signal, l_bound=20, guard_len=1, noise_len=3)
>>> det
    array([False, False,  True, False, False, False, False,  True, False,
            True])

Perform a non-wrapping CFAR

>>> signal = np.random.randint(100, size=10)
>>> signal
    array([41, 76, 95, 28, 25, 53, 10, 93, 54, 85])
>>> det =  mm.dsp.ca(signal, l_bound=20, guard_len=1, noise_len=3, mode='constant')
>>> det
    array([False,  True,  True, False, False, False, False,  True,  True,
            True])
mmwave.dsp.cfar.ca_(x, guard_len=4, noise_len=8, mode='wrap', l_bound=4000)

Uses Cell-Averaging CFAR (CA-CFAR) to calculate a threshold that can be used to calculate peaks in a signal.

Parameters:
  • x (ndarray) – Signal.
  • guard_len (int) – Number of samples adjacent to the CUT that are ignored.
  • noise_len (int) – Number of samples adjacent to the guard padding that are factored into the calculation.
  • mode (str) – Specify how to deal with edge cells. Examples include ‘wrap’ and ‘constant’.
  • l_bound (float or int) – Additive lower bound while calculating peak threshold.
Returns:

Tuple [ndarray, ndarray]
  1. (ndarray): Upper bound of noise threshold.
  2. (ndarray): Raw noise strength.

Examples

>>> signal = np.random.randint(100, size=10)
>>> signal
    array([41, 76, 95, 28, 25, 53, 10, 93, 54, 85])
>>> threshold = mm.dsp.ca_(signal, l_bound=20, guard_len=1, noise_len=3)
>>> threshold
    (array([70, 76, 64, 79, 81, 91, 74, 71, 70, 79]), array([50, 56, 44, 59, 61, 71, 54, 51, 50, 59]))

Perform a non-wrapping CFAR thresholding

>>> signal = np.random.randint(100, size=10)
>>> signal
    array([41, 76, 95, 28, 25, 53, 10, 93, 54, 85])
>>> threshold = mm.dsp.ca_(signal, l_bound=20, guard_len=1, noise_len=3, mode='constant')
>>> threshold
    (array([44, 37, 41, 65, 81, 91, 67, 51, 34, 46]), array([24, 17, 21, 45, 61, 71, 47, 31, 14, 26]))
mmwave.dsp.cfar.caso(x, *argv, **kwargs)

Detects peaks in signal using Cell-Averaging Smallest-Of CFAR (CASO-CFAR).

Parameters:
  • x (ndarray) – Signal.
  • *argv – See mmwave.dsp.cfar.caso_
  • **kwargs – See mmwave.dsp.cfar.caso_
Returns:

Boolean array of detected peaks in x.

Return type:

ndarray

Examples

>>> signal = np.random.randint(100, size=10)
>>> signal
    array([41, 76, 95, 28, 25, 53, 10, 93, 54, 85])
>>> det = mm.dsp.caso(signal, l_bound=20, guard_len=1, noise_len=3)
>>> det
    array([False, False,  True, False, False, False, False,  True,  True,
            True])

Perform a non-wrapping CFAR

>>> signal = np.random.randint(100, size=10)
>>> signal
    array([41, 76, 95, 28, 25, 53, 10, 93, 54, 85])
>>> det =  mm.dsp.caso(signal, l_bound=20, guard_len=1, noise_len=3, mode='constant')
>>> det
    array([False,  True,  True, False, False, False, False,  True,  True,
            True])
mmwave.dsp.cfar.caso_(x, guard_len=4, noise_len=8, mode='wrap', l_bound=4000)

Uses Cell-Averaging Smallest-Of CFAR (CASO-CFAR) to calculate a threshold that can be used to calculate peaks in a signal.

Parameters:
  • x (ndarray) – Signal.
  • guard_len (int) – Number of samples adjacent to the CUT that are ignored.
  • noise_len (int) – Number of samples adjacent to the guard padding that are factored into the calculation.
  • mode (str) – Specify how to deal with edge cells.
  • l_bound (float or int) – Additive lower bound while calculating peak threshold.
Returns:

Tuple [ndarray, ndarray]
  1. (ndarray): Upper bound of noise threshold.
  2. (ndarray): Raw noise strength.

Examples

>>> signal = np.random.randint(100, size=10)
>>> signal
    array([41, 76, 95, 28, 25, 53, 10, 93, 54, 85])
>>> threshold = mm.dsp.caso_(signal, l_bound=20, guard_len=1, noise_len=3)
>>> (threshold[0].astype(int), threshold[1].astype(int))
    (array([69, 55, 49, 72, 72, 86, 69, 55, 49, 72]), array([49, 35, 29, 52, 52, 66, 49, 35, 29, 52]))

Perform a non-wrapping CFAR thresholding

>>> signal = np.random.randint(100, size=10)
>>> signal
    array([41, 76, 95, 28, 25, 53, 10, 93, 54, 85])
>>> threshold = mm.dsp.caso_(signal, l_bound=20, guard_len=1, noise_len=3, mode='constant')
>>> (threshold[0].astype(int), threshold[1].astype(int))
    (array([69, 55, 49, 72, 72, 86, 69, 55, 49, 72]), array([49, 35, 29, 52, 52, 66, 49, 35, 29, 52]))
mmwave.dsp.cfar.cago(x, *argv, **kwargs)

Detects peaks in signal using Cell-Averaging Greatest-Of CFAR (CAGO-CFAR).

Parameters:
  • x (ndarray) – Signal.
  • *argv – See mmwave.dsp.cfar.cago_
  • **kwargs – See mmwave.dsp.cfar.cago_
Returns:

Boolean array of detected peaks in x.

Return type:

ndarray

Examples

>>> signal = np.random.randint(100, size=10)
>>> signal
    array([41, 76, 95, 28, 25, 53, 10, 93, 54, 85])
>>> det = mm.dsp.cago(signal, l_bound=20, guard_len=1, noise_len=3)
>>> det
    array([False, False,  True, False, False, False, False,  True, False,
            False])

Perform a non-wrapping CFAR

>>> signal = np.random.randint(100, size=10)
>>> signal
    array([41, 76, 95, 28, 25, 53, 10, 93, 54, 85])
>>> det = mm.dsp.cago(signal, l_bound=20, guard_len=1, noise_len=3, mode='constant')
>>> det
    array([False,  True,  True, False, False, False, False,  True,  True,
            True])
mmwave.dsp.cfar.cago_(x, guard_len=4, noise_len=8, mode='wrap', l_bound=4000)

Uses Cell-Averaging Greatest-Of CFAR (CAGO-CFAR) to calculate a threshold that can be used to calculate peaks in a signal.

Parameters:
  • x (ndarray) – Signal.
  • guard_len (int) – Number of samples adjacent to the CUT that are ignored.
  • noise_len (int) – Number of samples adjacent to the guard padding that are factored into the calculation.
  • mode (str) – Specify how to deal with edge cells.
  • l_bound (float or int) – Additive lower bound while calculating peak threshold.
Returns:

Tuple [ndarray, ndarray]
  1. (ndarray): Upper bound of noise threshold.
  2. (ndarray): Raw noise strength.

Examples

>>> signal = np.random.randint(100, size=10)
>>> signal
    array([41, 76, 95, 28, 25, 53, 10, 93, 54, 85])
>>> threshold = mm.dsp.cago_(signal, l_bound=20, guard_len=1, noise_len=3)
>>> (threshold[0].astype(int), threshold[1].astype(int))
    (array([72, 97, 80, 87, 90, 97, 80, 87, 90, 86]), array([52, 77, 60, 67, 70, 77, 60, 67, 70, 66]))

Perform a non-wrapping CFAR thresholding

>>> signal = np.random.randint(100, size=10)
>>> signal
    array([41, 76, 95, 28, 25, 53, 10, 93, 54, 85])
>>> threshold = mm.dsp.cago_(signal, l_bound=20, guard_len=1, noise_len=3, mode='constant')
>>> (threshold[0].astype(int), threshold[1].astype(int))
    (array([69, 55, 49, 72, 90, 97, 69, 55, 49, 72]), array([49, 35, 29, 52, 70, 77, 49, 35, 29, 52]))
mmwave.dsp.cfar.os(x, *argv, **kwargs)

Performs Ordered-Statistic CFAR (OS-CFAR) detection on the input array.

Parameters:
  • x (ndarray) – Noisy array to perform cfar on with log values
  • *argv – See mmwave.dsp.cfar.os_
  • **kwargs – See mmwave.dsp.cfar.os_
Returns:

Boolean array of detected peaks in x.

Return type:

ndarray

Examples

>>> signal = np.random.randint(100, size=10)
>>> signal
    array([41, 76, 95, 28, 25, 53, 10, 93, 54, 85])
>>> det = mm.dsp.os(signal, k=3, scale=1.1, guard_len=0, noise_len=3)
>>> det
    array([False,  True,  True, False, False, False, False,  True, False,
            True])
mmwave.dsp.cfar.os_(x, guard_len=0, noise_len=8, k=12, scale=1.0)

Performs Ordered-Statistic CFAR (OS-CFAR) detection on the input array.

Parameters:
  • x (ndarray) – Noisy array to perform cfar on with log values
  • guard_len (int) – Number of samples adjacent to the CUT that are ignored.
  • noise_len (int) – Number of samples adjacent to the guard padding that are factored into the calculation.
  • k (int) – Ordered statistic rank to sample from.
  • scale (float) – Scaling factor.
Returns:

Tuple [ndarray, ndarray]
  1. (ndarray): Upper bound of noise threshold.
  2. (ndarray): Raw noise strength.

Examples

>>> signal = np.random.randint(100, size=10)
>>> signal
    array([41, 76, 95, 28, 25, 53, 10, 93, 54, 85])
>>> threshold = mm.dsp.os_(signal, k=3, scale=1.1, guard_len=0, noise_len=3)
>>> (threshold[0].astype(int), threshold[1].astype(int))
    (array([93, 59, 58, 58, 83, 59, 59, 58, 83, 83]), array([85, 54, 53, 53, 76, 54, 54, 53, 76, 76]))
mmwave.dsp.cfar.peak_grouping(obj_raw, det_matrix, num_doppler_bins, max_range_idx, min_range_idx, group_in_doppler_direction, group_in_range_direction)

Performs peak grouping on detection Range/Doppler matrix.

The function groups neighboring peaks into one. The grouping is done according to two input flags: group_in_doppler_direction and group_in_doppler_direction. For each detected peak the function checks if the peak is greater than its neighbors. If this is true, the peak is copied to the output list of detected objects. The neighboring peaks that are used for checking are taken from the detection matrix and copied into 3x3 kernel regardless of whether they are CFAR detected or not. Note: Function always reads 9 samples per detected object from L3 memory into local array tempBuff, but it only needs to read according to input flags. For example if only the group_in_doppler_direction flag is set, it only needs to read middle row of the kernel, i.e. 3 samples per target from detection matrix.

Parameters:
  • obj_raw (np.ndarray) – (num_detected_objects, 3). detected objects from CFAR.
  • det_matrix (np.ndarray) – Range-doppler profile. shape is numRangeBins x num_doppler_bins.
  • num_doppler_bins (int) – number of doppler bins.
  • max_range_idx (int) – max range of detected objects.
  • min_range_idx (int) – min range of detected objects
  • group_in_doppler_direction (int) – flag to perform grouping along doppler direction.
  • group_in_range_direction (int) – flag to perform grouping along range direction.
Returns:

detected object after grouping.

Return type:

obj_out (np.ndarray)

mmwave.dsp.cfar.peak_grouping_qualified(obj_raw, num_doppler_bins, max_range_idx, min_range_idx, group_in_doppler_direction, group_in_range_direction)

Performs peak grouping on list of CFAR detected objects.

The function groups neighboring peaks into one. The grouping is done according to two input flags: group_in_doppler_direction and group_in_doppler_direction. For each detected peak the function checks if the peak is greater than its neighbors. If this is true, the peak is copied to the output list of detected objects. The neighboring peaks that are used for checking are taken from the list of CFAR detected objects, (not from the detection matrix), and copied into 3x3 kernel that has been initialized to zero for each peak under test. If the neighboring cell has not been detected by CFAR, its peak value is not copied into the kernel. Note: Function always search for 8 peaks in the list, but it only needs to search according to input flags.

Parameters:
  • obj_raw (np.ndarray) – (num_detected_objects, 3). detected objects from CFAR.
  • num_doppler_bins (int) – number of doppler bins.
  • max_range_idx (int) – max range of detected objects.
  • min_range_idx (int) – min range of detected objects
  • group_in_doppler_direction (int) – flag to perform grouping along doppler direction.
  • group_in_range_direction (int) – flag to perform grouping along range direction.
Returns:

detected object after grouping.

Return type:

obj_out (np.ndarray)