# Rsudp spectrogram is too noisy

Have a look at this record from rsudp. It shows cars driving past our house:

Notice the blues dots throughout the spectrogram. These indicate a very noisy spectrum and are meaningless. They could be eliminated by smoothing, either using ensemble averaging or by frequency averaging.
Swarm uses 86% overlap to achieve ensemble averaging. What is the setting for rsudp?
Frequency averaging is achieved by taking 3 (or 5 or 7) term running means down each column of data.

It uses 90% overlap. The line that does most of the work to calculate the spectrogram is here: https://github.com/raspishake/rsudp/blob/699d6881444713fc525de462c0a73dc7e4f63c54/rsudp/c_plot.py#L437

I played around quite a bit with the `specgram()` function in order to try and eliminate them but perhaps I tried the wrong things. I welcome improvements!

increasing the time period to display does help with resolution.

1 Like

Iâ€™m revising this issue because Iâ€™ve been having fun with the new version of Rsudp on Windows, but I find the presence of those negative spikes quite irritating. So I thought Iâ€™d explain whatâ€™s happening.

Hereâ€™s a piece of record with its raw spectrogram and below that a smoothed version - this has been done in Matlab, not Python, so it looks a bit different to Rsudp plots.

If you take a cross section down the spectrogram as shown by the green line, you get the following spectrum:

The difference between unsmoothed and smoothed is that smoothing has removed the negative spikes which are of no interest to anybody, while retaining the overall shape of the spectrum.

In the `specgram()` routine used by Rsudp, there is no facility for smoothing, so this would need to be done on the spectrogram matrix that comes out of the routine. In Matlab, this is a one-line operation involving the convolution of the spectrogram matrix with a vector [0.333 0.333 0.333] (for 3-term smoothing). I imagine there is a similar process in Python? A Google search on â€śmoving averageâ€ť or â€śrolling meanâ€ť revealed quite a few options in NumPy and SciPy.

I note that there is a facility in specgram to output an image. Is that what Rsudp uses? If so, things are not quite so straightforwardâ€¦

1 Like