Last active
June 2, 2020 04:30
-
-
Save iphysresearch/14106bf7a9b9d01eafc6d90a965d8330 to your computer and use it in GitHub Desktop.
Chapter 2 - Window functions (time domain)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from scipy.signal import triang, tukey | |
import matplotlib.pyplot as plt | |
import seaborn as sns | |
sns.set(context='paper', | |
style='ticks', | |
font_scale=1, | |
rc={'figure.figsize': (8, 5), | |
'figure.dpi': 100, # need fixed | |
'xtick.direction': 'in', | |
'ytick.direction': 'in', | |
'axes.linewidth': '1.3', | |
'axes.labelsize': 12, | |
'xtick.labelsize': 12, | |
'ytick.labelsize': 12, | |
'savefig.dpi': 300, | |
'legend.fontsize': 10, | |
# 'text.usetex':True, | |
}) | |
plt.figure(figsize=(6,5), dpi=100) | |
for window, label, c in zip([np.ones(128), triang(128), tukey(128, alpha=0.25), np.hanning(128), np.blackman(128)], | |
['rectangular', 'triangular', 'Tukey(r=0.25)', 'Hann','Blackman'], | |
['k', 'b', 'g','r','y']): | |
plt.plot(np.linspace(0,1,window.size), window, label=label, color=c) | |
plt.ylabel("Amplitude") | |
plt.xlabel("Sample") | |
plt.legend() | |
plt.ylabel('amplitude') | |
plt.xlabel('time [t/T]') | |
plt.yticks([0,0.2,0.4,0.6,0.8,1],['0','0.2','0.4','0.6','0.8','1']) | |
plt.xticks([0,0.2,0.4,0.6,0.8,1],['0','0.2','0.4','0.6','0.8','1']) | |
plt.xlim(0,1) | |
plt.ylim(0,1.02) | |
plt.savefig('C2_imags/C2_amp_window.png', dpi=300, bbox_inches='tight') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment