Fourier SNR: change markers with sampling frequency

This commit is contained in:
Eric Teunis de Boone 2023-01-11 16:31:22 +01:00
parent fe05908bbb
commit 1968814e06

View file

@ -217,18 +217,35 @@ if __name__ == "__main__":
# plot the snrs # plot the snrs
fig, axs2 = plt.subplots() fig, axs2 = plt.subplots()
fig.basefname="signal_to_noise_vs_N" fig.basefname="signal_to_noise_vs_N"
axs2.set_title("A: {:.2e}, $\\sigma$: {:.2e}".format(sine_amp, noise_sigma))
axs2.set_xlabel("$N = T*f_s$") axs2.set_xlabel("$N = T*f_s$")
axs2.set_ylabel("SNR") axs2.set_ylabel("SNR")
mycolors = {}
myshapes = { 250: '^', 500: 'v' }
for i, (f_sample, f_sine, t_lengths) in enumerate(fs_iter): for i, (f_sample, f_sine, t_lengths) in enumerate(fs_iter):
if f_sine in mycolors.keys():
color = mycolors[f_sine]
else:
color = None
if f_sample in myshapes.keys():
marker = myshapes[f_sample]
else:
marker = 'x'
# plot the means # plot the means
l = axs2.plot(t_lengths*f_sample, np.mean(my_snrs[i], axis=-1), marker='*', ls='none', label='f:{}MHz, fs:{}MHz'.format(f_sine, f_sample), markeredgecolor='black') l = axs2.plot(t_lengths*f_sample, np.mean(my_snrs[i], axis=-1), color=color, marker=marker, ls='none', label='f:{}MHz, fs:{}MHz'.format(f_sine, f_sample), markeredgecolor='black', mew=0.1)
color = l[0].get_color() color = l[0].get_color()
mycolors[f_sine] = color
myshapes[f_sample] = l[0].get_marker()
for k, t_length in enumerate(t_lengths): if True:
t_length = np.repeat(t_length * f_sample, my_snrs.shape[-1]) for k, t_length in enumerate(t_lengths):
axs2.plot(t_length, my_snrs[i,k], ls='none', color=color, marker='o', alpha=max(0.01, 1/my_snrs.shape[-1])) t_length = np.repeat(t_length * f_sample, my_snrs.shape[-1])
axs2.plot(t_length, my_snrs[i,k], ls='none', color=color, marker='o', alpha=max(0.01, 1/my_snrs.shape[-1]))
axs2.legend() axs2.legend()
@ -236,14 +253,30 @@ if __name__ == "__main__":
# plot snrs vs T # plot snrs vs T
fig, axs3 = plt.subplots() fig, axs3 = plt.subplots()
fig.basefname="signal_to_noise_vs_T" fig.basefname="signal_to_noise_vs_T"
axs3.set_title("A: {:.2e}, $\\sigma$: {:.2e}".format(sine_amp, noise_sigma))
axs3.set_xlabel("time [us]") axs3.set_xlabel("time [us]")
axs3.set_ylabel("SNR") axs3.set_ylabel("SNR")
#mycolors = {}
#myshapes = { 250: '^', 500: 'v' }
for i, (f_sample, f_sine, t_lengths) in enumerate(fs_iter): for i, (f_sample, f_sine, t_lengths) in enumerate(fs_iter):
if f_sine in mycolors.keys():
color = mycolors[f_sine]
else:
color = None
if f_sample in myshapes.keys():
marker = myshapes[f_sample]
else:
marker = 'x'
# plot the means # plot the means
l = axs3.plot(t_lengths, np.mean(my_snrs[i], axis=-1), marker='o', ls='none', label='f:{}MHz, fs:{}MHz'.format(f_sine, f_sample), markeredgecolor='black', markeredgewidth=1) l = axs3.plot(t_lengths, np.mean(my_snrs[i], axis=-1), color=color, marker=marker, ls='none', label='f:{}MHz, fs:{}MHz'.format(f_sine, f_sample), markeredgecolor='black', mew=1)
color = l[0].get_color() color = l[0].get_color()
mycolors[f_sine] = color
myshapes[f_sample] = l[0].get_marker()
for k, t_length in enumerate(t_lengths): for k, t_length in enumerate(t_lengths):
t_length = np.repeat(t_length , my_snrs.shape[-1]) t_length = np.repeat(t_length , my_snrs.shape[-1])