Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes G3 stream tagging in biasstep_rebias #398

Merged
merged 1 commit into from
Dec 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading