ionpulse_sequence_generator 2.4.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of ionpulse_sequence_generator might be problematic. Click here for more details.
- ionpulse_sequence_generator/__init__.py +91 -0
- ionpulse_sequence_generator/base/__init__.py +0 -0
- ionpulse_sequence_generator/base/configuration.py +23 -0
- ionpulse_sequence_generator/base/header.py +90 -0
- ionpulse_sequence_generator/base/jsonexportable.py +264 -0
- ionpulse_sequence_generator/event/__init__.py +0 -0
- ionpulse_sequence_generator/event/ddspidstatechange.py +65 -0
- ionpulse_sequence_generator/event/dioevent.py +73 -0
- ionpulse_sequence_generator/event/event.py +84 -0
- ionpulse_sequence_generator/event/multitonerfevent.py +139 -0
- ionpulse_sequence_generator/event/qubitevent.py +66 -0
- ionpulse_sequence_generator/event/readout.py +239 -0
- ionpulse_sequence_generator/event/singletonerfevent.py +185 -0
- ionpulse_sequence_generator/event/wait.py +63 -0
- ionpulse_sequence_generator/event/waveform.py +54 -0
- ionpulse_sequence_generator/hardware/__init__.py +0 -0
- ionpulse_sequence_generator/hardware/channel.py +115 -0
- ionpulse_sequence_generator/hardware/device.py +184 -0
- ionpulse_sequence_generator/hardware/hardware.py +780 -0
- ionpulse_sequence_generator/hardware/readout.py +500 -0
- ionpulse_sequence_generator/hardware/system.py +213 -0
- ionpulse_sequence_generator/hardware/units.py +97 -0
- ionpulse_sequence_generator/parameter/__init__.py +0 -0
- ionpulse_sequence_generator/parameter/parameter.py +479 -0
- ionpulse_sequence_generator/parameter/pid_parameter.py +118 -0
- ionpulse_sequence_generator/parameter/spline_parameter.py +370 -0
- ionpulse_sequence_generator/py.typed +0 -0
- ionpulse_sequence_generator/sequence/__init__.py +0 -0
- ionpulse_sequence_generator/sequence/conditional.py +121 -0
- ionpulse_sequence_generator/sequence/loop.py +108 -0
- ionpulse_sequence_generator/sequence/sequence.py +882 -0
- ionpulse_sequence_generator/utils/__init__.py +0 -0
- ionpulse_sequence_generator/utils/logging.py +96 -0
- ionpulse_sequence_generator/utils/utils.py +38 -0
- ionpulse_sequence_generator-2.4.1.dist-info/METADATA +52 -0
- ionpulse_sequence_generator-2.4.1.dist-info/RECORD +37 -0
- ionpulse_sequence_generator-2.4.1.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
from typing import Any, ClassVar
|
|
5
|
+
|
|
6
|
+
from ionpulse_sequence_generator.base.configuration import Configuration
|
|
7
|
+
from ionpulse_sequence_generator.base.jsonexportable import JSONexportable
|
|
8
|
+
from ionpulse_sequence_generator.hardware.channel import ChannelMask
|
|
9
|
+
from ionpulse_sequence_generator.hardware.system import System
|
|
10
|
+
from ionpulse_sequence_generator.parameter.parameter import Time
|
|
11
|
+
|
|
12
|
+
logger = logging.getLogger(__name__)
|
|
13
|
+
system = System()
|
|
14
|
+
configuration = Configuration()
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class Event(JSONexportable):
|
|
18
|
+
"""
|
|
19
|
+
# Event
|
|
20
|
+
This abstract base class defines a prototype for actions after a certain waiting time.
|
|
21
|
+
<-time->|action|
|
|
22
|
+
The type of action and it's parameters are described in the concrete child classes.
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
__slots__ = ("_ch_mask", "_post_time", "_time", "_type")
|
|
26
|
+
_instances: dict[int, Any] = {}
|
|
27
|
+
"""All instances of the class, keeping track of existing objects."""
|
|
28
|
+
_instance_dict: ClassVar[dict] = {}
|
|
29
|
+
"""Lookup dict to enable register() to find existing objects."""
|
|
30
|
+
typename = "event"
|
|
31
|
+
|
|
32
|
+
def __init__(self, name: str, ch_mask: ChannelMask, time: Time | None) -> None:
|
|
33
|
+
"""
|
|
34
|
+
Args:
|
|
35
|
+
name (str): name, exported to the JSON for debugging
|
|
36
|
+
ch_mask (ChannelMask): channel this event is defined on
|
|
37
|
+
time (Time | None): wait time until the action is performed
|
|
38
|
+
|
|
39
|
+
Raises:
|
|
40
|
+
ValueError: If the given ChannelMask is not a single channel.
|
|
41
|
+
"""
|
|
42
|
+
if not ch_mask.is_single_channel():
|
|
43
|
+
raise ValueError("Channel Mask for an event must be a single channel!")
|
|
44
|
+
super().__init__(name)
|
|
45
|
+
self._type = self.__class__.__name__
|
|
46
|
+
self._ch_mask = ch_mask
|
|
47
|
+
if time is not None:
|
|
48
|
+
self._time = time.register()
|
|
49
|
+
if configuration.check_post_time:
|
|
50
|
+
self._post_time: Time | None = None
|
|
51
|
+
|
|
52
|
+
def get_time(self) -> Time:
|
|
53
|
+
"""
|
|
54
|
+
Returns:
|
|
55
|
+
Time: wait time until the action is performed
|
|
56
|
+
"""
|
|
57
|
+
return self._time
|
|
58
|
+
|
|
59
|
+
def get_post_time(self) -> Time:
|
|
60
|
+
"""
|
|
61
|
+
Returns:
|
|
62
|
+
Time: wait time until the action is performed
|
|
63
|
+
"""
|
|
64
|
+
if not configuration.check_post_time:
|
|
65
|
+
raise ValueError("Trying to access post-time, but post-time check is deactivated!")
|
|
66
|
+
return self._post_time
|
|
67
|
+
|
|
68
|
+
def content_v(self) -> tuple:
|
|
69
|
+
return (
|
|
70
|
+
self._type,
|
|
71
|
+
self._time,
|
|
72
|
+
self._ch_mask,
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
def content_k(self) -> tuple:
|
|
76
|
+
return (
|
|
77
|
+
"type",
|
|
78
|
+
Time.typename,
|
|
79
|
+
ChannelMask.typename,
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
def mark(self) -> None:
|
|
83
|
+
self._marked = True
|
|
84
|
+
self._time.mark()
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
|
|
5
|
+
from ionpulse_sequence_generator.base.configuration import Configuration
|
|
6
|
+
from ionpulse_sequence_generator.hardware.channel import ChannelMask
|
|
7
|
+
from ionpulse_sequence_generator.hardware.hardware import QuenchHardware
|
|
8
|
+
from ionpulse_sequence_generator.hardware.system import System
|
|
9
|
+
from ionpulse_sequence_generator.hardware.units import Units
|
|
10
|
+
from ionpulse_sequence_generator.parameter.parameter import Amp, Freq, Phase, Time
|
|
11
|
+
from ionpulse_sequence_generator.parameter.spline_parameter import AmpSpline, FreqSpline, PhaseSpline
|
|
12
|
+
|
|
13
|
+
from .event import Event
|
|
14
|
+
|
|
15
|
+
logger = logging.getLogger(__name__)
|
|
16
|
+
system = System()
|
|
17
|
+
configuration = Configuration()
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class MultiToneRFEvent(Event):
|
|
21
|
+
"""
|
|
22
|
+
# QuenchEvent
|
|
23
|
+
This event is used to change one or more tones (Frequency, Phase, Amplitude) on a Quench
|
|
24
|
+
RF channel.
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
__slots__ = ("_amps", "_freqs", "_phases")
|
|
28
|
+
|
|
29
|
+
def __init__(
|
|
30
|
+
self,
|
|
31
|
+
name: str,
|
|
32
|
+
ch_idx: ChannelMask,
|
|
33
|
+
freqs: list[Freq | FreqSpline],
|
|
34
|
+
phases: list[Phase | PhaseSpline],
|
|
35
|
+
amps: list[Amp | AmpSpline],
|
|
36
|
+
time: Time,
|
|
37
|
+
) -> None:
|
|
38
|
+
"""
|
|
39
|
+
Changes output tones on a Quench channel. Up to 4 tones can be supplied.
|
|
40
|
+
If fewer parameters are applied, these arrays will be extended to fit the other tones.
|
|
41
|
+
Args:
|
|
42
|
+
name (str): name, exported to the JSON for debugging
|
|
43
|
+
ch_mask (ChannelMask): channel this event is defined on
|
|
44
|
+
freqs (list[Freq]): list of Frequencies (up to 4) to be set
|
|
45
|
+
phases (list[Phase]): list of Phases (up to 4) to be set
|
|
46
|
+
amps (list[Amp]): list of Amplitudes (up to 4) to be set
|
|
47
|
+
time (Time): Time until the parameters are applied
|
|
48
|
+
|
|
49
|
+
Raises:
|
|
50
|
+
ValueError: If the given number of paramters can not applied to the DDS cores within a Quench channel.
|
|
51
|
+
"""
|
|
52
|
+
super().__init__(name, ch_idx, time)
|
|
53
|
+
# check lengths and fill in missing parameters:
|
|
54
|
+
param_len = max(len(freqs), len(phases), len(amps))
|
|
55
|
+
if param_len > QuenchHardware._tones_per_channel:
|
|
56
|
+
raise ValueError(
|
|
57
|
+
f"Too many parameters for QuenchEvent, provided {param_len}"
|
|
58
|
+
f"parameters, but only {QuenchHardware._tones_per_channel} can be accepted!"
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
# calculate post_time from given spline parameters
|
|
62
|
+
if configuration.check_post_time:
|
|
63
|
+
self._post_time = Time(0, Units.ns)
|
|
64
|
+
for f in freqs:
|
|
65
|
+
if isinstance(f, FreqSpline):
|
|
66
|
+
self._post_time = Time.maximum(self._post_time, f._shaping_time)
|
|
67
|
+
for p in phases:
|
|
68
|
+
if isinstance(p, FreqSpline):
|
|
69
|
+
self._post_time = Time.maximum(self._post_time, p._shaping_time)
|
|
70
|
+
for a in amps:
|
|
71
|
+
if isinstance(a, AmpSpline):
|
|
72
|
+
self._post_time = Time.maximum(self._post_time, a._shaping_time)
|
|
73
|
+
|
|
74
|
+
def fill_params(
|
|
75
|
+
param_type: type[Amp | Freq | Phase],
|
|
76
|
+
param_list: list[Amp] | list[AmpSpline] | list[Freq] | list[FreqSpline] | list[Phase] | list[PhaseSpline],
|
|
77
|
+
) -> None:
|
|
78
|
+
for i in range(len(param_list) - param_len):
|
|
79
|
+
param_list.append(param_type(0))
|
|
80
|
+
|
|
81
|
+
fill_params(Freq, freqs)
|
|
82
|
+
fill_params(Phase, phases)
|
|
83
|
+
fill_params(Amp, amps)
|
|
84
|
+
|
|
85
|
+
# checking of parameter values only works for simple parameters for now
|
|
86
|
+
# TODO: add proper check for splines
|
|
87
|
+
for hw in system.get_hw_from_ch_mask(ch_idx):
|
|
88
|
+
hw.check_time(time._value, time._unit, edge=True)
|
|
89
|
+
for freq, phase, amp in zip(freqs, phases, amps):
|
|
90
|
+
if isinstance(amp, Amp):
|
|
91
|
+
hw.check_amp(amp._value, amp._unit)
|
|
92
|
+
if not isinstance(amp, Amp) or amp._value > 0:
|
|
93
|
+
if isinstance(freq, Freq):
|
|
94
|
+
hw.check_freq(freq._value, freq._unit)
|
|
95
|
+
if isinstance(phase, Phase):
|
|
96
|
+
hw.check_phase(phase._value, phase._unit)
|
|
97
|
+
|
|
98
|
+
self._freqs = []
|
|
99
|
+
self._phases = []
|
|
100
|
+
self._amps = []
|
|
101
|
+
for freq, phase, amp in zip(freqs, phases, amps):
|
|
102
|
+
self._freqs.append(freq.register())
|
|
103
|
+
self._phases.append(phase.register())
|
|
104
|
+
self._amps.append(amp.register())
|
|
105
|
+
|
|
106
|
+
def content_v(self) -> tuple:
|
|
107
|
+
"""
|
|
108
|
+
Returns:
|
|
109
|
+
tuple of content values of the class for serialization.
|
|
110
|
+
"""
|
|
111
|
+
return (
|
|
112
|
+
self._type,
|
|
113
|
+
self._time._idx,
|
|
114
|
+
self._ch_mask,
|
|
115
|
+
tuple([f._idx for f in self._freqs]),
|
|
116
|
+
tuple([p._idx for p in self._phases]),
|
|
117
|
+
tuple([a._idx for a in self._amps]),
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
def content_k(self) -> tuple:
|
|
121
|
+
"""
|
|
122
|
+
Returns:
|
|
123
|
+
tuple of content keys of the class for serialization.
|
|
124
|
+
"""
|
|
125
|
+
return (
|
|
126
|
+
"type",
|
|
127
|
+
Time.typename,
|
|
128
|
+
ChannelMask.typename,
|
|
129
|
+
Freq.typename,
|
|
130
|
+
Phase.typename,
|
|
131
|
+
Amp.typename,
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
def mark(self) -> None:
|
|
135
|
+
super().mark()
|
|
136
|
+
for freq, phase, amp in zip(self._freqs, self._phases, self._amps):
|
|
137
|
+
freq.mark()
|
|
138
|
+
phase.mark()
|
|
139
|
+
amp.mark()
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
|
|
5
|
+
from ionpulse_sequence_generator.hardware.channel import ChannelMask
|
|
6
|
+
from ionpulse_sequence_generator.hardware.system import System
|
|
7
|
+
from ionpulse_sequence_generator.parameter.parameter import Freq, Phase, Time
|
|
8
|
+
|
|
9
|
+
from .event import Event
|
|
10
|
+
|
|
11
|
+
logger = logging.getLogger(__name__)
|
|
12
|
+
system = System()
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class QubitEvent(Event):
|
|
16
|
+
"""
|
|
17
|
+
# QubitEdge (not implemented)
|
|
18
|
+
This Event changes Frequency and Phase reference for a single qubit on the DDS System,
|
|
19
|
+
to automatically update the phase for RF pulses.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
__slots__ = ("_flags", "_freq", "_phase")
|
|
23
|
+
|
|
24
|
+
def __init__(
|
|
25
|
+
self,
|
|
26
|
+
name: str,
|
|
27
|
+
ch_idx: ChannelMask,
|
|
28
|
+
freq: Freq,
|
|
29
|
+
phase: Phase,
|
|
30
|
+
time: Time,
|
|
31
|
+
flags: int = 0,
|
|
32
|
+
) -> None:
|
|
33
|
+
raise NotImplementedError
|
|
34
|
+
super().__init__(name, ch_idx, time)
|
|
35
|
+
for hw in system.get_hw_from_ch_mask(ch_idx):
|
|
36
|
+
hw.check_time(time._value, time._unit, edge=True)
|
|
37
|
+
hw.check_freq(freq._value, freq._unit)
|
|
38
|
+
hw.check_phase(phase._value, phase._unit)
|
|
39
|
+
self._flags = flags
|
|
40
|
+
self._freq = freq.register()
|
|
41
|
+
self._phase = phase.register()
|
|
42
|
+
|
|
43
|
+
def content_v(self) -> tuple:
|
|
44
|
+
return (
|
|
45
|
+
self._type,
|
|
46
|
+
self._time._idx,
|
|
47
|
+
self._ch_mask,
|
|
48
|
+
self._flags,
|
|
49
|
+
self._freq._idx,
|
|
50
|
+
self._phase._idx,
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
def content_k(self) -> tuple:
|
|
54
|
+
return (
|
|
55
|
+
"type",
|
|
56
|
+
Time.typename,
|
|
57
|
+
ChannelMask.typename,
|
|
58
|
+
"flags",
|
|
59
|
+
Freq.typename,
|
|
60
|
+
Phase.typename,
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
def mark(self) -> None:
|
|
64
|
+
super().mark()
|
|
65
|
+
self._freq.mark()
|
|
66
|
+
self._phase.mark()
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
from enum import Enum
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
from ionpulse_sequence_generator.hardware.channel import ChannelMask
|
|
6
|
+
from ionpulse_sequence_generator.hardware.hardware import DIOHardware
|
|
7
|
+
from ionpulse_sequence_generator.hardware.readout import (
|
|
8
|
+
CameraChannel,
|
|
9
|
+
PMTChannel,
|
|
10
|
+
ReadoutChannel,
|
|
11
|
+
ShotChannel,
|
|
12
|
+
VectorChannel,
|
|
13
|
+
)
|
|
14
|
+
from ionpulse_sequence_generator.hardware.system import System
|
|
15
|
+
|
|
16
|
+
from .event import Event
|
|
17
|
+
|
|
18
|
+
logger = logging.getLogger(__name__)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class ReadoutEvent(Event):
|
|
22
|
+
"""
|
|
23
|
+
# ReadoutEvent
|
|
24
|
+
Base class for all readout events. The channel mask is automatically set to the
|
|
25
|
+
readout channel of the system.
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
def __init__(self, name: str) -> None:
|
|
29
|
+
"""
|
|
30
|
+
Args:
|
|
31
|
+
name (str): Name of the event, exported to the json for debugging.
|
|
32
|
+
"""
|
|
33
|
+
ch_mask = System().readout.channel()
|
|
34
|
+
super().__init__(name, ch_mask, time=None)
|
|
35
|
+
|
|
36
|
+
def mark(self) -> None:
|
|
37
|
+
self._marked = True
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class PopPMTFIFO(ReadoutEvent):
|
|
41
|
+
"""
|
|
42
|
+
# PopPMTFIFO
|
|
43
|
+
This Readout event maps a PMT FIFO pop to a shot_channel. This will be asynchronously
|
|
44
|
+
processed by the SoC when new readout data is availiable.
|
|
45
|
+
"""
|
|
46
|
+
|
|
47
|
+
__slots__ = ("_pmt_channel", "_shot_channel", "_timestamp_vector_channel")
|
|
48
|
+
|
|
49
|
+
def __init__(
|
|
50
|
+
self,
|
|
51
|
+
name: str,
|
|
52
|
+
pmt_channel: PMTChannel,
|
|
53
|
+
shot_channel: ShotChannel,
|
|
54
|
+
timestamp_vector_channel: VectorChannel | None = None,
|
|
55
|
+
) -> None:
|
|
56
|
+
"""
|
|
57
|
+
Args:
|
|
58
|
+
name (str): Name of the event, exported to the json for debugging.
|
|
59
|
+
pmt_channel (PMTChannel): PMT channel to read data from (0-7)
|
|
60
|
+
shot_channel (ShotChannel): Short channel to write data to
|
|
61
|
+
(from user defined shot channels in Readout)
|
|
62
|
+
timestamp_vector_channel (_type_, optional): Vector channel to write timestamps to. Defaults to None.
|
|
63
|
+
"""
|
|
64
|
+
super().__init__(
|
|
65
|
+
name,
|
|
66
|
+
)
|
|
67
|
+
self._pmt_channel = pmt_channel
|
|
68
|
+
self._shot_channel = shot_channel
|
|
69
|
+
self._timestamp_vector_channel = timestamp_vector_channel
|
|
70
|
+
|
|
71
|
+
def content_v(self) -> tuple:
|
|
72
|
+
return (
|
|
73
|
+
self._type,
|
|
74
|
+
self._ch_mask,
|
|
75
|
+
self._pmt_channel,
|
|
76
|
+
self._shot_channel,
|
|
77
|
+
self._timestamp_vector_channel,
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
def content_k(self) -> tuple:
|
|
81
|
+
return (
|
|
82
|
+
"type",
|
|
83
|
+
ChannelMask.typename,
|
|
84
|
+
"pmt_channel",
|
|
85
|
+
"shot_channel",
|
|
86
|
+
"timestamp_vector_channel",
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
def to_json(self):
|
|
90
|
+
System().readout._num_used_pmt_channels.add(self._pmt_channel._index)
|
|
91
|
+
System().readout._num_used_shot_channels.add(self._shot_channel._index)
|
|
92
|
+
if self._timestamp_vector_channel is not None:
|
|
93
|
+
System().readout._num_used_vect_channels.add(self._timestamp_vector_channel._index)
|
|
94
|
+
return super().to_json()
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
class DiscriminatorType(Enum):
|
|
98
|
+
"""
|
|
99
|
+
# DiscriminatorType
|
|
100
|
+
defines the operation of the discriminator on the given pmt channels. See Discriminator.
|
|
101
|
+
"""
|
|
102
|
+
|
|
103
|
+
RAW = 0
|
|
104
|
+
CORRECT_BACKGROUND = 1
|
|
105
|
+
THRESHOLD = 2
|
|
106
|
+
CUSTOM = 3
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
class Discriminator(ReadoutEvent):
|
|
110
|
+
"""
|
|
111
|
+
# Discriminator
|
|
112
|
+
This Readout event reads values from the shot channels,
|
|
113
|
+
processes them and puts the result into a readout channel. The operation depends on
|
|
114
|
+
the given DiscriminatorType:
|
|
115
|
+
|
|
116
|
+
- RAW: No opertion, direct mapping of "shot_channel" to the readout channel
|
|
117
|
+
- CORRECT_BACKGROUND: Subtracts the "background_channel" from the "signal_channel"
|
|
118
|
+
- THRESHOLD: Returns 1 if the value in "shot_channel" is larger than the given "threshold"
|
|
119
|
+
- CUSTOM: User implementation in ionpulse
|
|
120
|
+
"""
|
|
121
|
+
|
|
122
|
+
def __init__(
|
|
123
|
+
self,
|
|
124
|
+
name: str,
|
|
125
|
+
discriminator_type: DiscriminatorType,
|
|
126
|
+
readout_channel: ReadoutChannel,
|
|
127
|
+
args: dict[str, Any] | None,
|
|
128
|
+
) -> None:
|
|
129
|
+
"""
|
|
130
|
+
Args:
|
|
131
|
+
name (str): Name of the event, exported to the json for debugging.
|
|
132
|
+
discriminator_type (DiscriminatorType): Type of the discriminator
|
|
133
|
+
readout_channel (ReadoutChannel): The readout channel the result will be written to
|
|
134
|
+
args (dict): Depending on the discriminator type, will be provided as a "dict"
|
|
135
|
+
in the discriminator in ionpulse for a custom implementation
|
|
136
|
+
Required dict entries:
|
|
137
|
+
- RAW:
|
|
138
|
+
"shot_channel" : ShotChannel
|
|
139
|
+
- CORRECT_BACKGROUND:
|
|
140
|
+
"background_channel" : ShotChannel,
|
|
141
|
+
"signal_channel" : ShotChannel
|
|
142
|
+
- THRESHOLD:
|
|
143
|
+
"shot_channel" : ShotChannel,
|
|
144
|
+
"threshold" : int
|
|
145
|
+
- CUSTOM:
|
|
146
|
+
depending on custom implementation
|
|
147
|
+
|
|
148
|
+
Raises:
|
|
149
|
+
ValueError: If the discriminator_type is not a DiscriminatorType
|
|
150
|
+
"""
|
|
151
|
+
if not isinstance(discriminator_type, DiscriminatorType):
|
|
152
|
+
raise ValueError(f"DiscriminatorType {discriminator_type} does not exist!")
|
|
153
|
+
super().__init__(
|
|
154
|
+
name,
|
|
155
|
+
)
|
|
156
|
+
self._readout_channel = readout_channel
|
|
157
|
+
self._discriminator_type = discriminator_type.value
|
|
158
|
+
self._args = args
|
|
159
|
+
|
|
160
|
+
def content_v(self) -> tuple:
|
|
161
|
+
return (
|
|
162
|
+
self._type,
|
|
163
|
+
self._ch_mask,
|
|
164
|
+
self._readout_channel,
|
|
165
|
+
self._discriminator_type,
|
|
166
|
+
self._args,
|
|
167
|
+
)
|
|
168
|
+
|
|
169
|
+
def content_k(self) -> tuple:
|
|
170
|
+
return (
|
|
171
|
+
"type",
|
|
172
|
+
ChannelMask.typename,
|
|
173
|
+
"readout_channel",
|
|
174
|
+
"discriminator_type",
|
|
175
|
+
"args",
|
|
176
|
+
)
|
|
177
|
+
|
|
178
|
+
def to_json(self):
|
|
179
|
+
System().readout._num_used_readout_channels.add(self._readout_channel._index)
|
|
180
|
+
return super().to_json()
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
class PopCameraFIFO(ReadoutEvent):
|
|
184
|
+
"""
|
|
185
|
+
# PopCameraFIFO
|
|
186
|
+
This Readout event maps a Camera FIFO pop (remote camera) to a shot_channel. This will be asynchronously
|
|
187
|
+
processed by the SoC when new readout data is availiable.
|
|
188
|
+
"""
|
|
189
|
+
|
|
190
|
+
__slots__ = ("_camera_channel", "_ion_mask_indices", "_shot_channels")
|
|
191
|
+
|
|
192
|
+
def __init__(
|
|
193
|
+
self,
|
|
194
|
+
name: str,
|
|
195
|
+
camera_channel: CameraChannel,
|
|
196
|
+
ion_mask_indices: list[int],
|
|
197
|
+
shot_channels: list[ShotChannel],
|
|
198
|
+
) -> None:
|
|
199
|
+
"""
|
|
200
|
+
Args:
|
|
201
|
+
name (str): Name of the event, exported to the json for debugging.
|
|
202
|
+
ion_mask_indices (list[int]): Camera channels (ion mask indices) to read data from (0-DIOHardware._n_cam_ions_max)
|
|
203
|
+
shot_channels (list[ShotChannel]): Short channels to write data to
|
|
204
|
+
(from user defined shot channels in Readout)
|
|
205
|
+
"""
|
|
206
|
+
super().__init__(
|
|
207
|
+
name,
|
|
208
|
+
)
|
|
209
|
+
if len(ion_mask_indices) is not len(shot_channels):
|
|
210
|
+
raise ValueError("Given number of ion masks does not match number of shot channels!")
|
|
211
|
+
if len(ion_mask_indices) > DIOHardware._n_cam_ions_max:
|
|
212
|
+
raise ValueError(f"Too many ion masks, maximum {DIOHardware._n_cam_ions_max} allowed!")
|
|
213
|
+
self._camera_channel = camera_channel
|
|
214
|
+
self._ion_mask_indices = ion_mask_indices
|
|
215
|
+
self._shot_channels = shot_channels
|
|
216
|
+
|
|
217
|
+
def content_v(self) -> tuple:
|
|
218
|
+
return (
|
|
219
|
+
self._type,
|
|
220
|
+
self._ch_mask,
|
|
221
|
+
self._camera_channel,
|
|
222
|
+
self._ion_mask_indices,
|
|
223
|
+
self._shot_channels,
|
|
224
|
+
)
|
|
225
|
+
|
|
226
|
+
def content_k(self) -> tuple:
|
|
227
|
+
return (
|
|
228
|
+
"type",
|
|
229
|
+
ChannelMask.typename,
|
|
230
|
+
"camera_channel",
|
|
231
|
+
"ion_mask",
|
|
232
|
+
"shot_channel",
|
|
233
|
+
)
|
|
234
|
+
|
|
235
|
+
def to_json(self):
|
|
236
|
+
System().readout._num_used_camera_channels.add(self._camera_channel._index)
|
|
237
|
+
for ch in self._shot_channels:
|
|
238
|
+
System().readout._num_used_shot_channels.add(ch._index)
|
|
239
|
+
return super().to_json()
|