# This is the 1d Kernel for High Pass (last scale)
       h1d_H = firwin(Nf[m],F_Bank_r[m],pass_zero=False)
       List_h.append(h1d_H)
       plt.plot(Freq,np.fft.fftshift(np.abs(np.fft.fft(h1d_H,n_t))),linewidth=1.5)
       
plt.xlim([0,0.4])    
plt.xlabel('$\hat{f}[-]$',fontsize=18)
plt.ylabel('Normalized Spectra',fontsize=18)

plt.tight_layout()
plt.savefig('Frequency_Splitting.pdf', dpi=100)  


Ex=201
# Compute the mPOD Temporal Basis
PSI_M = mPOD_K(K,dt,Nf,Ex,F_V,Keep,'nearest','reduced');


# Save as numpy array all the data
np.savez('Psis_mPOD',PSI_M=PSI_M)
 
# To make a comparison later, we also compute the POD basis
# Temporal structures are eigenvectors of K
Psi_P, Lambda_P, _ = np.linalg.svd(K)
# The POD has the unique feature of providing the amplitude of the modes
# with no need of projection. The amplitudes are:
Sigma_P=(Lambda_P)**0.5; 

# Obs: svd and eig on a symmetric positive matrix are equivalent.
np.savez('Psis_POD',Psi_P=Psi_P,Sigma_P=Sigma_P)
            plt.plot(Freq,
                     np.fft.fftshift(np.abs(np.fft.fft(h1d_H, n_t))),
                     linewidth=1.5)

plt.xlim([0, 0.4])
plt.rc('text', usetex=True)  # This is Miguel's customization
plt.rc('font', family='serif')

plt.xlabel('$\hat{f}[-]$', fontsize=18)
plt.ylabel('Normalized Spectra', fontsize=18)

plt.tight_layout()
plt.savefig('Frequency_Splitting.png', dpi=200)

# Compute the mPOD Temporal Basis
PSI_M, Ks = mPOD_K(data['K'], dt, Nf, Ex, F_V, Keep, 'nearest', 'reduced')

# Save the correlation matrices of each scale:
for i in range(0, Ks.shape[2]):
    K = Ks[:, :, i]
    K_HAT_ABS = np.fliplr(np.abs(np.fft.fftshift(np.fft.fft2(K - np.mean(K)))))

    fig, ax = plt.subplots(figsize=(4, 4))
    #ax.set_xlim([-0.5,0.5])
    #ax.set_ylim([-0.5,0.5])
    plt.rc('text', usetex=True)
    plt.rc('font', family='serif')
    plt.rc('xtick', labelsize=12)
    plt.rc('ytick', labelsize=12)
    plt.pcolor(Freq, Freq, K_HAT_ABS / np.size(D))  # We normalize the result
    ax.set_aspect('equal')  # Set equal aspect ratio