human
I am working on the file "Homeworks/HW10/listen_to_Handel.ipynb".
The first task is:
Plot spectrograms and periodograms
The filter we use
Can you write Python program for it?
assistant
#Here is the Python program you requested.

w, h = sig.freqz(filt)
fig = plt.figure()
plt.title('Anti-alias Frequency Response')
plt.plot(w/np.pi*Fs/2, dbAmplitude(h) )
plt.ylabel('Amplitude [dB]')
plt.xlabel('Frequency [Hz]')

fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2, figsize=(12,10),sharey=True)

# def with_logging(*args, **kwargs):
#     print(func.__name__ + " was called")
#     return func(*args, **kwargs)
def periodogram(*args,**kwargs):
  return sig.welch(*args,**kwargs,window='barthann',scaling='density')

f, Pxx = periodogram(y,fs=Fs,nperseg=1024)
ax1.plot(f, dbPower(Pxx))
ax1.set_title('Original signal')

f, Pxx = periodogram(y[::4], fs=Fs/4, nperseg=128)
ax2.plot(f, dbPower(Pxx))
ax2.set_title('Downsampled (x4) (aliased)')

f, Pxx = periodogram(lowpassFilter(y), fs=Fs, nperseg=1024)
ax3.plot(f, dbPower(Pxx))
ax3.set_title('Filtered')

f, Pxx = periodogram(lowpassFilter(y)[::4], fs=Fs/4, nperseg=128)
ax4.plot(f, dbPower(Pxx))
ax4.set_title('Filtered then Downsampled')

for ax in (ax1, ax2, ax3, ax4):
    ax.set_xlabel('Frequency [Hz]')
    ax.set_ylabel('Power Spectral Density [dB/Hz]')
plt.show()