-
Notifications
You must be signed in to change notification settings - Fork 0
/
experiment.py
executable file
·64 lines (50 loc) · 1.99 KB
/
experiment.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
from artiq.experiment import EnvExperiment, kernel, NumberValue
from acf.hardware_setup import HardwareSetup
from acf.experiment_data import ExperimentData
from acf.parameter_manager import ParameterManager
class ACFExperiment(EnvExperiment):
def setup(self, sequences):
"""Setup the experiment class.
Args:
seq (SequencesContainer): Container for all sequences.
"""
self.hardware = HardwareSetup()
self.hardware.initialize(self)
self.experiment_data = ExperimentData(self)
self.parameter_manager = ParameterManager(self)
self.init_sequences(sequences)
@kernel
def setup_run(self):
"""Setup to run at the beginning of the run method."""
self.core.reset()
# Init all DDSs
for dds in self.hardware.get_all_dds():
dds.init()
def init_sequences(self, sequences):
"""Set up the sequences.
Args:
sequences (SequencesContainer): The sequences container.
"""
self.seq = sequences
for sequence in self.seq.all_sequences:
sequence.initialize(self, self.seq, self.hardware)
def add_arg_from_param(self, param, min_value=None, max_value=None):
"""Add an argument who's default value comes from a stored parameter.
Args:
param (str): The name of the parameter.
min_value (float): Minimum value of the parameter.
max_value (float): Maximum value of the parameter.
"""
self.setattr_argument(
param,
NumberValue(
default=self.parameter_manager.get_param(param),
unit=self.parameter_manager.get_param_units(param),
precision=5,
min=min_value,
max=max_value
),
group="System Parameters",
)
# Set attribute manually because of forward slashes in parameter names
setattr(self, param.replace("/", "_"), getattr(self, param))