simonsobs / sodetlib

Tools for performing core instrument testing, quality control, and analysis tasks.
BSD 2-Clause "Simplified" License
5 stars 0 forks source link

Biasstep rebias #362

Closed yuhanwyhan closed 1 year ago

yuhanwyhan commented 1 year ago

this contains the script of re-biasing detectors using biasstep. this function has recently been tested in LATR-t with different loading conditions. this plot is showing the result of re-biasing detectors when LATR-t ful exposed to the room

Screenshot 2023-06-20 at 11 58 53 AM

this plot is showing the result of re-biasing detectors after covering the LATR-t with a metal plate

Screenshot 2023-06-20 at 11 59 40 AM

Notice the tests were done with UHF detectors (Uv31), and the change of loading between these two test are very large. in the field we expect lower and more gradually change of loadings.

The next level thing is to make the script run faster, this might involve only running part of the analysis code for bias-step.

jlashner commented 1 year ago

Hi Yuhan, I'm about to start reviewing this, but do you think you can post here (or in the docstring) like the overall strategy for how this works? Something like a flow-chart that documents what it will try to do at each step under what conditions, etc. would be really helpful for understanding this at a higher level

yuhanwyhan commented 1 year ago

Hi Yuhan, I'm about to start reviewing this, but do you think you can post here (or in the docstring) like the overall strategy for how this works? Something like a flow-chart that documents what it will try to do at each step under what conditions, etc. would be really helpful for understanding this at a higher level

the main logic is described in 4.2.2 of https://arxiv.org/pdf/2208.05997.pdf

extra parts of this script is for handling failures of bias_step and handling extreme situations of detectors stucked in SC state or in normal state

jlashner commented 1 year ago

Hi Yuhan, finally was able to read through the entire function. Here are the notes I took about the control flow. Do you agree with this as the intended behavior?

  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
jlashner commented 1 year ago

Can you give an estimate of the run-time?

yuhanwyhan commented 1 year ago

Can you give an estimate of the run-time?

4 mins if start from in-transition, 14 mins if start from SC. (tested in LATRt)

msilvafe commented 1 year ago

I like this description of the flow of the function. Since @yuhanwyhan gave the thumbs up to the description can you commit that to the docs rst file along with a link to Yuhan's conference proceedings @jlashner ?

yuhanwyhan commented 1 year ago

there is one potential rare failure mode I just realized. let's assume a situation that there is one bad biasline that causes heating or that biasline is short to a FR, and we don't want to touch it at all. The current script will still take a few bias_steps on this biasline. Although if a biasline is bad, we will not put bias_voltage on it to start with, so taking a biasstep round 0 voltage shouldn't do much damage, still....

the solution for this issue will require some re-writing.

the current script forces taking bg map for all 12 biaslines because when it calculates the v_estimate, it does the calculation for all biaslines and then apply the bg_map. One possible fix will be adding a for loop looping over the chosen biaslines and apply the bg_map inside the for loop such that the script only calculate the v_estimate for the chosen biaslines.

I suggest adding this fix into the later version of this script when we can test it cold again. Right now without a cold cryostat and MF/UHF UFMs, I am not confident that this change won't break the code.

yuhanwyhan commented 1 year ago

a way to make the script faster will be only running the R_tes calculation from biasstep except the final biasstep (running only the _compute_R0_I0_Pj part). An estimation of the run-time for each analysis block of the current biasstep function will be nice.

msilvafe commented 1 year ago

Added a simple docs page linking to the spie paper, and made the function a pysmurf action. I think I am happy to merge this in now and solve any problems with it as they come up.

@kmharrington mentioned 2 additional things needed for this to be used within the site data operations, and packaging:

  1. Getting the .g3 tags in the file to be something other than oper,bias_steps so they aren't all made into different operations books.
  2. Figure out how to get imprinter to bind them all together into one book

I’m happy to wait on 2 until later but if 1 is a simple-ish modification I would like to get that in before merge. We want to use this soon in SAT-MF1 though so if not simple ok to merge and open new issue/or with these additional things.

jlashner commented 1 year ago

Right, thanks for reminding me. Latest commit should do that, and sets all g3_tags to oper,biasstep_rebias

msilvafe commented 1 year ago

Right, thanks for reminding me. Latest commit should do that, and sets all g3_tags to oper,biasstep_rebias

Thanks let's get this merged then