Skip to content

Commit

Permalink
Merge pull request #18 from qt3uw/figure_folders
Browse files Browse the repository at this point in the history
Figures from figures234.py were not being saved. Now, directories are and the figures are saved in those directories.
  • Loading branch information
robert-academic authored Nov 20, 2024
2 parents 60fbb66 + d669070 commit 90b750e
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions figures234.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
}
pixel_size_mm = 0.0164935065
fname = 'data/raw_micromotion/8-18_Trial18_data.txt'
fig_dir = ["figures/figure_" + str(i) + "/" for i in range(2, 5)]

def get_default_trap():
"""
Expand All @@ -42,7 +43,8 @@ def y_cuts_panel():
trap.v_dc = -80.
fig, ax = trap.plot_y_cuts(include_gaps=True, figsize=(3.5, 3))
fig.tight_layout()
fig.savefig('figures/figure_2/fig2-y-cuts.pdf')
os.makedirs(fig_dir[0], exist_ok =True)
fig.savefig(fig_dir[0]+"fig2-y-cuts.pdf")

def e_field_panel():
"""
Expand All @@ -51,7 +53,9 @@ def e_field_panel():
trap = get_default_trap()
figp, axp = trap.plot_E_field(include_gaps=True, x_range=(-trap.c, trap.a + trap.b), normalized = False,
resolution=(256, 256), figsize=(6, 3.5))
figp.savefig('figures/figure_2/fig2-efield.pdf')
os.makedirs(fig_dir[0], exist_ok =True)
figp.savefig(fig_dir[0]+"fig2-efield.pdf")


def potential_energy_panel():
"""
Expand All @@ -69,7 +73,8 @@ def potential_energy_panel():
a.set_ylabel('y (mm)')
ax.set_title(None)
fig.tight_layout()
fig.savefig('figures/figure_2/fig2-potential_energy.pdf')
os.makedirs(fig_dir[0], exist_ok =True)
fig.savefig(fig_dir[0]+"fig2-potential_energy.pdf")

def get_data(fname):
"""
Expand Down Expand Up @@ -164,7 +169,8 @@ def merit_func(args):
ax.grid(True)
ax.legend(handles = [method_1, method_2])
fig.tight_layout()
fig.savefig('figures/figure_4/fig4-height_fit.pdf')
os.makedirs(fig_dir[2], exist_ok =True)
fig.savefig(fig_dir[2]+"fig4-height_fit.pdf")
return trap

def plot_escape(figsize=(3.5, 3)):
Expand All @@ -179,7 +185,8 @@ def plot_escape(figsize=(3.5, 3)):
ax.set_title(None)
plt.gca().invert_yaxis()
fig.tight_layout()
fig.savefig('figures/figure_4/fig4-trap_escape.pdf')
os.makedirs(fig_dir[2], exist_ok =True)
fig.savefig(fig_dir[2]+"fig4-trap_escape.pdf")

def plot_height_and_micro(pixelsize_error, figsize=(3.5, 3)):
voltage, height, micromotion, v_min, y_min, micro_min, c2m, minvolt_raw, RF_height = get_data(fname)
Expand All @@ -203,7 +210,8 @@ def plot_height_and_micro(pixelsize_error, figsize=(3.5, 3)):
ax2.axhline(RF_height, color='black', alpha=0.6)
ax2.legend(['Height', 'RF Null', 'Micromotion'], fontsize=18, loc='upper left')
ax2.axvline(minvolt_raw, color='black', alpha=0.6)
fig.savefig('figures/figure_3/fig3-height-micro-plot.pdf')
os.makedirs(fig_dir[1], exist_ok =True)
fig.savefig(fig_dir[1]+"fig3-height-micro-plot.pdf")
plt.show()

def plot_c2m_hist(folder):
Expand All @@ -219,7 +227,9 @@ def plot_c2m_hist(folder):
plt.axvline(x=-0.0005, color='black', linestyle='--', linewidth=0.5, alpha=0.5)
plt.xlabel('Charge-to-Mass Ratio (C/kg)')
plt.ylabel('Number of Occurrences')
plt.savefig('figures/figure_3/fig3-histogram.pdf')
os.makedirs(fig_dir[1], exist_ok =True)
plt.savefig(fig_dir[1]+"fig3-histogram.pdf")




Expand Down

0 comments on commit 90b750e

Please sign in to comment.