Improving SNR (signal to Noise) - sine wave over white noise - signal-processing

I'm reading a signal which is a constant frequency sine wave (F = 1KHz), constant phase and changing amplitude.
For example, if the read-back signal is "high" the amplitude will be (say) 1V.
If the read-back signal is "low" the amplitude will be (say) 0.01 V.
The signal is deep in white noise (full spectra).
How can I improve SNR to remove the noise but remain with the signal ?
Of course I tried steep filters BPF at the known frequency.
Any other ideas to remove the noise and get a better SNR ?

Related

How can a non-sine waveform can equate to combination of DC voltage?

It has been found that any repeating, non-sinusoidal waveform can be equated to a combination of DC voltage, sine waves, and/or cosine waves (sine waves with a 90 degree phase shift) at various amplitudes and frequencies.
Above excerpt from allaboutcircuits.com.
I understand that a non-sine wave can be broken down into a combination of harmonic sine waves. What I dont understand is how it states above that it can also be from DC voltage which isnt alternating like a sine wave.
Could someone help clarify? Thanks

Strange FFT spectrum from a near perfect sinusoid

I have retrieved some signal in my Abaqus simulation for verification purpose. The true signal shall be a perfect sinusoid at 300kHz and I performed fft on the sampled signal using scipy.fftpack.fft.
But I got a strange spectrum as shown below (sorry that I am too lazy to scale the x-axis of the spectrum to the correct frequency). In the same figure, I sliced the signal into pieces and plotted in the time domain. I also repeated the same process for a pure sine wave.
This totally surprises me. As indicated below in the code, sampling frequency is 16.66x of the frequency of the signal. At the moment, I think it is due to the very little error in the sampling period. In theory, Abaqus shall sample it in a regular time interval. As you can see, there is some little error so that the dots in my signal appear to be thicker than the perfect signal. But does such a small error give a striking difference in the frequency spectrum? Otherwise, why is the frequency spectrum like that?
FYI1: This is the magnified fft spectrum of my signal:
FYI2: This is the python code that was used to produce the above figures
def myfft(x, k, label):
plt.plot(np.abs(fft(x))[0:k], label = label)
plt.legend()
plt.subplot(4,1,1)
for i in range(149800//200):
plt.plot(mysignal[200*i:200*(i+1)], 'bo')
plt.subplot(4,1,2)
myfft(mysignal,150000//2, 'fft of my signal')
plt.subplot(4,1,3)
[Fs,f, sample] = [5e6,300000, 150000]
x = np.arange(sample)
y = np.sin(2 * np.pi * f * x / Fs)
for i in range(149800//200):
plt.plot(y[200*i:200*(i+1)], 'bo')
plt.subplot(4,1,4)
myfft(y,150000//2, 'fft of a perfect signal')
plt.subplots_adjust(top = 2, right = 2)
FYI3: Here is my signal in .npy and .txt format. The signal is pretty long. It has 150001 points. The .txt one is the raw file from Abaqus. The .npy format is what I used to produce the above plot - (1) the time vector is removed and (2) the data is in half precision and normalized.
Any standard FFT algorithm you use operates on the assumption that the signal you provide is uniformly sampled. Uniform in this context means equally spaced in time. Your signal is clearly not uniformly sampled, therefore the FFT does not "see" a perfect sine but a distorted version. As a consequence you see all these additional spectral components the FFT computes to map your distorted signal to the frequency domain. You have two options now. Resample your signal i.e. it is uniformly sampled and use your off the shelf FFT or take a non-uniform FFT to get your spectrum. Here is one library you could use to calculate your non-uniform FFT.

Calculating PSD of signal in GNURadio

My general aim is to calculate the power spectral density of an input signal exactly as what is seen in the QT GUI Frequency Sink block. I'll need to process the PSD values later on. Here is my current setup.
These graphs are produced when a signal (no transmission) is inputted.
Blue = signal, green = max of signal, pink = min of signal.
My implementation of PSD produces a graph that has the same height and shape as the actual PSD shown by the QT GUI Frequency Sink block, but wrong offset - the actual PSD is about 66 dB lower than mine.
I eyeballed the rough max/min/signal y-axis values:
Actual PSD has max = -76dB, min = -115dB, signal = -86dB.
My PSD has max = -10dB, min = -50dB, signal = -20dB.
I'm not really sure what I'm doing wrong; the offset of -66dB seems pretty arbitrary and I think I'm on the right track generally.
You need to scale result of FFT by FFT length. 20Log10(2048) = 66 dB. You are estimating the PSD by calculating the Periodogram which is magnitude squared of the FFT divided by length of FFT.

How to analyse the FFT output (Array [512])?

What do the values of a FFT output means?
I'm using AudioKit's FFT algorithm (framework written for Swift) and when I fft the AudioNode (the microphone sound), it gives me a variable containing the fft data. It's a variable of 512 positions (0 to 511).
When I do it, it gives me veeeery small results, like 0.00004231 or even 2.41233e-7, sometimes 2.41233e-12. What do these values means?
What I think:
index 0: 0 - x Hz
1: x - 2x Hz
2: 2x- 3x Hz
::
::
and so on...
Each array has the Amplitude value of that position.
Am I right? If no, please explain me. It will help me a lot.
The Fourier Transform maps a signal from the time domain to the frequency domain. As such, each FFT sample measures that given frequency intensity in the original signal.
For instance, fft[2] indicates how strong frequency 2 hz is in the original signal. Keep in mind there might be some scaling in the fft array returned by AudioKit, so please check the actual frequency range covered by those 512 samples.

what is the PSD unit by using FFT method

I'm just doing a power spectral density analysis of a signal in time domain. I'm following the fft method described in :
http://www.mathworks.com/support/tech-notes/1700/1702.html
It gives the real physical unit for the PSD. However, the unit is "power", is that mean "V^2/Hz"?
If I take 10*log10(power) or 10*log10(V^2/Hz), do I get the unit of "dB/Hz"?
Then how can I convert it to dBm/MHz?
It depends on the unit of your timeseries. Often we think of this as just "amplitude", but if your timeseries is a series of voltage amplitude vs. time, then your PSD estimate will be Volts^2/Hz. This is because the PSD is the Fourier Transform of the autocorrelation of your original signal: The autocorrelation has units of Volts^2, and running it through the Fourier Transform decomposes these units over frequency, instead of time, resulting in units of Volts^2/Hz. This is commonly referred to as Watts/Hz, but the conversion from Volts^2 to Watts is not very physically meaningful, as W = V^2/R.
10*log10(power) will result in a unit of dB/Hz, but remember that decibels are always a comparison between two power levels; you are quantifying a ratio of powers. A better definition of decibels is 10*log10(P1/P0), as explained here. If you simply plug a PSD bin estimate into this equation, you are setting your PSD bin to P1 and implicitly comparing it to a P0 value of 1. This may be what you want, and it may not be. For visualization purposes, this is fairly typical, but if you have a standard reference power you should be comparing to, you should use that for P0 instead.
Assuming that you are attempting to plot a dB Power Spectral Density estimate, to convert from Hz to MHz, you simple rescale the x-axis of your frequency graph. Remember that a MHz is just 1 million Hz, so the only difference is that 240000Hz = 0.24MHz
EDIT
The point brought up by mtrw is a very valid one; if you are dealing with large amounts of data and are averaging FFT vectors, I highly suggest the Multitaper method; it's a much more statistically sound method of sacrificing frequency resolution for greater confidence on your PSD estimate.
If you have a PSD in W/Hz i.e. 100 W/Hz then you have 50 dBm/Hz. dB/Hz or is often vaguely and generically used instead of dBm/Hz. Audacity uses dB as shorthand for dBFS (not dBFS/Hz, because it is computing a DFT, and discrete frequencies use a power spectrum and not a density) . A digital signal that reaches 50% of the maximum level has an amplitude of −6 dBFS, which is 6 dB below full scale – the removal of the MSB, hence the 6dB/bit figure (because 50% of maximum level is 25% of maximum power; 1/4 = - 6dB)
dBm is the logarithmic ratio of the power with respect to 1mW, you divide the power by 1mW to get a unitless ratio, and then take the logarithm to get dB units, which in this case makes more sense to be clarified as dBm.
dBc/Hz is the ratio with respect to the carrier power, which is a ratio of two dBm/Hz values, meaning you subtract them and you get dBc/Hz; you get the same result if you divide the two linear power levels in W and then convert the ratio to dB (or more appropriately dBc).
dB-Hz is a logarithmic measure of bandwidth with respect to 1Hz and
dBJ is a measure of spectral density as a logarithmic ratio to 1 joule, seeing as W/Hz is indeed J.
Power spectral density is a density function, so you need to integrate it to get the actual quantity, like a line Integral of a V/m electric field, or a probability density of probability per x. This does not make sense for discrete quantities and instead the power spectrum is used akin to a probability mass function. If you see dB (which should be used for the discrete frequency domain) instead of dBm/Hz then it's wrong, but if you see it instead of dBm then it's right, as long as it's made clear what the reference is.

Resources