Skip to content

Python Toolkit API Sequence

zhinst.toolkit.sequence.Sequence(code=None, *, constants=None, waveforms=None, command_table=None)

A representation of a ZI sequencer code.

This class enables a compact representation of a sequence for a Zurich Instruments device. Although a sequencer code can be represented by a simple string this class offers the following advantages:

  • Define a constants dictionary. The constants will be added automatically to the top of the resulting sequencer code and helps to prevent the use of fstrings (which require the escaping of {})
  • Link Waveforms to the sequence. This adds the waveform placeholder definitions to the top of the resulting sequencer code.
Note

This class is only for convenience. The same functionality can be achieved with a simple string.

Parameters:

Name Type Description Default
code Optional[str]

Sequencer code (default = None).

None
constants Optional[dict[str, float]]

A dictionary of constants to be added to the top of the resulting sequencer code. (default = None).

None
waveforms Waveforms

Waveforms that will be used in the sequence.

None
Example

waveforms = Waveforms() waveforms[0] = (0.5np.ones(1008), -0.2np.ones(1008), np.ones(1008)) sequencer = Sequence() sequencer.constants["PULSE_WIDTH"] = 10e-9 #ns sequencer.waveforms = waveforms sequencer.code = \"\"\"\ // Hello World repeat(5) ... \"\"\" str(sequencer) // Constants const PULSE_WIDTH = 10e-9; // Waveforms declaration assignWaveIndex(placeholder(1008, true, false), placeholder(1008, \ false, false), 0); assignWaveIndex(placeholder(1008, false, false), placeholder(1008, \ false, false), 2); // Hello World repeat(5) ...

code: str property writable

Code of the Sequence.

Returns:

Type Description
str

Code of the Sequence.

command_table: CommandTable property writable

Command table of the Sequence.

Returns:

Type Description
CommandTable

Command table of the Sequence.

constants: dict[str, float] property writable

Constants of the Sequence.

Returns:

Type Description
dict[str, float]

Constants of the Sequence.

waveforms: Waveforms property writable

Waveforms of the Sequence.

Returns:

Type Description
Waveforms

Waveforms of the Sequence.

to_string(*, waveform_snippet=True)

Convert the object into a string.

Parameters:

Name Type Description Default
waveform_snippet bool

Flag if the waveform declaration should be added to the top of the resulting sequence. (default = True).

True

Returns:

Type Description
str

String representation of the sequence.