From 1d6f0d3b36a8c163fbdb231bd49f52e8159d1663 Mon Sep 17 00:00:00 2001 From: Eric Teunis de Boone Date: Wed, 4 Jan 2023 11:05:20 +0100 Subject: [PATCH] ZH: use path.basename(__file__) for figure names --- .../ba_measure_beacon_phase.py | 8 ++++---- .../bb_measure_true_phase.py | 2 +- .../bc_baseline_phase_deltas.py | 2 +- .../bd_antenna_phase_deltas.py | 10 +++++----- .../ca_period_from_shower.py | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/simulations/airshower_beacon_simulation/ba_measure_beacon_phase.py b/simulations/airshower_beacon_simulation/ba_measure_beacon_phase.py index ad16f2e..7da7f03 100755 --- a/simulations/airshower_beacon_simulation/ba_measure_beacon_phase.py +++ b/simulations/airshower_beacon_simulation/ba_measure_beacon_phase.py @@ -199,10 +199,10 @@ if __name__ == "__main__": old_xlims = ax.get_xlim() ax.set_xlim(min(t_trace)-t_0-10,min(t_trace)-t_0+40) - fig.savefig(path.join(fig_dir, __file__ + f".A{h5ant.attrs['name']}.zoomed.pdf")) + fig.savefig(path.join(fig_dir, path.basename(__file__) + f".A{h5ant.attrs['name']}.zoomed.pdf")) ax.set_xlim(*old_xlims) - fig.savefig(path.join(fig_dir, __file__ + f".A{h5ant.attrs['name']}.pdf")) + fig.savefig(path.join(fig_dir, path.basename(__file__) + f".A{h5ant.attrs['name']}.pdf")) # save to file h5beacon_info = h5ant.require_group('beacon_info') @@ -236,7 +236,7 @@ if __name__ == "__main__": ax.axvline(f_beacon, ls='dashed', color='g') ax.hist(found_data[:,0], bins='sqrt', density=False) if fig_dir: - fig.savefig(path.join(fig_dir, __file__ + f".hist_freq.pdf")) + fig.savefig(path.join(fig_dir, path.basename(__file__) + f".hist_freq.pdf")) if True: fig, ax = plt.subplots() @@ -244,7 +244,7 @@ if __name__ == "__main__": ax.set_ylabel("Counts") ax.hist(found_data[:,2], bins='sqrt', density=False) if fig_dir: - fig.savefig(path.join(fig_dir, __file__ + f".hist_amp.pdf")) + fig.savefig(path.join(fig_dir, path.basename(__file__) + f".hist_amp.pdf")) if show_plots: plt.show() diff --git a/simulations/airshower_beacon_simulation/bb_measure_true_phase.py b/simulations/airshower_beacon_simulation/bb_measure_true_phase.py index f766e1b..0c3e6b5 100755 --- a/simulations/airshower_beacon_simulation/bb_measure_true_phase.py +++ b/simulations/airshower_beacon_simulation/bb_measure_true_phase.py @@ -103,7 +103,7 @@ if __name__ == "__main__": ax.plot(tx.x, tx.y, 'X', color='k', markeredgecolor='white') if fig_dir: - fig.savefig(path.join(fig_dir, __file__ + f".F{freq_name}.pdf")) + fig.savefig(path.join(fig_dir, path.basename(__file__) + f".F{freq_name}.pdf")) # Plot True Phases - Actual True Phases at their location if show_plots or fig_dir: diff --git a/simulations/airshower_beacon_simulation/bc_baseline_phase_deltas.py b/simulations/airshower_beacon_simulation/bc_baseline_phase_deltas.py index e8b5fec..70c4512 100755 --- a/simulations/airshower_beacon_simulation/bc_baseline_phase_deltas.py +++ b/simulations/airshower_beacon_simulation/bc_baseline_phase_deltas.py @@ -142,7 +142,7 @@ if __name__ == "__main__": extra_name = "measured" if plot_residuals: extra_name = "residuals" - fig.savefig(path.join(fig_dir, __file__ + f".{extra_name}.F{freq_name}.pdf")) + fig.savefig(path.join(fig_dir, path.basename(__file__) + f".{extra_name}.F{freq_name}.pdf")) if show_plots: plt.show() diff --git a/simulations/airshower_beacon_simulation/bd_antenna_phase_deltas.py b/simulations/airshower_beacon_simulation/bd_antenna_phase_deltas.py index 91bb818..0d3bcf0 100755 --- a/simulations/airshower_beacon_simulation/bd_antenna_phase_deltas.py +++ b/simulations/airshower_beacon_simulation/bd_antenna_phase_deltas.py @@ -74,7 +74,7 @@ if __name__ == "__main__": fig.colorbar(im, ax=ax) if fig_dir: - fig.savefig(path.join(fig_dir, __file__ + f".matrix.original.pdf")) + fig.savefig(path.join(fig_dir, path.basename(__file__) + f".matrix.original.pdf")) plt.close(fig) @@ -97,7 +97,7 @@ if __name__ == "__main__": fig.colorbar(im, ax=ax) if fig_dir: - fig.savefig(path.join(fig_dir, __file__ + f".matrix.first_row.pdf")) + fig.savefig(path.join(fig_dir, path.basename(__file__) + f".matrix.first_row.pdf")) plt.close(fig) @@ -132,7 +132,7 @@ if __name__ == "__main__": axs[1].scatter(np.arange(N_ant), mean_sigma_phase, c=colours,s=4) if fig_dir: - fig.savefig(path.join(fig_dir, __file__ + f".matrix.modified.pdf")) + fig.savefig(path.join(fig_dir, path.basename(__file__) + f".matrix.modified.pdf")) plt.close(fig) @@ -215,7 +215,7 @@ if __name__ == "__main__": extra_name = "measured" if plot_residuals: extra_name = "residuals" - fig.savefig(path.join(fig_dir, __file__ + f".phase.{extra_name}.pdf")) + fig.savefig(path.join(fig_dir, path.basename(__file__) + f".phase.{extra_name}.pdf")) ########################## ########################## @@ -259,7 +259,7 @@ if __name__ == "__main__": extra_name = '' if i == 1: extra_name = '.wrapped' - fig.savefig(path.join(fig_dir, __file__ + f".time_comparison{extra_name}.pdf")) + fig.savefig(path.join(fig_dir, path.basename(__file__) + f".time_comparison{extra_name}.pdf")) if show_plots: plt.show() diff --git a/simulations/airshower_beacon_simulation/ca_period_from_shower.py b/simulations/airshower_beacon_simulation/ca_period_from_shower.py index ee03958..6ca54df 100755 --- a/simulations/airshower_beacon_simulation/ca_period_from_shower.py +++ b/simulations/airshower_beacon_simulation/ca_period_from_shower.py @@ -110,7 +110,7 @@ def find_best_sample_shifts_summing_at_location(test_loc, antennas, allowed_samp ax.legend( ncol=5 ) if fig_dir: fig.tight_layout() - fname = path.join(fig_dir, __file__ + f'.{fig_distinguish}i{i}' + '.loc{:.1f}-{:.1f}-{:.1f}'.format(*test_loc)) + fname = path.join(fig_dir, path.basename(__file__) + f'.{fig_distinguish}i{i}' + '.loc{:.1f}-{:.1f}-{:.1f}'.format(*test_loc)) if True: old_xlim = ax.get_xlim()