Skip to content

Commit

Permalink
Add arg for plotting, add saving, default bgmap to not plot.
Browse files Browse the repository at this point in the history
  • Loading branch information
msilvafe committed May 25, 2023
1 parent 37ebf67 commit 6c19fbf
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions sodetlib/operations/bias_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -997,7 +997,8 @@ def plot_Rfrac(bsa, text_loc=(0.6, 0.8)):
def take_bgmap(S, cfg, bgs=None, dc_voltage=0.3, step_voltage=0.01,
step_duration=0.05, nsteps=20, high_current_mode=True,
hcm_wait_time=0, analysis_kwargs=None, dacs='pos',
use_waveform=True, show_plots=True,g3_tag=None):
use_waveform=True, show_plots=True, g3_tag=None, plot_rfrac=False,
show_plots=False):
"""
Function to easily create a bgmap. This will set all bias group voltages
to 0 (since this is best for generating the bg map), and run bias-steps
Expand Down Expand Up @@ -1039,6 +1040,10 @@ def take_bgmap(S, cfg, bgs=None, dc_voltage=0.3, step_voltage=0.01,
g3_tag: string, optional
if not None, overrides the default tag "oper,bgmap" sent to the g3
file
plot_rfrac : bool
Create rfrac plot, publish it, and save it. Default is False.
show_plots : bool
Show plot in addition to saving when running interactively. Default is False.
"""
if bgs is None:
bgs = cfg.dev.exp['active_bgs']
Expand All @@ -1062,8 +1067,8 @@ def take_bgmap(S, cfg, bgs=None, dc_voltage=0.3, step_voltage=0.01,
S, cfg, bgs, step_voltage=step_voltage, step_duration=step_duration,
nsteps=nsteps, high_current_mode=high_current_mode,
hcm_wait_time=hcm_wait_time, run_analysis=True, dacs=dacs,
use_waveform=use_waveform, g3_tag=g3_tag,
analysis_kwargs=_analysis_kwargs
use_waveform=use_waveform, g3_tag=g3_tag, plot_rfrac=plot_rfrac,
show_plots=show_plots, analysis_kwargs=_analysis_kwargs
)

if hasattr(bsa, 'bgmap'):
Expand All @@ -1081,7 +1086,8 @@ def take_bgmap(S, cfg, bgs=None, dc_voltage=0.3, step_voltage=0.01,
def take_bias_steps(S, cfg, bgs=None, step_voltage=0.05, step_duration=0.05,
nsteps=20, high_current_mode=True, hcm_wait_time=3,
run_analysis=True, analysis_kwargs=None, dacs='pos',
use_waveform=True, channel_mask=None, g3_tag=None):
use_waveform=True, channel_mask=None, g3_tag=None,
plot_rfrac=True, show_plots=False):
"""
Takes bias step data at the current DC voltage. Assumes bias lines
are already in low-current mode (if they are in high-current this will
Expand Down Expand Up @@ -1132,6 +1138,10 @@ def take_bias_steps(S, cfg, bgs=None, step_voltage=0.05, step_duration=0.05,
g3_tag: string, optional
if not None, overrides the default tag "oper,bias_steps" sent to the
g3 file
plot_rfrac : bool
Create rfrac plot, publish it, and save it. Default is True.
show_plots : bool
Show plot in addition to saving when running interactively. Default is False.
"""
if bgs is None:
bgs = cfg.dev.exp['active_bgs']
Expand Down Expand Up @@ -1205,7 +1215,13 @@ def take_bias_steps(S, cfg, bgs=None, step_voltage=0.05, step_duration=0.05,
if analysis_kwargs is None:
analysis_kwargs = {}
bsa.run_analysis(save=True, **analysis_kwargs)
plot_Rfrac(bsa)
if plot_rfrac:
fig, ax = plot_Rfrac(bsa)
path = sdl.make_filename(S, 'bs_rfrac_summary.png', plot=True)
fig.savefig(path)
S.pub.register_file(path, 'bs_rfrac_summary', plot=True, format='png')
if not show_plots:
plt.close(fig)
except Exception:
print(f"Bias step analysis failed with exception:")
print(traceback.format_exc())
Expand Down

0 comments on commit 6c19fbf

Please sign in to comment.