Skip to content

Commit

Permalink
Fixes G3 stream tagging in biasstep_rebias (#398)
Browse files Browse the repository at this point in the history
  • Loading branch information
jlashner authored Dec 5, 2023
1 parent c7bc197 commit 56d04ce
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions sodetlib/operations/bias_dets.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ def bias_to_rfrac(S, cfg, rfrac=0.5, bias_groups=None, iva=None,

sdl.set_action()
def biasstep_rebias(
S, cfg, target_percentage_rn = 0.5, bias_groups=None,
show_plots=True, make_plots=True):
S, cfg, target_percentage_rn=0.5, bias_groups=None,
show_plots=True, make_plots=True, g3_tag=None):

"""
re-bias detectors by taking bias_steps.
Expand All @@ -226,6 +226,8 @@ def biasstep_rebias(
generate plots
show_plots : bool
If this is set to False, the script will not show plots
g3_tag : str
User settable tag for g3 streams
Returns
----------
Expand All @@ -238,12 +240,12 @@ def biasstep_rebias(
bias_groups = cfg.dev.exp['active_bgs']
bias_groups = np.atleast_1d(bias_groups)

g3_tag = 'oper,biasstep_rebias'
bs_kwargs = dict(g3_tag=g3_tag, stream_subtype='biasstep_rebias')

## take the initial biasstep
S.log("taking the first biasstep")
S.log(f"Initial dc biases {S.get_tes_bias_bipolar_array()}")
bsa_0 = bias_steps.take_bias_steps(S, cfg, g3_tag=g3_tag)
bsa_0 = bias_steps.take_bias_steps(S, cfg, **bs_kwargs)
if make_plots:
fig, ax = bias_steps.plot_Rfrac(bsa_0)
fname = sdl.make_filename(S, 'intial_Rfrac.png', plot=True)
Expand All @@ -268,7 +270,7 @@ def biasstep_rebias(

if repeat_biasstep:
S.log("retaking biasstep due to failure")
bsa_0 = bias_steps.take_bias_steps(S, cfg, g3_tag=g3_tag)
bsa_0 = bias_steps.take_bias_steps(S, cfg, **bs_kwargs)
repeat_biasstep = False

percentage_rn_0 = bsa_0.R0/bsa_0.R_n_IV
Expand Down Expand Up @@ -318,7 +320,7 @@ def biasstep_rebias(


S.set_tes_bias_bipolar_array(safe_dc_biases)
bsa_0 = bias_steps.take_bias_steps(S, cfg, g3_tag=g3_tag)
bsa_0 = bias_steps.take_bias_steps(S, cfg, **bs_kwargs)
if make_plots:
fig, ax = bias_steps.plot_Rfrac(bsa_0)
fname = sdl.make_filename(S, 'post_overbiasing_Rfrac.png', plot=True)
Expand Down Expand Up @@ -364,7 +366,7 @@ def biasstep_rebias(
S.log(f"applying: {previous_dc_biases_dfn}")
S.log(f"waiting 10s for dissipation of UFM local heating")
time.sleep(10)
bsa_0 = bias_steps.take_bias_steps(S, cfg, g3_tag=g3_tag)
bsa_0 = bias_steps.take_bias_steps(S, cfg, **bs_kwargs)
percentage_rn_0 = bsa_0.R0/bsa_0.R_n_IV
drop_from_normal = False
for bl in bg_detectors_normal:
Expand Down Expand Up @@ -417,7 +419,7 @@ def biasstep_rebias(

## taking the second bias step
S.log("taking the 2nd biasstep")
bsa_1 = bias_steps.take_bias_steps(S, cfg, g3_tag=g3_tag)
bsa_1 = bias_steps.take_bias_steps(S, cfg, **bs_kwargs)
if make_plots:
fig, ax = bias_steps.plot_Rfrac(bsa_1)
fname = sdl.make_filename(S, '2nd_Rfrac.png', plot=True)
Expand All @@ -436,7 +438,7 @@ def biasstep_rebias(
S.log("the biasstep script might have failed, going to repeat the measurement")

if repeat_biasstep:
bsa_1 = bias_steps.take_bias_steps(S, cfg, g3_tag=g3_tag)
bsa_1 = bias_steps.take_bias_steps(S, cfg, **bs_kwargs)
repeat_biasstep = False

percentage_rn_1 = bsa_1.R0/bsa_1.R_n_IV
Expand Down Expand Up @@ -469,7 +471,7 @@ def biasstep_rebias(
S.set_tes_bias_bipolar_array(vbias_estimate)
S.log(f"applying {vbias_estimate}")
S.log("taking the final biasstep")
bsa_2 = bias_steps.take_bias_steps(S, cfg, g3_tag=g3_tag)
bsa_2 = bias_steps.take_bias_steps(S, cfg, **bs_kwargs)

## check for script failue
for bl in bias_groups:
Expand All @@ -481,7 +483,7 @@ def biasstep_rebias(
S.log("the biasstep script might have failed, going to repeat the measurement")

if repeat_biasstep:
bsa_2 = bias_steps.take_bias_steps(S, cfg, g3_tag=g3_tag)
bsa_2 = bias_steps.take_bias_steps(S, cfg, **bs_kwargs)
repeat_biasstep = False

if make_plots:
Expand Down Expand Up @@ -537,7 +539,7 @@ def biasstep_rebias(

## taking the extra bias step
S.log("taking the extra biasstep")
bsa_extra = bias_steps.take_bias_steps(S, cfg, g3_tag=g3_tag)
bsa_extra = bias_steps.take_bias_steps(S, cfg, **bs_kwargs)

## check for script failue
for bl in bias_groups:
Expand All @@ -549,7 +551,7 @@ def biasstep_rebias(
S.log("the biasstep script might have failed, going to repeat the measurement")

if repeat_biasstep:
bsa_extra = bias_steps.take_bias_steps(S, cfg, g3_tag=g3_tag)
bsa_extra = bias_steps.take_bias_steps(S, cfg, **bs_kwargs)
repeat_biasstep = False

if make_plots:
Expand Down Expand Up @@ -590,7 +592,7 @@ def biasstep_rebias(
S.set_tes_bias_bipolar_array(vbias_estimate_final)
S.log(f"applying {vbias_estimate_final}")
S.log("taking the final biasstep")
bsa_final = bias_steps.take_bias_steps(S, cfg, g3_tag=g3_tag)
bsa_final = bias_steps.take_bias_steps(S, cfg, **bs_kwargs)
if make_plots:
fig, ax = bias_steps.plot_Rfrac(bsa_final)
fname = sdl.make_filename(S, 'rebiased_Rfrac_2.png', plot=True)
Expand Down

0 comments on commit 56d04ce

Please sign in to comment.