Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spectrum display should make use of windowing #289

Open
tdunning opened this issue Feb 14, 2025 · 0 comments
Open

Spectrum display should make use of windowing #289

tdunning opened this issue Feb 14, 2025 · 0 comments
Labels

Comments

@tdunning
Copy link

When doing a spectral analysis, it is important to multiply each window of input samples by a so-called windowing function. This causes samples at the beginning and end of the window being reduced to zero with the original amplitude being retained in the middle of the window.

The reason that this is important is that the Fourier transform assumes the input is periodic. A batch of samples isn't, however, and there can be considerable mismatch between the beginning of the sample window and the end. That mismatch causes very poor quality in the quality of the display.

As an example, here are a few cycles of a sine wave:

Image

You can see how the first sample on the left is 0 and the last sample is about -1. If you do an analysis that presumes this sampled signal repeats these samples over and over, there will be a big jump from -1 back to 0 when you go from the end back to the beginning.

It is better to use a windowing function. A good choice is $2 \thinspace \sin^2({\pi t} / (n \Delta t))$. This changes our sine wave into this:

Image

Here, the windowing function is shown as a light red ghost on top of the windowed signal.

In the spectral display, this makes a lot of difference because the step from the end back to the beginning is an impulse that raises the noise floor dramatically.

For instance, here is a plot of the signal above with and without windowing. The difference in noise floor is about 150dB which is massive.

Image

In such a spectral displace, the vertical display should be calibrated using a factor based on the number of samples in a window and the gain of the input signal. If we want to display dBm (dB referenced to 1mW), and we have n = 10000 samples in our data and the input gives us a value of 127 for a 1V input, a 1dBm signal would appear to have a magnitude of 109dB after doing the Fourier transform which is computed using

$$s_{ref} = 20 \thinspace \log_{10} (127 \thinspace v_{0dB} \thinspace n)$$

where $v_{0dB} = \sqrt{0.05} = 0.22$ is the voltage that results in 1dB into a $50 \Omega$.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants