With python scipy I am processing (in real time) chunks of 250,000 each a CW pulsed beep radio signal in python from a RTLSDR. The signal after some basic processing and decimation is 9995 samples long and looks like:
A "beep" or high state as shown in the image above happens about once every 1,000,000 signals, and I process in chunks of 250,000 (before decimation). A high state has a duration of 189 samples (decimated).
The aim of the project is to:
(a) Calculate time between beeps (black arrow);
(b) Calculate beep length (red arrows)
I have tried a few techniques to smooth the signal in the picture (and improve SNR) but they are affecting the downstream calculations.
Moving Average Smoothing:
np.convolve(max_samples, [1]*189, 'valid')/189
Introduced artifacts on the padding edges, which caused downstream calculations particularly where a chunk edge slices the beginning of a rising edge because the "rising edge" largely disappears and is no longer detected.
Savitzky-Golay
signal.savgol_filter(max_samples, 189, 50)
I could not get this filter to output any plot that made sense:
Is there a better way to deal with the smoothing issue, especially as it relates to where a chunk has sliced a beeps rising edge, and still accurately calculating a beeps length?
If the answer is in the Savitzky Golay filter - what are sensible values? When I tried values like:
I get stack error:
-> 630 raise ValueError(
631 "array must not contain infs or NaNs")
632 return a
max_samples
- there is valid numbers in the array. $\endgroup$