Ever tried to automatically identify data bursts or recurring patterns in collected 5G New Radio (NR) slot measurements?
The nr_burst_finder
module demonstrates how to do this using NumPy and SciPy. Because slot measurements may contain gaps (i.e. measurements not reported for every slot), the first step is to map the reports onto a complete time slot grid.
Burst detection uses a sliding window technique:
- Perform a discrete linear convolution using a mask of ones.
(Reference:
np.convolve
) - This computes the cumulative sum over a sliding window of specified length.
- Use
scipy.signal.find_peaks
to find peaks with a height above the burst threshold. This returns:- Indices of detected bursts in the time slot grid
- Burst sizes
Pattern detection converts the full time slot grid into a 2D matrix, where:
- Each row is a shifted version of the data
- Columns represent consecutive slot sequences matching the pattern length
Steps:
- Create a rolling window view using
numpy.lib.stride_tricks.as_strided
- Shift the data and form a 2D array
- Flip the pattern array and compare it to each column
- Identify start indices of matched columns
This method is efficient and leverages NumPy’s stride tricks for fast, memory-friendly pattern searching.
For the example usage check out the nr_burst_finder.tbs_test
function or simply execute the script. Here is how to execute it:
>>> from nr_burst_finder import nr_burst_finder >>> nr_burst_finder.main() INFO:nr_burst_finder.nr_burst_finder:Collected measurements: SFN, slot, TBS [[ 29 18 0] [ 30 8 500] [ 30 9 1000] [ 30 18 500] [ 31 8 0] [ 31 9 0] [ 31 18 0] [ 32 8 500] [ 32 9 1000] [ 32 18 200] [ 33 8 0] [ 33 9 1000] [ 33 18 0] [ 33 19 0] [ 34 8 0] [ 34 9 0] [ 34 18 0] [ 35 8 0] [ 35 9 0] [ 35 18 0] [ 35 19 250] [ 36 8 250] [ 36 9 1000] [ 36 18 500] [ 36 19 0] [ 37 8 0] [ 37 9 0] [ 37 18 0] [ 37 19 0] [ 38 8 0] [ 38 9 0] [ 38 18 0] [ 38 19 0] [ 39 8 0] [ 39 9 1000] [ 39 18 2000]] INFO:nr_burst_finder.nr_burst_finder:Verifying bursts (burst_min_size:2000, burst_window:20, range of expected bursts:(3, 4)) INFO:nr_burst_finder.nr_burst_finder:Checking SAMPLE TBS bursts (min. burst size:2000, burst window: 20 ) INFO:nr_burst_finder.nr_burst_finder:Mapping SAMPLE TBS reports to full time range table (20 slots margins prepended to the beginning and appended at the end) INFO:nr_burst_finder.nr_burst_finder:Expected (3, min:3, max:4) SAMPLE TBS bursts>=2000 detected in (sfn/slot/size): [[30.0, 3.0, 2000.0], [35.0, 19.0, 2000.0], [39.0, 4.0, 3000.0]](measurement time: 29/18 - 39/18) INFO:nr_burst_finder.nr_burst_finder:Verifying TBS pattern INFO:nr_burst_finder.nr_burst_finder:Checking SAMPLE TBS pattern in consecutive slots(pattern:[0, 0, 0, 0, 500, 1000], compare_values:True) INFO:nr_burst_finder.nr_burst_finder:Mapping SAMPLE TBS reports to full time range table (0 slots margins prepended to the beginning and appended at the end) INFO:nr_burst_finder.nr_burst_finder:SAMPLE TBS pattern detected 2 times in (sfn/slot): [[30, 4], [32, 4]](measurement time: 29/18 - 39/18)