From bc1a609ecf77df8da6266438ae12b9bf2ac37fb6 Mon Sep 17 00:00:00 2001 From: simonscryo Date: Thu, 12 Jan 2023 21:30:09 +0000 Subject: [PATCH 01/31] first version biasstep rebiading --- scripts/start_pysmurf_ipython.py | 2 +- sodetlib/analysis/det_analysis.py | 5 +- sodetlib/noise.py | 4 +- sodetlib/operations/bias_dets.py | 224 ++++++++++++++++++++++++ sodetlib/operations/bias_steps.py | 3 +- sodetlib/smurf_funcs/optimize_params.py | 45 ++--- 6 files changed, 258 insertions(+), 25 deletions(-) diff --git a/scripts/start_pysmurf_ipython.py b/scripts/start_pysmurf_ipython.py index ff44b25c..df6a6ee4 100644 --- a/scripts/start_pysmurf_ipython.py +++ b/scripts/start_pysmurf_ipython.py @@ -24,7 +24,7 @@ reg = sdl.Registers(S) _ipython_config = traitlets.config.get_config() - _ipython_config.InteractiveShellEmbed.colors = "LightBG" + _ipython_config.InteractiveShellEmbed.colors = "Linux" embed(config=_ipython_config) diff --git a/sodetlib/analysis/det_analysis.py b/sodetlib/analysis/det_analysis.py index 8d4388be..3b3ecb81 100644 --- a/sodetlib/analysis/det_analysis.py +++ b/sodetlib/analysis/det_analysis.py @@ -669,7 +669,10 @@ def analyze_iv_info(iv_info_fp, phase, v_bias, mask, resp_bin -= norm_fit[1] # now in real current units - sc_fit = np.polyfit(i_bias_bin[:sc_idx], resp_bin[:sc_idx], 1) + try: + sc_fit = np.polyfit(i_bias_bin[:sc_idx], resp_bin[:sc_idx], 1) + except ValueError: + continue # subtract off unphysical y-offset in superconducting branch; this is # probably due to an undetected phase wrap at the kink between the diff --git a/sodetlib/noise.py b/sodetlib/noise.py index ba590408..4ec2ce2e 100644 --- a/sodetlib/noise.py +++ b/sodetlib/noise.py @@ -306,7 +306,7 @@ def plot_band_noise(am, nbins=40, noisedict=None, wl_f_range=(10,30), ax = axes_fk[b % 4, b // 4] m = (bands == b) & (fknees > 0) x = ax.hist(fknees[m], bins=bins) - text = f"Median: {np.median(fknees[m]):0.2f}\n" + text = f"Median: {np.median(fknees[m]):0.2f} Hz\n" text += f"Chans pictured: {np.sum(x[0]):0.0f}" ax.text(0.72, .7, text, transform=ax.transAxes) ax.axvline(np.median(fknees[m]), color='red') @@ -343,7 +343,7 @@ def plot_band_noise(am, nbins=40, noisedict=None, wl_f_range=(10,30), label=f'Med. WL: {med_wl:.1f} pA/rtHz') ax.set(ylabel=f'Band {b}\nASD (pA/rtHz)') ax.grid(linestyle='--', which='both') - ax.legend(loc='upper right') + ax.legend(loc='lower left') min_x = min(ax.get_xlim()[0], min_x) max_x = max(ax.get_xlim()[1], max_x) diff --git a/sodetlib/operations/bias_dets.py b/sodetlib/operations/bias_dets.py index 72973d01..2211db5d 100644 --- a/sodetlib/operations/bias_dets.py +++ b/sodetlib/operations/bias_dets.py @@ -201,3 +201,227 @@ def bias_to_rfrac(S, cfg, rfrac=0.5, bias_groups=None, iva=None, return biases +def biasstep_rebias( + S, cfg, target_percentage_rn = 0.5, bias_groups=None, + math_only=False): + + ## take the initial biasstep + S.log("taking the first biasstep") + bsa_0 = bias_steps.take_bias_steps(S, cfg) + if not math_only: + bias_steps.plot_Rfrac(bsa_0) + + repeat_biasstep = False + ## check for script failue + for bl in bias_groups: + mask_bg = np.where(bsa_0.bgmap==bl)[0] + per_bl_R0 = bsa_0.R0[mask_bg] + if np.isnan(np.nanmedian(per_bl_R0)): + ## the yield is very low, could it be the biasstep analysis script failed? repeat again + repeat_biasstep = True + S.log("the biasstep script might have failed, going to repeat the measurement") + + if repeat_biasstep: + S.log("retaking biasstep due to failure") + bsa_0 = bias_steps.take_bias_steps(S, cfg) + repeat_biasstep = False + + percentage_rn_0 = bsa_0.R0/bsa_0.R_n_IV + ## add in checks if detectors are SC + bg_overbias_needed = [] + overbias_needed = False + for bl in bias_groups: + mask_bg = np.where(bsa_0.bgmap==bl)[0] + per_bl_percentage_rn_0 = percentage_rn_0[mask_bg] + ## mask for SC + mask_sc = np.where((per_bl_percentage_rn_0 < 0.1) & (per_bl_percentage_rn_0 > -0.1)) + ## if more than 10 percent of the detectors are SC + if len(mask_sc[0]) > 0.1*len(mask_bg): + bg_overbias_needed.append(bl) + overbias_needed = True + + ## add in check if detectors are normal, hence we should increase the drop step + bg_detectors_normal = [] + drop_from_normal = False + for bl in bias_groups: + mask_bg = np.where(bsa_0.bgmap==bl)[0] + per_bl_percentage_rn_0 = percentage_rn_0[mask_bg] + ## mask for normal + mask_normal = np.where((per_bl_percentage_rn_0 > 0.9) | (per_bl_percentage_rn_0 < -0.9)) + ## if more than half of the detectors are normal + if len(mask_normal[0]) > 0.5*len(mask_bg): + bg_detectors_normal.append(bl) + drop_from_normal = True + + + if overbias_needed: + S.log("some BL are stuck in SC, going to over bias them, this takes about 4mins") + previous_dc_biases = S.get_tes_bias_bipolar_array() + + sdl.overbias_dets(S, cfg, bias_groups=bg_overbias_needed) + ##force wait time 3 mins for UFM to reach equalibrium + for sleep_index in range(3): + time.sleep(60) + safe_dc_biases = previous_dc_biases.copy() + for replace_bg in bg_overbias_needed: + safe_dc_biases[replace_bg] = cfg.dev.bias_groups[replace_bg]["testbed_100mK_bias_voltage"] + + S.set_tes_bias_bipolar_array(safe_dc_biases) + bsa_0 = bias_steps.take_bias_steps(S, cfg) + bias_steps.plot_Rfrac(bsa_0) + + ## add in check if detectors are normal now + percentage_rn_0 = bsa_0.R0/bsa_0.R_n_IV + drop_from_normal = False + for bl in bg_overbias_needed: + mask_bg = np.where(bsa_0.bgmap==bl)[0] + per_bl_percentage_rn_0 = percentage_rn_0[mask_bg] + ## mask for normal + mask_normal = np.where((per_bl_percentage_rn_0 > 0.9) | (per_bl_percentage_rn_0 < -0.9)) + ## if more than half of the detectors are normal + if len(mask_normal[0]) > 0.5*len(mask_bg): + bg_detectors_normal.append(bl) + drop_from_normal = True + + + ##preparing for the 2nd step + initial_dc_biases = S.get_tes_bias_bipolar_array() + new_bias_voltage = initial_dc_biases.copy() + + ## load IV analysis result so can use dynamic step size + iva = iv.IVAnalysis.load(bsa_0.meta['iv_file']) + + + for bl in bias_groups: + mask_bg = np.where(bsa_0.bgmap==bl)[0] + + per_bl_percentage_rn_0 = percentage_rn_0[mask_bg] + + med_per_bl_percentage_rn = np.nanmedian(per_bl_percentage_rn_0) + + ## use the latest IV to decide the step size, might be tricky to get a good step size in field + v_sc = iva.v_bias[iva.idxs[[mask_bg], 0]] + v_norm = iva.v_bias[iva.idxs[[mask_bg], 1]] + v_spread = np.nanmedian(v_norm) - np.nanmedian(v_sc) + ## take 15% of the spread as the step size, so the next biasstep will be taken from 0.25 ~ 0.75 percent Rn after considering the spread + delta_dc_bias = 0.15 * v_spread + + + ## if the current bias point is below 50% Rn, increase V_biaa + if med_per_bl_percentage_rn < 0.5: + new_bias_voltage[bl] = initial_dc_biases[bl] + delta_dc_bias + if med_per_bl_percentage_rn >= 0.5: + new_bias_voltage[bl] = initial_dc_biases[bl] - delta_dc_bias + ## if the detector is normal, take a larger step + if bl in bg_detectors_normal: + if initial_dc_biases[bl] > cfg.dev.bias_groups[replace_bg]["testbed_100mK_bias_voltage"]: + initial_dc_biases[bl] = cfg.dev.bias_groups[replace_bg]["testbed_100mK_bias_voltage"] + new_bias_voltage[bl] = initial_dc_biases[bl] - 0.5 * v_spread + + S.log("applying new voltage for 2nd biasstep") + S.set_tes_bias_bipolar_array(new_bias_voltage) + + ## taking the second bias step + S.log("taking the 2nd biasstep") + bsa_1 = bias_steps.take_bias_steps(S, cfg) + if not math_only: + bias_steps.plot_Rfrac(bsa_1) + + ## check for script failue + for bl in bias_groups: + mask_bg = np.where(bsa_1.bgmap==bl)[0] + per_bl_R0 = bsa_1.R0[mask_bg] + if np.isnan(np.nanmedian(per_bl_R0)): + ## the yield is very low, could it be the biasstep analysis script failed? repeat again + repeat_biasstep = True + 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) + repeat_biasstep = False + + percentage_rn_1 = bsa_1.R0/bsa_1.R_n_IV + + ## add in check if detectors were normal are still normal + if drop_from_normal: + S.log(f"some biaslines were in normal state during 1st biasstep: {bg_detectors_normal}") + drop_from_normal = False + for bl in bg_detectors_normal: + mask_bg = np.where(bsa_1.bgmap==bl)[0] + per_bl_percentage_rn_1 = percentage_rn_1[mask_bg] + ## mask for normal + mask_normal = np.where((per_bl_percentage_rn_1 > 0.9) | (per_bl_percentage_rn_1 < -0.9)) + ## if more than half of the detectors are normal + if len(mask_normal[0]) > 0.5*len(mask_bg): + drop_from_normal = True + + while drop_from_normal: + S.log(f"some biaslines are still in normal state: {bg_detectors_normal}") + percentage_rn_1 = bsa_1.R0/bsa_1.R_n_IV + S.log("droping detectors from normal to transition") + previous_dc_biases_dfn = S.get_tes_bias_bipolar_array() + + S.log(f"current tes bias voltages are: {previous_dc_biases_dfn}") + for bl in bg_detectors_normal: + mask_bg = np.where(bsa_1.bgmap==bl)[0] + v_sc = iva.v_bias[iva.idxs[[mask_bg], 0]] + v_norm = iva.v_bias[iva.idxs[[mask_bg], 1]] + v_spread = np.nanmedian(v_norm) - np.nanmedian(v_sc) + previous_dc_biases_dfn[bl] = previous_dc_biases_dfn[bl] - 0.5 * v_spread + + S.set_tes_bias_bipolar_array(previous_dc_biases_dfn) + bsa_1 = bias_steps.take_bias_steps(S, cfg) + percentage_rn_1 = bsa_1.R0/bsa_1.R_n_IV + drop_from_normal = False + bg_detectors_normal = [] + for bl in bias_groups: + mask_bg = np.where(bsa_1.bgmap==bl)[0] + per_bl_percentage_rn_1 = percentage_rn_1[mask_bg] + ## mask for normal + mask_normal = np.where((per_bl_percentage_rn_1 > 0.9) | (per_bl_percentage_rn_1 < -0.9)) + ## if more than half of the detectors are normal + if len(mask_normal[0]) > 0.5*len(mask_bg): + drop_from_normal = True + bg_detectors_normal.append(bl) + for bl in bg_detectors_normal: + if previous_dc_biases_dfn[bl] < 1: + drop_from_normal = False + + target_percentage_rn_array = target_percentage_rn * np.ones(len(percentage_rn_0)) + ## getting result from the previous 2 + v0 = np.zeros(bsa_0.bgmap.shape[0]) + for bl in range(12): + mask_bl = np.where(bsa_0.bgmap==bl)[0] + v0[mask_bl] = initial_dc_biases[bl] + + v1 = np.zeros(bsa_1.bgmap.shape[0]) + for bl in range(12): + mask_bl = np.where(bsa_1.bgmap==bl)[0] + v1[mask_bl] = new_bias_voltage[bl] + ## deciding the new bias point + vbias_estimate_array = (v0*(target_percentage_rn_array-percentage_rn_1) + v1*(percentage_rn_0 - target_percentage_rn_array)) / (percentage_rn_0 - percentage_rn_1) + + vbias_estimate = initial_dc_biases.copy() + for bl in bias_groups: + mask_bg = np.where(bsa_0.bgmap==bl)[0] + + per_bl_vbias_estimate = vbias_estimate_array[mask_bg] + med_per_bl_vbias_estimate = np.nanmedian(per_bl_vbias_estimate) + ## if the current bias point is below 50% Rn, increase V_biaa + vbias_estimate[bl] = med_per_bl_vbias_estimate + + S.log("applying the new bias voltages") + S.set_tes_bias_bipolar_array(vbias_estimate) + + S.log("taking the final biasstep") + bsa_2 = bias_steps.take_bias_steps(S, cfg) + if not math_only: + bias_steps.plot_Rfrac(bsa_2) + + + + + + + + diff --git a/sodetlib/operations/bias_steps.py b/sodetlib/operations/bias_steps.py index 29e4e6db..61d09f1b 100644 --- a/sodetlib/operations/bias_steps.py +++ b/sodetlib/operations/bias_steps.py @@ -1159,7 +1159,8 @@ def take_bias_steps(S, cfg, bgs=None, step_voltage=0.05, step_duration=0.05, dc_biases = initial_dc_biases init_current_mode = sdl.get_current_mode_array(S) if high_current_mode: - dc_biases = dc_biases / S.high_low_current_ratio + dc_biases[init_current_mode == 0] = (dc_biases[init_current_mode == 0] / + S.high_low_current_ratio) step_voltage /= S.high_low_current_ratio sdl.set_current_mode(S, bgs, 1) S.log(f"Waiting {hcm_wait_time} sec after switching to hcm") diff --git a/sodetlib/smurf_funcs/optimize_params.py b/sodetlib/smurf_funcs/optimize_params.py index 8109e927..420576a4 100644 --- a/sodetlib/smurf_funcs/optimize_params.py +++ b/sodetlib/smurf_funcs/optimize_params.py @@ -654,7 +654,8 @@ def cryo_amp_check(S, cfg): # Turns on both amplifiers and checks biasing. su.cprint("Checking biases", su.TermColors.HEADER) - S.C.write_ps_en(11) + S.C.write_ps_en(0b11) + time.sleep(0.1) amp_biases = S.get_amplifier_biases() biased_hemt = np.abs(amp_biases['hemt_Id']) > 0.2 biased_50K = np.abs(amp_biases['50K_Id']) > 0.2 @@ -735,25 +736,29 @@ def cryo_amp_check(S, cfg): # that average value of noise through band 0 is above 1. # Check limit makes sense when through system - su.cprint("Checking full-band response for band 0", su.TermColors.HEADER) - band_cfg = cfg.dev.bands[0] - S.set_att_uc(0, band_cfg['uc_att']) - - freq, response = S.full_band_resp(band=0) - # Get the response in-band - resp_inband = [] - band_width = 500e6 # Each band is 500 MHz wide - for f, r in zip(freq, np.abs(response)): - if -band_width/2 < f < band_width/2: - resp_inband.append(r) - # If the mean is > 1, say response received - if np.nanmean(resp_inband) > 1: #LESS THAN CHANGE - resp_check = True - su.cprint("Full band response check passed", True) - else: - resp_check = False - su.cprint("Full band response check failed - maybe something isn't " - "plugged in?", False) + + for band in [0, 4]: + su.cprint(f"Checking full-band response for band {band}", su.TermColors.HEADER) + band_cfg = cfg.dev.bands[band] + S.set_att_uc(band, band_cfg['uc_att']) + S.set_att_dc(band, band_cfg['dc_att']) + S.amplitude_scale[band] = band_cfg['drive'] + + freq, response = S.full_band_resp(band) + # Get the response in-band + resp_inband = [] + band_width = 500e6 # Each band is 500 MHz wide + for f, r in zip(freq, np.abs(response)): + if -band_width/2 < f < band_width/2: + resp_inband.append(r) + # If the mean is > 1, say response received + if np.nanmean(resp_inband) > 1: #LESS THAN CHANGE + resp_check = True + su.cprint("Full band response check passed", True) + else: + resp_check = False + su.cprint("Full band response check failed - maybe something isn't " + "plugged in?", False) # Check if ADC is clipping. Probably should be a different script, after # characterizing system to know what peak data amplitude to simulate From a3a11766bd88c40aad53022daa715915cdc29eea Mon Sep 17 00:00:00 2001 From: simonscryo Date: Thu, 12 Jan 2023 22:37:31 +0000 Subject: [PATCH 02/31] first version biasstep rebiading --- sodetlib/operations/bias_dets.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sodetlib/operations/bias_dets.py b/sodetlib/operations/bias_dets.py index 2211db5d..4d692a1e 100644 --- a/sodetlib/operations/bias_dets.py +++ b/sodetlib/operations/bias_dets.py @@ -3,7 +3,7 @@ import time import matplotlib.pyplot as plt from sodetlib.operations.iv import IVAnalysis - +from sodetlib.operations import uxm_setup, uxm_relock, tracking, bias_steps, iv, bias_dets np.seterr(all="ignore") @@ -205,6 +205,15 @@ def biasstep_rebias( S, cfg, target_percentage_rn = 0.5, bias_groups=None, math_only=False): + """ + Scripts work well when detectors are already in transistion. For extreme cases + such as detectors are all in SC, it takes a few run to put them perfectly in + transition. Next step is making this script can handle extreme cases faster + + + """ + + ## take the initial biasstep S.log("taking the first biasstep") bsa_0 = bias_steps.take_bias_steps(S, cfg) From f87db7a0abf97e7e992321c7b278a37afef08223 Mon Sep 17 00:00:00 2001 From: simonscryo Date: Tue, 17 Jan 2023 21:47:23 +0000 Subject: [PATCH 03/31] Remove unrelated local changes --- scripts/start_pysmurf_ipython.py | 2 +- sodetlib/analysis/det_analysis.py | 5 +-- sodetlib/noise.py | 4 +-- sodetlib/operations/bias_steps.py | 7 ++-- sodetlib/smurf_funcs/optimize_params.py | 45 +++++++++++-------------- 5 files changed, 27 insertions(+), 36 deletions(-) diff --git a/scripts/start_pysmurf_ipython.py b/scripts/start_pysmurf_ipython.py index df6a6ee4..ff44b25c 100644 --- a/scripts/start_pysmurf_ipython.py +++ b/scripts/start_pysmurf_ipython.py @@ -24,7 +24,7 @@ reg = sdl.Registers(S) _ipython_config = traitlets.config.get_config() - _ipython_config.InteractiveShellEmbed.colors = "Linux" + _ipython_config.InteractiveShellEmbed.colors = "LightBG" embed(config=_ipython_config) diff --git a/sodetlib/analysis/det_analysis.py b/sodetlib/analysis/det_analysis.py index 3b3ecb81..8d4388be 100644 --- a/sodetlib/analysis/det_analysis.py +++ b/sodetlib/analysis/det_analysis.py @@ -669,10 +669,7 @@ def analyze_iv_info(iv_info_fp, phase, v_bias, mask, resp_bin -= norm_fit[1] # now in real current units - try: - sc_fit = np.polyfit(i_bias_bin[:sc_idx], resp_bin[:sc_idx], 1) - except ValueError: - continue + sc_fit = np.polyfit(i_bias_bin[:sc_idx], resp_bin[:sc_idx], 1) # subtract off unphysical y-offset in superconducting branch; this is # probably due to an undetected phase wrap at the kink between the diff --git a/sodetlib/noise.py b/sodetlib/noise.py index 4ec2ce2e..ba590408 100644 --- a/sodetlib/noise.py +++ b/sodetlib/noise.py @@ -306,7 +306,7 @@ def plot_band_noise(am, nbins=40, noisedict=None, wl_f_range=(10,30), ax = axes_fk[b % 4, b // 4] m = (bands == b) & (fknees > 0) x = ax.hist(fknees[m], bins=bins) - text = f"Median: {np.median(fknees[m]):0.2f} Hz\n" + text = f"Median: {np.median(fknees[m]):0.2f}\n" text += f"Chans pictured: {np.sum(x[0]):0.0f}" ax.text(0.72, .7, text, transform=ax.transAxes) ax.axvline(np.median(fknees[m]), color='red') @@ -343,7 +343,7 @@ def plot_band_noise(am, nbins=40, noisedict=None, wl_f_range=(10,30), label=f'Med. WL: {med_wl:.1f} pA/rtHz') ax.set(ylabel=f'Band {b}\nASD (pA/rtHz)') ax.grid(linestyle='--', which='both') - ax.legend(loc='lower left') + ax.legend(loc='upper right') min_x = min(ax.get_xlim()[0], min_x) max_x = max(ax.get_xlim()[1], max_x) diff --git a/sodetlib/operations/bias_steps.py b/sodetlib/operations/bias_steps.py index 61d09f1b..aa4bef92 100644 --- a/sodetlib/operations/bias_steps.py +++ b/sodetlib/operations/bias_steps.py @@ -425,7 +425,7 @@ def run_analysis( ) self.R_n_IV = iva.R_n[chmap] self.R_n_IV[chmap == -1] = np.nan - self.Rfrac = self.R0 / self.R_n_IV + self.Rfrac = self.R0 / self.R_n if create_bg_map and save_bg_map and self._S is not None: # Write bgmap after compute_dc_params because bg-assignment @@ -960,7 +960,7 @@ def plot_Rfrac(bsa, text_loc=(0.6, 0.8)): chmap = sdl.map_band_chans(bsa.bands, bsa.channels, iva.bands, iva.channels) - Rfracs = bsa.R0 / iva.R_n_IV[chmap] + Rfracs = bsa.R0 / iva.R_n[chmap] lim = (-0.1, 1.2) nbins=30 bins = np.linspace(*lim, nbins) @@ -1159,8 +1159,7 @@ def take_bias_steps(S, cfg, bgs=None, step_voltage=0.05, step_duration=0.05, dc_biases = initial_dc_biases init_current_mode = sdl.get_current_mode_array(S) if high_current_mode: - dc_biases[init_current_mode == 0] = (dc_biases[init_current_mode == 0] / - S.high_low_current_ratio) + dc_biases = dc_biases / S.high_low_current_ratio step_voltage /= S.high_low_current_ratio sdl.set_current_mode(S, bgs, 1) S.log(f"Waiting {hcm_wait_time} sec after switching to hcm") diff --git a/sodetlib/smurf_funcs/optimize_params.py b/sodetlib/smurf_funcs/optimize_params.py index 420576a4..8109e927 100644 --- a/sodetlib/smurf_funcs/optimize_params.py +++ b/sodetlib/smurf_funcs/optimize_params.py @@ -654,8 +654,7 @@ def cryo_amp_check(S, cfg): # Turns on both amplifiers and checks biasing. su.cprint("Checking biases", su.TermColors.HEADER) - S.C.write_ps_en(0b11) - time.sleep(0.1) + S.C.write_ps_en(11) amp_biases = S.get_amplifier_biases() biased_hemt = np.abs(amp_biases['hemt_Id']) > 0.2 biased_50K = np.abs(amp_biases['50K_Id']) > 0.2 @@ -736,29 +735,25 @@ def cryo_amp_check(S, cfg): # that average value of noise through band 0 is above 1. # Check limit makes sense when through system - - for band in [0, 4]: - su.cprint(f"Checking full-band response for band {band}", su.TermColors.HEADER) - band_cfg = cfg.dev.bands[band] - S.set_att_uc(band, band_cfg['uc_att']) - S.set_att_dc(band, band_cfg['dc_att']) - S.amplitude_scale[band] = band_cfg['drive'] - - freq, response = S.full_band_resp(band) - # Get the response in-band - resp_inband = [] - band_width = 500e6 # Each band is 500 MHz wide - for f, r in zip(freq, np.abs(response)): - if -band_width/2 < f < band_width/2: - resp_inband.append(r) - # If the mean is > 1, say response received - if np.nanmean(resp_inband) > 1: #LESS THAN CHANGE - resp_check = True - su.cprint("Full band response check passed", True) - else: - resp_check = False - su.cprint("Full band response check failed - maybe something isn't " - "plugged in?", False) + su.cprint("Checking full-band response for band 0", su.TermColors.HEADER) + band_cfg = cfg.dev.bands[0] + S.set_att_uc(0, band_cfg['uc_att']) + + freq, response = S.full_band_resp(band=0) + # Get the response in-band + resp_inband = [] + band_width = 500e6 # Each band is 500 MHz wide + for f, r in zip(freq, np.abs(response)): + if -band_width/2 < f < band_width/2: + resp_inband.append(r) + # If the mean is > 1, say response received + if np.nanmean(resp_inband) > 1: #LESS THAN CHANGE + resp_check = True + su.cprint("Full band response check passed", True) + else: + resp_check = False + su.cprint("Full band response check failed - maybe something isn't " + "plugged in?", False) # Check if ADC is clipping. Probably should be a different script, after # characterizing system to know what peak data amplitude to simulate From 3e3eefcfc3c8cc331093eb5b86b5b31ee764c130 Mon Sep 17 00:00:00 2001 From: simonscryo Date: Tue, 17 Jan 2023 21:53:39 +0000 Subject: [PATCH 04/31] fix R_n, R_n_IV yet again --- sodetlib/operations/bias_steps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sodetlib/operations/bias_steps.py b/sodetlib/operations/bias_steps.py index aa4bef92..71ae89bd 100644 --- a/sodetlib/operations/bias_steps.py +++ b/sodetlib/operations/bias_steps.py @@ -425,7 +425,7 @@ def run_analysis( ) self.R_n_IV = iva.R_n[chmap] self.R_n_IV[chmap == -1] = np.nan - self.Rfrac = self.R0 / self.R_n + self.Rfrac = self.R0 / self.R_n_IV if create_bg_map and save_bg_map and self._S is not None: # Write bgmap after compute_dc_params because bg-assignment From d27467bd71d8696a252e1aeae0fead3d1c41f807 Mon Sep 17 00:00:00 2001 From: yuhanwyhan <38056285+yuhanwyhan@users.noreply.github.com> Date: Tue, 2 May 2023 22:22:08 -0400 Subject: [PATCH 05/31] update biasstep_rebias script --- sodetlib/operations/bias_dets.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sodetlib/operations/bias_dets.py b/sodetlib/operations/bias_dets.py index 4d692a1e..ef59a2c0 100644 --- a/sodetlib/operations/bias_dets.py +++ b/sodetlib/operations/bias_dets.py @@ -323,8 +323,8 @@ def biasstep_rebias( new_bias_voltage[bl] = initial_dc_biases[bl] - delta_dc_bias ## if the detector is normal, take a larger step if bl in bg_detectors_normal: - if initial_dc_biases[bl] > cfg.dev.bias_groups[replace_bg]["testbed_100mK_bias_voltage"]: - initial_dc_biases[bl] = cfg.dev.bias_groups[replace_bg]["testbed_100mK_bias_voltage"] + if initial_dc_biases[bl] > cfg.dev.bias_groups[bl]["testbed_100mK_bias_voltage"]: + initial_dc_biases[bl] = cfg.dev.bias_groups[bl]["testbed_100mK_bias_voltage"] new_bias_voltage[bl] = initial_dc_biases[bl] - 0.5 * v_spread S.log("applying new voltage for 2nd biasstep") From 14bbfd6f1e7917945c7f93565af15d69c1cd4a32 Mon Sep 17 00:00:00 2001 From: yuhanwyhan <38056285+yuhanwyhan@users.noreply.github.com> Date: Wed, 3 May 2023 14:29:51 -0400 Subject: [PATCH 06/31] update biasstep_rebias --- sodetlib/operations/bias_dets.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sodetlib/operations/bias_dets.py b/sodetlib/operations/bias_dets.py index ef59a2c0..fb1d817c 100644 --- a/sodetlib/operations/bias_dets.py +++ b/sodetlib/operations/bias_dets.py @@ -426,6 +426,8 @@ def biasstep_rebias( bsa_2 = bias_steps.take_bias_steps(S, cfg) if not math_only: bias_steps.plot_Rfrac(bsa_2) + + return bsa_2 From 42c66fd3718c56d7e95d9f144474c3c69ed58406 Mon Sep 17 00:00:00 2001 From: yuhanwyhan <38056285+yuhanwyhan@users.noreply.github.com> Date: Thu, 4 May 2023 17:43:54 -0400 Subject: [PATCH 07/31] update biasstep_rebias --- sodetlib/operations/bias_dets.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/sodetlib/operations/bias_dets.py b/sodetlib/operations/bias_dets.py index fb1d817c..a5d7c0a4 100644 --- a/sodetlib/operations/bias_dets.py +++ b/sodetlib/operations/bias_dets.py @@ -216,6 +216,8 @@ def biasstep_rebias( ## take the initial biasstep S.log("taking the first biasstep") + intical_current_biasvoltage = S.set_tes_bias_bipolar_array + S.log(f"current biasvoltage {intical_current_biasvoltage}") bsa_0 = bias_steps.take_bias_steps(S, cfg) if not math_only: bias_steps.plot_Rfrac(bsa_0) @@ -327,7 +329,7 @@ def biasstep_rebias( initial_dc_biases[bl] = cfg.dev.bias_groups[bl]["testbed_100mK_bias_voltage"] new_bias_voltage[bl] = initial_dc_biases[bl] - 0.5 * v_spread - S.log("applying new voltage for 2nd biasstep") + S.log(f"applying new voltage for 2nd biasstep {new_bias_voltage}") S.set_tes_bias_bipolar_array(new_bias_voltage) ## taking the second bias step @@ -378,7 +380,8 @@ def biasstep_rebias( v_spread = np.nanmedian(v_norm) - np.nanmedian(v_sc) previous_dc_biases_dfn[bl] = previous_dc_biases_dfn[bl] - 0.5 * v_spread - S.set_tes_bias_bipolar_array(previous_dc_biases_dfn) + S.set_tes_bias_bipolar_array(previous_dc_biases_dfn) + S.log(f"applying: {previous_dc_biases_dfn}") bsa_1 = bias_steps.take_bias_steps(S, cfg) percentage_rn_1 = bsa_1.R0/bsa_1.R_n_IV drop_from_normal = False @@ -421,13 +424,13 @@ def biasstep_rebias( S.log("applying the new bias voltages") S.set_tes_bias_bipolar_array(vbias_estimate) - + S.log(f"applying {set_tes_bias_bipolar_array}") S.log("taking the final biasstep") bsa_2 = bias_steps.take_bias_steps(S, cfg) if not math_only: bias_steps.plot_Rfrac(bsa_2) - return bsa_2 + return bsa_2,vbias_estimate From dde5a011ee6124d355da3c107f76f93318e12412 Mon Sep 17 00:00:00 2001 From: yuhanwyhan <38056285+yuhanwyhan@users.noreply.github.com> Date: Thu, 4 May 2023 17:49:39 -0400 Subject: [PATCH 08/31] Update bias_dets.py --- sodetlib/operations/bias_dets.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sodetlib/operations/bias_dets.py b/sodetlib/operations/bias_dets.py index a5d7c0a4..890c22ea 100644 --- a/sodetlib/operations/bias_dets.py +++ b/sodetlib/operations/bias_dets.py @@ -216,7 +216,7 @@ def biasstep_rebias( ## take the initial biasstep S.log("taking the first biasstep") - intical_current_biasvoltage = S.set_tes_bias_bipolar_array + intical_current_biasvoltage = S.get_tes_bias_bipolar_array() S.log(f"current biasvoltage {intical_current_biasvoltage}") bsa_0 = bias_steps.take_bias_steps(S, cfg) if not math_only: From 2dd275d9ce656838544697ef6c92cadc957c6130 Mon Sep 17 00:00:00 2001 From: yuhanwyhan <38056285+yuhanwyhan@users.noreply.github.com> Date: Thu, 4 May 2023 18:04:14 -0400 Subject: [PATCH 09/31] Update bias_dets.py --- sodetlib/operations/bias_dets.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sodetlib/operations/bias_dets.py b/sodetlib/operations/bias_dets.py index 890c22ea..903982ef 100644 --- a/sodetlib/operations/bias_dets.py +++ b/sodetlib/operations/bias_dets.py @@ -424,7 +424,7 @@ def biasstep_rebias( S.log("applying the new bias voltages") S.set_tes_bias_bipolar_array(vbias_estimate) - S.log(f"applying {set_tes_bias_bipolar_array}") + S.log(f"applying {vbias_estimate}") S.log("taking the final biasstep") bsa_2 = bias_steps.take_bias_steps(S, cfg) if not math_only: From 043eea53142f5abaeb175d89c5eb5e7d560bd869 Mon Sep 17 00:00:00 2001 From: yuhanwyhan <38056285+yuhanwyhan@users.noreply.github.com> Date: Mon, 19 Jun 2023 11:21:52 -0400 Subject: [PATCH 10/31] Update bias_dets.py --- sodetlib/operations/bias_dets.py | 122 +++++++++++++++++++++++++++++-- 1 file changed, 117 insertions(+), 5 deletions(-) diff --git a/sodetlib/operations/bias_dets.py b/sodetlib/operations/bias_dets.py index 903982ef..5ff90aaa 100644 --- a/sodetlib/operations/bias_dets.py +++ b/sodetlib/operations/bias_dets.py @@ -266,12 +266,12 @@ def biasstep_rebias( if overbias_needed: - S.log("some BL are stuck in SC, going to over bias them, this takes about 4mins") + S.log("some BL are stuck in SC, going to over bias them, this takes about 5mins") previous_dc_biases = S.get_tes_bias_bipolar_array() sdl.overbias_dets(S, cfg, bias_groups=bg_overbias_needed) - ##force wait time 3 mins for UFM to reach equalibrium - for sleep_index in range(3): + ##force wait time 5 mins for UFM to reach equalibrium + for sleep_index in range(5): time.sleep(60) safe_dc_biases = previous_dc_biases.copy() for replace_bg in bg_overbias_needed: @@ -325,9 +325,10 @@ def biasstep_rebias( new_bias_voltage[bl] = initial_dc_biases[bl] - delta_dc_bias ## if the detector is normal, take a larger step if bl in bg_detectors_normal: + S.log(f"some detectors are in normal state for bl{bl}, taking a large step") if initial_dc_biases[bl] > cfg.dev.bias_groups[bl]["testbed_100mK_bias_voltage"]: initial_dc_biases[bl] = cfg.dev.bias_groups[bl]["testbed_100mK_bias_voltage"] - new_bias_voltage[bl] = initial_dc_biases[bl] - 0.5 * v_spread + new_bias_voltage[bl] = initial_dc_biases[bl] - 0.3 * v_spread S.log(f"applying new voltage for 2nd biasstep {new_bias_voltage}") S.set_tes_bias_bipolar_array(new_bias_voltage) @@ -382,6 +383,8 @@ def biasstep_rebias( S.set_tes_bias_bipolar_array(previous_dc_biases_dfn) S.log(f"applying: {previous_dc_biases_dfn}") + S.log(f"waiting 30s for dissipation of UFM local heating") + time.sleep(30) bsa_1 = bias_steps.take_bias_steps(S, cfg) percentage_rn_1 = bsa_1.R0/bsa_1.R_n_IV drop_from_normal = False @@ -427,10 +430,119 @@ def biasstep_rebias( S.log(f"applying {vbias_estimate}") S.log("taking the final biasstep") bsa_2 = bias_steps.take_bias_steps(S, cfg) + + ## check for script failue + for bl in bias_groups: + mask_bg = np.where(bsa_2.bgmap==bl)[0] + per_bl_R0 = bsa_2.R0[mask_bg] + if np.isnan(np.nanmedian(per_bl_R0)): + ## the yield is very low, could it be the biasstep analysis script failed? repeat again + repeat_biasstep = True + 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) + repeat_biasstep = False + if not math_only: bias_steps.plot_Rfrac(bsa_2) + + + S.log("confirming if the current result is close to the target") + percentage_rn_confirm = bsa_2.R0/bsa_2.R_n_IV + succeeded_bl = [] + un_succeeded_bl = [] + for bl in bias_groups: + mask_bg = np.where(bsa_2.bgmap==bl)[0] + per_bl_percentage_rn_confirm = np.nanmedian(percentage_rn_confirm[mask_bg]) + if per_bl_percentage_rn_confirm > target_percentage_rn - 0.05 and per_bl_percentage_rn_confirm < target_percentage_rn + 0.05: + succeeded_bl.append(bl) + else: + un_succeeded_bl.append(bl) + S.log(f"succeeded bl: {succeeded_bl}") + S.log(f"unsucceeded bl: {un_succeeded_bl}") + + if len(un_succeeded_bl)==0: + bsa_final = bsa_2 + vbias_estimate_final = vbias_estimate + + + if len(un_succeeded_bl)!=0: + extra_step_bias_voltage = vbias_estimate.copy() + S.log("fine tunning unsucceeded bl") + for bl in un_succeeded_bl: + mask_bg = np.where(bsa_2.bgmap==bl)[0] + per_bl_percentage_rn_confirm = percentage_rn_confirm[mask_bg] + med_per_bl_percentage_confirm = np.nanmedian(per_bl_percentage_rn_confirm) + + ## use the latest IV to decide the step size, might be tricky to get a good step size in field + v_sc = iva.v_bias[iva.idxs[[mask_bg], 0]] + v_norm = iva.v_bias[iva.idxs[[mask_bg], 1]] + v_spread = np.nanmedian(v_norm) - np.nanmedian(v_sc) + ## take 15% of the spread as the step size, so the next biasstep will be taken from 0.25 ~ 0.75 percent Rn after considering the spread + delta_dc_bias = 0.15 * v_spread + ## if the current bias point is below 50% Rn, increase V_biaa + if med_per_bl_percentage_confirm < 0.5: + extra_step_bias_voltage[bl] = vbias_estimate[bl] + delta_dc_bias + if med_per_bl_percentage_confirm >= 0.5: + extra_step_bias_voltage[bl] = vbias_estimate[bl] - delta_dc_bias + + S.log(f"applying new voltage for extra step biasstep {extra_step_bias_voltage}") + S.set_tes_bias_bipolar_array(extra_step_bias_voltage) + + ## taking the extra bias step + S.log("taking the extra biasstep") + bsa_extra = bias_steps.take_bias_steps(S, cfg) + + ## check for script failue + for bl in bias_groups: + mask_bg = np.where(bsa_extra.bgmap==bl)[0] + per_bl_R0 = bsa_extra.R0[mask_bg] + if np.isnan(np.nanmedian(per_bl_R0)): + ## the yield is very low, could it be the biasstep analysis script failed? repeat again + repeat_biasstep = True + 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) + repeat_biasstep = False - return bsa_2,vbias_estimate + if not math_only: + bias_steps.plot_Rfrac(bsa_extra) + + percentage_rn_extra = bsa_extra.R0/bsa_extra.R_n_IV + + ## getting result from the previous 2 + v0 = np.zeros(bsa_2.bgmap.shape[0]) + for bl in range(12): + mask_bl = np.where(bsa_2.bgmap==bl)[0] + v0[mask_bl] = vbias_estimate[bl] + + v1 = np.zeros(bsa_extra.bgmap.shape[0]) + for bl in range(12): + mask_bl = np.where(bsa_extra.bgmap==bl)[0] + v1[mask_bl] = extra_step_bias_voltage[bl] + ## deciding the new bias point + vbias_estimate_array_extra = (v0*(target_percentage_rn_array-percentage_rn_extra) + v1*(percentage_rn_confirm - target_percentage_rn_array)) / (percentage_rn_confirm - percentage_rn_extra) + + vbias_estimate_final = initial_dc_biases.copy() + for bl in bias_groups: + mask_bg = np.where(bsa_2.bgmap==bl)[0] + + per_bl_vbias_estimate = vbias_estimate_array_extra[mask_bg] + med_per_bl_vbias_estimate = np.nanmedian(per_bl_vbias_estimate) + vbias_estimate_final[bl] = med_per_bl_vbias_estimate + + S.log("applying the new bias voltages") + 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) + if not math_only: + bias_steps.plot_Rfrac(bsa_final) + + + return bsa_final,vbias_estimate_final From 4122222e569af739f1bedb635edc79b77ab00b2d Mon Sep 17 00:00:00 2001 From: yuhanwyhan <38056285+yuhanwyhan@users.noreply.github.com> Date: Mon, 19 Jun 2023 19:50:23 -0400 Subject: [PATCH 11/31] Update bias_dets.py --- sodetlib/operations/bias_dets.py | 90 +++++++++++++------------------- 1 file changed, 36 insertions(+), 54 deletions(-) diff --git a/sodetlib/operations/bias_dets.py b/sodetlib/operations/bias_dets.py index 5ff90aaa..f3b7095b 100644 --- a/sodetlib/operations/bias_dets.py +++ b/sodetlib/operations/bias_dets.py @@ -294,6 +294,42 @@ def biasstep_rebias( bg_detectors_normal.append(bl) drop_from_normal = True +## drop normal detector into transition first + while drop_from_normal: + S.log(f"some biaslines are still in normal state: {bg_detectors_normal}") + percentage_rn_0 = bsa_0.R0/bsa_0.R_n_IV + S.log("droping detectors from normal to transition") + previous_dc_biases_dfn = S.get_tes_bias_bipolar_array() + + S.log(f"current tes bias voltages are: {previous_dc_biases_dfn}") + for bl in bg_detectors_normal: + mask_bg = np.where(bsa_0.bgmap==bl)[0] + v_sc = iva.v_bias[iva.idxs[[mask_bg], 0]] + v_norm = iva.v_bias[iva.idxs[[mask_bg], 1]] + v_spread = np.nanmedian(v_norm) - np.nanmedian(v_sc) + previous_dc_biases_dfn[bl] = previous_dc_biases_dfn[bl] - 0.5 * v_spread + + S.set_tes_bias_bipolar_array(previous_dc_biases_dfn) + 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) + percentage_rn_0 = bsa_0.R0/bsa_0.R_n_IV + drop_from_normal = False + for bl in bg_detectors_normal: + mask_bg = np.where(bsa_0.bgmap==bl)[0] + per_bl_percentage_rn_0 = percentage_rn_0[mask_bg] + ## mask for normal + mask_normal = np.where((per_bl_percentage_rn_0 > 0.9) | (per_bl_percentage_rn_0 < -0.9)) + ## if more than half of the detectors are normal + if len(mask_normal[0]) > 0.5*len(mask_bg): + drop_from_normal = True + for bl in bg_detectors_normal: + if previous_dc_biases_dfn[bl] < 0.5: + bg_detectors_normal.remove(bl) + + + ##preparing for the 2nd step initial_dc_biases = S.get_tes_bias_bipolar_array() @@ -323,12 +359,6 @@ def biasstep_rebias( new_bias_voltage[bl] = initial_dc_biases[bl] + delta_dc_bias if med_per_bl_percentage_rn >= 0.5: new_bias_voltage[bl] = initial_dc_biases[bl] - delta_dc_bias - ## if the detector is normal, take a larger step - if bl in bg_detectors_normal: - S.log(f"some detectors are in normal state for bl{bl}, taking a large step") - if initial_dc_biases[bl] > cfg.dev.bias_groups[bl]["testbed_100mK_bias_voltage"]: - initial_dc_biases[bl] = cfg.dev.bias_groups[bl]["testbed_100mK_bias_voltage"] - new_bias_voltage[bl] = initial_dc_biases[bl] - 0.3 * v_spread S.log(f"applying new voltage for 2nd biasstep {new_bias_voltage}") S.set_tes_bias_bipolar_array(new_bias_voltage) @@ -354,54 +384,6 @@ def biasstep_rebias( percentage_rn_1 = bsa_1.R0/bsa_1.R_n_IV - ## add in check if detectors were normal are still normal - if drop_from_normal: - S.log(f"some biaslines were in normal state during 1st biasstep: {bg_detectors_normal}") - drop_from_normal = False - for bl in bg_detectors_normal: - mask_bg = np.where(bsa_1.bgmap==bl)[0] - per_bl_percentage_rn_1 = percentage_rn_1[mask_bg] - ## mask for normal - mask_normal = np.where((per_bl_percentage_rn_1 > 0.9) | (per_bl_percentage_rn_1 < -0.9)) - ## if more than half of the detectors are normal - if len(mask_normal[0]) > 0.5*len(mask_bg): - drop_from_normal = True - - while drop_from_normal: - S.log(f"some biaslines are still in normal state: {bg_detectors_normal}") - percentage_rn_1 = bsa_1.R0/bsa_1.R_n_IV - S.log("droping detectors from normal to transition") - previous_dc_biases_dfn = S.get_tes_bias_bipolar_array() - - S.log(f"current tes bias voltages are: {previous_dc_biases_dfn}") - for bl in bg_detectors_normal: - mask_bg = np.where(bsa_1.bgmap==bl)[0] - v_sc = iva.v_bias[iva.idxs[[mask_bg], 0]] - v_norm = iva.v_bias[iva.idxs[[mask_bg], 1]] - v_spread = np.nanmedian(v_norm) - np.nanmedian(v_sc) - previous_dc_biases_dfn[bl] = previous_dc_biases_dfn[bl] - 0.5 * v_spread - - S.set_tes_bias_bipolar_array(previous_dc_biases_dfn) - S.log(f"applying: {previous_dc_biases_dfn}") - S.log(f"waiting 30s for dissipation of UFM local heating") - time.sleep(30) - bsa_1 = bias_steps.take_bias_steps(S, cfg) - percentage_rn_1 = bsa_1.R0/bsa_1.R_n_IV - drop_from_normal = False - bg_detectors_normal = [] - for bl in bias_groups: - mask_bg = np.where(bsa_1.bgmap==bl)[0] - per_bl_percentage_rn_1 = percentage_rn_1[mask_bg] - ## mask for normal - mask_normal = np.where((per_bl_percentage_rn_1 > 0.9) | (per_bl_percentage_rn_1 < -0.9)) - ## if more than half of the detectors are normal - if len(mask_normal[0]) > 0.5*len(mask_bg): - drop_from_normal = True - bg_detectors_normal.append(bl) - for bl in bg_detectors_normal: - if previous_dc_biases_dfn[bl] < 1: - drop_from_normal = False - target_percentage_rn_array = target_percentage_rn * np.ones(len(percentage_rn_0)) ## getting result from the previous 2 v0 = np.zeros(bsa_0.bgmap.shape[0]) From 858bcec3201d238e5e12ea59714344270555cd6e Mon Sep 17 00:00:00 2001 From: yuhanwyhan <38056285+yuhanwyhan@users.noreply.github.com> Date: Mon, 19 Jun 2023 19:57:58 -0400 Subject: [PATCH 12/31] Update bias_dets.py --- sodetlib/operations/bias_dets.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sodetlib/operations/bias_dets.py b/sodetlib/operations/bias_dets.py index f3b7095b..11d2277b 100644 --- a/sodetlib/operations/bias_dets.py +++ b/sodetlib/operations/bias_dets.py @@ -266,7 +266,7 @@ def biasstep_rebias( if overbias_needed: - S.log("some BL are stuck in SC, going to over bias them, this takes about 5mins") + S.log(f"some BL: {bg_overbias_needed} are stuck in SC, going to over bias them, this takes about 5mins") previous_dc_biases = S.get_tes_bias_bipolar_array() sdl.overbias_dets(S, cfg, bias_groups=bg_overbias_needed) From e4801458392f1a29a29668b37416d6d69c8cc7cf Mon Sep 17 00:00:00 2001 From: yuhanwyhan <38056285+yuhanwyhan@users.noreply.github.com> Date: Mon, 19 Jun 2023 20:02:18 -0400 Subject: [PATCH 13/31] Update bias_dets.py --- sodetlib/operations/bias_dets.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sodetlib/operations/bias_dets.py b/sodetlib/operations/bias_dets.py index 11d2277b..dc5b31c3 100644 --- a/sodetlib/operations/bias_dets.py +++ b/sodetlib/operations/bias_dets.py @@ -212,7 +212,8 @@ def biasstep_rebias( """ - + ## load IV analysis result so can use dynamic step size + iva = iv.IVAnalysis.load(bsa_0.meta['iv_file']) ## take the initial biasstep S.log("taking the first biasstep") @@ -335,8 +336,7 @@ def biasstep_rebias( initial_dc_biases = S.get_tes_bias_bipolar_array() new_bias_voltage = initial_dc_biases.copy() - ## load IV analysis result so can use dynamic step size - iva = iv.IVAnalysis.load(bsa_0.meta['iv_file']) + for bl in bias_groups: From db0b073a4250cccbcc7d3ab0898d5abff4bff140 Mon Sep 17 00:00:00 2001 From: yuhanwyhan <38056285+yuhanwyhan@users.noreply.github.com> Date: Mon, 19 Jun 2023 20:04:05 -0400 Subject: [PATCH 14/31] Update bias_dets.py --- sodetlib/operations/bias_dets.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sodetlib/operations/bias_dets.py b/sodetlib/operations/bias_dets.py index dc5b31c3..29a726f2 100644 --- a/sodetlib/operations/bias_dets.py +++ b/sodetlib/operations/bias_dets.py @@ -212,8 +212,6 @@ def biasstep_rebias( """ - ## load IV analysis result so can use dynamic step size - iva = iv.IVAnalysis.load(bsa_0.meta['iv_file']) ## take the initial biasstep S.log("taking the first biasstep") @@ -222,7 +220,10 @@ def biasstep_rebias( bsa_0 = bias_steps.take_bias_steps(S, cfg) if not math_only: bias_steps.plot_Rfrac(bsa_0) - + + ## load IV analysis result so can use dynamic step size + iva = iv.IVAnalysis.load(bsa_0.meta['iv_file']) + repeat_biasstep = False ## check for script failue for bl in bias_groups: From d06ad93a2fe48fc6c2f8d851d52b2cef212c747a Mon Sep 17 00:00:00 2001 From: yuhanwyhan <38056285+yuhanwyhan@users.noreply.github.com> Date: Mon, 19 Jun 2023 20:09:40 -0400 Subject: [PATCH 15/31] Update bias_dets.py --- sodetlib/operations/bias_dets.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sodetlib/operations/bias_dets.py b/sodetlib/operations/bias_dets.py index 29a726f2..cce9c4fb 100644 --- a/sodetlib/operations/bias_dets.py +++ b/sodetlib/operations/bias_dets.py @@ -326,6 +326,8 @@ def biasstep_rebias( ## if more than half of the detectors are normal if len(mask_normal[0]) > 0.5*len(mask_bg): drop_from_normal = True + else: + bg_detectors_normal.remove(bl) for bl in bg_detectors_normal: if previous_dc_biases_dfn[bl] < 0.5: bg_detectors_normal.remove(bl) From 77df01cf768952bf3e6ee10cf4534f60c5098fd6 Mon Sep 17 00:00:00 2001 From: yuhanwyhan <38056285+yuhanwyhan@users.noreply.github.com> Date: Mon, 19 Jun 2023 20:48:57 -0400 Subject: [PATCH 16/31] Update bias_dets.py --- sodetlib/operations/bias_dets.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sodetlib/operations/bias_dets.py b/sodetlib/operations/bias_dets.py index cce9c4fb..8ba2850f 100644 --- a/sodetlib/operations/bias_dets.py +++ b/sodetlib/operations/bias_dets.py @@ -309,7 +309,12 @@ def biasstep_rebias( v_sc = iva.v_bias[iva.idxs[[mask_bg], 0]] v_norm = iva.v_bias[iva.idxs[[mask_bg], 1]] v_spread = np.nanmedian(v_norm) - np.nanmedian(v_sc) - previous_dc_biases_dfn[bl] = previous_dc_biases_dfn[bl] - 0.5 * v_spread + if previous_dc_biases_dfn[bl] > v_spread: + previous_dc_biases_dfn[bl] = previous_dc_biases_dfn[bl] - 0.5 * v_spread + else: + previous_dc_biases_dfn[bl] = previous_dc_biases_dfn[bl] - 0.3 * v_spread + bg_detectors_normal.remove(bl) + S.log(f'biasline {bl} is approching 0 voltage, a confirmation new IV curve is recommended') S.set_tes_bias_bipolar_array(previous_dc_biases_dfn) S.log(f"applying: {previous_dc_biases_dfn}") @@ -407,7 +412,8 @@ def biasstep_rebias( per_bl_vbias_estimate = vbias_estimate_array[mask_bg] med_per_bl_vbias_estimate = np.nanmedian(per_bl_vbias_estimate) - ## if the current bias point is below 50% Rn, increase V_biaa + if np.isnan(med_per_bl_vbias_estimate): + med_per_bl_vbias_estimate = (v1 + v0)/2 vbias_estimate[bl] = med_per_bl_vbias_estimate S.log("applying the new bias voltages") From ce45d670f8357058db4a43398e97ff5d27c9f79d Mon Sep 17 00:00:00 2001 From: yuhanwyhan <38056285+yuhanwyhan@users.noreply.github.com> Date: Tue, 20 Jun 2023 11:45:03 -0400 Subject: [PATCH 17/31] Update bias_dets.py --- sodetlib/operations/bias_dets.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sodetlib/operations/bias_dets.py b/sodetlib/operations/bias_dets.py index 8ba2850f..c93623fc 100644 --- a/sodetlib/operations/bias_dets.py +++ b/sodetlib/operations/bias_dets.py @@ -522,8 +522,11 @@ def biasstep_rebias( per_bl_vbias_estimate = vbias_estimate_array_extra[mask_bg] med_per_bl_vbias_estimate = np.nanmedian(per_bl_vbias_estimate) + if np.isnan(med_per_bl_vbias_estimate): + med_per_bl_vbias_estimate = (v1 + v0)/2 vbias_estimate_final[bl] = med_per_bl_vbias_estimate + S.log("applying the new bias voltages") S.set_tes_bias_bipolar_array(vbias_estimate_final) S.log(f"applying {vbias_estimate_final}") From 56ee1336968e68a00c4e00ff0bb32dae5706cd36 Mon Sep 17 00:00:00 2001 From: yuhanwyhan <38056285+yuhanwyhan@users.noreply.github.com> Date: Tue, 20 Jun 2023 15:30:58 -0400 Subject: [PATCH 18/31] Update bias_dets.py --- sodetlib/operations/bias_dets.py | 85 +++++++++++++++++++++++++------- 1 file changed, 67 insertions(+), 18 deletions(-) diff --git a/sodetlib/operations/bias_dets.py b/sodetlib/operations/bias_dets.py index c93623fc..deb13056 100644 --- a/sodetlib/operations/bias_dets.py +++ b/sodetlib/operations/bias_dets.py @@ -3,7 +3,7 @@ import time import matplotlib.pyplot as plt from sodetlib.operations.iv import IVAnalysis -from sodetlib.operations import uxm_setup, uxm_relock, tracking, bias_steps, iv, bias_dets +from sodetlib.operations import bias_steps, iv np.seterr(all="ignore") @@ -203,23 +203,52 @@ def bias_to_rfrac(S, cfg, rfrac=0.5, bias_groups=None, iva=None, def biasstep_rebias( S, cfg, target_percentage_rn = 0.5, bias_groups=None, - math_only=False): + show_plots=True, make_plots=True): """ - Scripts work well when detectors are already in transistion. For extreme cases - such as detectors are all in SC, it takes a few run to put them perfectly in - transition. Next step is making this script can handle extreme cases faster - + re-bias detectors by taking bias_steps. + + Args + ----- + S : SmurfControl + Pysmurf instance + cfg : DetConfig + det config instance + target_percentage_rn : float + this is the target percentage rn for the script to bias to, numbers should be + between 0.3 and 0.7 for general usage. + bias_groups : list + List of bias groups to bias. If None, this will default to the active + bgs specified in the device cfg. + make_plots : bool + If this is set to False, the script will still apply the bias-voltage but will not + generate plots + show_plots : bool + If this is set to False, the script will not show plots + Returns + ---------- + bsa_final : + analysis result of the last biasstep taken with the re-biased bais voltage + vbias_estimate_final : + final bias_voltages calculated and applied by the script """ + if bias_groups is None: + bias_groups = cfg.dev.exp['active_bgs'] + bias_groups = np.atleast_1d(bias_groups) ## take the initial biasstep S.log("taking the first biasstep") - intical_current_biasvoltage = S.get_tes_bias_bipolar_array() - S.log(f"current biasvoltage {intical_current_biasvoltage}") + S.log(f"Initial dc biases {S.get_tes_bipolar_array()}") bsa_0 = bias_steps.take_bias_steps(S, cfg) - if not math_only: - bias_steps.plot_Rfrac(bsa_0) + if make_plots: + fig, ax = bias_steps.plot_Rfrac(bsa_0) + fname = sdl.make_filename(S, 'intial_Rfrac.png', plot=True) + fig.savefig(fname) + S.pub.register_file(fname, 'biasstep_rfrac', format='png', plot=True) + if not show_plots: + plt.close(fig) + ## load IV analysis result so can use dynamic step size iva = iv.IVAnalysis.load(bsa_0.meta['iv_file']) @@ -374,8 +403,13 @@ def biasstep_rebias( ## taking the second bias step S.log("taking the 2nd biasstep") bsa_1 = bias_steps.take_bias_steps(S, cfg) - if not math_only: - bias_steps.plot_Rfrac(bsa_1) + if make_plots: + fig, ax = bias_steps.plot_Rfrac(bsa_1) + fname = sdl.make_filename(S, '2nd_Rfrac.png', plot=True) + fig.savefig(fname) + S.pub.register_file(fname, 'biasstep_rfrac', format='png', plot=True) + if not show_plots: + plt.close(fig) ## check for script failue for bl in bias_groups: @@ -435,8 +469,13 @@ def biasstep_rebias( bsa_2 = bias_steps.take_bias_steps(S, cfg) repeat_biasstep = False - if not math_only: - bias_steps.plot_Rfrac(bsa_2) + if make_plots: + fig, ax = bias_steps.plot_Rfrac(bsa_2) + fname = sdl.make_filename(S, 'rebiased_Rfrac.png', plot=True) + fig.savefig(fname) + S.pub.register_file(fname, 'biasstep_rfrac', format='png', plot=True) + if not show_plots: + plt.close(fig) S.log("confirming if the current result is close to the target") @@ -498,8 +537,13 @@ def biasstep_rebias( bsa_extra = bias_steps.take_bias_steps(S, cfg) repeat_biasstep = False - if not math_only: - bias_steps.plot_Rfrac(bsa_extra) + if make_plots: + fig, ax = bias_steps.plot_Rfrac(bsa_extra) + fname = sdl.make_filename(S, '3rd_Rfrac.png', plot=True) + fig.savefig(fname) + S.pub.register_file(fname, 'biasstep_rfrac', format='png', plot=True) + if not show_plots: + plt.close(fig) percentage_rn_extra = bsa_extra.R0/bsa_extra.R_n_IV @@ -532,8 +576,13 @@ def biasstep_rebias( S.log(f"applying {vbias_estimate_final}") S.log("taking the final biasstep") bsa_final = bias_steps.take_bias_steps(S, cfg) - if not math_only: - bias_steps.plot_Rfrac(bsa_final) + if make_plots: + fig, ax = bias_steps.plot_Rfrac(bsa_final) + fname = sdl.make_filename(S, 'rebiased_Rfrac_2.png', plot=True) + fig.savefig(fname) + S.pub.register_file(fname, 'biasstep_rfrac', format='png', plot=True) + if not show_plots: + plt.close(fig) return bsa_final,vbias_estimate_final From aefe18311a0d69d3e07dfc454ef74d7adf5d00f9 Mon Sep 17 00:00:00 2001 From: yuhanwyhan <38056285+yuhanwyhan@users.noreply.github.com> Date: Tue, 20 Jun 2023 15:35:39 -0400 Subject: [PATCH 19/31] Update bias_dets.py --- sodetlib/operations/bias_dets.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sodetlib/operations/bias_dets.py b/sodetlib/operations/bias_dets.py index deb13056..5d2b362e 100644 --- a/sodetlib/operations/bias_dets.py +++ b/sodetlib/operations/bias_dets.py @@ -239,7 +239,7 @@ def biasstep_rebias( ## take the initial biasstep S.log("taking the first biasstep") - S.log(f"Initial dc biases {S.get_tes_bipolar_array()}") + S.log(f"Initial dc biases {S.get_tes_bias_bipolar_array()}") bsa_0 = bias_steps.take_bias_steps(S, cfg) if make_plots: fig, ax = bias_steps.plot_Rfrac(bsa_0) From 05fea5d1b4fcdea22c099d60ce505abc5ab64626 Mon Sep 17 00:00:00 2001 From: yuhanwyhan <38056285+yuhanwyhan@users.noreply.github.com> Date: Tue, 20 Jun 2023 16:31:26 -0400 Subject: [PATCH 20/31] Update bias_dets.py --- sodetlib/operations/bias_dets.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sodetlib/operations/bias_dets.py b/sodetlib/operations/bias_dets.py index 5d2b362e..880239ac 100644 --- a/sodetlib/operations/bias_dets.py +++ b/sodetlib/operations/bias_dets.py @@ -310,7 +310,13 @@ def biasstep_rebias( S.set_tes_bias_bipolar_array(safe_dc_biases) bsa_0 = bias_steps.take_bias_steps(S, cfg) - bias_steps.plot_Rfrac(bsa_0) + if make_plots: + fig, ax = bias_steps.plot_Rfrac(bsa_0) + fname = sdl.make_filename(S, 'post_overbiasing_Rfrac.png', plot=True) + fig.savefig(fname) + S.pub.register_file(fname, 'biasstep_rfrac', format='png', plot=True) + if not show_plots: + plt.close(fig) ## add in check if detectors are normal now percentage_rn_0 = bsa_0.R0/bsa_0.R_n_IV From 87fbf1816a92368c1c4454168f4f1f42bf8b8c6c Mon Sep 17 00:00:00 2001 From: yuhanwyhan <38056285+yuhanwyhan@users.noreply.github.com> Date: Tue, 20 Jun 2023 17:07:40 -0400 Subject: [PATCH 21/31] Update bias_dets.py --- sodetlib/operations/bias_dets.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sodetlib/operations/bias_dets.py b/sodetlib/operations/bias_dets.py index 880239ac..612cc649 100644 --- a/sodetlib/operations/bias_dets.py +++ b/sodetlib/operations/bias_dets.py @@ -306,7 +306,13 @@ def biasstep_rebias( time.sleep(60) safe_dc_biases = previous_dc_biases.copy() for replace_bg in bg_overbias_needed: - safe_dc_biases[replace_bg] = cfg.dev.bias_groups[replace_bg]["testbed_100mK_bias_voltage"] + try: + safe_dc_biases[replace_bg] = cfg.dev.bias_groups[replace_bg]["testbed_100mK_bias_voltage"] + except: + mask_bg = np.where(bsa_0.bgmap==replace_bg)[0] + v_norm_bl = np.nanmedian(iva.v_bias[iva.idxs[[mask_bg], 1]]) + safe_dc_biases[replace_bg] = v_norm_bl + S.set_tes_bias_bipolar_array(safe_dc_biases) bsa_0 = bias_steps.take_bias_steps(S, cfg) From e651ce43244c59b5bbf84b64fc1310efb4b3c3c6 Mon Sep 17 00:00:00 2001 From: yuhanwyhan <38056285+yuhanwyhan@users.noreply.github.com> Date: Tue, 20 Jun 2023 17:20:54 -0400 Subject: [PATCH 22/31] Update bias_dets.py --- sodetlib/operations/bias_dets.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sodetlib/operations/bias_dets.py b/sodetlib/operations/bias_dets.py index 612cc649..024af7f9 100644 --- a/sodetlib/operations/bias_dets.py +++ b/sodetlib/operations/bias_dets.py @@ -308,7 +308,7 @@ def biasstep_rebias( for replace_bg in bg_overbias_needed: try: safe_dc_biases[replace_bg] = cfg.dev.bias_groups[replace_bg]["testbed_100mK_bias_voltage"] - except: + except KeyError: mask_bg = np.where(bsa_0.bgmap==replace_bg)[0] v_norm_bl = np.nanmedian(iva.v_bias[iva.idxs[[mask_bg], 1]]) safe_dc_biases[replace_bg] = v_norm_bl From 92e29a8e363181be209c71602d654d7393d6f5c8 Mon Sep 17 00:00:00 2001 From: yuhanwyhan <38056285+yuhanwyhan@users.noreply.github.com> Date: Tue, 20 Jun 2023 17:30:52 -0400 Subject: [PATCH 23/31] Update bias_dets.py --- sodetlib/operations/bias_dets.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sodetlib/operations/bias_dets.py b/sodetlib/operations/bias_dets.py index 024af7f9..6eb5d19d 100644 --- a/sodetlib/operations/bias_dets.py +++ b/sodetlib/operations/bias_dets.py @@ -459,7 +459,7 @@ def biasstep_rebias( per_bl_vbias_estimate = vbias_estimate_array[mask_bg] med_per_bl_vbias_estimate = np.nanmedian(per_bl_vbias_estimate) if np.isnan(med_per_bl_vbias_estimate): - med_per_bl_vbias_estimate = (v1 + v0)/2 + med_per_bl_vbias_estimate = (np.nanmedian(v1[mask_bg]) + np.nanmedian(v0[mask_bg]))/2 vbias_estimate[bl] = med_per_bl_vbias_estimate S.log("applying the new bias voltages") @@ -579,7 +579,7 @@ def biasstep_rebias( per_bl_vbias_estimate = vbias_estimate_array_extra[mask_bg] med_per_bl_vbias_estimate = np.nanmedian(per_bl_vbias_estimate) if np.isnan(med_per_bl_vbias_estimate): - med_per_bl_vbias_estimate = (v1 + v0)/2 + med_per_bl_vbias_estimate = (np.nanmedian(v1[mask_bg]) + np.nanmedian(v0[mask_bg]))/2 vbias_estimate_final[bl] = med_per_bl_vbias_estimate From ef1f259f91ce91038cbd61bd3b48182467f7df06 Mon Sep 17 00:00:00 2001 From: yuhanwyhan <38056285+yuhanwyhan@users.noreply.github.com> Date: Tue, 20 Jun 2023 17:37:21 -0400 Subject: [PATCH 24/31] Update det_config.py for adding in 'testbed_100mK_bias_voltage' that is used in the biasstep_rebias script --- sodetlib/det_config.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sodetlib/det_config.py b/sodetlib/det_config.py index 441eb45f..65ae83c9 100644 --- a/sodetlib/det_config.py +++ b/sodetlib/det_config.py @@ -99,7 +99,8 @@ def odict_rep(dumper, data): } bg_defaults = { 'overbias_voltage': 19.9, - 'cool_voltage': 10.0 + 'cool_voltage': 10.0, + 'testbed_100mK_bias_voltage': 10.0 } From 2d3b2fbabec9396170b498aed80564758631971c Mon Sep 17 00:00:00 2001 From: yuhanwyhan <38056285+yuhanwyhan@users.noreply.github.com> Date: Tue, 20 Jun 2023 17:49:09 -0400 Subject: [PATCH 25/31] Update det_config.py --- sodetlib/det_config.py | 1 + 1 file changed, 1 insertion(+) diff --git a/sodetlib/det_config.py b/sodetlib/det_config.py index 65ae83c9..8d1405d4 100644 --- a/sodetlib/det_config.py +++ b/sodetlib/det_config.py @@ -101,6 +101,7 @@ def odict_rep(dumper, data): 'overbias_voltage': 19.9, 'cool_voltage': 10.0, 'testbed_100mK_bias_voltage': 10.0 + 'overbias_sleep_time_sec': 300 } From 076db687efca7301427a47db81d73721991697bd Mon Sep 17 00:00:00 2001 From: yuhanwyhan <38056285+yuhanwyhan@users.noreply.github.com> Date: Tue, 20 Jun 2023 17:49:22 -0400 Subject: [PATCH 26/31] Update det_config.py --- sodetlib/det_config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sodetlib/det_config.py b/sodetlib/det_config.py index 8d1405d4..599dd3d2 100644 --- a/sodetlib/det_config.py +++ b/sodetlib/det_config.py @@ -100,7 +100,7 @@ def odict_rep(dumper, data): bg_defaults = { 'overbias_voltage': 19.9, 'cool_voltage': 10.0, - 'testbed_100mK_bias_voltage': 10.0 + 'testbed_100mK_bias_voltage': 10.0, 'overbias_sleep_time_sec': 300 } From 6dd051713b95e613feeef2594317d2b0118d3111 Mon Sep 17 00:00:00 2001 From: yuhanwyhan <38056285+yuhanwyhan@users.noreply.github.com> Date: Tue, 20 Jun 2023 17:53:57 -0400 Subject: [PATCH 27/31] Update det_config.py --- sodetlib/det_config.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sodetlib/det_config.py b/sodetlib/det_config.py index 599dd3d2..f83f886a 100644 --- a/sodetlib/det_config.py +++ b/sodetlib/det_config.py @@ -78,7 +78,10 @@ def odict_rep(dumper, data): "res_fit_file": None, # Overbiasing - 'overbias_wait': 2.0 + 'overbias_wait': 2.0, + + # overbias wait time + 'overbias_sleep_time_sec': 300 } band_defaults = { # General @@ -100,8 +103,7 @@ def odict_rep(dumper, data): bg_defaults = { 'overbias_voltage': 19.9, 'cool_voltage': 10.0, - 'testbed_100mK_bias_voltage': 10.0, - 'overbias_sleep_time_sec': 300 + 'testbed_100mK_bias_voltage': 10.0 } From 01fd395e304cb7c105efdf9c2ee0f10588e00b66 Mon Sep 17 00:00:00 2001 From: yuhanwyhan <38056285+yuhanwyhan@users.noreply.github.com> Date: Tue, 20 Jun 2023 17:56:14 -0400 Subject: [PATCH 28/31] Update bias_dets.py --- sodetlib/operations/bias_dets.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sodetlib/operations/bias_dets.py b/sodetlib/operations/bias_dets.py index 6eb5d19d..90057c1a 100644 --- a/sodetlib/operations/bias_dets.py +++ b/sodetlib/operations/bias_dets.py @@ -301,9 +301,9 @@ def biasstep_rebias( previous_dc_biases = S.get_tes_bias_bipolar_array() sdl.overbias_dets(S, cfg, bias_groups=bg_overbias_needed) - ##force wait time 5 mins for UFM to reach equalibrium - for sleep_index in range(5): - time.sleep(60) + ##force wait for UFM to reach equalibrium + sleep_time = cfg.dev.experiment["overbias_sleep_time_sec"] + time.sleep(sleep_time) safe_dc_biases = previous_dc_biases.copy() for replace_bg in bg_overbias_needed: try: From 1327af09e45c28027d55366f36770a3c69777cda Mon Sep 17 00:00:00 2001 From: jlashner Date: Sat, 2 Sep 2023 15:30:43 -0400 Subject: [PATCH 29/31] Makes biasstep_rebias an action, and simple docs page --- docs/index.rst | 1 + docs/operations/biasstep_rebias.rst | 48 +++++++++++++++++++++++++++++ sodetlib/operations/bias_dets.py | 1 + 3 files changed, 50 insertions(+) create mode 100644 docs/operations/biasstep_rebias.rst diff --git a/docs/index.rst b/docs/index.rst index c87e2c51..640c7b24 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -22,6 +22,7 @@ Contents operations/setup operations/bias_steps + operations/biasstep_rebias operations/iv operations/squid_curves operations/complex_impedance diff --git a/docs/operations/biasstep_rebias.rst b/docs/operations/biasstep_rebias.rst new file mode 100644 index 00000000..d38af010 --- /dev/null +++ b/docs/operations/biasstep_rebias.rst @@ -0,0 +1,48 @@ +Bias Step Rebias +================================ + +For various reasons, it may be beneficial to bias or rebias detectors into their +transition using bias-step functions instead of IVs, since +- bias steps can be much faster than IVs +- bias steps don't require overbiasing + +Yuhan Wang has developed the bias-step rebiasing function to find a suitable +bias-point using just bias steps, which is described in greater detail in `his +spie proceeding `_. + +The general control flow is as follows: + + 1. Take initial bias steps bsa_0 + will rebias if there are any bias lines where R0 is all nan + If >10% of dets are have Rfrac < 0.1, marks bg as overbias_needed + If >50% of dets have Rfrac > 0.9, marks bg as normal (and drop from normal needed) + 2. Overbias overbias_needed bgs + runs overbias_dets on bgs that need overbiasing, and waits + For biaslines that have been overbiased, set the DC bias voltage to testbed_100mK_bias_voltage + Run bias steps + (no bias retry here) + Check normal condition (above) and add updated bias lines to bg_detectors_normal array if they meet it + 3. Drop from normal + For each normal bg, step voltage by 0.5(V_norm - V_SC) determined from IV + Run bias steps + update bsa_0 so it's always the last bias step ran + These bias steps don't have a retry + Check normal condition. If any bgs are still normal, repeat. + After exiting loop, the resulting DC biases are initial_dc_biases + 4. Find new bjas voltage and take bias steps: + vspread is diff between median normal and median SC voltages based on IV + New bias voltage is init +/- 0.15*vspread where +/- is determined by + whether or not the median Rfrac is > or < than 0.5 + Take bias steps (bsa_1) and retry if needed + 5. Determine new bias point for each channel: + v_estimate = (v0 (target - Rfrac_1) + v1 (Rfrac_0 - target)) / (Rfrac_0 - Rfrac_1) + vnew = median(v_estimate[bg]), or if all are nan, vnew = (v1 - v0) / 2 + 6. Set bias to vnew and retake bias steps bsa_2 (with retry if needed) + BG is successful if abs(Rfrac - target) < 0.05 + 7. Fine tuning unsuccessful bias groups + Step 0.15 vspread in the appropriate direction + Take bias steps (with retry) + v_estimate2 = (v0 (target - Rfrac_1) + v1 (Rfrac_0 - target)) / (Rfrac_0 - Rfrac_1) + with v0= prev estimate and v1 = prev estimate + delta + Apply v_estimate2, retake bias steps. + 8. Return final bias step and bias voltages diff --git a/sodetlib/operations/bias_dets.py b/sodetlib/operations/bias_dets.py index 90057c1a..4c701123 100644 --- a/sodetlib/operations/bias_dets.py +++ b/sodetlib/operations/bias_dets.py @@ -201,6 +201,7 @@ def bias_to_rfrac(S, cfg, rfrac=0.5, bias_groups=None, iva=None, return biases +sdl.set_action() def biasstep_rebias( S, cfg, target_percentage_rn = 0.5, bias_groups=None, show_plots=True, make_plots=True): From b2b6101f7bde8a5c8a42071e7b924837d84b990e Mon Sep 17 00:00:00 2001 From: jlashner Date: Sat, 2 Sep 2023 18:20:51 -0400 Subject: [PATCH 30/31] Change g3_tag for bias_step functions --- sodetlib/operations/bias_dets.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/sodetlib/operations/bias_dets.py b/sodetlib/operations/bias_dets.py index 4c701123..671e5757 100644 --- a/sodetlib/operations/bias_dets.py +++ b/sodetlib/operations/bias_dets.py @@ -238,10 +238,12 @@ def biasstep_rebias( bias_groups = cfg.dev.exp['active_bgs'] bias_groups = np.atleast_1d(bias_groups) + g3_tag = 'oper,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) + bsa_0 = bias_steps.take_bias_steps(S, cfg, g3_tag='oper,biasstep_rebias') if make_plots: fig, ax = bias_steps.plot_Rfrac(bsa_0) fname = sdl.make_filename(S, 'intial_Rfrac.png', plot=True) @@ -266,7 +268,7 @@ def biasstep_rebias( if repeat_biasstep: S.log("retaking biasstep due to failure") - bsa_0 = bias_steps.take_bias_steps(S, cfg) + bsa_0 = bias_steps.take_bias_steps(S, cfg, g3_tag=g3_tag) repeat_biasstep = False percentage_rn_0 = bsa_0.R0/bsa_0.R_n_IV @@ -316,7 +318,7 @@ def biasstep_rebias( S.set_tes_bias_bipolar_array(safe_dc_biases) - bsa_0 = bias_steps.take_bias_steps(S, cfg) + bsa_0 = bias_steps.take_bias_steps(S, cfg, g3_tag=g3_tag) if make_plots: fig, ax = bias_steps.plot_Rfrac(bsa_0) fname = sdl.make_filename(S, 'post_overbiasing_Rfrac.png', plot=True) @@ -362,7 +364,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) + bsa_0 = bias_steps.take_bias_steps(S, cfg, g3_tag=g3_tag) percentage_rn_0 = bsa_0.R0/bsa_0.R_n_IV drop_from_normal = False for bl in bg_detectors_normal: @@ -415,7 +417,7 @@ def biasstep_rebias( ## taking the second bias step S.log("taking the 2nd biasstep") - bsa_1 = bias_steps.take_bias_steps(S, cfg) + bsa_1 = bias_steps.take_bias_steps(S, cfg, g3_tag=g3_tag) if make_plots: fig, ax = bias_steps.plot_Rfrac(bsa_1) fname = sdl.make_filename(S, '2nd_Rfrac.png', plot=True) @@ -434,7 +436,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) + bsa_1 = bias_steps.take_bias_steps(S, cfg, g3_tag=g3_tag) repeat_biasstep = False percentage_rn_1 = bsa_1.R0/bsa_1.R_n_IV @@ -467,7 +469,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) + bsa_2 = bias_steps.take_bias_steps(S, cfg, g3_tag=g3_tag) ## check for script failue for bl in bias_groups: @@ -479,7 +481,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) + bsa_2 = bias_steps.take_bias_steps(S, cfg, g3_tag=g3_tag) repeat_biasstep = False if make_plots: @@ -535,7 +537,7 @@ def biasstep_rebias( ## taking the extra bias step S.log("taking the extra biasstep") - bsa_extra = bias_steps.take_bias_steps(S, cfg) + bsa_extra = bias_steps.take_bias_steps(S, cfg, g3_tag=g3_tag) ## check for script failue for bl in bias_groups: @@ -547,7 +549,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) + bsa_extra = bias_steps.take_bias_steps(S, cfg, g3_tag=g3_tag) repeat_biasstep = False if make_plots: @@ -588,7 +590,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) + bsa_final = bias_steps.take_bias_steps(S, cfg, g3_tag=g3_tag) if make_plots: fig, ax = bias_steps.plot_Rfrac(bsa_final) fname = sdl.make_filename(S, 'rebiased_Rfrac_2.png', plot=True) From 7e25878f589dc7724437533b4ca67dd3f9ae8f2c Mon Sep 17 00:00:00 2001 From: jlashner Date: Sun, 3 Sep 2023 09:42:11 -0300 Subject: [PATCH 31/31] fix remaining hardcoded g3_tag --- sodetlib/operations/bias_dets.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sodetlib/operations/bias_dets.py b/sodetlib/operations/bias_dets.py index 671e5757..43fad5fa 100644 --- a/sodetlib/operations/bias_dets.py +++ b/sodetlib/operations/bias_dets.py @@ -243,7 +243,7 @@ def 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='oper,biasstep_rebias') + bsa_0 = bias_steps.take_bias_steps(S, cfg, g3_tag=g3_tag) if make_plots: fig, ax = bias_steps.plot_Rfrac(bsa_0) fname = sdl.make_filename(S, 'intial_Rfrac.png', plot=True)