As we observed in the previous labs and theory with their corresponding exercises, Fourier analysis is a very important tool in Signal Processing.
Let us revisit fourier transform by exploring the concept through their various properties. Refer to this Table of Fourier Transform Pairs and Properties and implement in gnuradio the following :
Forward/ReverseOption. Hint: The output should be a triangle wave
Try to implement other properties from the link of fourier transform pairs and properties as well.
NOTE: Use the
FFT Block for the above exercises. Use complex sources. The
FFT block takes an input vector and outputs a complex vector. Use to appropriate stream to vector and complex to real/imaginary convertor blocks where necessary
The power of the FFT output is given by multiplying the complex output of the FFT by its complex conjugate
If you remember from the lab 2 introduction an SDR dongle passes the incoming signal through a mixer where the receiver sets the frequency you observe by setting the “LO” frequency which is mixed (multiplied) with the incoming signal. The signal is actually mixed with 2 LO’s, one cosine wave and one sine wave. This is called quadrature sampling, and is done so that it is possible to distinguish a signal that is some frequency(say 2MHz) below the “LO” frequency, or 2MHz above the LO frequency. With just a single mixing and one measurement, one just cannot distinguish between a signal at those two frequencies.
See this jupyter notebook for an introduction to the idea.
Now demonstrate IQ processing in gnuradio. We can demonstrate this at much lower frequencies as well. Set the sample-rate to 48kHz. Create 2 tones(cosine signals), one at 8kHz, one at 12kHz. Create your LO at 10kHz, one a cosine and one a sine.
Try using the two signals independently, and added together, this is the overall ‘signal’. Now multiply this signal by the cosine and the sine “LO’s”. This now will become your IQ signal. In gnuradio, this is passed into a “float to complex” block, where the cosine LO mixed signal is the real, and the sine multiplied is the imaginary. This can then be passed into a sink.
Add different syncs along the way, looking at just the cosine (“I”) or sine (“Q”) multiplied signals. With just the single incoming tone, demonstrate that you can in fact recover it after mixing. Do we need a filter? Where? Add one if needed.
The Discrete Fourier Transform for N samples is given by:
Evaluating the DFT’s sums directly involves complex multiplications and N(N−1) complex additions, of which operations can be saved by eliminating trivial operations such as multiplications by 1. Multiplications are particularly expensive computations.
Fast Fourier transform algorithms drastically reduce the computational complexity. The radix-2 Cooley–Tukey algorithm is a widely used FFT algorithm. In comparison to the traditional DFT it can compute the same result with only complex multiplications (again, ignoring simplifications of multiplications by 1 and similar) and complex additions.
The DFT implemented through a Cooley-Tukey Decimation in frequency FFT algorithm has the flowgraph shown below.
Use appropriate Constant multiplies and and adders to construct the above in gnuradio. Are the outputs the Valid frequency domain results?
You now have the tools necessary to create the digital signal processing for a Spectrometer for a radio telescope. A spectrometer:
Use GnuRadio to create the signal processing chain to achieve this. Use an osmocom airspy source. Use an FFT to separate frequency components.
As mentioned above, A spectrometer is used to record and measure the spectral content of signals, such as radio waves received from astronomical sources. Specifically, a spectrometer measures the power spectral density (PSD, measured in units of ) of a signal. Analysis of spectral content can reveal details of radio sources, as well as properties of the intervening medium like galactic neutral hydrogen. The Power Spectral Density is given by the Wiener-Kinchin theorem for wide sense stationary signals as:
and in the fourier domain E stands for the expected value i.e. the mean
There are therefore two distinct classes of spectrometers: 1) ones that approximate by first forming the autocorrelation, then taking a Fourier transform and 2) those that first convert into the frequency domain to form X(k) before evaluating . These are Autocorrelation Spectrometers and Fourier Tranform Filterbanks respectively.
The one we made above is a fourier transform filterbank. A filterbank is simply an array of band-pass filters, designed to split an input signal into multiple components. A spectrometer is referred to as a analysis filterbank where the output of each filter is squared and averaged.
The spectrometer we constructed effectively works as a array of band-pass FIR filters. If you recall FIR filters their design involves something called window-functions designed to optimise the filter response. The Discrete Fourier transform as it were uses the rectangular window function across each frequency channel. The response is non-ideal leading to spectral leakage i.e. the signal showing up in neighboring frequency channels. Below is a Demonstration of DFT leakage - a tone at 5.1MHz, sampled at 128MHz, and Fourier-transformed with 64 points, appears to varying levels in all the output frequency bins.
This can be improveed by using better windowing functions to properly define the frequency channel. Below are some commonly used windowing functions.
Note the frequncy response, the main lobe width and the attenuation of the side lobes determine how well defined are the frequency channels. The figures below illustrate the difference. The second plot shows the window response in some frequency bins, the ones with the higher sidelobes as responses of boxcar windows and the the lower sidelobes are of the hann window.
In your spectrometer flowgraph, change the window field in the FFT block and observe how the response of a tone ( a sinusoud signal ) changes for different windows.
Despite the appropraite windowing, spectral leakage persists, moreover there is something called a scalloping loss. Scalloping loss is the loss in energy between frequency bin centres due to the non-flat nature of the single-bin frequency response.
The polyphase filter bank (PFB) technique is a mechanism for alleviating the aforementioned drawbacks of the straightforward DFT. The PFB produces a flat response across the channel and provides excellent suppression of out-of-band signals, as shown below.
“Instead of taking an N-point transform directly, a block of data of size N x P = M is read, and multiplied point-by-point with a window function (in other words, the data is ‘weighted’). As mentioned before, the shape of the window function determines the shape of the single-bin frequency response. Since we wish the single-bin frequency response to resemble a rectangular function as much as possible, we choose its Fourier Transform pair, the sinc function, as our window function. Once the multiplication is done, the block of data is split into P subsets of length N each, and added point-by-point. This array is then passed to a regular DFT routine to get an N-point transform that exhibits less leakage. This method is presented graphically below”1
The same process, mathematically:
Where, where the sub-filter coefficients correspond to what are called P-tap ‘polyphase sub-filters’. The N such polyphase sub-filters that make up this operation, together with the following DFT stage, are collectively called a ‘polyphase filter bank’ (‘PFB’). A realization of this filter bank is shown below:
Add the polyphase filters to your spectrometer just before taking the FFT. Refer to the diagram above, the dotted squares are simply band-pass FIR filters. Use a hann/hamming window.
The ployphase filter can be realized by implementing following flowgraph:
constant muliplier blocks are sections of the filter window as seen the diagram detailing the process above. The filter window is designed by using import block to import
numpy and assigning thhree constant variables as:
np.arange(-np.pi*4/2.0, np.pi*4/2.0, np.pi/vec_length)
custom_window are all the window co-efficients/taps you need to do the multiplications, your vector length samples at a time. The constants in the constant mulitplier blocks from the top to bottom are as follows:
custom_window[-vec_length:] custom_window[2*vec_length:3*vec_length] custom_window[vec_length:2*vec_length] custom_window[0:vec_length]
Save the spectrometer data for science! (Use File Sink)
NOTE: Our Low Noise Amplifier (LNA) needs to be powered to actually work. We can configure the airspy dongle by settign bias=1 in the device arguments field of the osmocom source block such as: