qcodes.instrument_drivers.tektronix package
Submodules
qcodes.instrument_drivers.tektronix.AWG5014 module
- class qcodes.instrument_drivers.tektronix.AWG5014.Tektronix_AWG5014(*args: Any, **kwargs: Any)[source]
Bases:
VisaInstrument
This is the QCoDeS driver for the Tektronix AWG5014 Arbitrary Waveform Generator.
The driver makes some assumptions on the settings of the instrument:
The output channels are always in Amplitude/Offset mode
The output markers are always in High/Low mode
Todo
Implement support for cable transfer function compensation
Implement more instrument functionality in the driver
Remove double functionality
Remove inconsistensies between the name of a parameter and the name of the same variable in the tektronix manual
In the future, we should consider the following:
Removing test_send??
That sequence element (SQEL) parameter functions exist but no corresponding parameters.
Initializes the AWG5014.
- Parameters
name – name of the instrument
address – GPIB or ethernet address as used by VISA
timeout – visa timeout, in secs. long default (180) to accommodate large waveforms
num_channels – number of channels on the device
- AWG_FILE_FORMAT_HEAD = {'CLOCK_SOURCE': 'h', 'COUPLING': 'h', 'DIVIDER_RATE': 'h', 'EVENT_INPUT_IMPEDANCE': 'h', 'EVENT_INPUT_POLARITY': 'h', 'EVENT_INPUT_THRESHOLD': 'd', 'EXTERNAL_REFERENCE_TYPE': 'h', 'HOLD_REPETITION_RATE': 'h', 'INTERLEAVE': 'h', 'INTERLEAVE_ADJ_AMPLITUDE': 'd', 'INTERLEAVE_ADJ_PHASE': 'd', 'INTERNAL_TRIGGER_RATE': 'd', 'JUMP_TIMING': 'h', 'REFERENCE_CLOCK_FREQUENCY_SELECTION': 'h', 'REFERENCE_MULTIPLIER_RATE': 'h', 'REFERENCE_SOURCE': 'h', 'REPETITION_RATE': 'd', 'RUN_MODE': 'h', 'RUN_STATE': 'h', 'SAMPLING_RATE': 'd', 'TRIGGER_INPUT_IMPEDANCE': 'h', 'TRIGGER_INPUT_POLARITY': 'h', 'TRIGGER_INPUT_SLOPE': 'h', 'TRIGGER_INPUT_THRESHOLD': 'd', 'TRIGGER_SOURCE': 'h', 'WAIT_VALUE': 'h', 'ZEROING': 'h'}
- AWG_FILE_FORMAT_CHANNEL = {'ANALOG_AMPLITUDE_N': 'd', 'ANALOG_DIRECT_OUTPUT_N': 'h', 'ANALOG_FILTER_N': 'h', 'ANALOG_HIGH_N': 'd', 'ANALOG_LOW_N': 'd', 'ANALOG_METHOD_N': 'h', 'ANALOG_OFFSET_N': 'd', 'CHANNEL_SKEW_N': 'd', 'CHANNEL_STATE_N': 'h', 'DC_OUTPUT_LEVEL_N': 'd', 'DELAY_IN_POINTS_N': 'd', 'DELAY_IN_TIME_N': 'd', 'DIGITAL_AMPLITUDE_N': 'd', 'DIGITAL_HIGH_N': 'd', 'DIGITAL_LOW_N': 'd', 'DIGITAL_METHOD_N': 'h', 'DIGITAL_OFFSET_N': 'd', 'EXTERNAL_ADD_N': 'h', 'MARKER1_AMPLITUDE_N': 'd', 'MARKER1_HIGH_N': 'd', 'MARKER1_LOW_N': 'd', 'MARKER1_METHOD_N': 'h', 'MARKER1_OFFSET_N': 'd', 'MARKER1_SKEW_N': 'd', 'MARKER2_AMPLITUDE_N': 'd', 'MARKER2_HIGH_N': 'd', 'MARKER2_LOW_N': 'd', 'MARKER2_METHOD_N': 'h', 'MARKER2_OFFSET_N': 'd', 'MARKER2_SKEW_N': 'd', 'OUTPUT_WAVEFORM_NAME_N': 's', 'PHASE_DELAY_INPUT_METHOD_N': 'h', 'PHASE_N': 'd'}
- get_state() Literal['Idle', 'Waiting for trigger', 'Running'] [source]
This query returns the run state of the arbitrary waveform generator or the sequencer.
- Returns
Either ‘Idle’, ‘Waiting for trigger’, or ‘Running’.
- Raises
ValueError – if none of the three states above apply.
- run() str [source]
This command initiates the output of a waveform or a sequence. This is equivalent to pressing Run/Stop button on the front panel. The instrument can be put in the run state only when output waveforms are assigned to channels.
- Returns
The output of self.get_state()
- force_trigger() None [source]
This command generates a trigger event. This is equivalent to pressing the Force Trigger button on front panel.
- get_folder_contents(print_contents: bool = True) str [source]
This query returns the current contents and state of the mass storage media (on the AWG Windows machine).
- Parameters
print_contents – If True, the folder name and the query output are printed. Default: True.
- Returns
A comma-seperated string of the folder contents.
- Return type
- get_current_folder_name() str [source]
This query returns the current directory of the file system on the arbitrary waveform generator. The current directory for the programmatic interface is different from the currently selected directory in the Windows Explorer on the instrument.
- Returns
A string with the full path of the current folder.
- set_current_folder_name(file_path: str) int [source]
Set the current directory of the file system on the arbitrary waveform generator. The current directory for the programmatic interface is different from the currently selected directory in the Windows Explorer on the instrument.
- Parameters
file_path – The full path.
- Returns
The number of bytes written to instrument
- goto_root() None [source]
Set the current directory of the file system on the arbitrary waveform generator to C: (the ‘root’ location in Windows).
- create_and_goto_dir(folder: str) str [source]
Set the current directory of the file system on the arbitrary waveform generator. Creates the directory if if doesn’t exist. Queries the resulting folder for its contents.
- Parameters
folder – The path of the directory to set as current. Note: this function expects only root level directories.
- Returns
A comma-seperated string of the folder contents.
- all_channels_on() None [source]
Set the state of all channels to be ON. Note: only channels with defined waveforms can be ON.
- force_trigger_event() None [source]
This command generates a trigger event. Equivalent to self.force_trigger.
- force_event() None [source]
This command generates a forced event. This is used to generate the event when the sequence is waiting for an event jump. This is equivalent to pressing the Force Event button on the front panel of the instrument.
- set_sqel_event_target_index(element_no: int, index: int) None [source]
This command sets the target index for the sequencer’s event jump operation. Note that this will take effect only when the event jump target type is set to INDEX.
- Parameters
element_no – The sequence element number
index – The index to set the target to
- set_sqel_goto_target_index(element_no: int, goto_to_index_no: int) None [source]
This command sets the target index for the GOTO command of the sequencer. After generating the waveform specified in a sequence element, the sequencer jumps to the element specified as GOTO target. This is an unconditional jump. If GOTO target is not specified, the sequencer simply moves on to the next element. If the Loop Count is Infinite, the GOTO target which is specified in the element is not used. For this command to work, the goto state of the squencer must be ON and the sequence element must exist. Note that the first element of a sequence is taken to be 1 not 0.
- Parameters
element_no – The sequence element number
goto_to_index_no – The target index number
- set_sqel_goto_state(element_no: int, goto_state: int) None [source]
This command sets the GOTO state of the sequencer for the specified sequence element.
- Parameters
element_no – The sequence element number
goto_state – The GOTO state of the sequencer. Must be either 0 (OFF) or 1 (ON).
- set_sqel_loopcnt_to_inf(element_no: int, state: int = 1) None [source]
This command sets the infinite looping state for a sequence element. When an infinite loop is set on an element, the sequencer continuously executes that element. To break the infinite loop, issue self.stop()
- get_sqel_loopcnt(element_no: int = 1) str [source]
This query returns the loop count (number of repetitions) of a sequence element. Loop count setting for an element is ignored if the infinite looping state is set to ON.
- Parameters
element_no – The sequence element number. Default: 1.
- set_sqel_loopcnt(loopcount: int, element_no: int = 1) None [source]
This command sets the loop count. Loop count setting for an element is ignored if the infinite looping state is set to ON.
- Parameters
loopcount – The number of times the sequence is being output. The maximal possible number is 65536, beyond that: infinity.
element_no – The sequence element number. Default: 1.
- set_sqel_waveform(waveform_name: str, channel: int, element_no: int = 1) None [source]
This command sets the waveform for a sequence element on the specified channel.
- Parameters
waveform_name – Name of the waveform. Must be in the waveform list (either User Defined or Predefined).
channel – The output channel (1-4)
element_no – The sequence element number. Default: 1.
- get_sqel_waveform(channel: int, element_no: int = 1) str [source]
This query returns the waveform for a sequence element on the specified channel.
- Parameters
channel – The output channel (1-4)
element_no – The sequence element number. Default: 1.
- Returns
The name of the waveform.
- set_sqel_trigger_wait(element_no: int, state: int = 1) str [source]
This command sets the wait trigger state for an element. Send a trigger signal in one of the following ways:
By using an external trigger signal.
By pressing the “Force Trigger” button on the front panel
By using self.force_trigger or self.force_trigger_event
- Parameters
element_no – The sequence element number.
state – The wait trigger state. Must be either 0 (OFF) or 1 (ON). Default: 1.
- Returns
The current state (after setting it).
- get_sqel_trigger_wait(element_no: int) str [source]
This query returns the wait trigger state for an element. Send a trigger signal in one of the following ways:
By using an external trigger signal.
By pressing the “Force Trigger” button on the front panel
By using self.force_trigger or self.force_trigger_event
- Parameters
element_no – The sequence element number.
- Returns
‘1’.
- Return type
The current state. Example
- set_sqel_event_jump_target_index(element_no: int, jtar_index_no: int) None [source]
Duplicate of set_sqel_event_target_index
- set_sqel_event_jump_type(element_no: int, jtar_state: str) None [source]
This command sets the event jump target type for the jump for the specified sequence element. Generate an event in one of the following ways:
By connecting an external cable to instrument rear panel for external event.
By pressing the Force Event button on the front panel.
By using self.force_event
- Parameters
element_no – The sequence element number
jtar_state – The jump target type. Must be either ‘INDEX’, ‘NEXT’, or ‘OFF’.
- get_sq_mode() str [source]
This query returns the type of the arbitrary waveform generator’s sequencer. The sequence is executed by the hardware sequencer whenever possible.
- Returns
Either ‘HARD’ or ‘SOFT’ indicating that the instrument is in either hardware or software sequencer mode.
- Return type
- generate_sequence_cfg() Dict[str, float] [source]
This function is used to generate a config file, that is used when generating sequence files, from existing settings in the awg. Querying the AWG for these settings takes ~0.7 seconds
- generate_channel_cfg() Dict[str, Optional[float]] [source]
Function to query if the current channel settings that have been changed from their default value and put them in a dictionary that can easily be written into an awg file, so as to prevent said awg file from falling back to default values. (See
make_awg_file()
andAWG_FILE_FORMAT_CHANNEL()
) NOTE: This only works for settings changed via the corresponding QCoDeS parameter.- Returns
A dict with the current setting for each entry in AWG_FILE_FORMAT_HEAD iff this entry applies to the AWG5014 AND has been changed from its default value.
- static parse_marker_channel_name(name: str) _MarkerDescriptor [source]
returns from the channel index and marker index from a marker descriptor string e.g. ‘1M1’->(1,1)
- make_send_and_load_awg_file_from_forged_sequence(seq: Dict[Any, Any], filename: str = 'customawgfile.awg', preservechannelsettings: bool = True) None [source]
Makes an awg file form a forged sequence as produced by broadbean.sequence.Sequence.forge. The forged sequence is a dictionary (see
fs_schmea
) that does not need to be created by broadbean.- Parameters
seq – the sequence dictionary
filename – filename of the uploaded awg file. See
make_send_and_load_awg_file()
preservechannelsettings – see
make_send_and_load_awg_file()
- send_awg_file(filename: str, awg_file: bytes, verbose: bool = False) None [source]
Writes an .awg-file onto the disk of the AWG. Overwrites existing files.
- Parameters
filename – The name that the file will get on the AWG.
awg_file – A byte sequence containing the awg_file. Usually the output of self.make_awg_file.
verbose – A boolean to allow/suppress printing of messages about the status of the filw writing. Default: False.
- load_awg_file(filename: str) None [source]
Loads an .awg-file from the disc of the AWG into the AWG memory. This may overwrite all instrument settings, the waveform list, and the sequence in the sequencer.
- Parameters
filename – The filename of the .awg-file to load.
- make_awg_file(waveforms: Union[Sequence[Sequence[ndarray]], Sequence[ndarray]], m1s: Union[Sequence[Sequence[ndarray]], Sequence[ndarray]], m2s: Union[Sequence[Sequence[ndarray]], Sequence[ndarray]], nreps: Sequence[int], trig_waits: Sequence[int], goto_states: Sequence[int], jump_tos: Sequence[int], channels: Optional[Sequence[int]] = None, preservechannelsettings: bool = True) bytes [source]
- Parameters
waveforms – A list of the waveforms to be packed. The list should be filled like so: [[wfm1ch1, wfm2ch1, …], [wfm1ch2, wfm2ch2], …] Each waveform should be a numpy array with values in the range -1 to 1 (inclusive). If you do not wish to send waveforms to channels 1 and 2, use the channels parameter.
m1s – A list of marker 1’s. The list should be filled like so: [[elem1m1ch1, elem2m1ch1, …], [elem1m1ch2, elem2m1ch2], …] Each marker should be a numpy array containing only 0’s and 1’s
m2s – A list of marker 2’s. The list should be filled like so: [[elem1m2ch1, elem2m2ch1, …], [elem1m2ch2, elem2m2ch2], …] Each marker should be a numpy array containing only 0’s and 1’s
nreps – List of integers specifying the no. of repetitions per sequence element. Allowed values: 0 to 65536. O corresponds to Infinite repetitions.
trig_waits – List of len(segments) of integers specifying the trigger wait state of each sequence element. Allowed values: 0 (OFF) or 1 (ON).
goto_states – List of len(segments) of integers specifying the goto state of each sequence element. Allowed values: 0 to 65536 (0 means next)
jump_tos – List of len(segments) of integers specifying the logic jump state for each sequence element. Allowed values: 0 (OFF) or 1 (ON).
channels (list) – List of channels to send the waveforms to. Example: [1, 3, 2]
preservechannelsettings (bool) – If True, the current channel settings are found from the parameter history and added to the .awg file. Else, channel settings are not written in the file and will be reset to factory default when the file is loaded. Default: True.
- make_send_and_load_awg_file(waveforms: Sequence[Sequence[ndarray]], m1s: Sequence[Sequence[ndarray]], m2s: Sequence[Sequence[ndarray]], nreps: Sequence[int], trig_waits: Sequence[int], goto_states: Sequence[int], jump_tos: Sequence[int], channels: Optional[Sequence[int]] = None, filename: str = 'customawgfile.awg', preservechannelsettings: bool = True) None [source]
Makes an .awg-file, sends it to the AWG and loads it. The .awg-file is uploaded to C:\Users\OEM\Documents. The waveforms appear in the user defined waveform list with names wfm001ch1, wfm002ch1, …
- Parameters
waveforms – A list of the waveforms to upload. The list should be filled like so: [[wfm1ch1, wfm2ch1, …], [wfm1ch2, wfm2ch2], …] Each waveform should be a numpy array with values in the range -1 to 1 (inclusive). If you do not wish to send waveforms to channels 1 and 2, use the channels parameter.
m1s – A list of marker 1’s. The list should be filled like so: [[elem1m1ch1, elem2m1ch1, …], [elem1m1ch2, elem2m1ch2], …] Each marker should be a numpy array containing only 0’s and 1’s
m2s – A list of marker 2’s. The list should be filled like so: [[elem1m2ch1, elem2m2ch1, …], [elem1m2ch2, elem2m2ch2], …] Each marker should be a numpy array containing only 0’s and 1’s
nreps – List of integers specifying the no. of repetions per sequence element. Allowed values: 0 to 65536. 0 corresponds to Infinite repetions.
trig_waits – List of len(segments) of integers specifying the trigger wait state of each sequence element. Allowed values: 0 (OFF) or 1 (ON).
goto_states – List of len(segments) of integers specifying the goto state of each sequence element. Allowed values: 0 to 65536 (0 means next)
jump_tos – List of len(segments) of integers specifying the logic jump state for each sequence element. Allowed values: 0 (OFF) or 1 (ON).
channels – List of channels to send the waveforms to. Example: [1, 3, 2]
filename – The name of the .awg-file. Should end with the .awg extension. Default: ‘customawgfile.awg’
preservechannelsettings – If True, the current channel settings are found from the parameter history and added to the .awg file. Else, channel settings are reset to the factory default values. Default: True.
- make_and_save_awg_file(waveforms: Sequence[Sequence[ndarray]], m1s: Sequence[Sequence[ndarray]], m2s: Sequence[Sequence[ndarray]], nreps: Sequence[int], trig_waits: Sequence[int], goto_states: Sequence[int], jump_tos: Sequence[int], channels: Optional[Sequence[int]] = None, filename: str = 'customawgfile.awg', preservechannelsettings: bool = True) None [source]
Makes an .awg-file and saves it locally.
- Parameters
waveforms – A list of the waveforms to upload. The list should be filled like so: [[wfm1ch1, wfm2ch1, …], [wfm1ch2, wfm2ch2], …] Each waveform should be a numpy array with values in the range -1 to 1 (inclusive). If you do not wish to send waveforms to channels 1 and 2, use the channels parameter.
m1s – A list of marker 1’s. The list should be filled like so: [[elem1m1ch1, elem2m1ch1, …], [elem1m1ch2, elem2m1ch2], …] Each marker should be a numpy array containing only 0’s and 1’s
m2s – A list of marker 2’s. The list should be filled like so: [[elem1m2ch1, elem2m2ch1, …], [elem1m2ch2, elem2m2ch2], …] Each marker should be a numpy array containing only 0’s and 1’s
nreps – List of integers specifying the no. of repetions per sequence element. Allowed values: 0 to 65536. O corresponds to Infinite repetions.
trig_waits – List of len(segments) of integers specifying the trigger wait state of each sequence element. Allowed values: 0 (OFF) or 1 (ON).
goto_states – List of len(segments) of integers specifying the goto state of each sequence element. Allowed values: 0 to 65536 (0 means next)
jump_tos – List of len(segments) of integers specifying the logic jump state for each sequence element. Allowed values: 0 (OFF) or 1 (ON).
channels – List of channels to send the waveforms to. Example: [1, 3, 2]
preservechannelsettings – If True, the current channel settings are found from the parameter history and added to the .awg file. Else, channel settings are not written in the file and will be reset to factory default when the file is loaded. Default: True.
filename – The full path of the .awg-file. Should end with the .awg extension. Default: ‘customawgfile.awg’
- get_error() str [source]
This function retrieves and returns data from the error and event queues.
- Returns
String containing the error/event number, the error/event description.
- delete_all_waveforms_from_list() None [source]
Delete all user-defined waveforms in the list in a single action. Note that there is no “UNDO” action once the waveforms are deleted. Use caution before issuing this command.
If the deleted waveform(s) is (are) currently loaded into waveform memory, it (they) is (are) unloaded. If the RUN state of the instrument is ON, the state is turned OFF. If the channel is on, it will be switched off.
- send_DC_pulse(DC_channel_number: int, set_level: float, length: float) None [source]
Sets the DC level on the specified channel, waits a while and then resets it to what it was before.
Note: Make sure that the output DC state is ON.
- send_waveform_to_list(w: ndarray, m1: ndarray, m2: ndarray, wfmname: str) None [source]
Send a single complete waveform directly to the “User defined” waveform list (prepend it). The data type of the input arrays is unimportant, but the marker arrays must contain only 1’s and 0’s.
- clear_message_queue(verbose: bool = False) None [source]
Function to clear up (flush) the VISA message queue of the AWG instrument. Reads all messages in the the queue.
- Parameters
verbose – If True, the read messages are printed. Default: False.
- __getitem__(key: str) Union[Callable[[...], Any], Parameter]
Delegate instrument[‘name’] to parameter or function ‘name’.
- add_function(name: str, **kwargs: Any) None
Bind one
Function
to this instrument.Instrument subclasses can call this repeatedly in their
__init__
for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST
(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only. If your case is more complicated, you’re probably better off simply making a new method in yourInstrument
subclass definition.- Parameters
name – How the Function will be stored within
instrument.Functions
and also how you address it using the shortcut methods:instrument.call(func_name, *args)
etc.**kwargs – constructor kwargs for
Function
- Raises
KeyError – If this instrument already has a function with this name.
- add_parameter(name: str, parameter_class: Optional[Type[ParameterBase]] = None, **kwargs: Any) None
Bind one Parameter to this instrument.
Instrument subclasses can call this repeatedly in their
__init__
for every real parameter of the instrument.In this sense, parameters are the state variables of the instrument, anything the user can set and/or get.
- Parameters
name – How the parameter will be stored within
parameters
and also how you address it using the shortcut methods:instrument.set(param_name, value)
etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter
.**kwargs – Constructor arguments for
parameter_class
.
- Raises
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- add_submodule(name: str, submodule: Union[InstrumentModule, ChannelTuple]) None
Bind one submodule to this instrument.
Instrument subclasses can call this repeatedly in their
__init__
method for every submodule of the instrument.Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an
InstrumentModule
or aChannelTuple
.- Parameters
name – How the submodule will be stored within
instrument.submodules
and also how it can be addressed.submodule – The submodule to be stored.
- Raises
- property ancestors: List[qcodes.instrument.instrument_base.InstrumentBase]
Returns a list of instruments, starting from the current instrument and following to the parent instrument and the parents parent instrument until the root instrument is reached.
- ask(cmd: str) str
Write a command string to the hardware and return a response.
Subclasses that transform
cmd
should override this method, and in it callsuper().ask(new_cmd)
. Subclasses that define a new hardware communication should instead overrideask_raw
.- Parameters
cmd – The string to send to the instrument.
- Returns
response
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- ask_raw(cmd: str) str
Low-level interface to
visa_handle.ask
.- Parameters
cmd – The command to send to the instrument.
- Returns
The instrument’s response.
- Return type
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns
The return value of the function.
- check_error(ret_code: int) None
Default error checking, raises an error if return code
!=0
. Does not differentiate between warnings or specific error messages. Override this function in your driver if you want to add specific error messages.- Parameters
ret_code – A Visa error code. See eg: https://github.com/hgrecco/pyvisa/blob/master/pyvisa/errors.py
- Raises
visa.VisaIOError – if
ret_code
indicates a communication problem.
- classmethod close_all() None
Try to close all instruments registered in
_all_instruments
This is handy for use with atexit to ensure that all instruments are closed when a python session is closed.Examples
>>> atexit.register(qc.Instrument.close_all())
- connect_message(idn_param: str = 'IDN', begin_time: Optional[float] = None) None
Print a standard message on initial connection to an instrument.
- Parameters
idn_param – Name of parameter that returns ID dict. Default
IDN
.begin_time –
time.time()
when init started. Default isself._t0
, set at start ofInstrument.__init__
.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self
, whose keys should be treated as attributes ofself
.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self
, whose attributes should be passed through toself
.
- static exist(name: str, instrument_class: Optional[type] = None) bool
Check if an instrument with a given names exists (i.e. is already instantiated).
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- classmethod find_instrument(name: str, instrument_class: Optional[Type[T]] = None) T
Find an existing instrument by name.
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- Returns
The instrument found.
- Raises
- get(param_name: str) Any
Shortcut for getting a parameter from its name.
- Parameters
param_name – The name of a parameter of this instrument.
- Returns
The current value of the parameter.
- get_idn() Dict[str, Optional[str]]
Parse a standard VISA
*IDN?
response into an ID dict.Even though this is the VISA standard, it applies to various other types as well, such as IPInstruments, so it is included here in the Instrument base class.
Override this if your instrument does not support
*IDN?
or returns a nonstandard IDN string. This string is supposed to be a comma-separated list of vendor, model, serial, and firmware, but semicolon and colon are also common separators so we accept them here as well.- Returns
A dict containing vendor, model, serial, and firmware.
- classmethod instances() List[Instrument]
Get all currently defined instances of this instrument class.
You can use this to get the objects back if you lose track of them, and it’s also used by the test system to find objects to test against.
- Returns
A list of instances.
- invalidate_cache() None
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- static is_valid(instr_instance: Instrument) bool
Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a “valid” instrument.
- Parameters
instr_instance – Instance of an Instrument class or its subclass.
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Name of the instrument This is equivalent to full_name for backwards compatibility.
- omit_delegate_attrs: List[str] = []
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: Optional[qcodes.instrument.instrument_base.InstrumentBase]
Returns the parent instrument. By default this is
None
. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters
update – If
True
, update the state by querying the instrument. IfFalse
, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- classmethod record_instance(instance: Instrument) None
Record (a weak ref to) an instance in a class’s instance list.
Also records the instance in list of all instruments, and verifies that there are no other instruments with the same name.
This method is called after initialization of the instrument is completed.
- Parameters
instance – Instance to record.
- Raises
KeyError – If another instance with the same name is already present.
- classmethod remove_instance(instance: Instrument) None
Remove a particular instance from the record.
- Parameters
instance – The instance to remove
- property root_instrument: qcodes.instrument.instrument_base.InstrumentBase
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters
param_name – The name of a parameter of this instrument.
value – The new value to set.
- set_address(address: str) None
Set the address for this instrument.
- Parameters
address – The visa resource name to use to connect. The address should be the actual address and just that. If you wish to change the backend for VISA, use the self.visalib attribute (and then call this function).
- set_terminator(terminator: Optional[str]) None
Change the read terminator to use.
- Parameters
terminator – Character(s) to look for at the end of a read and to end each write command with. eg.
\r\n
. If None the terminator will not be set.
- snapshot(update: Optional[bool] = False) Dict[Any, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base()
.- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: Optional[bool] = True, params_to_skip_update: Optional[Sequence[str]] = None) Dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncoder
supports).- Parameters
update – If True, update the state by querying the instrument. If None only update if the state is known to be invalid. If False, just use the latest values in memory and never update.
params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_get
attribute of those parameters instead.
- Returns
base snapshot
- Return type
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters
verbose – If
True
, then information about the parameters that are being check is printed.
- write(cmd: str) None
Write a command string with NO response to the hardware.
Subclasses that transform
cmd
should override this method, and in it callsuper().write(new_cmd)
. Subclasses that define a new hardware communication should instead overridewrite_raw
.- Parameters
cmd – The string to send to the instrument.
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- write_raw(cmd: str) None
Low-level interface to
visa_handle.write
.- Parameters
cmd – The command to send to the instrument.
- parameters: Dict[str, ParameterBase] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter()
.
- functions: Dict[str, Function] = {}
All the functions supported by this instrument. Usually populated via
add_function()
.
- submodules: Dict[str, Union['InstrumentModule', 'ChannelTuple']] = {}
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule()
.
- instrument_modules: Dict[str, 'InstrumentModule'] = {}
All the
InstrumentModule
of this instrument Usually populated viaadd_submodule()
.
qcodes.instrument_drivers.tektronix.AWG5208 module
- class qcodes.instrument_drivers.tektronix.AWG5208.AWG5208(*args: Any, **kwargs: Any)[source]
Bases:
AWG70000A
The QCoDeS driver for Tektronix AWG5208
- Parameters
name – The name used internally by QCoDeS in the DataSet
address – The VISA resource name of the instrument
timeout – The VISA timeout time (in seconds).
- __getitem__(key: str) Union[Callable[[...], Any], Parameter]
Delegate instrument[‘name’] to parameter or function ‘name’.
- add_function(name: str, **kwargs: Any) None
Bind one
Function
to this instrument.Instrument subclasses can call this repeatedly in their
__init__
for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST
(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only. If your case is more complicated, you’re probably better off simply making a new method in yourInstrument
subclass definition.- Parameters
name – How the Function will be stored within
instrument.Functions
and also how you address it using the shortcut methods:instrument.call(func_name, *args)
etc.**kwargs – constructor kwargs for
Function
- Raises
KeyError – If this instrument already has a function with this name.
- add_parameter(name: str, parameter_class: Optional[Type[ParameterBase]] = None, **kwargs: Any) None
Bind one Parameter to this instrument.
Instrument subclasses can call this repeatedly in their
__init__
for every real parameter of the instrument.In this sense, parameters are the state variables of the instrument, anything the user can set and/or get.
- Parameters
name – How the parameter will be stored within
parameters
and also how you address it using the shortcut methods:instrument.set(param_name, value)
etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter
.**kwargs – Constructor arguments for
parameter_class
.
- Raises
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- add_submodule(name: str, submodule: Union[InstrumentModule, ChannelTuple]) None
Bind one submodule to this instrument.
Instrument subclasses can call this repeatedly in their
__init__
method for every submodule of the instrument.Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an
InstrumentModule
or aChannelTuple
.- Parameters
name – How the submodule will be stored within
instrument.submodules
and also how it can be addressed.submodule – The submodule to be stored.
- Raises
- property ancestors: List[qcodes.instrument.instrument_base.InstrumentBase]
Returns a list of instruments, starting from the current instrument and following to the parent instrument and the parents parent instrument until the root instrument is reached.
- ask(cmd: str) str
Write a command string to the hardware and return a response.
Subclasses that transform
cmd
should override this method, and in it callsuper().ask(new_cmd)
. Subclasses that define a new hardware communication should instead overrideask_raw
.- Parameters
cmd – The string to send to the instrument.
- Returns
response
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- ask_raw(cmd: str) str
Low-level interface to
visa_handle.ask
.- Parameters
cmd – The command to send to the instrument.
- Returns
The instrument’s response.
- Return type
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns
The return value of the function.
- check_error(ret_code: int) None
Default error checking, raises an error if return code
!=0
. Does not differentiate between warnings or specific error messages. Override this function in your driver if you want to add specific error messages.- Parameters
ret_code – A Visa error code. See eg: https://github.com/hgrecco/pyvisa/blob/master/pyvisa/errors.py
- Raises
visa.VisaIOError – if
ret_code
indicates a communication problem.
- classmethod close_all() None
Try to close all instruments registered in
_all_instruments
This is handy for use with atexit to ensure that all instruments are closed when a python session is closed.Examples
>>> atexit.register(qc.Instrument.close_all())
- connect_message(idn_param: str = 'IDN', begin_time: Optional[float] = None) None
Print a standard message on initial connection to an instrument.
- Parameters
idn_param – Name of parameter that returns ID dict. Default
IDN
.begin_time –
time.time()
when init started. Default isself._t0
, set at start ofInstrument.__init__
.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self
, whose keys should be treated as attributes ofself
.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self
, whose attributes should be passed through toself
.
- delete_sequence_from_list(seqname: str) None
Delete the specified sequence from the sequence list
- Parameters
seqname – The name of the sequence (as it appears in the sequence list, not the file name) to delete
- static exist(name: str, instrument_class: Optional[type] = None) bool
Check if an instrument with a given names exists (i.e. is already instantiated).
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- classmethod find_instrument(name: str, instrument_class: Optional[Type[T]] = None) T
Find an existing instrument by name.
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- Returns
The instrument found.
- Raises
- get(param_name: str) Any
Shortcut for getting a parameter from its name.
- Parameters
param_name – The name of a parameter of this instrument.
- Returns
The current value of the parameter.
- get_idn() Dict[str, Optional[str]]
Parse a standard VISA
*IDN?
response into an ID dict.Even though this is the VISA standard, it applies to various other types as well, such as IPInstruments, so it is included here in the Instrument base class.
Override this if your instrument does not support
*IDN?
or returns a nonstandard IDN string. This string is supposed to be a comma-separated list of vendor, model, serial, and firmware, but semicolon and colon are also common separators so we accept them here as well.- Returns
A dict containing vendor, model, serial, and firmware.
- classmethod instances() List[Instrument]
Get all currently defined instances of this instrument class.
You can use this to get the objects back if you lose track of them, and it’s also used by the test system to find objects to test against.
- Returns
A list of instances.
- invalidate_cache() None
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- static is_valid(instr_instance: Instrument) bool
Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a “valid” instrument.
- Parameters
instr_instance – Instance of an Instrument class or its subclass.
- loadSEQXFile(filename: str, path: Optional[str] = None) None
Load a seqx file from instrument disk memory. All sequences in the file are loaded into the sequence list.
- Parameters
filename – The name of the sequence file INCLUDING the extension
path – Path to load from. If omitted, the default path (self.seqxFileFolder) is used.
- loadWFMXFile(filename: str, path: Optional[str] = None) None
Loads a wfmx from memory into the waveform list Only loading from the C: drive is supported
- Parameters
filename – Name of the file (with extension)
path – Path to load from. If omitted, the default path (self.wfmxFileFolder) is used.
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- static makeSEQXFile(trig_waits: Sequence[int], nreps: Sequence[int], event_jumps: Sequence[int], event_jump_to: Sequence[int], go_to: Sequence[int], wfms: Sequence[Sequence[ndarray]], amplitudes: Sequence[float], seqname: str, flags: Optional[Sequence[Sequence[Sequence[int]]]] = None) bytes
Make a full .seqx file (bundle) A .seqx file can presumably hold several sequences, but for now we support only packing a single sequence
For a single sequence, a .seqx file is a bundle of two files and two folders:
- /Sequences
sequence.sml
- /Waveforms
wfm1.wfmx wfm2.wfmx …
setup.xml userNotes.txt
- Parameters
trig_waits – Wait for a trigger? If yes, you must specify the trigger input. 0 for off, 1 for ‘TrigA’, 2 for ‘TrigB’, 3 for ‘Internal’.
nreps – No. of repetitions. 0 corresponds to infinite.
event_jumps – Jump when event triggered? If yes, you must specify the trigger input. 0 for off, 1 for ‘TrigA’, 2 for ‘TrigB’, 3 for ‘Internal’.
event_jump_to – Jump target in case of event. 1-indexed, 0 means next. Must be specified for all elements.
go_to – Which element to play next. 1-indexed, 0 means next.
wfms – numpy arrays describing each waveform plus two markers, packed like np.array([wfm, m1, m2]). These numpy arrays are then again packed in lists according to: [[wfmch1pos1, wfmch1pos2, …], [wfmch2pos1, …], …]
amplitudes – The peak-to-peak amplitude in V of the channels, i.e. a list [ch1_amp, ch2_amp].
seqname – The name of the sequence. This name will appear in the sequence list. Note that all spaces are converted to ‘_’
flags – Flags for the auxiliary outputs. 0 for ‘No change’, 1 for ‘High’, 2 for ‘Low’, 3 for ‘Toggle’, or 4 for ‘Pulse’. 4 flags [A, B, C, D] for every channel in every element, packed like: [[ch1pos1, ch1pos2, …], [ch2pos1, …], …] If omitted, no flags will be set.
- Returns
The binary .seqx file, ready to be sent to the instrument.
- static makeWFMXFile(data: ndarray, amplitude: float) bytes
Compose a WFMX file
- Parameters
data – A numpy array holding the data. Markers can be included.
amplitude – The peak-to-peak amplitude (V) assumed to be set on the channel that will play this waveform. This information is needed as the waveform must be rescaled to (-1, 1) where -1 will correspond to the channel’s min. voltage and 1 to the channel’s max. voltage.
- Returns
The binary .wfmx file, ready to be sent to the instrument.
- static make_SEQX_from_forged_sequence(seq: Dict[int, Dict[Any, Any]], amplitudes: List[float], seqname: str, channel_mapping: Optional[Dict[Union[str, int], int]] = None) bytes
Make a .seqx from a forged broadbean sequence. Supports subsequences.
- Parameters
seq – The output of broadbean’s Sequence.forge()
amplitudes – A list of the AWG channels’ voltage amplitudes. The first entry is ch1 etc.
channel_mapping – A mapping from what the channel is called in the broadbean sequence to the integer describing the physical channel it should be assigned to.
seqname – The name that the sequence will have in the AWG’s sequence list. Used for loading the sequence.
- Returns
- The binary .seqx file contents. Can be sent directly to the
instrument or saved on disk.
- property name: str
Name of the instrument This is equivalent to full_name for backwards compatibility.
- omit_delegate_attrs: List[str] = []
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: Optional[qcodes.instrument.instrument_base.InstrumentBase]
Returns the parent instrument. By default this is
None
. Any SubInstrument should subclass this to return the parent instrument.
- play(wait_for_running: bool = True, timeout: float = 10) None
Run the AWG/Func. Gen. This command is equivalent to pressing the play button on the front panel.
- Parameters
wait_for_running – If True, this command is blocking while the instrument is getting ready to play
timeout – The maximal time to wait for the instrument to play. Raises an exception is this time is reached.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters
update – If
True
, update the state by querying the instrument. IfFalse
, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- classmethod record_instance(instance: Instrument) None
Record (a weak ref to) an instance in a class’s instance list.
Also records the instance in list of all instruments, and verifies that there are no other instruments with the same name.
This method is called after initialization of the instrument is completed.
- Parameters
instance – Instance to record.
- Raises
KeyError – If another instance with the same name is already present.
- classmethod remove_instance(instance: Instrument) None
Remove a particular instance from the record.
- Parameters
instance – The instance to remove
- property root_instrument: qcodes.instrument.instrument_base.InstrumentBase
- sendSEQXFile(seqx: bytes, filename: str, path: Optional[str] = None) None
Send a binary seqx file to the AWG’s memory
- Parameters
seqx – The binary seqx file, preferably the output of makeSEQXFile.
filename – The name of the file on the AWG disk, including the extension.
path – The path to the directory where the file should be saved. If omitted, seqxFileFolder will be used.
- sendWFMXFile(wfmx: bytes, filename: str, path: Optional[str] = None) None
Send a binary wfmx file to the AWG’s memory
- Parameters
wfmx – The binary wfmx file, preferably the output of makeWFMXFile.
filename – The name of the file on the AWG disk, including the extension.
path – The path to the directory where the file should be saved. If omitted, seqxFileFolder will be used.
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters
param_name – The name of a parameter of this instrument.
value – The new value to set.
- set_address(address: str) None
Set the address for this instrument.
- Parameters
address – The visa resource name to use to connect. The address should be the actual address and just that. If you wish to change the backend for VISA, use the self.visalib attribute (and then call this function).
- set_terminator(terminator: Optional[str]) None
Change the read terminator to use.
- Parameters
terminator – Character(s) to look for at the end of a read and to end each write command with. eg.
\r\n
. If None the terminator will not be set.
- snapshot(update: Optional[bool] = False) Dict[Any, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base()
.- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: Optional[bool] = True, params_to_skip_update: Optional[Sequence[str]] = None) Dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncoder
supports).- Parameters
update – If True, update the state by querying the instrument. If None only update if the state is known to be invalid. If False, just use the latest values in memory and never update.
params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_get
attribute of those parameters instead.
- Returns
base snapshot
- Return type
- stop() None
Stop the output of the instrument. This command is equivalent to pressing the stop button on the front panel.
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters
verbose – If
True
, then information about the parameters that are being check is printed.
- write(cmd: str) None
Write a command string with NO response to the hardware.
Subclasses that transform
cmd
should override this method, and in it callsuper().write(new_cmd)
. Subclasses that define a new hardware communication should instead overridewrite_raw
.- Parameters
cmd – The string to send to the instrument.
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- write_raw(cmd: str) None
Low-level interface to
visa_handle.write
.- Parameters
cmd – The command to send to the instrument.
- parameters: Dict[str, ParameterBase] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter()
.
- functions: Dict[str, Function] = {}
All the functions supported by this instrument. Usually populated via
add_function()
.
- submodules: Dict[str, Union['InstrumentModule', 'ChannelTuple']] = {}
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule()
.
- instrument_modules: Dict[str, 'InstrumentModule'] = {}
All the
InstrumentModule
of this instrument Usually populated viaadd_submodule()
.
qcodes.instrument_drivers.tektronix.AWG70000A module
- class qcodes.instrument_drivers.tektronix.AWG70000A.SRValidator(awg: AWG70000A)[source]
-
Validator to validate the AWG clock sample rate
- Parameters
awg – The parent instrument instance. We need this since sample rate validation depends on many clock settings
- is_numeric = False
- property valid_values: Tuple[qcodes.validators.validators.T, ...]
- class qcodes.instrument_drivers.tektronix.AWG70000A.AWGChannel(parent: Instrument, name: str, channel: int)[source]
Bases:
InstrumentChannel
Class to hold a channel of the AWG.
- Parameters
parent – The Instrument instance to which the channel is to be attached.
name – The name used in the DataSet
channel – The channel number, either 1 or 2.
- setWaveform(name: str) None [source]
Select a waveform from the waveform list to output on this channel
- Parameters
name – The name of the waveform
- setSequenceTrack(seqname: str, tracknr: int) None [source]
Assign a track from a sequence to this channel.
- Parameters
seqname – Name of the sequence in the sequence list
tracknr – Which track to use (1 or 2)
- __getitem__(key: str) Union[Callable[[...], Any], Parameter]
Delegate instrument[‘name’] to parameter or function ‘name’.
- add_function(name: str, **kwargs: Any) None
Bind one
Function
to this instrument.Instrument subclasses can call this repeatedly in their
__init__
for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST
(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only. If your case is more complicated, you’re probably better off simply making a new method in yourInstrument
subclass definition.- Parameters
name – How the Function will be stored within
instrument.Functions
and also how you address it using the shortcut methods:instrument.call(func_name, *args)
etc.**kwargs – constructor kwargs for
Function
- Raises
KeyError – If this instrument already has a function with this name.
- add_parameter(name: str, parameter_class: Optional[Type[ParameterBase]] = None, **kwargs: Any) None
Bind one Parameter to this instrument.
Instrument subclasses can call this repeatedly in their
__init__
for every real parameter of the instrument.In this sense, parameters are the state variables of the instrument, anything the user can set and/or get.
- Parameters
name – How the parameter will be stored within
parameters
and also how you address it using the shortcut methods:instrument.set(param_name, value)
etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter
.**kwargs – Constructor arguments for
parameter_class
.
- Raises
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- add_submodule(name: str, submodule: Union[InstrumentModule, ChannelTuple]) None
Bind one submodule to this instrument.
Instrument subclasses can call this repeatedly in their
__init__
method for every submodule of the instrument.Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an
InstrumentModule
or aChannelTuple
.- Parameters
name – How the submodule will be stored within
instrument.submodules
and also how it can be addressed.submodule – The submodule to be stored.
- Raises
- property ancestors: List[qcodes.instrument.instrument_base.InstrumentBase]
Returns a list of instruments, starting from the current instrument and following to the parent instrument and the parents parent instrument until the root instrument is reached.
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns
The return value of the function.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self
, whose keys should be treated as attributes ofself
.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self
, whose attributes should be passed through toself
.
- get(param_name: str) Any
Shortcut for getting a parameter from its name.
- Parameters
param_name – The name of a parameter of this instrument.
- Returns
The current value of the parameter.
- invalidate_cache() None
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Name of the instrument This is equivalent to full_name for backwards compatibility.
- omit_delegate_attrs: List[str] = []
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: qcodes.instrument.instrument_base.InstrumentBase
Returns the parent instrument. By default this is
None
. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters
update – If
True
, update the state by querying the instrument. IfFalse
, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- property root_instrument: qcodes.instrument.instrument_base.InstrumentBase
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters
param_name – The name of a parameter of this instrument.
value – The new value to set.
- snapshot(update: Optional[bool] = False) Dict[Any, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base()
.- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: Optional[bool] = False, params_to_skip_update: Optional[Sequence[str]] = None) Dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncoder
supports).- Parameters
update – If
True
, update the state by querying the instrument. If None update the state if known to be invalid. IfFalse
, just use the latest values in memory and never update state.params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_get
attribute of those parameters instead.
- Returns
base snapshot
- Return type
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters
verbose – If
True
, then information about the parameters that are being check is printed.
- parameters: Dict[str, ParameterBase] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter()
.
- functions: Dict[str, Function] = {}
All the functions supported by this instrument. Usually populated via
add_function()
.
- submodules: Dict[str, Union['InstrumentModule', 'ChannelTuple']] = {}
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule()
.
- instrument_modules: Dict[str, 'InstrumentModule'] = {}
All the
InstrumentModule
of this instrument Usually populated viaadd_submodule()
.
- class qcodes.instrument_drivers.tektronix.AWG70000A.AWG70000A(*args: Any, **kwargs: Any)[source]
Bases:
VisaInstrument
The QCoDeS driver for Tektronix AWG70000A series AWG’s.
The drivers for AWG70001A/AWG70001B and AWG70002A/AWG70002B should be subclasses of this general class.
- Parameters
name – The name used internally by QCoDeS in the DataSet
address – The VISA resource name of the instrument
timeout – The VISA timeout time (in seconds)
num_channels – Number of channels on the AWG
- wait_for_operation_to_complete() None [source]
Waits for the latest issued overlapping command to finish
- play(wait_for_running: bool = True, timeout: float = 10) None [source]
Run the AWG/Func. Gen. This command is equivalent to pressing the play button on the front panel.
- Parameters
wait_for_running – If True, this command is blocking while the instrument is getting ready to play
timeout – The maximal time to wait for the instrument to play. Raises an exception is this time is reached.
- stop() None [source]
Stop the output of the instrument. This command is equivalent to pressing the stop button on the front panel.
- delete_sequence_from_list(seqname: str) None [source]
Delete the specified sequence from the sequence list
- Parameters
seqname – The name of the sequence (as it appears in the sequence list, not the file name) to delete
- static makeWFMXFile(data: ndarray, amplitude: float) bytes [source]
Compose a WFMX file
- Parameters
data – A numpy array holding the data. Markers can be included.
amplitude – The peak-to-peak amplitude (V) assumed to be set on the channel that will play this waveform. This information is needed as the waveform must be rescaled to (-1, 1) where -1 will correspond to the channel’s min. voltage and 1 to the channel’s max. voltage.
- Returns
The binary .wfmx file, ready to be sent to the instrument.
- sendSEQXFile(seqx: bytes, filename: str, path: Optional[str] = None) None [source]
Send a binary seqx file to the AWG’s memory
- Parameters
seqx – The binary seqx file, preferably the output of makeSEQXFile.
filename – The name of the file on the AWG disk, including the extension.
path – The path to the directory where the file should be saved. If omitted, seqxFileFolder will be used.
- sendWFMXFile(wfmx: bytes, filename: str, path: Optional[str] = None) None [source]
Send a binary wfmx file to the AWG’s memory
- Parameters
wfmx – The binary wfmx file, preferably the output of makeWFMXFile.
filename – The name of the file on the AWG disk, including the extension.
path – The path to the directory where the file should be saved. If omitted, seqxFileFolder will be used.
- loadWFMXFile(filename: str, path: Optional[str] = None) None [source]
Loads a wfmx from memory into the waveform list Only loading from the C: drive is supported
- Parameters
filename – Name of the file (with extension)
path – Path to load from. If omitted, the default path (self.wfmxFileFolder) is used.
- loadSEQXFile(filename: str, path: Optional[str] = None) None [source]
Load a seqx file from instrument disk memory. All sequences in the file are loaded into the sequence list.
- Parameters
filename – The name of the sequence file INCLUDING the extension
path – Path to load from. If omitted, the default path (self.seqxFileFolder) is used.
- static make_SEQX_from_forged_sequence(seq: Dict[int, Dict[Any, Any]], amplitudes: List[float], seqname: str, channel_mapping: Optional[Dict[Union[str, int], int]] = None) bytes [source]
Make a .seqx from a forged broadbean sequence. Supports subsequences.
- Parameters
seq – The output of broadbean’s Sequence.forge()
amplitudes – A list of the AWG channels’ voltage amplitudes. The first entry is ch1 etc.
channel_mapping – A mapping from what the channel is called in the broadbean sequence to the integer describing the physical channel it should be assigned to.
seqname – The name that the sequence will have in the AWG’s sequence list. Used for loading the sequence.
- Returns
- The binary .seqx file contents. Can be sent directly to the
instrument or saved on disk.
- __getitem__(key: str) Union[Callable[[...], Any], Parameter]
Delegate instrument[‘name’] to parameter or function ‘name’.
- add_function(name: str, **kwargs: Any) None
Bind one
Function
to this instrument.Instrument subclasses can call this repeatedly in their
__init__
for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST
(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only. If your case is more complicated, you’re probably better off simply making a new method in yourInstrument
subclass definition.- Parameters
name – How the Function will be stored within
instrument.Functions
and also how you address it using the shortcut methods:instrument.call(func_name, *args)
etc.**kwargs – constructor kwargs for
Function
- Raises
KeyError – If this instrument already has a function with this name.
- add_parameter(name: str, parameter_class: Optional[Type[ParameterBase]] = None, **kwargs: Any) None
Bind one Parameter to this instrument.
Instrument subclasses can call this repeatedly in their
__init__
for every real parameter of the instrument.In this sense, parameters are the state variables of the instrument, anything the user can set and/or get.
- Parameters
name – How the parameter will be stored within
parameters
and also how you address it using the shortcut methods:instrument.set(param_name, value)
etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter
.**kwargs – Constructor arguments for
parameter_class
.
- Raises
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- add_submodule(name: str, submodule: Union[InstrumentModule, ChannelTuple]) None
Bind one submodule to this instrument.
Instrument subclasses can call this repeatedly in their
__init__
method for every submodule of the instrument.Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an
InstrumentModule
or aChannelTuple
.- Parameters
name – How the submodule will be stored within
instrument.submodules
and also how it can be addressed.submodule – The submodule to be stored.
- Raises
- property ancestors: List[qcodes.instrument.instrument_base.InstrumentBase]
Returns a list of instruments, starting from the current instrument and following to the parent instrument and the parents parent instrument until the root instrument is reached.
- ask(cmd: str) str
Write a command string to the hardware and return a response.
Subclasses that transform
cmd
should override this method, and in it callsuper().ask(new_cmd)
. Subclasses that define a new hardware communication should instead overrideask_raw
.- Parameters
cmd – The string to send to the instrument.
- Returns
response
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- ask_raw(cmd: str) str
Low-level interface to
visa_handle.ask
.- Parameters
cmd – The command to send to the instrument.
- Returns
The instrument’s response.
- Return type
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns
The return value of the function.
- check_error(ret_code: int) None
Default error checking, raises an error if return code
!=0
. Does not differentiate between warnings or specific error messages. Override this function in your driver if you want to add specific error messages.- Parameters
ret_code – A Visa error code. See eg: https://github.com/hgrecco/pyvisa/blob/master/pyvisa/errors.py
- Raises
visa.VisaIOError – if
ret_code
indicates a communication problem.
- classmethod close_all() None
Try to close all instruments registered in
_all_instruments
This is handy for use with atexit to ensure that all instruments are closed when a python session is closed.Examples
>>> atexit.register(qc.Instrument.close_all())
- connect_message(idn_param: str = 'IDN', begin_time: Optional[float] = None) None
Print a standard message on initial connection to an instrument.
- Parameters
idn_param – Name of parameter that returns ID dict. Default
IDN
.begin_time –
time.time()
when init started. Default isself._t0
, set at start ofInstrument.__init__
.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self
, whose keys should be treated as attributes ofself
.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self
, whose attributes should be passed through toself
.
- static exist(name: str, instrument_class: Optional[type] = None) bool
Check if an instrument with a given names exists (i.e. is already instantiated).
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- classmethod find_instrument(name: str, instrument_class: Optional[Type[T]] = None) T
Find an existing instrument by name.
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- Returns
The instrument found.
- Raises
- get(param_name: str) Any
Shortcut for getting a parameter from its name.
- Parameters
param_name – The name of a parameter of this instrument.
- Returns
The current value of the parameter.
- get_idn() Dict[str, Optional[str]]
Parse a standard VISA
*IDN?
response into an ID dict.Even though this is the VISA standard, it applies to various other types as well, such as IPInstruments, so it is included here in the Instrument base class.
Override this if your instrument does not support
*IDN?
or returns a nonstandard IDN string. This string is supposed to be a comma-separated list of vendor, model, serial, and firmware, but semicolon and colon are also common separators so we accept them here as well.- Returns
A dict containing vendor, model, serial, and firmware.
- classmethod instances() List[Instrument]
Get all currently defined instances of this instrument class.
You can use this to get the objects back if you lose track of them, and it’s also used by the test system to find objects to test against.
- Returns
A list of instances.
- invalidate_cache() None
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- static is_valid(instr_instance: Instrument) bool
Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a “valid” instrument.
- Parameters
instr_instance – Instance of an Instrument class or its subclass.
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- static makeSEQXFile(trig_waits: Sequence[int], nreps: Sequence[int], event_jumps: Sequence[int], event_jump_to: Sequence[int], go_to: Sequence[int], wfms: Sequence[Sequence[ndarray]], amplitudes: Sequence[float], seqname: str, flags: Optional[Sequence[Sequence[Sequence[int]]]] = None) bytes [source]
Make a full .seqx file (bundle) A .seqx file can presumably hold several sequences, but for now we support only packing a single sequence
For a single sequence, a .seqx file is a bundle of two files and two folders:
- /Sequences
sequence.sml
- /Waveforms
wfm1.wfmx wfm2.wfmx …
setup.xml userNotes.txt
- Parameters
trig_waits – Wait for a trigger? If yes, you must specify the trigger input. 0 for off, 1 for ‘TrigA’, 2 for ‘TrigB’, 3 for ‘Internal’.
nreps – No. of repetitions. 0 corresponds to infinite.
event_jumps – Jump when event triggered? If yes, you must specify the trigger input. 0 for off, 1 for ‘TrigA’, 2 for ‘TrigB’, 3 for ‘Internal’.
event_jump_to – Jump target in case of event. 1-indexed, 0 means next. Must be specified for all elements.
go_to – Which element to play next. 1-indexed, 0 means next.
wfms – numpy arrays describing each waveform plus two markers, packed like np.array([wfm, m1, m2]). These numpy arrays are then again packed in lists according to: [[wfmch1pos1, wfmch1pos2, …], [wfmch2pos1, …], …]
amplitudes – The peak-to-peak amplitude in V of the channels, i.e. a list [ch1_amp, ch2_amp].
seqname – The name of the sequence. This name will appear in the sequence list. Note that all spaces are converted to ‘_’
flags – Flags for the auxiliary outputs. 0 for ‘No change’, 1 for ‘High’, 2 for ‘Low’, 3 for ‘Toggle’, or 4 for ‘Pulse’. 4 flags [A, B, C, D] for every channel in every element, packed like: [[ch1pos1, ch1pos2, …], [ch2pos1, …], …] If omitted, no flags will be set.
- Returns
The binary .seqx file, ready to be sent to the instrument.
- property name: str
Name of the instrument This is equivalent to full_name for backwards compatibility.
- omit_delegate_attrs: List[str] = []
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: Optional[qcodes.instrument.instrument_base.InstrumentBase]
Returns the parent instrument. By default this is
None
. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters
update – If
True
, update the state by querying the instrument. IfFalse
, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- classmethod record_instance(instance: Instrument) None
Record (a weak ref to) an instance in a class’s instance list.
Also records the instance in list of all instruments, and verifies that there are no other instruments with the same name.
This method is called after initialization of the instrument is completed.
- Parameters
instance – Instance to record.
- Raises
KeyError – If another instance with the same name is already present.
- classmethod remove_instance(instance: Instrument) None
Remove a particular instance from the record.
- Parameters
instance – The instance to remove
- property root_instrument: qcodes.instrument.instrument_base.InstrumentBase
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters
param_name – The name of a parameter of this instrument.
value – The new value to set.
- set_address(address: str) None
Set the address for this instrument.
- Parameters
address – The visa resource name to use to connect. The address should be the actual address and just that. If you wish to change the backend for VISA, use the self.visalib attribute (and then call this function).
- set_terminator(terminator: Optional[str]) None
Change the read terminator to use.
- Parameters
terminator – Character(s) to look for at the end of a read and to end each write command with. eg.
\r\n
. If None the terminator will not be set.
- snapshot(update: Optional[bool] = False) Dict[Any, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base()
.- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: Optional[bool] = True, params_to_skip_update: Optional[Sequence[str]] = None) Dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncoder
supports).- Parameters
update – If True, update the state by querying the instrument. If None only update if the state is known to be invalid. If False, just use the latest values in memory and never update.
params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_get
attribute of those parameters instead.
- Returns
base snapshot
- Return type
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters
verbose – If
True
, then information about the parameters that are being check is printed.
- write(cmd: str) None
Write a command string with NO response to the hardware.
Subclasses that transform
cmd
should override this method, and in it callsuper().write(new_cmd)
. Subclasses that define a new hardware communication should instead overridewrite_raw
.- Parameters
cmd – The string to send to the instrument.
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- write_raw(cmd: str) None
Low-level interface to
visa_handle.write
.- Parameters
cmd – The command to send to the instrument.
- parameters: Dict[str, ParameterBase] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter()
.
- functions: Dict[str, Function] = {}
All the functions supported by this instrument. Usually populated via
add_function()
.
- submodules: Dict[str, Union['InstrumentModule', 'ChannelTuple']] = {}
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule()
.
- instrument_modules: Dict[str, 'InstrumentModule'] = {}
All the
InstrumentModule
of this instrument Usually populated viaadd_submodule()
.
qcodes.instrument_drivers.tektronix.AWG70002A module
- class qcodes.instrument_drivers.tektronix.AWG70002A.AWG70002A(*args: Any, **kwargs: Any)[source]
Bases:
AWG70000A
The QCoDeS driver for Tektronix AWG70002A series AWG’s.
All the actual driver meat is in the superclass AWG70000A.
- Parameters
name – The name used internally by QCoDeS in the DataSet
address – The VISA resource name of the instrument
timeout – The VISA timeout time (in seconds).
- __getitem__(key: str) Union[Callable[[...], Any], Parameter]
Delegate instrument[‘name’] to parameter or function ‘name’.
- add_function(name: str, **kwargs: Any) None
Bind one
Function
to this instrument.Instrument subclasses can call this repeatedly in their
__init__
for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST
(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only. If your case is more complicated, you’re probably better off simply making a new method in yourInstrument
subclass definition.- Parameters
name – How the Function will be stored within
instrument.Functions
and also how you address it using the shortcut methods:instrument.call(func_name, *args)
etc.**kwargs – constructor kwargs for
Function
- Raises
KeyError – If this instrument already has a function with this name.
- add_parameter(name: str, parameter_class: Optional[Type[ParameterBase]] = None, **kwargs: Any) None
Bind one Parameter to this instrument.
Instrument subclasses can call this repeatedly in their
__init__
for every real parameter of the instrument.In this sense, parameters are the state variables of the instrument, anything the user can set and/or get.
- Parameters
name – How the parameter will be stored within
parameters
and also how you address it using the shortcut methods:instrument.set(param_name, value)
etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter
.**kwargs – Constructor arguments for
parameter_class
.
- Raises
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- add_submodule(name: str, submodule: Union[InstrumentModule, ChannelTuple]) None
Bind one submodule to this instrument.
Instrument subclasses can call this repeatedly in their
__init__
method for every submodule of the instrument.Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an
InstrumentModule
or aChannelTuple
.- Parameters
name – How the submodule will be stored within
instrument.submodules
and also how it can be addressed.submodule – The submodule to be stored.
- Raises
- property ancestors: List[qcodes.instrument.instrument_base.InstrumentBase]
Returns a list of instruments, starting from the current instrument and following to the parent instrument and the parents parent instrument until the root instrument is reached.
- ask(cmd: str) str
Write a command string to the hardware and return a response.
Subclasses that transform
cmd
should override this method, and in it callsuper().ask(new_cmd)
. Subclasses that define a new hardware communication should instead overrideask_raw
.- Parameters
cmd – The string to send to the instrument.
- Returns
response
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- ask_raw(cmd: str) str
Low-level interface to
visa_handle.ask
.- Parameters
cmd – The command to send to the instrument.
- Returns
The instrument’s response.
- Return type
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns
The return value of the function.
- check_error(ret_code: int) None
Default error checking, raises an error if return code
!=0
. Does not differentiate between warnings or specific error messages. Override this function in your driver if you want to add specific error messages.- Parameters
ret_code – A Visa error code. See eg: https://github.com/hgrecco/pyvisa/blob/master/pyvisa/errors.py
- Raises
visa.VisaIOError – if
ret_code
indicates a communication problem.
- classmethod close_all() None
Try to close all instruments registered in
_all_instruments
This is handy for use with atexit to ensure that all instruments are closed when a python session is closed.Examples
>>> atexit.register(qc.Instrument.close_all())
- connect_message(idn_param: str = 'IDN', begin_time: Optional[float] = None) None
Print a standard message on initial connection to an instrument.
- Parameters
idn_param – Name of parameter that returns ID dict. Default
IDN
.begin_time –
time.time()
when init started. Default isself._t0
, set at start ofInstrument.__init__
.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self
, whose keys should be treated as attributes ofself
.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self
, whose attributes should be passed through toself
.
- delete_sequence_from_list(seqname: str) None
Delete the specified sequence from the sequence list
- Parameters
seqname – The name of the sequence (as it appears in the sequence list, not the file name) to delete
- static exist(name: str, instrument_class: Optional[type] = None) bool
Check if an instrument with a given names exists (i.e. is already instantiated).
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- classmethod find_instrument(name: str, instrument_class: Optional[Type[T]] = None) T
Find an existing instrument by name.
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- Returns
The instrument found.
- Raises
- get(param_name: str) Any
Shortcut for getting a parameter from its name.
- Parameters
param_name – The name of a parameter of this instrument.
- Returns
The current value of the parameter.
- get_idn() Dict[str, Optional[str]]
Parse a standard VISA
*IDN?
response into an ID dict.Even though this is the VISA standard, it applies to various other types as well, such as IPInstruments, so it is included here in the Instrument base class.
Override this if your instrument does not support
*IDN?
or returns a nonstandard IDN string. This string is supposed to be a comma-separated list of vendor, model, serial, and firmware, but semicolon and colon are also common separators so we accept them here as well.- Returns
A dict containing vendor, model, serial, and firmware.
- classmethod instances() List[Instrument]
Get all currently defined instances of this instrument class.
You can use this to get the objects back if you lose track of them, and it’s also used by the test system to find objects to test against.
- Returns
A list of instances.
- invalidate_cache() None
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- static is_valid(instr_instance: Instrument) bool
Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a “valid” instrument.
- Parameters
instr_instance – Instance of an Instrument class or its subclass.
- loadSEQXFile(filename: str, path: Optional[str] = None) None
Load a seqx file from instrument disk memory. All sequences in the file are loaded into the sequence list.
- Parameters
filename – The name of the sequence file INCLUDING the extension
path – Path to load from. If omitted, the default path (self.seqxFileFolder) is used.
- loadWFMXFile(filename: str, path: Optional[str] = None) None
Loads a wfmx from memory into the waveform list Only loading from the C: drive is supported
- Parameters
filename – Name of the file (with extension)
path – Path to load from. If omitted, the default path (self.wfmxFileFolder) is used.
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- static makeSEQXFile(trig_waits: Sequence[int], nreps: Sequence[int], event_jumps: Sequence[int], event_jump_to: Sequence[int], go_to: Sequence[int], wfms: Sequence[Sequence[ndarray]], amplitudes: Sequence[float], seqname: str, flags: Optional[Sequence[Sequence[Sequence[int]]]] = None) bytes
Make a full .seqx file (bundle) A .seqx file can presumably hold several sequences, but for now we support only packing a single sequence
For a single sequence, a .seqx file is a bundle of two files and two folders:
- /Sequences
sequence.sml
- /Waveforms
wfm1.wfmx wfm2.wfmx …
setup.xml userNotes.txt
- Parameters
trig_waits – Wait for a trigger? If yes, you must specify the trigger input. 0 for off, 1 for ‘TrigA’, 2 for ‘TrigB’, 3 for ‘Internal’.
nreps – No. of repetitions. 0 corresponds to infinite.
event_jumps – Jump when event triggered? If yes, you must specify the trigger input. 0 for off, 1 for ‘TrigA’, 2 for ‘TrigB’, 3 for ‘Internal’.
event_jump_to – Jump target in case of event. 1-indexed, 0 means next. Must be specified for all elements.
go_to – Which element to play next. 1-indexed, 0 means next.
wfms – numpy arrays describing each waveform plus two markers, packed like np.array([wfm, m1, m2]). These numpy arrays are then again packed in lists according to: [[wfmch1pos1, wfmch1pos2, …], [wfmch2pos1, …], …]
amplitudes – The peak-to-peak amplitude in V of the channels, i.e. a list [ch1_amp, ch2_amp].
seqname – The name of the sequence. This name will appear in the sequence list. Note that all spaces are converted to ‘_’
flags – Flags for the auxiliary outputs. 0 for ‘No change’, 1 for ‘High’, 2 for ‘Low’, 3 for ‘Toggle’, or 4 for ‘Pulse’. 4 flags [A, B, C, D] for every channel in every element, packed like: [[ch1pos1, ch1pos2, …], [ch2pos1, …], …] If omitted, no flags will be set.
- Returns
The binary .seqx file, ready to be sent to the instrument.
- static makeWFMXFile(data: ndarray, amplitude: float) bytes
Compose a WFMX file
- Parameters
data – A numpy array holding the data. Markers can be included.
amplitude – The peak-to-peak amplitude (V) assumed to be set on the channel that will play this waveform. This information is needed as the waveform must be rescaled to (-1, 1) where -1 will correspond to the channel’s min. voltage and 1 to the channel’s max. voltage.
- Returns
The binary .wfmx file, ready to be sent to the instrument.
- static make_SEQX_from_forged_sequence(seq: Dict[int, Dict[Any, Any]], amplitudes: List[float], seqname: str, channel_mapping: Optional[Dict[Union[str, int], int]] = None) bytes
Make a .seqx from a forged broadbean sequence. Supports subsequences.
- Parameters
seq – The output of broadbean’s Sequence.forge()
amplitudes – A list of the AWG channels’ voltage amplitudes. The first entry is ch1 etc.
channel_mapping – A mapping from what the channel is called in the broadbean sequence to the integer describing the physical channel it should be assigned to.
seqname – The name that the sequence will have in the AWG’s sequence list. Used for loading the sequence.
- Returns
- The binary .seqx file contents. Can be sent directly to the
instrument or saved on disk.
- property name: str
Name of the instrument This is equivalent to full_name for backwards compatibility.
- omit_delegate_attrs: List[str] = []
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: Optional[qcodes.instrument.instrument_base.InstrumentBase]
Returns the parent instrument. By default this is
None
. Any SubInstrument should subclass this to return the parent instrument.
- play(wait_for_running: bool = True, timeout: float = 10) None
Run the AWG/Func. Gen. This command is equivalent to pressing the play button on the front panel.
- Parameters
wait_for_running – If True, this command is blocking while the instrument is getting ready to play
timeout – The maximal time to wait for the instrument to play. Raises an exception is this time is reached.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters
update – If
True
, update the state by querying the instrument. IfFalse
, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- classmethod record_instance(instance: Instrument) None
Record (a weak ref to) an instance in a class’s instance list.
Also records the instance in list of all instruments, and verifies that there are no other instruments with the same name.
This method is called after initialization of the instrument is completed.
- Parameters
instance – Instance to record.
- Raises
KeyError – If another instance with the same name is already present.
- classmethod remove_instance(instance: Instrument) None
Remove a particular instance from the record.
- Parameters
instance – The instance to remove
- property root_instrument: qcodes.instrument.instrument_base.InstrumentBase
- sendSEQXFile(seqx: bytes, filename: str, path: Optional[str] = None) None
Send a binary seqx file to the AWG’s memory
- Parameters
seqx – The binary seqx file, preferably the output of makeSEQXFile.
filename – The name of the file on the AWG disk, including the extension.
path – The path to the directory where the file should be saved. If omitted, seqxFileFolder will be used.
- sendWFMXFile(wfmx: bytes, filename: str, path: Optional[str] = None) None
Send a binary wfmx file to the AWG’s memory
- Parameters
wfmx – The binary wfmx file, preferably the output of makeWFMXFile.
filename – The name of the file on the AWG disk, including the extension.
path – The path to the directory where the file should be saved. If omitted, seqxFileFolder will be used.
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters
param_name – The name of a parameter of this instrument.
value – The new value to set.
- set_address(address: str) None
Set the address for this instrument.
- Parameters
address – The visa resource name to use to connect. The address should be the actual address and just that. If you wish to change the backend for VISA, use the self.visalib attribute (and then call this function).
- set_terminator(terminator: Optional[str]) None
Change the read terminator to use.
- Parameters
terminator – Character(s) to look for at the end of a read and to end each write command with. eg.
\r\n
. If None the terminator will not be set.
- snapshot(update: Optional[bool] = False) Dict[Any, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base()
.- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: Optional[bool] = True, params_to_skip_update: Optional[Sequence[str]] = None) Dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncoder
supports).- Parameters
update – If True, update the state by querying the instrument. If None only update if the state is known to be invalid. If False, just use the latest values in memory and never update.
params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_get
attribute of those parameters instead.
- Returns
base snapshot
- Return type
- stop() None
Stop the output of the instrument. This command is equivalent to pressing the stop button on the front panel.
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters
verbose – If
True
, then information about the parameters that are being check is printed.
- write(cmd: str) None
Write a command string with NO response to the hardware.
Subclasses that transform
cmd
should override this method, and in it callsuper().write(new_cmd)
. Subclasses that define a new hardware communication should instead overridewrite_raw
.- Parameters
cmd – The string to send to the instrument.
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- write_raw(cmd: str) None
Low-level interface to
visa_handle.write
.- Parameters
cmd – The command to send to the instrument.
- visa_handle: visa.resources.MessageBasedResource = visa.resources.MessageBasedResource
- parameters: Dict[str, ParameterBase] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter()
.
- functions: Dict[str, Function] = {}
All the functions supported by this instrument. Usually populated via
add_function()
.
- submodules: Dict[str, Union['InstrumentModule', 'ChannelTuple']] = {}
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule()
.
- instrument_modules: Dict[str, 'InstrumentModule'] = {}
All the
InstrumentModule
of this instrument Usually populated viaadd_submodule()
.
qcodes.instrument_drivers.tektronix.AWGFileParser module
- qcodes.instrument_drivers.tektronix.AWGFileParser.parse_awg_file(awgfilepath: str) Tuple[Tuple[List[List[Dict[Any, Any]]], List[List[Dict[Any, Any]]], List[List[Dict[Any, Any]]], List[Union[str, int]], List[Union[str, int]], List[Union[str, int]], List[Union[str, int]], List[int]], Dict[str, Union[str, int, Tuple[Any, ...]]]] [source]
Parser for a binary .awg file. Returns a tuple matching the call signature of make_send_and_load_awg_file and a dictionary with instrument settings
NOTE: Build-in waveforms are not stored in .awg files. Blame tektronix.
- Parameters
awgfilepath – The absolute path to the awg file
- Returns
A tuple and a dict, where the tuple is (wfms, m1s, m2s, nreps, trigs, gotos, jumps, channels) and the dict contains all instrument settings from the file
qcodes.instrument_drivers.tektronix.DPO7200xx module
QCoDeS driver for the MSO/DPO5000/B, DPO7000/C, DPO70000/B/C/D/DX/SX, DSA70000/B/C/D, and MSO70000/C/DX Series Digital Oscilloscopes
- qcodes.instrument_drivers.tektronix.DPO7200xx.strip_quotes(string: str) str [source]
This function is used as a get_parser for various parameters in this driver
- exception qcodes.instrument_drivers.tektronix.DPO7200xx.ModeError[source]
Bases:
Exception
Raise this exception if we are in a wrong mode to perform an action
- args
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class qcodes.instrument_drivers.tektronix.DPO7200xx.TektronixDPO7000xx(*args: Any, **kwargs: Any)[source]
Bases:
VisaInstrument
QCoDeS driver for the MSO/DPO5000/B, DPO7000/C, DPO70000/B/C/D/DX/SX, DSA70000/B/C/D, and MSO70000/C/DX Series Digital Oscilloscopes
- number_of_channels = 4
- number_of_measurements = 8
- ask_raw(cmd: str) str [source]
Sometimes the instrument returns non-ascii characters in response strings manually adjust the encoding to latin-1
- __getitem__(key: str) Union[Callable[[...], Any], Parameter]
Delegate instrument[‘name’] to parameter or function ‘name’.
- add_function(name: str, **kwargs: Any) None
Bind one
Function
to this instrument.Instrument subclasses can call this repeatedly in their
__init__
for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST
(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only. If your case is more complicated, you’re probably better off simply making a new method in yourInstrument
subclass definition.- Parameters
name – How the Function will be stored within
instrument.Functions
and also how you address it using the shortcut methods:instrument.call(func_name, *args)
etc.**kwargs – constructor kwargs for
Function
- Raises
KeyError – If this instrument already has a function with this name.
- add_parameter(name: str, parameter_class: Optional[Type[ParameterBase]] = None, **kwargs: Any) None
Bind one Parameter to this instrument.
Instrument subclasses can call this repeatedly in their
__init__
for every real parameter of the instrument.In this sense, parameters are the state variables of the instrument, anything the user can set and/or get.
- Parameters
name – How the parameter will be stored within
parameters
and also how you address it using the shortcut methods:instrument.set(param_name, value)
etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter
.**kwargs – Constructor arguments for
parameter_class
.
- Raises
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- add_submodule(name: str, submodule: Union[InstrumentModule, ChannelTuple]) None
Bind one submodule to this instrument.
Instrument subclasses can call this repeatedly in their
__init__
method for every submodule of the instrument.Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an
InstrumentModule
or aChannelTuple
.- Parameters
name – How the submodule will be stored within
instrument.submodules
and also how it can be addressed.submodule – The submodule to be stored.
- Raises
- property ancestors: List[qcodes.instrument.instrument_base.InstrumentBase]
Returns a list of instruments, starting from the current instrument and following to the parent instrument and the parents parent instrument until the root instrument is reached.
- ask(cmd: str) str
Write a command string to the hardware and return a response.
Subclasses that transform
cmd
should override this method, and in it callsuper().ask(new_cmd)
. Subclasses that define a new hardware communication should instead overrideask_raw
.- Parameters
cmd – The string to send to the instrument.
- Returns
response
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns
The return value of the function.
- check_error(ret_code: int) None
Default error checking, raises an error if return code
!=0
. Does not differentiate between warnings or specific error messages. Override this function in your driver if you want to add specific error messages.- Parameters
ret_code – A Visa error code. See eg: https://github.com/hgrecco/pyvisa/blob/master/pyvisa/errors.py
- Raises
visa.VisaIOError – if
ret_code
indicates a communication problem.
- classmethod close_all() None
Try to close all instruments registered in
_all_instruments
This is handy for use with atexit to ensure that all instruments are closed when a python session is closed.Examples
>>> atexit.register(qc.Instrument.close_all())
- connect_message(idn_param: str = 'IDN', begin_time: Optional[float] = None) None
Print a standard message on initial connection to an instrument.
- Parameters
idn_param – Name of parameter that returns ID dict. Default
IDN
.begin_time –
time.time()
when init started. Default isself._t0
, set at start ofInstrument.__init__
.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self
, whose keys should be treated as attributes ofself
.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self
, whose attributes should be passed through toself
.
- static exist(name: str, instrument_class: Optional[type] = None) bool
Check if an instrument with a given names exists (i.e. is already instantiated).
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- classmethod find_instrument(name: str, instrument_class: Optional[Type[T]] = None) T
Find an existing instrument by name.
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- Returns
The instrument found.
- Raises
- get(param_name: str) Any
Shortcut for getting a parameter from its name.
- Parameters
param_name – The name of a parameter of this instrument.
- Returns
The current value of the parameter.
- get_idn() Dict[str, Optional[str]]
Parse a standard VISA
*IDN?
response into an ID dict.Even though this is the VISA standard, it applies to various other types as well, such as IPInstruments, so it is included here in the Instrument base class.
Override this if your instrument does not support
*IDN?
or returns a nonstandard IDN string. This string is supposed to be a comma-separated list of vendor, model, serial, and firmware, but semicolon and colon are also common separators so we accept them here as well.- Returns
A dict containing vendor, model, serial, and firmware.
- classmethod instances() List[Instrument]
Get all currently defined instances of this instrument class.
You can use this to get the objects back if you lose track of them, and it’s also used by the test system to find objects to test against.
- Returns
A list of instances.
- invalidate_cache() None
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- static is_valid(instr_instance: Instrument) bool
Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a “valid” instrument.
- Parameters
instr_instance – Instance of an Instrument class or its subclass.
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Name of the instrument This is equivalent to full_name for backwards compatibility.
- omit_delegate_attrs: List[str] = []
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: Optional[qcodes.instrument.instrument_base.InstrumentBase]
Returns the parent instrument. By default this is
None
. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters
update – If
True
, update the state by querying the instrument. IfFalse
, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- classmethod record_instance(instance: Instrument) None
Record (a weak ref to) an instance in a class’s instance list.
Also records the instance in list of all instruments, and verifies that there are no other instruments with the same name.
This method is called after initialization of the instrument is completed.
- Parameters
instance – Instance to record.
- Raises
KeyError – If another instance with the same name is already present.
- classmethod remove_instance(instance: Instrument) None
Remove a particular instance from the record.
- Parameters
instance – The instance to remove
- property root_instrument: qcodes.instrument.instrument_base.InstrumentBase
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters
param_name – The name of a parameter of this instrument.
value – The new value to set.
- set_address(address: str) None
Set the address for this instrument.
- Parameters
address – The visa resource name to use to connect. The address should be the actual address and just that. If you wish to change the backend for VISA, use the self.visalib attribute (and then call this function).
- set_terminator(terminator: Optional[str]) None
Change the read terminator to use.
- Parameters
terminator – Character(s) to look for at the end of a read and to end each write command with. eg.
\r\n
. If None the terminator will not be set.
- snapshot(update: Optional[bool] = False) Dict[Any, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base()
.- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: Optional[bool] = True, params_to_skip_update: Optional[Sequence[str]] = None) Dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncoder
supports).- Parameters
update – If True, update the state by querying the instrument. If None only update if the state is known to be invalid. If False, just use the latest values in memory and never update.
params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_get
attribute of those parameters instead.
- Returns
base snapshot
- Return type
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters
verbose – If
True
, then information about the parameters that are being check is printed.
- write(cmd: str) None
Write a command string with NO response to the hardware.
Subclasses that transform
cmd
should override this method, and in it callsuper().write(new_cmd)
. Subclasses that define a new hardware communication should instead overridewrite_raw
.- Parameters
cmd – The string to send to the instrument.
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- write_raw(cmd: str) None
Low-level interface to
visa_handle.write
.- Parameters
cmd – The command to send to the instrument.
- parameters: Dict[str, ParameterBase] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter()
.
- functions: Dict[str, Function] = {}
All the functions supported by this instrument. Usually populated via
add_function()
.
- submodules: Dict[str, Union['InstrumentModule', 'ChannelTuple']] = {}
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule()
.
- instrument_modules: Dict[str, 'InstrumentModule'] = {}
All the
InstrumentModule
of this instrument Usually populated viaadd_submodule()
.
- class qcodes.instrument_drivers.tektronix.DPO7200xx.TektronixDPOData(parent: Union[Instrument, InstrumentChannel], name: str)[source]
Bases:
InstrumentChannel
This submodule sets and retrieves information regarding the data source for the “CURVE?” query, which is used when retrieving waveform data.
- __getitem__(key: str) Union[Callable[[...], Any], Parameter]
Delegate instrument[‘name’] to parameter or function ‘name’.
- add_function(name: str, **kwargs: Any) None
Bind one
Function
to this instrument.Instrument subclasses can call this repeatedly in their
__init__
for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST
(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only. If your case is more complicated, you’re probably better off simply making a new method in yourInstrument
subclass definition.- Parameters
name – How the Function will be stored within
instrument.Functions
and also how you address it using the shortcut methods:instrument.call(func_name, *args)
etc.**kwargs – constructor kwargs for
Function
- Raises
KeyError – If this instrument already has a function with this name.
- add_parameter(name: str, parameter_class: Optional[Type[ParameterBase]] = None, **kwargs: Any) None
Bind one Parameter to this instrument.
Instrument subclasses can call this repeatedly in their
__init__
for every real parameter of the instrument.In this sense, parameters are the state variables of the instrument, anything the user can set and/or get.
- Parameters
name – How the parameter will be stored within
parameters
and also how you address it using the shortcut methods:instrument.set(param_name, value)
etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter
.**kwargs – Constructor arguments for
parameter_class
.
- Raises
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- add_submodule(name: str, submodule: Union[InstrumentModule, ChannelTuple]) None
Bind one submodule to this instrument.
Instrument subclasses can call this repeatedly in their
__init__
method for every submodule of the instrument.Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an
InstrumentModule
or aChannelTuple
.- Parameters
name – How the submodule will be stored within
instrument.submodules
and also how it can be addressed.submodule – The submodule to be stored.
- Raises
- property ancestors: List[qcodes.instrument.instrument_base.InstrumentBase]
Returns a list of instruments, starting from the current instrument and following to the parent instrument and the parents parent instrument until the root instrument is reached.
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns
The return value of the function.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self
, whose keys should be treated as attributes ofself
.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self
, whose attributes should be passed through toself
.
- get(param_name: str) Any
Shortcut for getting a parameter from its name.
- Parameters
param_name – The name of a parameter of this instrument.
- Returns
The current value of the parameter.
- invalidate_cache() None
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Name of the instrument This is equivalent to full_name for backwards compatibility.
- omit_delegate_attrs: List[str] = []
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: qcodes.instrument.instrument_base.InstrumentBase
Returns the parent instrument. By default this is
None
. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters
update – If
True
, update the state by querying the instrument. IfFalse
, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- property root_instrument: qcodes.instrument.instrument_base.InstrumentBase
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters
param_name – The name of a parameter of this instrument.
value – The new value to set.
- snapshot(update: Optional[bool] = False) Dict[Any, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base()
.- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: Optional[bool] = False, params_to_skip_update: Optional[Sequence[str]] = None) Dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncoder
supports).- Parameters
update – If
True
, update the state by querying the instrument. If None update the state if known to be invalid. IfFalse
, just use the latest values in memory and never update state.params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_get
attribute of those parameters instead.
- Returns
base snapshot
- Return type
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters
verbose – If
True
, then information about the parameters that are being check is printed.
- parameters: Dict[str, ParameterBase] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter()
.
- functions: Dict[str, Function] = {}
All the functions supported by this instrument. Usually populated via
add_function()
.
- submodules: Dict[str, Union['InstrumentModule', 'ChannelTuple']] = {}
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule()
.
- instrument_modules: Dict[str, 'InstrumentModule'] = {}
All the
InstrumentModule
of this instrument Usually populated viaadd_submodule()
.
- class qcodes.instrument_drivers.tektronix.DPO7200xx.TekronixDPOWaveform(parent: Union[Instrument, InstrumentChannel], name: str, identifier: str)[source]
Bases:
InstrumentChannel
This submodule retrieves data from waveform sources, e.g. channels.
- valid_identifiers = ['CH1', 'CH2', 'CH3', 'CH4', 'MATH1', 'MATH2', 'MATH3', 'MATH4', 'REF1', 'REF2', 'REF3', 'REF4']
- __getitem__(key: str) Union[Callable[[...], Any], Parameter]
Delegate instrument[‘name’] to parameter or function ‘name’.
- add_function(name: str, **kwargs: Any) None
Bind one
Function
to this instrument.Instrument subclasses can call this repeatedly in their
__init__
for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST
(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only. If your case is more complicated, you’re probably better off simply making a new method in yourInstrument
subclass definition.- Parameters
name – How the Function will be stored within
instrument.Functions
and also how you address it using the shortcut methods:instrument.call(func_name, *args)
etc.**kwargs – constructor kwargs for
Function
- Raises
KeyError – If this instrument already has a function with this name.
- add_parameter(name: str, parameter_class: Optional[Type[ParameterBase]] = None, **kwargs: Any) None
Bind one Parameter to this instrument.
Instrument subclasses can call this repeatedly in their
__init__
for every real parameter of the instrument.In this sense, parameters are the state variables of the instrument, anything the user can set and/or get.
- Parameters
name – How the parameter will be stored within
parameters
and also how you address it using the shortcut methods:instrument.set(param_name, value)
etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter
.**kwargs – Constructor arguments for
parameter_class
.
- Raises
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- add_submodule(name: str, submodule: Union[InstrumentModule, ChannelTuple]) None
Bind one submodule to this instrument.
Instrument subclasses can call this repeatedly in their
__init__
method for every submodule of the instrument.Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an
InstrumentModule
or aChannelTuple
.- Parameters
name – How the submodule will be stored within
instrument.submodules
and also how it can be addressed.submodule – The submodule to be stored.
- Raises
- property ancestors: List[qcodes.instrument.instrument_base.InstrumentBase]
Returns a list of instruments, starting from the current instrument and following to the parent instrument and the parents parent instrument until the root instrument is reached.
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns
The return value of the function.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self
, whose keys should be treated as attributes ofself
.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self
, whose attributes should be passed through toself
.
- get(param_name: str) Any
Shortcut for getting a parameter from its name.
- Parameters
param_name – The name of a parameter of this instrument.
- Returns
The current value of the parameter.
- invalidate_cache() None
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Name of the instrument This is equivalent to full_name for backwards compatibility.
- omit_delegate_attrs: List[str] = []
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: qcodes.instrument.instrument_base.InstrumentBase
Returns the parent instrument. By default this is
None
. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters
update – If
True
, update the state by querying the instrument. IfFalse
, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- property root_instrument: qcodes.instrument.instrument_base.InstrumentBase
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters
param_name – The name of a parameter of this instrument.
value – The new value to set.
- snapshot(update: Optional[bool] = False) Dict[Any, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base()
.- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: Optional[bool] = False, params_to_skip_update: Optional[Sequence[str]] = None) Dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncoder
supports).- Parameters
update – If
True
, update the state by querying the instrument. If None update the state if known to be invalid. IfFalse
, just use the latest values in memory and never update state.params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_get
attribute of those parameters instead.
- Returns
base snapshot
- Return type
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters
verbose – If
True
, then information about the parameters that are being check is printed.
- parameters: Dict[str, ParameterBase] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter()
.
- functions: Dict[str, Function] = {}
All the functions supported by this instrument. Usually populated via
add_function()
.
- submodules: Dict[str, Union['InstrumentModule', 'ChannelTuple']] = {}
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule()
.
- instrument_modules: Dict[str, 'InstrumentModule'] = {}
All the
InstrumentModule
of this instrument Usually populated viaadd_submodule()
.
- class qcodes.instrument_drivers.tektronix.DPO7200xx.TektronixDPOWaveformFormat(parent: Union[Instrument, InstrumentChannel], name: str)[source]
Bases:
InstrumentChannel
With this sub module we can query waveform formatting data. Please note that parameters defined in this submodule effects all waveform sources, whereas parameters defined in the submodule ‘TekronixDPOWaveform’ apply to specific waveform sources (e.g. channel1 or math2)
- __getitem__(key: str) Union[Callable[[...], Any], Parameter]
Delegate instrument[‘name’] to parameter or function ‘name’.
- add_function(name: str, **kwargs: Any) None
Bind one
Function
to this instrument.Instrument subclasses can call this repeatedly in their
__init__
for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST
(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only. If your case is more complicated, you’re probably better off simply making a new method in yourInstrument
subclass definition.- Parameters
name – How the Function will be stored within
instrument.Functions
and also how you address it using the shortcut methods:instrument.call(func_name, *args)
etc.**kwargs – constructor kwargs for
Function
- Raises
KeyError – If this instrument already has a function with this name.
- add_parameter(name: str, parameter_class: Optional[Type[ParameterBase]] = None, **kwargs: Any) None
Bind one Parameter to this instrument.
Instrument subclasses can call this repeatedly in their
__init__
for every real parameter of the instrument.In this sense, parameters are the state variables of the instrument, anything the user can set and/or get.
- Parameters
name – How the parameter will be stored within
parameters
and also how you address it using the shortcut methods:instrument.set(param_name, value)
etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter
.**kwargs – Constructor arguments for
parameter_class
.
- Raises
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- add_submodule(name: str, submodule: Union[InstrumentModule, ChannelTuple]) None
Bind one submodule to this instrument.
Instrument subclasses can call this repeatedly in their
__init__
method for every submodule of the instrument.Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an
InstrumentModule
or aChannelTuple
.- Parameters
name – How the submodule will be stored within
instrument.submodules
and also how it can be addressed.submodule – The submodule to be stored.
- Raises
- property ancestors: List[qcodes.instrument.instrument_base.InstrumentBase]
Returns a list of instruments, starting from the current instrument and following to the parent instrument and the parents parent instrument until the root instrument is reached.
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns
The return value of the function.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self
, whose keys should be treated as attributes ofself
.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self
, whose attributes should be passed through toself
.
- get(param_name: str) Any
Shortcut for getting a parameter from its name.
- Parameters
param_name – The name of a parameter of this instrument.
- Returns
The current value of the parameter.
- invalidate_cache() None
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Name of the instrument This is equivalent to full_name for backwards compatibility.
- omit_delegate_attrs: List[str] = []
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: qcodes.instrument.instrument_base.InstrumentBase
Returns the parent instrument. By default this is
None
. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters
update – If
True
, update the state by querying the instrument. IfFalse
, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- property root_instrument: qcodes.instrument.instrument_base.InstrumentBase
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters
param_name – The name of a parameter of this instrument.
value – The new value to set.
- snapshot(update: Optional[bool] = False) Dict[Any, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base()
.- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: Optional[bool] = False, params_to_skip_update: Optional[Sequence[str]] = None) Dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncoder
supports).- Parameters
update – If
True
, update the state by querying the instrument. If None update the state if known to be invalid. IfFalse
, just use the latest values in memory and never update state.params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_get
attribute of those parameters instead.
- Returns
base snapshot
- Return type
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters
verbose – If
True
, then information about the parameters that are being check is printed.
- parameters: Dict[str, ParameterBase] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter()
.
- functions: Dict[str, Function] = {}
All the functions supported by this instrument. Usually populated via
add_function()
.
- submodules: Dict[str, Union['InstrumentModule', 'ChannelTuple']] = {}
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule()
.
- instrument_modules: Dict[str, 'InstrumentModule'] = {}
All the
InstrumentModule
of this instrument Usually populated viaadd_submodule()
.
- class qcodes.instrument_drivers.tektronix.DPO7200xx.TektronixDPOChannel(parent: Union[Instrument, InstrumentChannel], name: str, channel_number: int)[source]
Bases:
InstrumentChannel
The main channel module for the oscilloscope. The parameters defined here reflect the waveforms as they are displayed on the instrument display.
- set_trace_length(value: int) None [source]
Set the trace length when retrieving data through the ‘waveform’ interface
- Parameters
value – The requested number of samples in the trace
- set_trace_time(value: float) None [source]
- Parameters
value – The time over which a trace is desired.
- __getitem__(key: str) Union[Callable[[...], Any], Parameter]
Delegate instrument[‘name’] to parameter or function ‘name’.
- add_function(name: str, **kwargs: Any) None
Bind one
Function
to this instrument.Instrument subclasses can call this repeatedly in their
__init__
for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST
(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only. If your case is more complicated, you’re probably better off simply making a new method in yourInstrument
subclass definition.- Parameters
name – How the Function will be stored within
instrument.Functions
and also how you address it using the shortcut methods:instrument.call(func_name, *args)
etc.**kwargs – constructor kwargs for
Function
- Raises
KeyError – If this instrument already has a function with this name.
- add_parameter(name: str, parameter_class: Optional[Type[ParameterBase]] = None, **kwargs: Any) None
Bind one Parameter to this instrument.
Instrument subclasses can call this repeatedly in their
__init__
for every real parameter of the instrument.In this sense, parameters are the state variables of the instrument, anything the user can set and/or get.
- Parameters
name – How the parameter will be stored within
parameters
and also how you address it using the shortcut methods:instrument.set(param_name, value)
etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter
.**kwargs – Constructor arguments for
parameter_class
.
- Raises
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- add_submodule(name: str, submodule: Union[InstrumentModule, ChannelTuple]) None
Bind one submodule to this instrument.
Instrument subclasses can call this repeatedly in their
__init__
method for every submodule of the instrument.Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an
InstrumentModule
or aChannelTuple
.- Parameters
name – How the submodule will be stored within
instrument.submodules
and also how it can be addressed.submodule – The submodule to be stored.
- Raises
- property ancestors: List[qcodes.instrument.instrument_base.InstrumentBase]
Returns a list of instruments, starting from the current instrument and following to the parent instrument and the parents parent instrument until the root instrument is reached.
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns
The return value of the function.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self
, whose keys should be treated as attributes ofself
.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self
, whose attributes should be passed through toself
.
- get(param_name: str) Any
Shortcut for getting a parameter from its name.
- Parameters
param_name – The name of a parameter of this instrument.
- Returns
The current value of the parameter.
- invalidate_cache() None
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Name of the instrument This is equivalent to full_name for backwards compatibility.
- omit_delegate_attrs: List[str] = []
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: qcodes.instrument.instrument_base.InstrumentBase
Returns the parent instrument. By default this is
None
. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters
update – If
True
, update the state by querying the instrument. IfFalse
, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- property root_instrument: qcodes.instrument.instrument_base.InstrumentBase
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters
param_name – The name of a parameter of this instrument.
value – The new value to set.
- snapshot(update: Optional[bool] = False) Dict[Any, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base()
.- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: Optional[bool] = False, params_to_skip_update: Optional[Sequence[str]] = None) Dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncoder
supports).- Parameters
update – If
True
, update the state by querying the instrument. If None update the state if known to be invalid. IfFalse
, just use the latest values in memory and never update state.params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_get
attribute of those parameters instead.
- Returns
base snapshot
- Return type
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters
verbose – If
True
, then information about the parameters that are being check is printed.
- parameters: Dict[str, ParameterBase] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter()
.
- functions: Dict[str, Function] = {}
All the functions supported by this instrument. Usually populated via
add_function()
.
- submodules: Dict[str, Union['InstrumentModule', 'ChannelTuple']] = {}
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule()
.
- instrument_modules: Dict[str, 'InstrumentModule'] = {}
All the
InstrumentModule
of this instrument Usually populated viaadd_submodule()
.
- class qcodes.instrument_drivers.tektronix.DPO7200xx.TektronixDPOHorizontal(parent: Union[Instrument, InstrumentChannel], name: str)[source]
Bases:
InstrumentChannel
This module controls the horizontal axis of the scope
- __getitem__(key: str) Union[Callable[[...], Any], Parameter]
Delegate instrument[‘name’] to parameter or function ‘name’.
- add_function(name: str, **kwargs: Any) None
Bind one
Function
to this instrument.Instrument subclasses can call this repeatedly in their
__init__
for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST
(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only. If your case is more complicated, you’re probably better off simply making a new method in yourInstrument
subclass definition.- Parameters
name – How the Function will be stored within
instrument.Functions
and also how you address it using the shortcut methods:instrument.call(func_name, *args)
etc.**kwargs – constructor kwargs for
Function
- Raises
KeyError – If this instrument already has a function with this name.
- add_parameter(name: str, parameter_class: Optional[Type[ParameterBase]] = None, **kwargs: Any) None
Bind one Parameter to this instrument.
Instrument subclasses can call this repeatedly in their
__init__
for every real parameter of the instrument.In this sense, parameters are the state variables of the instrument, anything the user can set and/or get.
- Parameters
name – How the parameter will be stored within
parameters
and also how you address it using the shortcut methods:instrument.set(param_name, value)
etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter
.**kwargs – Constructor arguments for
parameter_class
.
- Raises
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- add_submodule(name: str, submodule: Union[InstrumentModule, ChannelTuple]) None
Bind one submodule to this instrument.
Instrument subclasses can call this repeatedly in their
__init__
method for every submodule of the instrument.Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an
InstrumentModule
or aChannelTuple
.- Parameters
name – How the submodule will be stored within
instrument.submodules
and also how it can be addressed.submodule – The submodule to be stored.
- Raises
- property ancestors: List[qcodes.instrument.instrument_base.InstrumentBase]
Returns a list of instruments, starting from the current instrument and following to the parent instrument and the parents parent instrument until the root instrument is reached.
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns
The return value of the function.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self
, whose keys should be treated as attributes ofself
.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self
, whose attributes should be passed through toself
.
- get(param_name: str) Any
Shortcut for getting a parameter from its name.
- Parameters
param_name – The name of a parameter of this instrument.
- Returns
The current value of the parameter.
- invalidate_cache() None
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Name of the instrument This is equivalent to full_name for backwards compatibility.
- omit_delegate_attrs: List[str] = []
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: qcodes.instrument.instrument_base.InstrumentBase
Returns the parent instrument. By default this is
None
. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters
update – If
True
, update the state by querying the instrument. IfFalse
, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- property root_instrument: qcodes.instrument.instrument_base.InstrumentBase
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters
param_name – The name of a parameter of this instrument.
value – The new value to set.
- snapshot(update: Optional[bool] = False) Dict[Any, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base()
.- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: Optional[bool] = False, params_to_skip_update: Optional[Sequence[str]] = None) Dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncoder
supports).- Parameters
update – If
True
, update the state by querying the instrument. If None update the state if known to be invalid. IfFalse
, just use the latest values in memory and never update state.params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_get
attribute of those parameters instead.
- Returns
base snapshot
- Return type
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters
verbose – If
True
, then information about the parameters that are being check is printed.
- parameters: Dict[str, ParameterBase] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter()
.
- functions: