Skip to content

Commit

Permalink
Add set_biases and zero_biases to smurf module
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianJKoopman committed Nov 27, 2023
1 parent 590dcfa commit 9ad95d7
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 0 deletions.
66 changes: 66 additions & 0 deletions src/sorunlib/smurf.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,72 @@ def bias_dets(concurrent=True, settling_time=0):
check_response(smurf, resp)


def set_biases(bias, bias_group=None, concurrent=True, settling_time=0):
"""Set the detector biases on all SMuRF Controllers.
Args:
bias: (int, float, list)
Biases to set. If a float is passed, this will be used for all
specified bias groups. If a list of floats is passed, it must be
the same size of the list of bias groups.
bias_group: (int, list, optional)
Bias group or list of bias groups to set. If None, will set all
bias groups. Defaults to None.
concurrent (bool, optional): A bool which determines how the operation
is run across the active SMuRF controllers. It runs in parallel if
True, and in series if False.
settling_time (float, optional):
Time in seconds to wait between operation runs across the active
SMuRF controlls if *not* running concurrently. If running
concurrently this is ignored. Defaults to 0 seconds.
"""
for smurf in run.CLIENTS['smurf']:
smurf.set_biases.start(bias=bias, bg=bias_group)
if not concurrent:
resp = smurf.set_biases.wait()
check_response(smurf, resp)

# Allow cryo to settle
time.sleep(settling_time)

if concurrent:
for smurf in run.CLIENTS['smurf']:
resp = smurf.set_biases.wait()
check_response(smurf, resp)


def zero_biases(bias_group=None, concurrent=True, settling_time=0):
"""Set the detector biases on all SMuRF Controllers.
Args:
bias_group: (int, list, optional)
Bias group or list of bias groups to set. If None, will zero all
bias groups. Defaults to None.
concurrent (bool, optional): A bool which determines how the operation
is run across the active SMuRF controllers. It runs in parallel if
True, and in series if False.
settling_time (float, optional):
Time in seconds to wait between operation runs across the active
SMuRF controlls if *not* running concurrently. If running
concurrently this is ignored. Defaults to 0 seconds.
"""
for smurf in run.CLIENTS['smurf']:
smurf.zero_biases.start(bg=bias_group)
if not concurrent:
resp = smurf.zero_biases.wait()
check_response(smurf, resp)

# Allow cryo to settle
time.sleep(settling_time)

if concurrent:
for smurf in run.CLIENTS['smurf']:
resp = smurf.zero_biases.wait()
check_response(smurf, resp)


def take_bgmap(tag=None, concurrent=True, settling_time=0):
"""Take a bgmap on all SMuRF Controllers.
Expand Down
18 changes: 18 additions & 0 deletions tests/test_smurf.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,24 @@ def test_bias_dets(concurrent):
client.bias_dets.start.assert_called_once()


@patch('sorunlib.create_clients', mocked_clients)
@pytest.mark.parametrize("concurrent", [(True), (False)])
def test_set_biases(concurrent):
smurf.run.initialize(test_mode=True)
smurf.set_biases(bias=1, bias_group=None, concurrent=concurrent)
for client in smurf.run.CLIENTS['smurf']:
client.set_biases.start.assert_called_once()


@patch('sorunlib.create_clients', mocked_clients)
@pytest.mark.parametrize("concurrent", [(True), (False)])
def test_zero_biases(concurrent):
smurf.run.initialize(test_mode=True)
smurf.zero_biases(bias_group=None, concurrent=concurrent)
for client in smurf.run.CLIENTS['smurf']:
client.zero_biases.start.assert_called_once()


@patch('sorunlib.create_clients', mocked_clients)
@pytest.mark.parametrize("concurrent", [(True), (False)])
def test_bgmap(concurrent):
Expand Down

0 comments on commit 9ad95d7

Please sign in to comment.