0
0
SciPydata~10 mins

Windowing before FFT in SciPy - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the Hann window function from scipy.signal.

SciPy
from scipy.signal import [1]
Drag options to blanks, or click blank then click option'
Ahamming
Bblackman
Chann
Dbartlett
Attempts:
3 left
💡 Hint
Common Mistakes
Importing the wrong window function like hamming or blackman.
Misspelling the function name.
2fill in blank
medium

Complete the code to create a Hann window of length 256.

SciPy
window = hann([1])
Drag options to blanks, or click blank then click option'
A128
B1024
C512
D256
Attempts:
3 left
💡 Hint
Common Mistakes
Using a window length different from the signal length.
Confusing window length with FFT length.
3fill in blank
hard

Fix the error in applying the window to the signal array named 'signal'.

SciPy
windowed_signal = signal [1] window
Drag options to blanks, or click blank then click option'
A+
B*
C-
D/
Attempts:
3 left
💡 Hint
Common Mistakes
Adding or subtracting the window instead of multiplying.
Dividing the signal by the window.
4fill in blank
hard

Fill the blank to compute the FFT of the windowed signal and get its magnitude.

SciPy
fft_result = np.fft.[1](windowed_signal)
magnitude = np.abs(fft_result)
Drag options to blanks, or click blank then click option'
Afft
Bifft
Creal
Dimag
Attempts:
3 left
💡 Hint
Common Mistakes
Using inverse FFT instead of FFT.
Trying to get magnitude by accessing .real or .imag.
5fill in blank
hard

Fill all three blanks to create a windowed signal, compute its FFT, and plot the magnitude spectrum.

SciPy
import matplotlib.pyplot as plt

window = hann([1])
signal = np.sin(2 * np.pi * 5 * np.arange([2]) / [3])
windowed_signal = signal * window
fft_result = np.fft.fft(windowed_signal)
magnitude = np.abs(fft_result)
plt.plot(magnitude)
plt.title('Magnitude Spectrum')
plt.xlabel('Frequency Bin')
plt.ylabel('Magnitude')
plt.show()
Drag options to blanks, or click blank then click option'
A256
B100
D512
Attempts:
3 left
💡 Hint
Common Mistakes
Using different lengths for window and signal.
Not matching the range length with window length.