ZH: use path.basename(__file__) for figure names

This commit is contained in:
Eric Teunis de Boone 2023-01-04 11:05:20 +01:00
parent ee9497b140
commit 1d6f0d3b36
5 changed files with 12 additions and 12 deletions

View file

@ -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()

View file

@ -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:

View file

@ -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()

View file

@ -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()

View file

@ -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()