Skip to content

Commit

Permalink
Adds general task to set TES biases
Browse files Browse the repository at this point in the history
  • Loading branch information
jlashner committed Oct 11, 2023
1 parent 0e28f87 commit 968ca64
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions socs/agents/pysmurf_controller/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,47 @@ def overbias_tes(self, session, params):
sdl.overbias_dets(S, cfg, **kw)

return True, "Finished Overbiasing TES"

@ocs_agent.param('bgs', default=None)
@ocs_agent.params('bias', default=0)
def set_biases(self, session, params):
"""set_biases(bg=None, bias=0)
**Task** - Task used ot set TES biases.
Args
-----
bg: int, list, optional
bg, or list of bgs to set. If None, will set all bgs.
bias: int, float, list
Biases to set. If a float is passed, this will be used for all
specified bgs. If a list of floats is passed, it must be the same
size of the list of bgs.
"""
if params['bgs'] is None:
bgs = np.arange(12)
else:
bgs = np.atleast_1d(params['bgs'])

if isinstance(params['bias'], (int, float)):
biases = [params['bias'] for _ in bgs]
else:
if len(params['bias']) != len(bgs):
return False, "Number of biases must match number of bgs"
biases = params['bias']

with self.lock.acquire_timeout(0, job='set_biases') as acquired:
if not acquired:
return False, f"Operation failed: {self.lock.job} is running."

session.set_status('running')
S, _ = self._get_smurf_control(session=session)

for bg, bias in zip(bgs, biases):
S.set_tes_bias_bipolar(bg, bias)

return True, f"Finished setting biases to {params['biases']}"


@ocs_agent.param('rfrac', default=(0.3, 0.6))
@ocs_agent.param('kwargs', default=None)
Expand Down Expand Up @@ -987,6 +1028,7 @@ def main(args=None):
agent.register_task('take_noise', controller.take_noise)
agent.register_task('bias_dets', controller.bias_dets)
agent.register_task('all_off', controller.all_off)
agent.register_task('set_biases', controller.set_biases)

runner.run(agent, auto_reconnect=True)

Expand Down

0 comments on commit 968ca64

Please sign in to comment.