def main(): solar_mass = 2. * 10**30 m1 = 1.4 * solar_mass m2 = 1.4 * solar_mass mc = (m1 * m2)**(3. / 5.) / (m1 + m2)**(1. / 5.) r = 1000. t_coal = 1 phi_coal = 0 iota = np.pi / 8 theta = 0 phi = 0 psi = 0 t_dur = 0.15 t_max = t_coal - (t_dur / 100.) t_from_merger = 0 #print("M_c: {}".format(mc)) num_pts = 10000 x = np.linspace(t_max - t_dur - t_from_merger, t_max - t_from_merger, num_pts) x_disp = np.linspace(0, max(x), num_pts) #x = np.linspace(0, 0.3, 10000) y = np.array([ detector_response(t, r, mc, t_coal, phi_coal, iota, theta, phi, psi) for t in x ]) #y = np.array([f_gw(t, t_coal, mc) for t in x]) fig = plt.figure(figsize=(1980.0 / 96, 1080.0 / 96)) plt.rcParams.update({'font.size': 32, 'text.usetex': 'true'}) ax = fig.add_subplot(111) ax.plot(x_disp, y, color='black') ax.set_ylabel('Strain', rotation=0) ax.set_xlabel('t') ax.set_xticklabels([]) ax.set_yticklabels([]) ax.set_xticks([]) ax.set_yticks([]) ax.spines['left'].set_position('zero') ax.spines['bottom'].set_position('zero') ax.spines['right'].set_color('none') ax.spines['top'].set_color('none') ax.xaxis.set_label_coords(1.0, 0.44) ax.yaxis.set_label_coords(0.0, 0.9) #ax.set_xlim(0, 1.25 * max(x_disp)) plt.savefig(os.path.join(images_path(), 'linear_waveform.png')) plt.show() return
def main(): data_path = '/home/marlin/Documents/Documents/Studium/Masterarbeit/Forschungsphase/Code/Git/master_project/bns_net/saves/inception_res_net_266201913382/inception_res_net_snr_plot_last_epoch_266201913382.hf5' with h5py.File(data_path, 'r') as FILE: x = FILE['x1'][:] y = FILE['y'][:] line = np.linspace(0, 1.1 * max(x)) fig = plt.figure(figsize=(1980.0 / 96, 1080.0 / 96)) plt.rcParams.update({'font.size': 32, 'text.usetex': 'true'}) plt.grid() plt.scatter(x, y) plt.plot(line, line, color='red', zorder=4) plt.xlabel('Label SNR') plt.ylabel('Recovered SNR') plt.savefig(os.path.join(images_path(), 'streak_plot.png')) plt.show() return
def main(): approximant = 'TaylorF2' mass1 = 1.4 mass2 = 1.4 delta_t = 1.0 / 4096 f_lower = 20 final_x_sec = 68 hp, hc = get_td_waveform(approximant=approximant, mass1=mass1, mass2=mass2, delta_t=delta_t, f_lower=f_lower) dur = hp.sample_times[-1] hp = hp.time_slice(dur - final_x_sec - hp.delta_t, dur) x = hp.sample_times y = hp.data[:] box_height = 1.1 * max(abs(y)) print("Duration: {}".format(hp.duration)) print("Length y: {}".format(len(y))) fig = plt.figure(figsize=(1980.0 / 96, 1080.0 / 96)) plt.rcParams.update({'font.size': 32, 'text.usetex': 'true'}) ax = fig.add_subplot(111) lw = 2 separate = 0.25 window_size = 0.5 left_edge = dur - window_size rect_1s_1 = patches.Rectangle((left_edge + separate / 2, -box_height), window_size - separate / 2, 2 * box_height, linewidth=lw, edgecolor='black', facecolor='none', zorder=4) ax.add_patch(rect_1s_1) window_size = 0.5 left_edge -= window_size rect_1s_2 = patches.Rectangle((left_edge + separate / 2, -box_height), window_size - separate / 2, 2 * box_height, linewidth=lw, edgecolor='purple', facecolor='none', zorder=4) ax.add_patch(rect_1s_2) window_size = 1.0 left_edge -= window_size rect_2s = patches.Rectangle((left_edge + separate / 2, -box_height), window_size - separate / 2, 2 * box_height, linewidth=lw, edgecolor='blue', facecolor='none', zorder=4) ax.add_patch(rect_2s) window_size = 2.0 left_edge -= window_size rect_4s = patches.Rectangle((left_edge + separate / 2, -box_height), window_size - separate / 2, 2 * box_height, linewidth=lw, edgecolor='cyan', facecolor='none', zorder=4) ax.add_patch(rect_4s) window_size = 4.0 left_edge -= window_size rect_8s = patches.Rectangle((left_edge + separate / 2, -box_height), window_size - separate / 2, 2 * box_height, linewidth=lw, edgecolor='green', facecolor='none', zorder=4) ax.add_patch(rect_8s) window_size = 8.0 left_edge -= window_size rect_16s = patches.Rectangle((left_edge + separate / 2, -box_height), window_size - separate / 2, 2 * box_height, linewidth=lw, edgecolor='yellow', facecolor='none', zorder=4) ax.add_patch(rect_16s) window_size = 16.0 left_edge -= window_size rect_32s = patches.Rectangle((left_edge + separate / 2, -box_height), window_size - separate / 2, 2 * box_height, linewidth=lw, edgecolor='magenta', facecolor='none', zorder=4) ax.add_patch(rect_32s) window_size = 32.0 left_edge -= window_size rect_64s = patches.Rectangle((left_edge + separate / 2, -box_height), window_size - separate / 2, 2 * box_height, linewidth=lw, edgecolor='red', facecolor='none', zorder=4) ax.add_patch(rect_64s) ax.plot(x, y) #ax.set_ylabel('Strain', rotation=0) ax.set_xlabel('t in s') ax.set_yticklabels([]) ax.set_yticks([]) ax.xaxis.set_label_coords(1.05, 0) #ax.yaxis.set_label_coords(0.05, 0.9) ax.spines['left'].set_color('none') ax.spines['right'].set_color('none') ax.spines['top'].set_color('none') ax.set_ylim((-1.2 * max(abs(y)), 1.2 * max(abs(y)))) plt.savefig(os.path.join(images_path(), 'multirate_filtering.png')) plt.show() return
def main(): x = np.linspace(-2, 2, 1000) y_true = f(x) y_para = g(x) y_over = h(x, 5) x_sample = np.array([-1, 0, 1]) y_sample = f(x_sample) #Sets how many parts the figure has gridsize = (2, 3) #Sets the aspect-ratio of all the small plots #0.25 is the part that sets it to have a usual aspect-ratio of 1 #The factor behind is y / x, (i.e. 3 / 4 for 4:3 final aspect-ratio) global_aspect = 0.25 * 10.0 / 16.0 fig = plt.figure(figsize=(1980.0 / 96, 1080.0 / 96)) plt.rcParams.update({'font.size': 22, 'text.usetex': 'true'}) ax1 = plt.subplot2grid(gridsize, (0, 0), rowspan=2) ax2 = plt.subplot2grid(gridsize, (0, 1)) ax3 = plt.subplot2grid(gridsize, (1, 1)) ax4 = plt.subplot2grid(gridsize, (0, 2)) ax5 = plt.subplot2grid(gridsize, (1, 2)) #Ground trues ax1.set_aspect(global_aspect) ax1.spines['left'].set_position('zero') ax1.spines['bottom'].set_position('zero') ax1.spines['right'].set_color('none') ax1.spines['top'].set_color('none') ax1.set_yticks([5, 10, 15]) ax1.plot(x, y_true, '--', color='black', zorder=1) ax1.scatter(x_sample, y_sample, color='red', zorder=2) #Plot arrow pointing up ax2.set_xlim(-1, 1) ax2.set_ylim(-1, 1) ax2.axis('off') x_start = -0.6 y_start = -0.22 - 0.3 dx = 2 * 0.6 dy = 2 * 0.22 ax2.arrow(x_start, y_start, dx, dy, color='black', width=0.001, head_width=0.075, length_includes_head=True, head_length=0.15) mid_x = x_start + dx / 2 mid_y = y_start + dy / 2 ax2.text(mid_x, mid_y, "Quadratic fit", ha='center', va='top', rotation=rad_to_deg(np.arctan(dy / dx))) #Plot arrow pointing down ax3.set_xlim(-1, 1) ax3.set_ylim(-1, 1) ax3.axis('off') x_start = -0.6 y_start = 0.22 + 0.3 dx = 2 * 0.6 dy = -2 * 0.22 ax3.arrow(x_start, y_start, dx, dy, color='black', width=0.001, head_width=0.075, length_includes_head=True, head_length=0.15) mid_x = x_start + dx / 2 mid_y = y_start + dy / 2 ax3.text(mid_x, mid_y, "Cubic fit", ha='center', va='bottom', rotation=rad_to_deg(np.arctan(dy / dx))) #Parabola regression ax4.set_aspect(global_aspect) ax4.spines['left'].set_position('zero') ax4.spines['bottom'].set_position('zero') ax4.spines['right'].set_color('none') ax4.spines['top'].set_color('none') ax4.set_yticks([5, 10, 15]) ax4.plot(x, y_para, zorder=1) ax4.scatter(x_sample, y_sample, color='red', zorder=2) #Cubic regression ax5.set_ylim(ax4.get_ylim()) ax5.set_aspect(global_aspect) ax5.spines['left'].set_position('zero') ax5.spines['bottom'].set_position('zero') ax5.spines['right'].set_color('none') ax5.spines['top'].set_color('none') ax5.set_yticks([5, 10, 15]) ax5.plot(x, y_true, '--', color='black', zorder=1) ax5.plot(x, y_over, zorder=2) ax5.scatter(x_sample, y_sample, color='red', zorder=3) plt.savefig(os.path.join(images_path(), 'overfitting.png')) plt.show() return
def main(): FontSize = 48 results_path = '/home/marlin/Documents/Documents/Studium/Masterarbeit/Forschungsphase/Code/Git/master_project/bns_net/saves/long_data_2/results' snrSensPath = os.path.join(results_path, 'new_SNR_200_steps_sensitivty.hf5') pSensPath = os.path.join(results_path, 'p_score_200_steps_new_log_sensitivty.hf5') snrSensSnrPath = os.path.join(results_path, 'new_SNR_200_steps_sensitivty_snr.hf5') pSensSnrPath = os.path.join( results_path, 'p_score_200_steps_new_log_sensitivty_snr.hf5') #combinedSnrFalseAlarmPath = os.path.join(results_path, 'combined_snr_100_steps.hf5') #combinedPFalseAlarmPath = os.path.join(results_path, 'combined_snr_100_steps.hf5') #Plot sensitivity as range dpi = 96 plt.rcParams.update({'font.size': FontSize, 'text.usetex': 'true'}) fig, ax = plt.subplots(figsize=(1920.0 / dpi, 1440.0 / dpi), dpi=dpi) plt.rcParams.update({'font.size': FontSize, 'text.usetex': 'true'}) with h5py.File(snrSensPath, 'r') as f: x = f['x'][:] y = f['radius'][:] with h5py.File(pSensPath, 'r') as f: x2 = f['x'][1:-1] y2 = f['radius'][1:-1] ax.semilogx(x, y, label='SNR', linewidth=3) ax.semilogx(x2, y2, label='p-score', linewidth=3) ax.set_xlabel('False alarm per month') ax.set_ylabel('Sensitive distance in Mpc') x_low, x_high = ax.get_xlim() ax.set_xlim(x_high, 9 * 10**-1) ax.grid() ax.legend() plotName = 'SensitivitySNR.png' plt.savefig(os.path.join(images_path(), plotName)) plt.show() #Plot sensitivity as percentage dpi = 96 plt.rcParams.update({'font.size': FontSize, 'text.usetex': 'true'}) fig, ax = plt.subplots(figsize=(1920.0 / dpi, 1440.0 / dpi), dpi=dpi) plt.rcParams.update({'font.size': FontSize, 'text.usetex': 'true'}) with h5py.File(snrSensSnrPath, 'r') as f: x = f['bins'][:] y = f['y'][:] maxIdx = 56 - min(x) + 1 x = x[:maxIdx] / (39.225 * np.sqrt(2)) y = y[:maxIdx] with h5py.File(pSensSnrPath, 'r') as f: x2 = f['bins'][:] y2 = f['y'][:] x2 = x2[:maxIdx] / (39.225 * np.sqrt(2)) y2 = y2[:maxIdx] ax.plot(x, y, label='SNR', linewidth=3) ax.plot(x2, y2, label='p-score', linewidth=3) ax.set_xlabel('pSNR') ax.set_ylabel('Ratio of detected signals') #x_low, x_high = ax.get_xlim() #ax.set_xlim(x_high, 10**-1) ax.grid() ax.legend() plotName = 'SensitivityPercentage.png' plt.savefig(os.path.join(images_path(), plotName)) plt.show() return
def main(): x = np.linspace(-4, 4, 10000) y_1 = np.array([Err_1(pt) for pt in x]) y_2 = np.array([Err_2(pt) for pt in x]) y_3 = np.array([Err_3(pt) for pt in x]) gridsize = (6, 3) #Sets the aspect-ratio of all the small plots #0.25 is the part that sets it to have a usual aspect-ratio of 1 #The factor behind is y / x, (i.e. 3 / 4 for 4:3 final aspect-ratio) global_aspect = 0.25 * 10.0 / 16.0 fig = plt.figure(figsize=(1980.0/96, 1080.0/96)) plt.rcParams.update({'font.size': 22, 'text.usetex': 'true'}) ax1 = plt.subplot2grid(gridsize, (0, 0), rowspan=5) ax2 = plt.subplot2grid(gridsize, (0, 1), rowspan=5) ax3 = plt.subplot2grid(gridsize, (0, 2), rowspan=5) ax4 = plt.subplot2grid(gridsize, (5, 0)) ax5 = plt.subplot2grid(gridsize, (5, 1)) ax6 = plt.subplot2grid(gridsize, (5, 2)) #Plot non squished error ax1.plot(x, y_1) ax1.grid() ax1.set_xlabel('x') ax1.set_ylabel('y') ax1.set_xticks([-4, -2, 0, 2, 4]) #Plot squished error ax2.plot(x, y_2) ax2.grid() ax2.set_xlabel('x') ax2.set_ylabel('y') ax2.set_xticks([-4, -2, 0, 2, 4]) #Plot squished and cutoff error ax3.plot(x, y_3) ax3.grid() ax3.set_xlabel('x') ax3.set_ylabel('y') ax3.set_xticks([-4, -2, 0, 2, 4]) #Put label (a) ax4.set_xlim(-1, 1) ax4.set_ylim(-1, 1) ax4.axis('off') ax4.text(0, 0, '(a)', ha='center', va='bottom') #Put label (b) ax5.set_xlim(-1, 1) ax5.set_ylim(-1, 1) ax5.axis('off') ax5.text(0, 0, '(b)', ha='center', va='bottom') #Put label (c) ax6.set_xlim(-1, 1) ax6.set_ylim(-1, 1) ax6.axis('off') ax6.text(0, 0, '(c)', ha='center', va='bottom') plt.tight_layout() plt.savefig(os.path.join(images_path(), 'loss_evolution.png')) plt.show() return
def main(): FontSize = 48 results_path = '/home/marlin/Documents/Documents/Studium/Masterarbeit/Forschungsphase/Code/Git/master_project/bns_net/saves/long_data_2/results' snrSensPath = os.path.join( results_path, 'combined_steps_P_log_scale_SNR_sensitivity.hf5') pSensPath = os.path.join(results_path, 'combined_steps_P_log_scale_sensitivity.hf5') #combinedSnrFalseAlarmPath = os.path.join(results_path, 'combined_snr_100_steps.hf5') #combinedPFalseAlarmPath = os.path.join(results_path, 'combined_snr_100_steps.hf5') #Plot SNR sensitivity as range with h5py.File(snrSensPath, 'r') as f: x = f['snr'][:] y = f['p-score'][:] z = f['radius'][:] fa = f['xy'][:] per = f['percentage'][:] shape = (int(np.sqrt(len(x))), int(np.sqrt(len(x)))) x = x.reshape(shape) y = y.reshape(shape) z = z.reshape(shape) fa = fa.reshape(shape) per = per.reshape(shape) snr = x[0] p = y.transpose()[0] dpi = 96 plt.rcParams.update({'font.size': FontSize, 'text.usetex': 'true'}) fig, ax = plt.subplots(figsize=(1920.0 / dpi, 1440.0 / dpi), dpi=dpi) plt.rcParams.update({'font.size': FontSize, 'text.usetex': 'true'}) ps = [0.408, 0.5, 0.75, 0.95] colors = ['blue', 'red', 'green', 'black'] for i, pt in enumerate(ps): minIdx = np.argmin(np.abs(p - pt)) lab = p[minIdx] ax.semilogx(fa[minIdx][:-1], z[minIdx][:-1], label='p-score: %.2f' % lab, color=colors[i]) ax.set_xlabel('False alarms per month') ax.set_ylabel('Sensitive distance in Mpc') x_low, x_high = ax.get_xlim() ax.set_xlim(x_high, 9 * 10**-1) #plt.plot([min(snr), max(snr)], [15500, 15500], color='black', linestyle='dotted', label='Upper limit Krastev', linewidth=2) ax.grid() ax.legend() plotName = 'CombinedSensitivitySNR.png' plt.savefig(os.path.join(images_path(), plotName)) plt.show() #Plot SNR percentages dpi = 96 plt.rcParams.update({'font.size': FontSize, 'text.usetex': 'true'}) fig, ax = plt.subplots(figsize=(1920.0 / dpi, 1440.0 / dpi), dpi=dpi) plt.rcParams.update({'font.size': FontSize, 'text.usetex': 'true'}) for i, pt in enumerate(ps): minIdx = np.argmin(np.abs(p - pt)) lab = p[minIdx] ax.semilogx(fa[minIdx], per[minIdx], label='p-score: %.2f' % lab, color=colors[i]) ax.set_xlabel('False alarms per month') ax.set_ylabel('Ratio of detected signals') x_low, x_high = ax.get_xlim() ax.set_xlim(x_high, 10**-1) #plt.plot([min(snr), max(snr)], [15500, 15500], color='black', linestyle='dotted', label='Upper limit Krastev', linewidth=2) ax.grid() ax.legend() plotName = 'CombinedSensitivityPercentageSNR.png' plt.savefig(os.path.join(images_path(), plotName)) plt.show() #Plot p-score sensitivity as range with h5py.File(snrSensPath, 'r') as f: x = f['snr'][:] y = f['p-score'][:] z = f['radius'][:] fa = f['xy'][:] per = f['percentage'][:] shape = (int(np.sqrt(len(x))), int(np.sqrt(len(x)))) x = x.reshape(shape) y = y.reshape(shape) z = z.reshape(shape) fa = fa.reshape(shape) per = per.reshape(shape) snr = x[0] p = y.transpose()[0] dpi = 96 plt.rcParams.update({'font.size': FontSize, 'text.usetex': 'true'}) fig, ax = plt.subplots(figsize=(1920.0 / dpi, 1440.0 / dpi), dpi=dpi) plt.rcParams.update({'font.size': FontSize, 'text.usetex': 'true'}) snrs = [4, 6.7, 8, 15] colors = ['blue', 'red', 'green', 'black'] for i, pt in enumerate(snrs): minIdx = np.argmin(np.abs(snr - pt)) lab = snr[minIdx] ax.semilogx(fa.transpose()[minIdx][:-1], z.transpose()[minIdx][:-1], label='SNR: %.2f' % lab, color=colors[i]) ax.set_xlabel('False alarms per month') ax.set_ylabel('Sensitive distance in Mpc') x_low, x_high = ax.get_xlim() ax.set_xlim(x_high, 9 * 10**-1) #plt.plot([min(snr), max(snr)], [15500, 15500], color='black', linestyle='dotted', label='Upper limit Krastev', linewidth=2) ax.grid() ax.legend() plotName = 'CombinedSensitivityP.png' plt.savefig(os.path.join(images_path(), plotName)) plt.show() #Plot p-score percentages dpi = 96 plt.rcParams.update({'font.size': FontSize, 'text.usetex': 'true'}) fig, ax = plt.subplots(figsize=(1920.0 / dpi, 1440.0 / dpi), dpi=dpi) plt.rcParams.update({'font.size': FontSize, 'text.usetex': 'true'}) for i, pt in enumerate(snrs): minIdx = np.argmin(np.abs(snr - pt)) lab = snr[minIdx] ax.semilogx(fa.transpose()[minIdx], per.transpose()[minIdx], label='SNR: %.2f' % lab, color=colors[i]) ax.set_xlabel('False alarms per month') ax.set_ylabel('Ratio of detected signals') x_low, x_high = ax.get_xlim() ax.set_xlim(x_high, 10**-1) #plt.plot([min(snr), max(snr)], [15500, 15500], color='black', linestyle='dotted', label='Upper limit Krastev', linewidth=2) ax.grid() ax.legend() plotName = 'CombinedSensitivityPercentageP.png' plt.savefig(os.path.join(images_path(), plotName)) plt.show() return
def main(): FontSize = 48 results_path = '/home/marlin/Documents/Documents/Studium/Masterarbeit/Forschungsphase/Code/Git/master_project/bns_net/saves/long_data_2/results' snrFalseAlarmPath = os.path.join(results_path, 'SNR_200_steps_false_alarm.hf5') pFalseAlarmPath = os.path.join( results_path, 'p_score_200_steps_new_log_false_alarm.hf5') #combinedSnrFalseAlarmPath = os.path.join(results_path, 'combined_snr_100_steps.hf5') #combinedPFalseAlarmPath = os.path.join(results_path, 'combined_snr_100_steps.hf5') #Plot SNR false alarm rate dpi = 96 plt.figure(figsize=(1920.0 / dpi, 1440.0 / dpi), dpi=dpi) plt.rcParams.update({'font.size': FontSize, 'text.usetex': 'true'}) with h5py.File(snrFalseAlarmPath, 'r') as f: x = f['x'][:] y = f['y'][:] plt.semilogy(x, y, label='Our network') plt.xlabel('SNR') plt.ylabel('False alarms per month') plt.plot([min(x), max(x)], [15500, 15500], color='black', linestyle='dotted', label='Upper limit Krastev', linewidth=2) y_low, y_high = plt.ylim() plt.ylim(9 * 10**-1, y_high) plt.grid() plt.legend() plotName = 'FalseAlarmSNR.png' plt.savefig(os.path.join(images_path(), plotName)) plt.show() #Plot p-score false alarm rate dpi = 96 plt.figure(figsize=(1920.0 / dpi, 1440.0 / dpi), dpi=dpi) plt.rcParams.update({'font.size': FontSize, 'text.usetex': 'true'}) with h5py.File(pFalseAlarmPath, 'r') as f: x = f['x'][1:] y = f['y'][1:] plt.semilogy(x, y, label='Our network') plt.xlabel('p-score') plt.ylabel('False alarms per month') plt.plot([min(x), max(x)], [15500, 15500], color='black', linestyle='dotted', label='Upper limit Krastev', linewidth=2) y_low, y_high = plt.ylim() plt.ylim(9 * 10**-1, y_high) plt.grid() plt.legend() plotName = 'FalseAlarmP.png' plt.savefig(os.path.join(images_path(), plotName)) plt.show() #Plot p-score false alarm rate 2 dpi = 96 plt.figure(figsize=(1920.0 / dpi, 1440.0 / dpi), dpi=dpi) plt.rcParams.update({'font.size': FontSize, 'text.usetex': 'true'}) with h5py.File(pFalseAlarmPath, 'r') as f: x = -np.log(1 - f['x'][1:]) y = f['y'][1:] plt.loglog(x, y, label='Our network') plt.plot([plt.xlim()[0], plt.xlim()[1]], [15500, 15500], color='black', linestyle='dotted', label='Upper limit Krastev', linewidth=2) plt.xlabel('$-\log (1-$p-score$)$') plt.ylabel('False alarms per month') y_low, y_high = plt.ylim() plt.ylim(9 * 10**-1, y_high) plt.grid() #plt.ylim(plt.ylim()[0], 100000) plt.legend() plotName = 'FalseAlarmP2.png' plt.savefig(os.path.join(images_path(), plotName)) plt.show() return
def main(): FontSize = 48 results_path = '/home/marlin/Documents/Documents/Studium/Masterarbeit/Forschungsphase/Code/Git/master_project/bns_net/saves/long_data_2/results' snrFalseAlarmPath = os.path.join( results_path, 'combined_steps_P_log_scale_SNR_false_alarm.hf5') pFalseAlarmPath = os.path.join( results_path, 'combined_steps_P_log_scale_false_alarm.hf5') #combinedSnrFalseAlarmPath = os.path.join(results_path, 'combined_snr_100_steps.hf5') #combinedPFalseAlarmPath = os.path.join(results_path, 'combined_snr_100_steps.hf5') #Plot SNR false alarm rate dpi = 96 plt.figure(figsize=(1920.0 / dpi, 1440.0 / dpi), dpi=dpi) plt.rcParams.update({'font.size': FontSize, 'text.usetex': 'true'}) with h5py.File(snrFalseAlarmPath, 'r') as f: x = f['x'][:] y = f['y'][:] z = f['z'][:] shape = (int(np.sqrt(len(x))), int(np.sqrt(len(x)))) x = x.reshape(shape) y = y.reshape(shape) z = z.reshape(shape) snr = x[0] p = y.transpose()[0] ps = [0.408, 0.5, 0.75, 0.95] colors = ['blue', 'red', 'green', 'black'] for i, pt in enumerate(ps): minIdx = np.argmin(np.abs(p - pt)) lab = p[minIdx] plt.semilogy(x[0], z[minIdx], label='p-score: %.2f' % lab, color=colors[i]) print("False alarm rate SNR at p-score: %.2f" % lab) print("Max (x, y): ({}, {})".format(x[0][0], z[minIdx][0])) print("Min (x, y): ({}, {})".format(x[0][-1], z[minIdx][-1])) plt.xlabel('SNR') plt.ylabel('False alarms per month') #plt.plot([min(snr), max(snr)], [15500, 15500], color='black', linestyle='dotted', label='Upper limit Krastev', linewidth=2) y_low, y_high = plt.ylim() #plt.ylim(10**-1, y_high) plt.ylim(9 * 10**-1, 2 * 10**3) plt.grid() plt.legend() plotName = 'CombinedFalseAlarmSNR.png' plt.savefig(os.path.join(images_path(), plotName)) plt.show() #Plot p-score false alarm rate dpi = 96 plt.figure(figsize=(1920.0 / dpi, 1440.0 / dpi), dpi=dpi) plt.rcParams.update({'font.size': FontSize, 'text.usetex': 'true'}) with h5py.File(pFalseAlarmPath, 'r') as f: x = f['x'][:] y = f['y'][:] z = f['z'][:] shape = (int(np.sqrt(len(x))), int(np.sqrt(len(x)))) x = x.reshape(shape) y = y.reshape(shape) z = z.reshape(shape) snr = x[0] p = y.transpose()[0] snrs = [4, 6.7, 8, 15] colors = ['blue', 'red', 'green', 'black'] for i, pt in enumerate(snrs): minIdx = np.argmin(np.abs(snr - pt)) lab = snr[minIdx] plt.semilogy(y.transpose()[0], z.transpose()[minIdx], label='SNR: %.2f' % lab, color=colors[i]) print("False alarm rate p-score at SNR: %.2f" % lab) print("Max (x, y): ({}, {})".format(y.transpose()[0][0], z.transpose()[minIdx][0])) print("Min (x, y): ({}, {})".format(y.transpose()[0][-2], z.transpose()[minIdx][-2])) plt.xlabel('p-score') plt.ylabel('False alarms per month') #plt.plot([min(p), max(p)], [15500, 15500], color='black', linestyle='dotted', label='Upper limit Krastev', linewidth=2) y_low, y_high = plt.ylim() #plt.ylim(10**-1, y_high) plt.ylim(9 * 10**-1, 2 * 10**3) plt.grid() plt.legend() plotName = 'CombinedFalseAlarmP.png' plt.savefig(os.path.join(images_path(), plotName)) plt.show() #Plot p-score false alarm rate 2 dpi = 96 plt.figure(figsize=(1920.0 / dpi, 1440.0 / dpi), dpi=dpi) plt.rcParams.update({'font.size': FontSize, 'text.usetex': 'true'}) with h5py.File(pFalseAlarmPath, 'r') as f: x = f['x'][:] y = -np.log(1 - f['y'][:]) z = f['z'][:] shape = (int(np.sqrt(len(x))), int(np.sqrt(len(x)))) x = x.reshape(shape) y = y.reshape(shape) z = z.reshape(shape) snr = x[0] p = y.transpose()[0] snrs = [4, 6.7, 8, 15] colors = ['blue', 'red', 'green', 'black'] for i, pt in enumerate(snrs): minIdx = np.argmin(np.abs(snr - pt)) lab = snr[minIdx] plt.loglog(y.transpose()[0], z.transpose()[minIdx], label='SNR: %.2f' % lab, color=colors[i]) plt.xlabel('$-\log (1-$p-score$)$') plt.ylabel('False alarms per month') #plt.plot([min(p), max(p)], [15500, 15500], color='black', linestyle='dotted', label='Upper limit Krastev', linewidth=2) y_low, y_high = plt.ylim() #plt.ylim(9*10**-1, y_high) plt.ylim(9 * 10**-1, 2 * 10**3) plt.grid() plt.legend() plotName = 'CombinedFalseAlarmP2.png' plt.savefig(os.path.join(images_path(), plotName)) plt.show() ##Plot p-score false alarm rate 2 #dpi = 96 #plt.figure(figsize=(1920.0/dpi, 1440.0/dpi), dpi=dpi) #plt.rcParams.update({'font.size': 32, 'text.usetex': 'true'}) #with h5py.File(pFalseAlarmPath, 'r') as f: #x = -np.log(1-f['x'][1:]) #y = f['y'][1:] #plt.loglog(x, y, label='Our network') #plt.plot([plt.xlim()[0], plt.xlim()[1]], [15500, 15500], color='black', linestyle='dotted', label='Upper limit Krastev', linewidth=2) #plt.xlabel('$-\log (1-$p-score$)$') #plt.ylabel('False alarms per month') #plt.grid() ##plt.ylim(plt.ylim()[0], 100000) #plt.legend() #plotName = 'CombinedFalseAlarmP2.png' #plt.savefig(os.path.join(images_path(), plotName)) #plt.show() return