0
0
SciPydata~10 mins

Why signal processing extracts information in SciPy - Test Your Understanding

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

Complete the code to import the signal module from scipy.

SciPy
from scipy import [1]
Drag options to blanks, or click blank then click option'
Asignal
Bstats
Coptimize
Dintegrate
Attempts:
3 left
💡 Hint
Common Mistakes
Importing the wrong scipy module like stats or optimize.
Forgetting to import signal before using its functions.
2fill in blank
medium

Complete the code to create a simple sine wave signal using numpy.

SciPy
import numpy as np
fs = 1000  # Sampling frequency
T = 1.0   # seconds
x = np.linspace(0, T, int(T*fs), endpoint=False)
signal = np.sin(2 * np.pi * 5 * [1])
Drag options to blanks, or click blank then click option'
Afs
BT
Cx
Dnp.pi
Attempts:
3 left
💡 Hint
Common Mistakes
Using fs or T instead of the time array x.
Using np.pi incorrectly inside the sine function.
3fill in blank
hard

Fix the error in the code to compute the Fourier Transform of the signal.

SciPy
from scipy import signal
import numpy as np
fs = 1000
T = 1.0
x = np.linspace(0, T, int(T*fs), endpoint=False)
sig = np.sin(2 * np.pi * 5 * x)
freqs, psd = signal.welch(sig, [1])
Drag options to blanks, or click blank then click option'
Asig
Bx
CT
Dfs
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the time array or signal instead of the sampling frequency.
Confusing the order of arguments in the function call.
4fill in blank
hard

Fill both blanks to create a bandpass filter and apply it to the signal.

SciPy
from scipy import signal
fs = 500
nyq = 0.5 * [1]
low = 10 / nyq
high = 50 / [2]
b, a = signal.butter(4, [low, high], btype='band')
filtered = signal.lfilter(b, a, sig)
Drag options to blanks, or click blank then click option'
Afs
Bsig
Cnyq
Attempts:
3 left
💡 Hint
Common Mistakes
Using the signal variable instead of fs or nyq.
Using fs for the second blank instead of nyq.
5fill in blank
hard

Fill both blanks to create a dictionary of frequencies and their power values above a threshold.

SciPy
result = {freq[1]: psd for freq, psd in zip(freqs, psd) if psd [2] 0.01}
Drag options to blanks, or click blank then click option'
A.round(2)
C>
D.astype(int)
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to convert power values to int which loses precision.
Using wrong comparison operators in the filter condition.