Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion docker/pysmurf_controller/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ FROM simonsobs/so_smurf_base:v0.0.6
# sodetlib Install
#################################################################
WORKDIR /
RUN git clone --branch v0.5.6 --depth 1 https://github.com/simonsobs/sodetlib.git
RUN git clone --branch v0.6.0 --depth 1 https://github.com/simonsobs/sodetlib.git
# allow versioneer to determine sodetlib version safely
USER cryo
RUN git config --global --add safe.directory /sodetlib
Expand Down
17 changes: 5 additions & 12 deletions socs/agents/pysmurf_controller/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -1077,7 +1077,7 @@ def zero_biases(self, session, params):
self.agent.wait('set_biases')
return True, 'Finished zeroing biases'

@ocs_agent.param('rfrac', default=(0.3, 0.6))
@ocs_agent.param('rfrac', default=None)
@ocs_agent.param('kwargs', default=None)
def bias_dets(self, session, params):
"""bias_dets(rfrac=(0.3, 0.6), kwargs=None)
Expand All @@ -1097,9 +1097,7 @@ def bias_dets(self, session, params):
Args
-------
rfrac : float, tuple
Target rfrac range to aim for. If this is a float, bias voltages
will be chosen to get the median rfrac of each bias group as close
as possible to that value. If
Target rfrac (range) to aim for.
kwargs : dict
Additional kwargs to pass to the ``bias_dets`` function.

Expand All @@ -1120,14 +1118,9 @@ def bias_dets(self, session, params):
return False, f"Operation failed: {self.lock.job} is running."

S, cfg = self._get_smurf_control(session=session)
if isinstance(params['rfrac'], (int, float)):
biases = bias_dets.bias_to_rfrac(
S, cfg, rfrac=params['rfrac'], **params['kwargs']
)
else:
biases = bias_dets.bias_to_rfrac_range(
S, cfg, rfrac_range=params['rfrac'], **params['kwargs']
)
biases = bias_dets.bias_to_rfrac(
S, cfg, rfrac=params['rfrac'], **params['kwargs']
)

session.data['biases'] = biases.tolist()

Expand Down
13 changes: 9 additions & 4 deletions tests/agents/test_pysmurf_controller_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ def mock_pysmurf(*args, **kwargs):
exp_defaults = {
# General stuff
'downsample_factor': 20, 'coupling_mode': 'dc', 'synthesis_scale': 1,
'active_bands': [0, 1, 2, 3, 4, 5, 6, 7],
'active_bgs': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],

# Amp stuff
"amps_to_bias": ['hemt', 'hemt1', 'hemt2', '50k', '50k1', '50k2'],
Expand Down Expand Up @@ -99,6 +101,9 @@ def mock_pysmurf(*args, **kwargs):
# Misc files
"tunefile": None, "bgmap_file": None, "iv_file": None,
"res_fit_file": None,

# Biasing
'rfrac': [0.3, 0.6],
}
cfg.dev.exp.__getitem__.side_effect = exp_defaults.__getitem__

Expand Down Expand Up @@ -146,7 +151,7 @@ def mock_ivanalysis(**kwargs):
"""
iva = mock.MagicMock()
# iva.load.return_value = iva
iva.R = np.full((2, 12), 1)
iva.R = np.full((NCHANS, 12), 1)
iva.R_n = np.full(NCHANS, 7e-3)
iva.bgmap = np.zeros(NCHANS)
iva.v_bias = np.full((12, ), 2)
Expand Down Expand Up @@ -373,21 +378,21 @@ def test_take_noise(agent):
assert res[0] is True


def mock_bias_to_rfrac_range(*args, **kwargs):
def mock_bias_to_rfrac(*args, **kwargs):
biases = np.full((12,), 10.)
return biases


@mock.patch('socs.agents.pysmurf_controller.agent.PysmurfController._get_smurf_control', mock_pysmurf)
@mock.patch('sodetlib.operations.bias_dets.bias_to_rfrac_range', mock_bias_to_rfrac_range)
@mock.patch('sodetlib.operations.bias_dets.bias_to_rfrac', mock_bias_to_rfrac)
def test_bias_dets(agent):
"""test_bias_dets()

**Test** - Tests bias_dets task.
"""
session = create_session('bias_dets')
mm = mock.MagicMock()
res = agent.bias_dets(session, {'rfrac': (0.3, 0.6),
res = agent.bias_dets(session, {'rfrac': None,
'kwargs': {'iva': mock_ivanalysis(S=mm, cfg=mm, run_kwargs=mm,
sid=mm, start_times=mm, stop_times=mm)}})
assert res[0] is True
Expand Down