Added function save_image to save multiple figures in a single pdf
This commit is contained in:
@ -26,6 +26,7 @@ import ipywidgets as widgets
|
|||||||
from IPython.display import display, clear_output
|
from IPython.display import display, clear_output
|
||||||
|
|
||||||
|
|
||||||
|
from matplotlib.backends.backend_pdf import PdfPages
|
||||||
|
|
||||||
# %% Functions for listing files with specific string in name
|
# %% Functions for listing files with specific string in name
|
||||||
|
|
||||||
@ -1939,7 +1940,7 @@ def process_pbp_parquet(dir_path_pbp, dir_path_hk,
|
|||||||
ddf_hk['temporary_col'] = 1
|
ddf_hk['temporary_col'] = 1
|
||||||
|
|
||||||
ddf_hk_1s = ddf_hk[['Sample Flow Controller Read (sccm)',
|
ddf_hk_1s = ddf_hk[['Sample Flow Controller Read (sccm)',
|
||||||
'Sample Flow Controller Read (vccm)']].resample(dt_str).mean()
|
'Sample Flow Controller Read (vccm)']].resample(dt_str).mean() # do i need a fill na here?
|
||||||
ddf_hk_1s[['original_idx']] = ddf_hk[['temporary_col']].resample(dt_str).count()
|
ddf_hk_1s[['original_idx']] = ddf_hk[['temporary_col']].resample(dt_str).count()
|
||||||
|
|
||||||
ddf_hk_1s = ddf_hk_1s[ddf_hk_1s['original_idx'] != 0]
|
ddf_hk_1s = ddf_hk_1s[ddf_hk_1s['original_idx'] != 0]
|
||||||
@ -1971,10 +1972,11 @@ def process_pbp_parquet(dir_path_pbp, dir_path_hk,
|
|||||||
ddf_pbp_hk['S_numConc_within_range_std'] = ddf_pbp_hk['Scatt numb within range'] / (ddf_pbp_hk['Sample Flow Controller Read (sccm)'] * (dt/60))
|
ddf_pbp_hk['S_numConc_within_range_std'] = ddf_pbp_hk['Scatt numb within range'] / (ddf_pbp_hk['Sample Flow Controller Read (sccm)'] * (dt/60))
|
||||||
ddf_pbp_hk['S_numConc_within_range_vol'] = ddf_pbp_hk['Scatt numb within range'] / (ddf_pbp_hk['Sample Flow Controller Read (vccm)'] * (dt/60))
|
ddf_pbp_hk['S_numConc_within_range_vol'] = ddf_pbp_hk['Scatt numb within range'] / (ddf_pbp_hk['Sample Flow Controller Read (vccm)'] * (dt/60))
|
||||||
|
|
||||||
ddf_pbp['temporary_col'] = 1
|
|
||||||
|
|
||||||
|
|
||||||
# Calculate histograms of different classifications/flags:
|
# Calculate histograms of different classifications/flags:
|
||||||
|
ddf_pbp['temporary_col'] = 1
|
||||||
|
|
||||||
dNdlogDmev, dMdlogDmev = process_hist_and_dist(ddf_pbp, 'BC mass within range', None, None, inc_mass_bin_lims, inc_mass_bin_ctrs, dt_str, flow=ddf_pbp_hk['Sample Flow Controller Read (vccm)'], rho_eff=rho_eff, BC_type=BC_type)
|
dNdlogDmev, dMdlogDmev = process_hist_and_dist(ddf_pbp, 'BC mass within range', None, None, inc_mass_bin_lims, inc_mass_bin_ctrs, dt_str, flow=ddf_pbp_hk['Sample Flow Controller Read (vccm)'], rho_eff=rho_eff, BC_type=BC_type)
|
||||||
dNdlogDmev_thin, dMdlogDmev_thin = process_hist_and_dist(ddf_pbp, 'BC mass within range', 'cnts_thin', 1, inc_mass_bin_lims, inc_mass_bin_ctrs, dt_str, flow=ddf_pbp_hk['Sample Flow Controller Read (vccm)'], rho_eff=rho_eff, BC_type=BC_type)
|
dNdlogDmev_thin, dMdlogDmev_thin = process_hist_and_dist(ddf_pbp, 'BC mass within range', 'cnts_thin', 1, inc_mass_bin_lims, inc_mass_bin_ctrs, dt_str, flow=ddf_pbp_hk['Sample Flow Controller Read (vccm)'], rho_eff=rho_eff, BC_type=BC_type)
|
||||||
@ -2151,3 +2153,22 @@ def raw_traces_plot(ch0_plot=[], ch1_plot=[],
|
|||||||
display(widgets.HBox([backward_button, forward_button]))
|
display(widgets.HBox([backward_button, forward_button]))
|
||||||
interactive_plot = widgets.interactive(update_plot, event_index=event_slider)
|
interactive_plot = widgets.interactive(update_plot, event_index=event_slider)
|
||||||
display(interactive_plot)
|
display(interactive_plot)
|
||||||
|
|
||||||
|
|
||||||
|
#%% Functions for plots
|
||||||
|
|
||||||
|
|
||||||
|
def save_image(filename):
|
||||||
|
|
||||||
|
with PdfPages(filename) as p:
|
||||||
|
|
||||||
|
# get_fignums Return list of existing
|
||||||
|
# figure numbers
|
||||||
|
fig_nums = plt.get_fignums()
|
||||||
|
figs = [plt.figure(n) for n in fig_nums]
|
||||||
|
|
||||||
|
# iterating over the numbers in list
|
||||||
|
for fig in figs:
|
||||||
|
|
||||||
|
# and saving the files
|
||||||
|
fig.savefig(p, format='pdf')
|
Reference in New Issue
Block a user