qfabric.sequence¶
sequence¶
- class qfabric.sequence.sequence.Sequence¶
Bases:
objectPulse sequence for an experiment.
- property nominal_duration: float¶
Nominal duration of the entire pulse sequence in seconds.
AWG may introduce a small duration change, due to segment length requirements or time to switch between segments.
- add_step(step, repeats=1, delay_time_after_previous=0)¶
Appends a step in the sequence.
- Parameters:
step (Step) – Step to append.
repeats (int) – Number of repeats for this step. Default 1.
delay_time_after_previous (float) – Optional delay time after the previous step. Default 0. This delay time, as well as duration of each step, may not be exact due to AWG limitations.
- get_steps()¶
Gets all steps.
The executed steps also include a start step and a stop step, which are not included in the return value of this function. The start and stop steps are added in the experiment manager before programming the AWG devices.
- Returns:
Steps of this sequence.
- Return type:
list[Step]
- get_repeats()¶
Gets number of repeats of each step.
- Returns:
Number of repeats of each step of this sequence.
- Return type:
list[int]
- to_dict()¶
Dict representation of the sequence, without function details.
This can be serialized to JSON for saving.
- Returns:
Dict representation of the sequence.
- Return type:
dict[str, Any]
- classmethod from_dict(dict_value)¶
Uses
SequenceVisualizeOnlyto build a visualization only sequence.- Parameters:
dict_value (dict[str, Any]) – Dict representation of the sequence.
- class qfabric.sequence.sequence.SequenceVisualizeOnly¶
Bases:
SequenceSequence subclass that is only for visualization.
This class is for building a sequence back from a dictionary. It may not contain the same dynamic code as the actual sequence. For example, if the function definition changes or the import path changes, the output may change. Therefore it is only for pulse sequence visualization.
- classmethod from_dict(dict_value)¶
Uses
SequenceVisualizeOnlyto build a visualization only sequence.- Parameters:
dict_value (dict[str, Any]) – Dict representation of the sequence.
step¶
- class qfabric.sequence.step.Step(name)¶
Bases:
objectStep in a pulse sequence.
Step is the building block for a sequence, often consists one (or a few) logically-related pulses in a sequence. It is designed so that each step is replayed on the AWG exactly as defined with phase coherence. Due to AWG segment size limits, the actual duration of a step is often slightly longer than the defined duration. Therefore pulses spanning different steps may not have exact phase relations as defined.
- Parameters:
name (str) – Step name.
- property duration: float¶
Nominal duration of this step.
If
durationis not set, uses the longest function defined on all channels.
- add_analog_function(channel, function)¶
Adds an analog function to a channel.
- Parameters:
channel (int) – Index of the analog channel.
function (AnalogFunction) – Analog function to use for this channel.
- add_digital_function(channel, function)¶
Adds a digital function to a channel.
- Parameters:
channel (int) – Index of the digital channel.
function (DigitalFunction) – Digital function to use for this channel.
- get_functions_on_device(analog_channels, digital_channels)¶
Splits functions on selected channels to form a device step.
Used to isolate functions used on each of the AWG device.
- Parameters:
analog_channels (list[int]) – Analog channels of this device.
digital_channels (list[int]) – Digital channels of this device.
- Returns:
Device step containing only functions defined on these channels.
- Return type:
- to_dict()¶
Dict representation of the step, without function details.
This can be serialized to JSON for saving.
- Returns:
dict representation of the step.
- Return type:
dict[str, Any]
- classmethod from_dict(dict_value)¶
Uses
StepVisualizeOnlyto build a visualization only step.- Parameters:
dict_value (dict[str, Any]) – Dict representation of the step.
- class qfabric.sequence.step.StepVisualizeOnly(name)¶
Bases:
StepStep subclass that is only for visualization.
- classmethod from_dict(dict_value)¶
Uses
StepVisualizeOnlyto build a visualization only step.- Parameters:
dict_value (dict[str, Any]) – Dict representation of the step.
- class qfabric.sequence.step.StartStep(duration, digital_channel_on=0)¶
Bases:
StepPulse sequence start step.
function¶
- class qfabric.sequence.function.Function¶
Bases:
objectBase class for all analog or digital functions.
All subclasses are automatically decorated by
@dataclass. All attributes of these subclasses that affect the output of the function should be defined as field (annotated instance variables), see below for an example.class FunctionWithFrequency(AnalogFunction): frequency: float def __init__(self, frequency: float): self.frequency = frequency
Without defining these attributes as fields, the AWG memory loaded may not be correct. If cache / state attributes are needed (that do not affect the output of the function), these attributes can be defined as fields with compare=False, see below.
from dataclasses import field class FunctionWithTimings(DigitalFunction): time_1: float time_2: float time_3: float _total_time: float = field(compare=False) # cache. Does not affect output. def __init__(self, time_1: float, time_2: float, time_3: float): self.time_1 = time_1 self.time_2 = time_2 self.time_3 = time_3 # adds times and save in a field without comparison. self._total_time = time_1 + time_2 + time_3 @property def min_duration(self) -> float: # does not need to add up times here. return self._total_time
All subclasses used as actual functions should override
min_duration().- abstract property min_duration: float¶
Minimum duration of this function.
- to_dict()¶
Dict representation of the function without guarantee of reproduction.
This can be serialized to JSON for saving. If the class definition is changed or removed, the output of this function may not be reproduced after saving and loading.
- Returns:
dict representation of the step.
- Return type:
dict[str, Any]
- class qfabric.sequence.function.AnalogFunction¶
Bases:
FunctionBase class for all analog functions.
All subclasses should override
output().- classmethod from_dict(dict_value)¶
Uses
AnalogFunctionVisualizeOnlyto build a visualization only function.- Parameters:
dict_value (dict[str, Any]) – Dict representation of the function.
- class qfabric.sequence.function.AnalogFunctionVisualizeOnly¶
Bases:
AnalogFunctionAnalogFunction subclass that is only for visualization.
- classmethod from_dict(dict_value)¶
Uses
AnalogFunctionVisualizeOnlyto build a visualization only function.- Parameters:
dict_value (dict[str, Any]) – Dict representation of the function.
- Return type:
- class qfabric.sequence.function.AnalogEmpty¶
Bases:
AnalogFunctionAnalog function with zero output.
- class qfabric.sequence.function.DigitalFunction¶
Bases:
FunctionBase class for all digital functions.
All subclasses should override
output().- classmethod from_dict(dict_value)¶
Uses
DigitalFunctionVisualizeOnlyto build a visualization only function.- Parameters:
dict_value (dict[str, Any]) – Dict representation of the function.
- class qfabric.sequence.function.DigitalFunctionVisualizeOnly¶
Bases:
DigitalFunctionDigitalFunction subclass that is only for visualization.
- classmethod from_dict(dict_value)¶
Uses
DigitalFunctionVisualizeOnlyto build a visualization only function.- Parameters:
dict_value (dict[str, Any]) – Dict representation of the function.
- Return type:
- class qfabric.sequence.function.DigitalEmpty¶
Bases:
DigitalFunctionDigital function with zero output.
- class qfabric.sequence.function.AnalogSum(function_1, *functions)¶
Bases:
AnalogFunctionSum of multiple analog functions.
- Parameters:
function_1 (AnalogFunction) – Function 1 to be summed.
*functions (AnalogFunction) – Other functions to be summed.
- to_dict()¶
Dict representation of the function without guarantee of reproduction.
This can be serialized to JSON for saving. If the class definition is changed or removed, the output of this function may not be reproduced after saving and loading.
- Returns:
dict representation of the step.
- Return type:
dict[str, Any]
- class qfabric.sequence.function.AnalogProduct(function_1, *functions)¶
Bases:
AnalogFunctionProduct of multiple analog functions.
- Parameters:
function_1 (AnalogFunction) – Function 1 to be multiplied.
*functions (AnalogFunction) – Other functions to be multiplied.
- to_dict()¶
Dict representation of the function without guarantee of reproduction.
This can be serialized to JSON for saving. If the class definition is changed or removed, the output of this function may not be reproduced after saving and loading.
- Returns:
dict representation of the step.
- Return type:
dict[str, Any]
- class qfabric.sequence.function.AnalogSequence¶
Bases:
AnalogFunctionSequence of analog functions.
This is useful to build longer steps containing multiple analog pulses on the same channel, with optional phase coherence between the pulses.
- add_function(function, delay_time_after_previous=0, duration=None, coherent_phase=False)¶
Appends an analog function.
- Parameters:
function (AnalogFunction) – Analog function to be appended.
delay_time_after_previous (float) – Delay time after the previous function. Default 0.
duration (float) – Duration of this function. If None, the minimum function duration is used.
coherent_phase (bool) – If True, the phase of the function is calculated relative to the start of this function sequence. Otherwise, the phase of the function is calculated relative to the start of this appended function.
- to_dict()¶
Dict representation of the function without guarantee of reproduction.
This can be serialized to JSON for saving. If the class definition is changed or removed, the output of this function may not be reproduced after saving and loading.
- Returns:
dict representation of the step.
- Return type:
dict[str, Any]
- class qfabric.sequence.function.DigitalSequence(default_on=False)¶
Bases:
DigitalFunctionSequence of digital functions.
This is useful to build longer steps containing multiple digital pulses on the same channel.
- add_function(function, delay_time_after_previous=0, duration=None)¶
Appends a digital function.
- Parameters:
function (DigitalFunction) – Digital function to be appended.
delay_time_after_previous (float) – Delay time after the previous function. Default 0.
duration (float) – Duration of this function. If None, the minimum function duration is used.
- to_dict()¶
Dict representation of the function without guarantee of reproduction.
This can be serialized to JSON for saving. If the class definition is changed or removed, the output of this function may not be reproduced after saving and loading.
- Returns:
dict representation of the step.
- Return type:
dict[str, Any]
basic_functions¶
- class qfabric.sequence.basic_functions.SineWave(frequency, amplitude, phase=0, start_time=None, stop_time=None)¶
Bases:
AnalogFunctionSine wave.
- Parameters:
frequency (float) – Cyclic frequency of the sine wave.
amplitude (float) – Amplitude of the sine wave.
phase (float) – Phase of the sine wave. Default 0.
start_time (float) – Start time. If None, it starts from the beginning of the step. Default None.
stop_time (float) – Stop time. If None, it stops at the end of the step. Default None.
- class qfabric.sequence.basic_functions.SineSweep(start_frequency, stop_frequency, start_amplitude, stop_amplitude, start_time, stop_time, phase=0)¶
Bases:
AnalogFunctionSine frequency and/or amplitude sweep.
- Parameters:
start_frequency (float) – Cyclic frequency at start.
stop_frequency (float) – Cyclic frequency at stop.
start_amplitude (float) – Amplitude at start.
stop_amplitude (float) – Amplitude at stop.
start_time (float) – Start time.
stop_time (float) – Stop time.
phase (float) – Phase of the sine sweep. Default 0.
- class qfabric.sequence.basic_functions.ConstantAnalog(amplitude, start_time=None, stop_time=None)¶
Bases:
AnalogFunctionConstant analog function.
- Parameters:
amplitude (float) – Amplitude.
start_time (float) – Start time. If None, it starts from the beginning of the step. Default None.
stop_time (float) – Stop time. If None, it stops at the end of the step. Default None.
- class qfabric.sequence.basic_functions.LinearRamp(start_amplitude, stop_amplitude, start_time, stop_time)¶
Bases:
AnalogFunctionLinear ramp function.
- Parameters:
start_amplitude (float) – Start amplitude.
stop_amplitude (float) – Stop amplitude.
start_time (float) – Start time.
stop_time (float) – Stop time.
- class qfabric.sequence.basic_functions.HammingWindow(amplitude=1, start_time=None, stop_time=None)¶
Bases:
AnalogFunctionHamming Window function.
This is usually used with another
AnalogFunctioninAnalogProductto produce an analog pulse without sinc-square lumps.- Parameters:
amplitude (float) – Maximum amplitude of the window. Default 1.
start_time (float) – Start time. If None, it starts from the beginning of the step. Default None.
stop_time (float) – Stop time. If None, it stops at the end of the step. Default None.
- class qfabric.sequence.basic_functions.DigitalOn¶
Bases:
DigitalFunctionDigital constant true.
- class qfabric.sequence.basic_functions.DigitalOff¶
Bases:
DigitalFunctionDigital constant false.
- class qfabric.sequence.basic_functions.DigitalPulse(start_time, stop_time, default_off=True)¶
Bases:
DigitalFunctionDigital pulse.
- Parameters:
start_time (float) – Start time of the pulse.
stop_time (float) – Stop time of the pulse.
default_off (bool) – Whether to output false when the pulse is off. This switch flips the polarity of the output. Default True.
- class qfabric.sequence.basic_functions.DigitalMultiPulses(start_times, stop_times, default_off=True)¶
Bases:
DigitalFunctionMultiple digital pulses.
- Parameters:
start_times (npt.NDArray[np.float64]) – Start times of the pulses.
stop_time (npt.NDArray[np.float64]) – Stop times of the pulses.
default_off (bool) – Whether to output false when the pulse is off. This switch flips the polarity of the output. Default True.