Keysight Drivers

Classes:

Keysight33210A(name, address[, silent])

QCoDeS driver for the Keysight 33210A waveform generator.

Keysight33250A(name, address[, silent])

QCoDeS driver for the Keysight 33250A waveform generator.

Keysight33511B(name, address[, silent])

QCoDeS driver for the Keysight 33511B waveform generator.

Keysight33512B(name, address[, silent])

QCoDeS driver for the Keysight 33512B waveform generator.

Keysight33522B(name, address[, silent])

QCoDeS driver for the Keysight 33522B waveform generator.

Keysight33622A(name, address[, silent])

QCoDeS driver for the Keysight 33622A waveform generator.

Keysight33xxxOutputChannel(parent, name, channum)

Class to hold the output channel of a Keysight 33xxxx waveform generator.

Keysight33xxxSyncChannel(parent, name)

Class to hold the sync output of a Keysight 33xxxx waveform generator.

Keysight34410A(name, address[, silent])

This is the qcodes driver for the Keysight 34410A Multimeter

Keysight34411A(name, address[, silent])

This is the qcodes driver for the Keysight 34411A Multimeter

Keysight34460A(name, address[, silent])

This is the qcodes driver for the Keysight 34460A Multimeter

Keysight34461A(name, address[, silent])

This is the qcodes driver for the Keysight 34461A Multimeter

Keysight34465A(name, address[, silent])

This is the qcodes driver for the Keysight 34465A Multimeter

Keysight34470A(name, address[, silent])

This is the qcodes driver for the Keysight 34470A Multimeter

Keysight34934A(parent, name, slot)

Create an instance for module 34933A.

Keysight34980A(name, address[, terminator])

QCodes driver for 34980A switch/measure unit

Keysight34980ASwitchMatrixSubModule(parent, ...)

A base class for Switch Matrix submodules for the 34980A systems.

KeysightB1500(name, address, **kwargs)

Driver for Keysight B1500 Semiconductor Parameter Analyzer.

KeysightB1500CVSweepMeasurement(name, ...)

CV sweep measurement outputs a list of primary (capacitance) and secondary parameter (disipation).

KeysightB1500CVSweeper(parent, name, **kwargs)

KeysightB1500Correction(parent, name, **kwargs)

A Keysight B1520A CMU submodule for performing open/short/load corrections.

KeysightB1500FrequencyList(parent, name, ...)

A frequency list for open/short/load correction for Keysight B1520A CMU.

KeysightB1500IVSweeper(parent, name, **kwargs)

KeysightB1511B(parent, name, slot_nr, **kwargs)

Driver for Keysight B1511B Source/Monitor Unit module for B1500 Semiconductor Parameter Analyzer.

KeysightB1517A(parent, name, slot_nr, **kwargs)

Driver for Keysight B1517A Source/Monitor Unit module for B1500 Semiconductor Parameter Analyzer.

KeysightB1520A(parent, name, slot_nr, **kwargs)

Driver for Keysight B1520A Capacitance Measurement Unit module for B1500 Semiconductor Parameter Analyzer.

KeysightB1530A(parent, name, slot_nr, **kwargs)

Driver for Keysight B1530A Waveform Generator/Fast Measurement Unit module for B1500 Semiconductor Parameter Analyzer.

KeysightB2200(name, address, **kwargs)

QCodes driver for B2200

KeysightB2201(name, address, **kwargs)

QCodes driver for B2201

KeysightB2962A(name, address, **kwargs)

This is the qcodes driver for the Keysight B2962A 6.5 Digit Low Noise Power Source

KeysightB2962AChannel(parent, name, chan)

param parent:

The instrument to which the channel is attached.

KeysightE4980A(name, address[, terminator])

QCodes driver for E4980A Precision LCR Meter

KeysightE4980ACorrection(parent, name)

Module for correction settings.

KeysightE4980AMeasurementPair(name, names, ...)

Data class for E4980A measurement, which will always return two items at once.

KeysightE4980AMeasurements()

All the measurement function for E4980A LCR meter.

KeysightInfiniium(name, address[, timeout, ...])

This is the QCoDeS driver for the Keysight Infiniium oscilloscopes

KeysightInfiniiumBoundMeasurement(parent, ...)

Initialize measurement subsystem bound to a specific channel

KeysightInfiniiumChannel(parent, name, ...)

Initialize an infiniium channel.

KeysightInfiniiumFunction(parent, name, ...)

Initialize an infiniium channel.

KeysightInfiniiumUnboundMeasurement(parent, ...)

Initialize measurement subsystem where target is set by the parameter source.

KeysightM9336A(name, address[, options, ...])

AWG Driver for the Keysight M9336A PXIe I/Q Arbitrary Waveform Generator.

KeysightM9336AAWGChannel(parent, name, chan)

Represent the three channels of the Keysight KTM Awg driver.

KeysightM960x(name, address[, options, dll_path])

Provide a wrapper for the Keysight KtM960x DAC.

KeysightN5173B(name, address, **kwargs)

KeysightN5183B(name, address, **kwargs)

KeysightN5222B(name, address, **kwargs)

Driver for Keysight PNA N5222B.

KeysightN5230C(name, address, **kwargs)

KeysightN5232B(name, address, **kwargs)

KeysightN5245A(name, address, **kwargs)

KeysightN6705B(name, address, **kwargs)

KeysightN6705BChannel(parent, name, chan)

KeysightN9030B(name, address, **kwargs)

Driver for Keysight N9030B PXA signal analyzer.

KeysightN9030BPhaseNoiseMode(parent, name, ...)

Phase Noise Mode for Keysight N9030B instrument.

KeysightN9030BSpectrumAnalyzerMode(parent, ...)

Spectrum Analyzer Mode for Keysight N9030B instrument.

KeysightP9374A(name, address, **kwargs)

KeysightPNAPort(parent, name, port, ...)

Allow operations on individual PNA ports.

KeysightPNATrace(parent, name, trace_name, ...)

Allow operations on individual PNA traces.

class qcodes.instrument_drivers.Keysight.Keysight33210A(name: str, address: str, silent: bool = False, **kwargs: Any)[source]

Bases: WaveformGenerator_33XXX

QCoDeS driver for the Keysight 33210A waveform generator.

Parameters:
  • name – The name of the instrument used internally by QCoDeS. Must be unique.

  • address – The VISA resource name.

  • silent – If True, no connect message is printed.

  • **kwargs – kwargs are forwarded to base class.

Methods:

__del__()

Close the instrument and remove its instance record.

__getitem__(key)

Delegate instrument['name'] to parameter or function 'name'.

__getstate__()

Prevent pickling instruments, and give a nice error message.

__repr__()

Simplified repr giving just the class and name.

add_function(name, **kwargs)

Bind one Function to this instrument.

add_parameter(name[, parameter_class])

Bind one Parameter to this instrument.

add_submodule(name, submodule)

Bind one submodule to this instrument.

ask(cmd)

Write a command string to the hardware and return a response.

ask_raw(cmd)

Low-level interface to visa_handle.ask.

call(func_name, *args)

Shortcut for calling a function from its name.

close()

Disconnect and irreversibly tear down the instrument.

close_all()

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.

connect_message([idn_param, begin_time])

Print a standard message on initial connection to an instrument.

device_clear()

Clear the buffers of the device

error()

Return the first error message in the queue.

exist(name[, instrument_class])

Check if an instrument with a given names exists (i.e. is already instantiated).

find_instrument(name[, instrument_class])

Find an existing instrument by name.

flush_error_queue([verbose])

Clear the instrument error queue, and prints it.

get(param_name)

Shortcut for getting a parameter from its name.

get_component(full_name)

Recursively get a component of the instrument by full_name.

get_idn()

Parse a standard VISA *IDN? response into an ID dict.

instances()

Get all currently defined instances of this instrument class.

invalidate_cache()

Invalidate the cache of all parameters on the instrument.

is_valid(instr_instance)

Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a "valid" instrument.

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

print_readable_snapshot([update, max_chars])

Prints a readable version of the snapshot.

record_instance(instance)

Record (a weak ref to) an instance in a class's instance list.

remove_instance(instance)

Remove a particular instance from the record.

set(param_name, value)

Shortcut for setting a parameter from its name and new value.

set_address(address)

Set the address for this instrument.

set_terminator(terminator)

Change the read terminator to use.

snapshot([update])

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class NumpyJSONEncoder supports).

validate_status([verbose])

Validate the values of all gettable parameters

write(cmd)

Write a command string with NO response to the hardware.

write_raw(cmd)

Low-level interface to visa_handle.write.

Attributes:

ancestors

Ancestors in the form of a list of InstrumentBase

delegate_attr_dicts

A list of names (strings) of dictionaries which are (or will be) attributes of self, whose keys should be treated as attributes of self.

delegate_attr_objects

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

full_name

Full name of the instrument.

label

Nicely formatted label of the instrument.

name

Full name of the instrument

name_parts

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs

A list of attribute names (strings) to not delegate to any other dictionary or object.

parent

The parent instrument.

root_instrument

The topmost parent of this module.

short_name

Short name of the instrument.

visa_handle

The VISA resource used by this instrument.

resource_manager

The VISA resource manager used by this instrument.

parameters

All the parameters supported by this instrument.

functions

All the functions supported by this instrument.

submodules

All the submodules of this instrument such as channel lists or logical groupings of parameters.

instrument_modules

All the InstrumentModule of this instrument Usually populated via add_submodule().

__del__() None

Close the instrument and remove its instance record.

__getitem__(key: str) Callable[..., Any] | Parameter

Delegate instrument[‘name’] to parameter or function ‘name’.

__getstate__() None

Prevent pickling instruments, and give a nice error message.

__repr__() str

Simplified repr giving just the class and 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.

Note

We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.

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: type[ParameterBase] | None = 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: 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 a ChannelTuple.

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:
  • KeyError – If this instrument already contains a submodule with this name.

  • TypeError – If the submodule that we are trying to add is not an instance of an Metadatable object.

property ancestors: tuple[InstrumentBase, ...]

Ancestors in the form of a list of InstrumentBase

The list starts with the current module then the parent and the parents parent 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 call super().ask(new_cmd). Subclasses that define a new hardware communication should instead override ask_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:

str

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.

close() None

Disconnect and irreversibly tear down the instrument.

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: float | None = 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_timetime.time() when init started. Default is self._t0, set at start of Instrument.__init__.

delegate_attr_dicts: ClassVar[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 of self.

delegate_attr_objects: ClassVar[list[str]] = []

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

device_clear() None

Clear the buffers of the device

error() tuple[int, str]

Return the first error message in the queue. It also clears it from the error queue.

Up to 20 errors can be stored in the instrument’s error queue. Error retrieval is first-in-first-out (FIFO).

If more than 20 errors have occurred, the most recent error stored in the queue is replaced with -350,”Queue overflow”. No additional errors are stored until you remove errors from the queue. If no errors have occurred when you read the error queue, the instrument responds with +0,”No error”.

Returns:

The error code and the error message.

static exist(name: str, instrument_class: type[Instrument] | None = 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: type[T] | None = None) T | Instrument

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:
  • KeyError – If no instrument of that name was found, or if its reference is invalid (dead).

  • TypeError – If a specific class was requested but a different type was found.

flush_error_queue(verbose: bool = True) None

Clear the instrument error queue, and prints it.

Parameters:

verbose – If true, the error messages are printed. Default: True.

property full_name: str

Full name of the instrument.

For an InstrumentModule this includes all parents separated by _

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_component(full_name: str) MetadatableWithName

Recursively get a component of the instrument by full_name.

Parameters:

full_name – The name of the component to get.

Returns:

The component with the given name.

Raises:

KeyError – If the component does not exist.

get_idn() dict[str, str | None]

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[T]

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.

property label: str

Nicely formatted label of the instrument.

load_metadata(metadata: Mapping[str, Any]) None

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

property name: str

Full name of the instrument

This is equivalent to full_name() for backwards compatibility.

property name_parts: list[str]

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs: ClassVar[list[str]] = []

A list of attribute names (strings) to not delegate to any other dictionary or object.

property parent: InstrumentBase | None

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. If False, 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: InstrumentBase

The topmost parent of this module.

For the root_instrument this is self.

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: str | None) 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.

property short_name: str

Short name of the instrument.

For an InstrumentModule this does not include any parent names.

snapshot(update: bool | None = False) dict[str, 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: bool | None = True, params_to_skip_update: Sequence[str] | None = 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:

dict

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 call super().write(new_cmd). Subclasses that define a new hardware communication should instead override write_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.

visabackend: str = visabackend
visa_handle: pyvisa.resources.MessageBasedResource = visa_handle

The VISA resource used by this instrument.

visalib: str | None = visalib
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, 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 via add_submodule().

log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
metadata: dict[str, Any] = {}
resource_manager = resource_manager

The VISA resource manager used by this instrument.

class qcodes.instrument_drivers.Keysight.Keysight33250A(name: str, address: str, silent: bool = False, **kwargs: Any)[source]

Bases: WaveformGenerator_33XXX

QCoDeS driver for the Keysight 33250A waveform generator.

Parameters:
  • name – The name of the instrument used internally by QCoDeS. Must be unique.

  • address – The VISA resource name.

  • silent – If True, no connect message is printed.

  • **kwargs – kwargs are forwarded to base class.

Methods:

__del__()

Close the instrument and remove its instance record.

__getitem__(key)

Delegate instrument['name'] to parameter or function 'name'.

__getstate__()

Prevent pickling instruments, and give a nice error message.

__repr__()

Simplified repr giving just the class and name.

add_function(name, **kwargs)

Bind one Function to this instrument.

add_parameter(name[, parameter_class])

Bind one Parameter to this instrument.

add_submodule(name, submodule)

Bind one submodule to this instrument.

ask(cmd)

Write a command string to the hardware and return a response.

ask_raw(cmd)

Low-level interface to visa_handle.ask.

call(func_name, *args)

Shortcut for calling a function from its name.

close()

Disconnect and irreversibly tear down the instrument.

close_all()

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.

connect_message([idn_param, begin_time])

Print a standard message on initial connection to an instrument.

device_clear()

Clear the buffers of the device

error()

Return the first error message in the queue.

exist(name[, instrument_class])

Check if an instrument with a given names exists (i.e. is already instantiated).

find_instrument(name[, instrument_class])

Find an existing instrument by name.

flush_error_queue([verbose])

Clear the instrument error queue, and prints it.

get(param_name)

Shortcut for getting a parameter from its name.

get_component(full_name)

Recursively get a component of the instrument by full_name.

get_idn()

Parse a standard VISA *IDN? response into an ID dict.

instances()

Get all currently defined instances of this instrument class.

invalidate_cache()

Invalidate the cache of all parameters on the instrument.

is_valid(instr_instance)

Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a "valid" instrument.

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

print_readable_snapshot([update, max_chars])

Prints a readable version of the snapshot.

record_instance(instance)

Record (a weak ref to) an instance in a class's instance list.

remove_instance(instance)

Remove a particular instance from the record.

set(param_name, value)

Shortcut for setting a parameter from its name and new value.

set_address(address)

Set the address for this instrument.

set_terminator(terminator)

Change the read terminator to use.

snapshot([update])

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class NumpyJSONEncoder supports).

validate_status([verbose])

Validate the values of all gettable parameters

write(cmd)

Write a command string with NO response to the hardware.

write_raw(cmd)

Low-level interface to visa_handle.write.

Attributes:

ancestors

Ancestors in the form of a list of InstrumentBase

delegate_attr_dicts

A list of names (strings) of dictionaries which are (or will be) attributes of self, whose keys should be treated as attributes of self.

delegate_attr_objects

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

full_name

Full name of the instrument.

label

Nicely formatted label of the instrument.

name

Full name of the instrument

name_parts

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs

A list of attribute names (strings) to not delegate to any other dictionary or object.

parent

The parent instrument.

root_instrument

The topmost parent of this module.

short_name

Short name of the instrument.

visa_handle

The VISA resource used by this instrument.

resource_manager

The VISA resource manager used by this instrument.

parameters

All the parameters supported by this instrument.

functions

All the functions supported by this instrument.

submodules

All the submodules of this instrument such as channel lists or logical groupings of parameters.

instrument_modules

All the InstrumentModule of this instrument Usually populated via add_submodule().

__del__() None

Close the instrument and remove its instance record.

__getitem__(key: str) Callable[..., Any] | Parameter

Delegate instrument[‘name’] to parameter or function ‘name’.

__getstate__() None

Prevent pickling instruments, and give a nice error message.

__repr__() str

Simplified repr giving just the class and 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.

Note

We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.

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: type[ParameterBase] | None = 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: 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 a ChannelTuple.

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:
  • KeyError – If this instrument already contains a submodule with this name.

  • TypeError – If the submodule that we are trying to add is not an instance of an Metadatable object.

property ancestors: tuple[InstrumentBase, ...]

Ancestors in the form of a list of InstrumentBase

The list starts with the current module then the parent and the parents parent 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 call super().ask(new_cmd). Subclasses that define a new hardware communication should instead override ask_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:

str

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.

close() None

Disconnect and irreversibly tear down the instrument.

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: float | None = 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_timetime.time() when init started. Default is self._t0, set at start of Instrument.__init__.

delegate_attr_dicts: ClassVar[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 of self.

delegate_attr_objects: ClassVar[list[str]] = []

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

device_clear() None

Clear the buffers of the device

error() tuple[int, str]

Return the first error message in the queue. It also clears it from the error queue.

Up to 20 errors can be stored in the instrument’s error queue. Error retrieval is first-in-first-out (FIFO).

If more than 20 errors have occurred, the most recent error stored in the queue is replaced with -350,”Queue overflow”. No additional errors are stored until you remove errors from the queue. If no errors have occurred when you read the error queue, the instrument responds with +0,”No error”.

Returns:

The error code and the error message.

static exist(name: str, instrument_class: type[Instrument] | None = 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: type[T] | None = None) T | Instrument

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:
  • KeyError – If no instrument of that name was found, or if its reference is invalid (dead).

  • TypeError – If a specific class was requested but a different type was found.

flush_error_queue(verbose: bool = True) None

Clear the instrument error queue, and prints it.

Parameters:

verbose – If true, the error messages are printed. Default: True.

property full_name: str

Full name of the instrument.

For an InstrumentModule this includes all parents separated by _

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_component(full_name: str) MetadatableWithName

Recursively get a component of the instrument by full_name.

Parameters:

full_name – The name of the component to get.

Returns:

The component with the given name.

Raises:

KeyError – If the component does not exist.

get_idn() dict[str, str | None]

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[T]

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.

property label: str

Nicely formatted label of the instrument.

load_metadata(metadata: Mapping[str, Any]) None

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

property name: str

Full name of the instrument

This is equivalent to full_name() for backwards compatibility.

property name_parts: list[str]

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs: ClassVar[list[str]] = []

A list of attribute names (strings) to not delegate to any other dictionary or object.

property parent: InstrumentBase | None

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. If False, 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: InstrumentBase

The topmost parent of this module.

For the root_instrument this is self.

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: str | None) 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.

property short_name: str

Short name of the instrument.

For an InstrumentModule this does not include any parent names.

snapshot(update: bool | None = False) dict[str, 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: bool | None = True, params_to_skip_update: Sequence[str] | None = 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:

dict

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 call super().write(new_cmd). Subclasses that define a new hardware communication should instead override write_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.

visabackend: str = visabackend
visa_handle: pyvisa.resources.MessageBasedResource = visa_handle

The VISA resource used by this instrument.

visalib: str | None = visalib
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, 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 via add_submodule().

log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
metadata: dict[str, Any] = {}
resource_manager = resource_manager

The VISA resource manager used by this instrument.

class qcodes.instrument_drivers.Keysight.Keysight33511B(name: str, address: str, silent: bool = False, **kwargs: Any)[source]

Bases: WaveformGenerator_33XXX

QCoDeS driver for the Keysight 33511B waveform generator.

Parameters:
  • name – The name of the instrument used internally by QCoDeS. Must be unique.

  • address – The VISA resource name.

  • silent – If True, no connect message is printed.

  • **kwargs – kwargs are forwarded to base class.

Methods:

__del__()

Close the instrument and remove its instance record.

__getitem__(key)

Delegate instrument['name'] to parameter or function 'name'.

__getstate__()

Prevent pickling instruments, and give a nice error message.

__repr__()

Simplified repr giving just the class and name.

add_function(name, **kwargs)

Bind one Function to this instrument.

add_parameter(name[, parameter_class])

Bind one Parameter to this instrument.

add_submodule(name, submodule)

Bind one submodule to this instrument.

ask(cmd)

Write a command string to the hardware and return a response.

ask_raw(cmd)

Low-level interface to visa_handle.ask.

call(func_name, *args)

Shortcut for calling a function from its name.

close()

Disconnect and irreversibly tear down the instrument.

close_all()

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.

connect_message([idn_param, begin_time])

Print a standard message on initial connection to an instrument.

device_clear()

Clear the buffers of the device

error()

Return the first error message in the queue.

exist(name[, instrument_class])

Check if an instrument with a given names exists (i.e. is already instantiated).

find_instrument(name[, instrument_class])

Find an existing instrument by name.

flush_error_queue([verbose])

Clear the instrument error queue, and prints it.

get(param_name)

Shortcut for getting a parameter from its name.

get_component(full_name)

Recursively get a component of the instrument by full_name.

get_idn()

Parse a standard VISA *IDN? response into an ID dict.

instances()

Get all currently defined instances of this instrument class.

invalidate_cache()

Invalidate the cache of all parameters on the instrument.

is_valid(instr_instance)

Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a "valid" instrument.

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

print_readable_snapshot([update, max_chars])

Prints a readable version of the snapshot.

record_instance(instance)

Record (a weak ref to) an instance in a class's instance list.

remove_instance(instance)

Remove a particular instance from the record.

set(param_name, value)

Shortcut for setting a parameter from its name and new value.

set_address(address)

Set the address for this instrument.

set_terminator(terminator)

Change the read terminator to use.

snapshot([update])

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class NumpyJSONEncoder supports).

validate_status([verbose])

Validate the values of all gettable parameters

write(cmd)

Write a command string with NO response to the hardware.

write_raw(cmd)

Low-level interface to visa_handle.write.

Attributes:

ancestors

Ancestors in the form of a list of InstrumentBase

delegate_attr_dicts

A list of names (strings) of dictionaries which are (or will be) attributes of self, whose keys should be treated as attributes of self.

delegate_attr_objects

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

full_name

Full name of the instrument.

label

Nicely formatted label of the instrument.

name

Full name of the instrument

name_parts

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs

A list of attribute names (strings) to not delegate to any other dictionary or object.

parent

The parent instrument.

root_instrument

The topmost parent of this module.

short_name

Short name of the instrument.

visa_handle

The VISA resource used by this instrument.

resource_manager

The VISA resource manager used by this instrument.

parameters

All the parameters supported by this instrument.

functions

All the functions supported by this instrument.

submodules

All the submodules of this instrument such as channel lists or logical groupings of parameters.

instrument_modules

All the InstrumentModule of this instrument Usually populated via add_submodule().

__del__() None

Close the instrument and remove its instance record.

__getitem__(key: str) Callable[..., Any] | Parameter

Delegate instrument[‘name’] to parameter or function ‘name’.

__getstate__() None

Prevent pickling instruments, and give a nice error message.

__repr__() str

Simplified repr giving just the class and 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.

Note

We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.

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: type[ParameterBase] | None = 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: 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 a ChannelTuple.

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:
  • KeyError – If this instrument already contains a submodule with this name.

  • TypeError – If the submodule that we are trying to add is not an instance of an Metadatable object.

property ancestors: tuple[InstrumentBase, ...]

Ancestors in the form of a list of InstrumentBase

The list starts with the current module then the parent and the parents parent 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 call super().ask(new_cmd). Subclasses that define a new hardware communication should instead override ask_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:

str

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.

close() None

Disconnect and irreversibly tear down the instrument.

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: float | None = 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_timetime.time() when init started. Default is self._t0, set at start of Instrument.__init__.

delegate_attr_dicts: ClassVar[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 of self.

delegate_attr_objects: ClassVar[list[str]] = []

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

device_clear() None

Clear the buffers of the device

error() tuple[int, str]

Return the first error message in the queue. It also clears it from the error queue.

Up to 20 errors can be stored in the instrument’s error queue. Error retrieval is first-in-first-out (FIFO).

If more than 20 errors have occurred, the most recent error stored in the queue is replaced with -350,”Queue overflow”. No additional errors are stored until you remove errors from the queue. If no errors have occurred when you read the error queue, the instrument responds with +0,”No error”.

Returns:

The error code and the error message.

static exist(name: str, instrument_class: type[Instrument] | None = 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: type[T] | None = None) T | Instrument

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:
  • KeyError – If no instrument of that name was found, or if its reference is invalid (dead).

  • TypeError – If a specific class was requested but a different type was found.

flush_error_queue(verbose: bool = True) None

Clear the instrument error queue, and prints it.

Parameters:

verbose – If true, the error messages are printed. Default: True.

property full_name: str

Full name of the instrument.

For an InstrumentModule this includes all parents separated by _

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_component(full_name: str) MetadatableWithName

Recursively get a component of the instrument by full_name.

Parameters:

full_name – The name of the component to get.

Returns:

The component with the given name.

Raises:

KeyError – If the component does not exist.

get_idn() dict[str, str | None]

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[T]

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.

property label: str

Nicely formatted label of the instrument.

load_metadata(metadata: Mapping[str, Any]) None

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

property name: str

Full name of the instrument

This is equivalent to full_name() for backwards compatibility.

property name_parts: list[str]

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs: ClassVar[list[str]] = []

A list of attribute names (strings) to not delegate to any other dictionary or object.

property parent: InstrumentBase | None

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. If False, 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: InstrumentBase

The topmost parent of this module.

For the root_instrument this is self.

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: str | None) 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.

property short_name: str

Short name of the instrument.

For an InstrumentModule this does not include any parent names.

snapshot(update: bool | None = False) dict[str, 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: bool | None = True, params_to_skip_update: Sequence[str] | None = 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:

dict

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 call super().write(new_cmd). Subclasses that define a new hardware communication should instead override write_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.

visabackend: str = visabackend
visa_handle: pyvisa.resources.MessageBasedResource = visa_handle

The VISA resource used by this instrument.

visalib: str | None = visalib
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, 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 via add_submodule().

log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
metadata: dict[str, Any] = {}
resource_manager = resource_manager

The VISA resource manager used by this instrument.

class qcodes.instrument_drivers.Keysight.Keysight33512B(name: str, address: str, silent: bool = False, **kwargs: Any)[source]

Bases: WaveformGenerator_33XXX

QCoDeS driver for the Keysight 33512B waveform generator.

Parameters:
  • name – The name of the instrument used internally by QCoDeS. Must be unique.

  • address – The VISA resource name.

  • silent – If True, no connect message is printed.

  • **kwargs – kwargs are forwarded to base class.

Methods:

__del__()

Close the instrument and remove its instance record.

__getitem__(key)

Delegate instrument['name'] to parameter or function 'name'.

__getstate__()

Prevent pickling instruments, and give a nice error message.

__repr__()

Simplified repr giving just the class and name.

add_function(name, **kwargs)

Bind one Function to this instrument.

add_parameter(name[, parameter_class])

Bind one Parameter to this instrument.

add_submodule(name, submodule)

Bind one submodule to this instrument.

ask(cmd)

Write a command string to the hardware and return a response.

ask_raw(cmd)

Low-level interface to visa_handle.ask.

call(func_name, *args)

Shortcut for calling a function from its name.

close()

Disconnect and irreversibly tear down the instrument.

close_all()

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.

connect_message([idn_param, begin_time])

Print a standard message on initial connection to an instrument.

device_clear()

Clear the buffers of the device

error()

Return the first error message in the queue.

exist(name[, instrument_class])

Check if an instrument with a given names exists (i.e. is already instantiated).

find_instrument(name[, instrument_class])

Find an existing instrument by name.

flush_error_queue([verbose])

Clear the instrument error queue, and prints it.

get(param_name)

Shortcut for getting a parameter from its name.

get_component(full_name)

Recursively get a component of the instrument by full_name.

get_idn()

Parse a standard VISA *IDN? response into an ID dict.

instances()

Get all currently defined instances of this instrument class.

invalidate_cache()

Invalidate the cache of all parameters on the instrument.

is_valid(instr_instance)

Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a "valid" instrument.

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

print_readable_snapshot([update, max_chars])

Prints a readable version of the snapshot.

record_instance(instance)

Record (a weak ref to) an instance in a class's instance list.

remove_instance(instance)

Remove a particular instance from the record.

set(param_name, value)

Shortcut for setting a parameter from its name and new value.

set_address(address)

Set the address for this instrument.

set_terminator(terminator)

Change the read terminator to use.

snapshot([update])

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class NumpyJSONEncoder supports).

validate_status([verbose])

Validate the values of all gettable parameters

write(cmd)

Write a command string with NO response to the hardware.

write_raw(cmd)

Low-level interface to visa_handle.write.

Attributes:

ancestors

Ancestors in the form of a list of InstrumentBase

delegate_attr_dicts

A list of names (strings) of dictionaries which are (or will be) attributes of self, whose keys should be treated as attributes of self.

delegate_attr_objects

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

full_name

Full name of the instrument.

label

Nicely formatted label of the instrument.

name

Full name of the instrument

name_parts

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs

A list of attribute names (strings) to not delegate to any other dictionary or object.

parent

The parent instrument.

root_instrument

The topmost parent of this module.

short_name

Short name of the instrument.

visa_handle

The VISA resource used by this instrument.

resource_manager

The VISA resource manager used by this instrument.

parameters

All the parameters supported by this instrument.

functions

All the functions supported by this instrument.

submodules

All the submodules of this instrument such as channel lists or logical groupings of parameters.

instrument_modules

All the InstrumentModule of this instrument Usually populated via add_submodule().

__del__() None

Close the instrument and remove its instance record.

__getitem__(key: str) Callable[..., Any] | Parameter

Delegate instrument[‘name’] to parameter or function ‘name’.

__getstate__() None

Prevent pickling instruments, and give a nice error message.

__repr__() str

Simplified repr giving just the class and 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.

Note

We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.

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: type[ParameterBase] | None = 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: 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 a ChannelTuple.

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:
  • KeyError – If this instrument already contains a submodule with this name.

  • TypeError – If the submodule that we are trying to add is not an instance of an Metadatable object.

property ancestors: tuple[InstrumentBase, ...]

Ancestors in the form of a list of InstrumentBase

The list starts with the current module then the parent and the parents parent 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 call super().ask(new_cmd). Subclasses that define a new hardware communication should instead override ask_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:

str

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.

close() None

Disconnect and irreversibly tear down the instrument.

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: float | None = 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_timetime.time() when init started. Default is self._t0, set at start of Instrument.__init__.

delegate_attr_dicts: ClassVar[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 of self.

delegate_attr_objects: ClassVar[list[str]] = []

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

device_clear() None

Clear the buffers of the device

error() tuple[int, str]

Return the first error message in the queue. It also clears it from the error queue.

Up to 20 errors can be stored in the instrument’s error queue. Error retrieval is first-in-first-out (FIFO).

If more than 20 errors have occurred, the most recent error stored in the queue is replaced with -350,”Queue overflow”. No additional errors are stored until you remove errors from the queue. If no errors have occurred when you read the error queue, the instrument responds with +0,”No error”.

Returns:

The error code and the error message.

static exist(name: str, instrument_class: type[Instrument] | None = 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: type[T] | None = None) T | Instrument

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:
  • KeyError – If no instrument of that name was found, or if its reference is invalid (dead).

  • TypeError – If a specific class was requested but a different type was found.

flush_error_queue(verbose: bool = True) None

Clear the instrument error queue, and prints it.

Parameters:

verbose – If true, the error messages are printed. Default: True.

property full_name: str

Full name of the instrument.

For an InstrumentModule this includes all parents separated by _

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_component(full_name: str) MetadatableWithName

Recursively get a component of the instrument by full_name.

Parameters:

full_name – The name of the component to get.

Returns:

The component with the given name.

Raises:

KeyError – If the component does not exist.

get_idn() dict[str, str | None]

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[T]

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.

property label: str

Nicely formatted label of the instrument.

load_metadata(metadata: Mapping[str, Any]) None

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

property name: str

Full name of the instrument

This is equivalent to full_name() for backwards compatibility.

property name_parts: list[str]

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs: ClassVar[list[str]] = []

A list of attribute names (strings) to not delegate to any other dictionary or object.

property parent: InstrumentBase | None

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. If False, 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: InstrumentBase

The topmost parent of this module.

For the root_instrument this is self.

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: str | None) 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.

property short_name: str

Short name of the instrument.

For an InstrumentModule this does not include any parent names.

snapshot(update: bool | None = False) dict[str, 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: bool | None = True, params_to_skip_update: Sequence[str] | None = 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:

dict

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 call super().write(new_cmd). Subclasses that define a new hardware communication should instead override write_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.

visabackend: str = visabackend
visa_handle: pyvisa.resources.MessageBasedResource = visa_handle

The VISA resource used by this instrument.

visalib: str | None = visalib
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, 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 via add_submodule().

log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
metadata: dict[str, Any] = {}
resource_manager = resource_manager

The VISA resource manager used by this instrument.

class qcodes.instrument_drivers.Keysight.Keysight33522B(name: str, address: str, silent: bool = False, **kwargs: Any)[source]

Bases: WaveformGenerator_33XXX

QCoDeS driver for the Keysight 33522B waveform generator.

Parameters:
  • name – The name of the instrument used internally by QCoDeS. Must be unique.

  • address – The VISA resource name.

  • silent – If True, no connect message is printed.

  • **kwargs – kwargs are forwarded to base class.

Methods:

__del__()

Close the instrument and remove its instance record.

__getitem__(key)

Delegate instrument['name'] to parameter or function 'name'.

__getstate__()

Prevent pickling instruments, and give a nice error message.

__repr__()

Simplified repr giving just the class and name.

add_function(name, **kwargs)

Bind one Function to this instrument.

add_parameter(name[, parameter_class])

Bind one Parameter to this instrument.

add_submodule(name, submodule)

Bind one submodule to this instrument.

ask(cmd)

Write a command string to the hardware and return a response.

ask_raw(cmd)

Low-level interface to visa_handle.ask.

call(func_name, *args)

Shortcut for calling a function from its name.

close()

Disconnect and irreversibly tear down the instrument.

close_all()

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.

connect_message([idn_param, begin_time])

Print a standard message on initial connection to an instrument.

device_clear()

Clear the buffers of the device

error()

Return the first error message in the queue.

exist(name[, instrument_class])

Check if an instrument with a given names exists (i.e. is already instantiated).

find_instrument(name[, instrument_class])

Find an existing instrument by name.

flush_error_queue([verbose])

Clear the instrument error queue, and prints it.

get(param_name)

Shortcut for getting a parameter from its name.

get_component(full_name)

Recursively get a component of the instrument by full_name.

get_idn()

Parse a standard VISA *IDN? response into an ID dict.

instances()

Get all currently defined instances of this instrument class.

invalidate_cache()

Invalidate the cache of all parameters on the instrument.

is_valid(instr_instance)

Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a "valid" instrument.

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

print_readable_snapshot([update, max_chars])

Prints a readable version of the snapshot.

record_instance(instance)

Record (a weak ref to) an instance in a class's instance list.

remove_instance(instance)

Remove a particular instance from the record.

set(param_name, value)

Shortcut for setting a parameter from its name and new value.

set_address(address)

Set the address for this instrument.

set_terminator(terminator)

Change the read terminator to use.

snapshot([update])

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class NumpyJSONEncoder supports).

validate_status([verbose])

Validate the values of all gettable parameters

write(cmd)

Write a command string with NO response to the hardware.

write_raw(cmd)

Low-level interface to visa_handle.write.

Attributes:

ancestors

Ancestors in the form of a list of InstrumentBase

delegate_attr_dicts

A list of names (strings) of dictionaries which are (or will be) attributes of self, whose keys should be treated as attributes of self.

delegate_attr_objects

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

full_name

Full name of the instrument.

label

Nicely formatted label of the instrument.

name

Full name of the instrument

name_parts

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs

A list of attribute names (strings) to not delegate to any other dictionary or object.

parent

The parent instrument.

root_instrument

The topmost parent of this module.

short_name

Short name of the instrument.

visa_handle

The VISA resource used by this instrument.

resource_manager

The VISA resource manager used by this instrument.

parameters

All the parameters supported by this instrument.

functions

All the functions supported by this instrument.

submodules

All the submodules of this instrument such as channel lists or logical groupings of parameters.

instrument_modules

All the InstrumentModule of this instrument Usually populated via add_submodule().

__del__() None

Close the instrument and remove its instance record.

__getitem__(key: str) Callable[..., Any] | Parameter

Delegate instrument[‘name’] to parameter or function ‘name’.

__getstate__() None

Prevent pickling instruments, and give a nice error message.

__repr__() str

Simplified repr giving just the class and 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.

Note

We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.

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: type[ParameterBase] | None = 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: 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 a ChannelTuple.

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:
  • KeyError – If this instrument already contains a submodule with this name.

  • TypeError – If the submodule that we are trying to add is not an instance of an Metadatable object.

property ancestors: tuple[InstrumentBase, ...]

Ancestors in the form of a list of InstrumentBase

The list starts with the current module then the parent and the parents parent 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 call super().ask(new_cmd). Subclasses that define a new hardware communication should instead override ask_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:

str

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.

close() None

Disconnect and irreversibly tear down the instrument.

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: float | None = 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_timetime.time() when init started. Default is self._t0, set at start of Instrument.__init__.

delegate_attr_dicts: ClassVar[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 of self.

delegate_attr_objects: ClassVar[list[str]] = []

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

device_clear() None

Clear the buffers of the device

error() tuple[int, str]

Return the first error message in the queue. It also clears it from the error queue.

Up to 20 errors can be stored in the instrument’s error queue. Error retrieval is first-in-first-out (FIFO).

If more than 20 errors have occurred, the most recent error stored in the queue is replaced with -350,”Queue overflow”. No additional errors are stored until you remove errors from the queue. If no errors have occurred when you read the error queue, the instrument responds with +0,”No error”.

Returns:

The error code and the error message.

static exist(name: str, instrument_class: type[Instrument] | None = 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: type[T] | None = None) T | Instrument

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:
  • KeyError – If no instrument of that name was found, or if its reference is invalid (dead).

  • TypeError – If a specific class was requested but a different type was found.

flush_error_queue(verbose: bool = True) None

Clear the instrument error queue, and prints it.

Parameters:

verbose – If true, the error messages are printed. Default: True.

property full_name: str

Full name of the instrument.

For an InstrumentModule this includes all parents separated by _

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_component(full_name: str) MetadatableWithName

Recursively get a component of the instrument by full_name.

Parameters:

full_name – The name of the component to get.

Returns:

The component with the given name.

Raises:

KeyError – If the component does not exist.

get_idn() dict[str, str | None]

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[T]

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.

property label: str

Nicely formatted label of the instrument.

load_metadata(metadata: Mapping[str, Any]) None

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

property name: str

Full name of the instrument

This is equivalent to full_name() for backwards compatibility.

property name_parts: list[str]

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs: ClassVar[list[str]] = []

A list of attribute names (strings) to not delegate to any other dictionary or object.

property parent: InstrumentBase | None

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. If False, 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: InstrumentBase

The topmost parent of this module.

For the root_instrument this is self.

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: str | None) 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.

property short_name: str

Short name of the instrument.

For an InstrumentModule this does not include any parent names.

snapshot(update: bool | None = False) dict[str, 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: bool | None = True, params_to_skip_update: Sequence[str] | None = 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:

dict

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 call super().write(new_cmd). Subclasses that define a new hardware communication should instead override write_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.

visabackend: str = visabackend
visa_handle: pyvisa.resources.MessageBasedResource = visa_handle

The VISA resource used by this instrument.

visalib: str | None = visalib
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, 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 via add_submodule().

log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
metadata: dict[str, Any] = {}
resource_manager = resource_manager

The VISA resource manager used by this instrument.

class qcodes.instrument_drivers.Keysight.Keysight33622A(name: str, address: str, silent: bool = False, **kwargs: Any)[source]

Bases: WaveformGenerator_33XXX

QCoDeS driver for the Keysight 33622A waveform generator.

Parameters:
  • name – The name of the instrument used internally by QCoDeS. Must be unique.

  • address – The VISA resource name.

  • silent – If True, no connect message is printed.

  • **kwargs – kwargs are forwarded to base class.

Methods:

__del__()

Close the instrument and remove its instance record.

__getitem__(key)

Delegate instrument['name'] to parameter or function 'name'.

__getstate__()

Prevent pickling instruments, and give a nice error message.

__repr__()

Simplified repr giving just the class and name.

add_function(name, **kwargs)

Bind one Function to this instrument.

add_parameter(name[, parameter_class])

Bind one Parameter to this instrument.

add_submodule(name, submodule)

Bind one submodule to this instrument.

ask(cmd)

Write a command string to the hardware and return a response.

ask_raw(cmd)

Low-level interface to visa_handle.ask.

call(func_name, *args)

Shortcut for calling a function from its name.

close()

Disconnect and irreversibly tear down the instrument.

close_all()

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.

connect_message([idn_param, begin_time])

Print a standard message on initial connection to an instrument.

device_clear()

Clear the buffers of the device

error()

Return the first error message in the queue.

exist(name[, instrument_class])

Check if an instrument with a given names exists (i.e. is already instantiated).

find_instrument(name[, instrument_class])

Find an existing instrument by name.

flush_error_queue([verbose])

Clear the instrument error queue, and prints it.

get(param_name)

Shortcut for getting a parameter from its name.

get_component(full_name)

Recursively get a component of the instrument by full_name.

get_idn()

Parse a standard VISA *IDN? response into an ID dict.

instances()

Get all currently defined instances of this instrument class.

invalidate_cache()

Invalidate the cache of all parameters on the instrument.

is_valid(instr_instance)

Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a "valid" instrument.

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

print_readable_snapshot([update, max_chars])

Prints a readable version of the snapshot.

record_instance(instance)

Record (a weak ref to) an instance in a class's instance list.

remove_instance(instance)

Remove a particular instance from the record.

set(param_name, value)

Shortcut for setting a parameter from its name and new value.

set_address(address)

Set the address for this instrument.

set_terminator(terminator)

Change the read terminator to use.

snapshot([update])

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class NumpyJSONEncoder supports).

validate_status([verbose])

Validate the values of all gettable parameters

write(cmd)

Write a command string with NO response to the hardware.

write_raw(cmd)

Low-level interface to visa_handle.write.

Attributes:

ancestors

Ancestors in the form of a list of InstrumentBase

delegate_attr_dicts

A list of names (strings) of dictionaries which are (or will be) attributes of self, whose keys should be treated as attributes of self.

delegate_attr_objects

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

full_name

Full name of the instrument.

label

Nicely formatted label of the instrument.

name

Full name of the instrument

name_parts

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs

A list of attribute names (strings) to not delegate to any other dictionary or object.

parent

The parent instrument.

root_instrument

The topmost parent of this module.

short_name

Short name of the instrument.

visa_handle

The VISA resource used by this instrument.

resource_manager

The VISA resource manager used by this instrument.

parameters

All the parameters supported by this instrument.

functions

All the functions supported by this instrument.

submodules

All the submodules of this instrument such as channel lists or logical groupings of parameters.

instrument_modules

All the InstrumentModule of this instrument Usually populated via add_submodule().

__del__() None

Close the instrument and remove its instance record.

__getitem__(key: str) Callable[..., Any] | Parameter

Delegate instrument[‘name’] to parameter or function ‘name’.

__getstate__() None

Prevent pickling instruments, and give a nice error message.

__repr__() str

Simplified repr giving just the class and 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.

Note

We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.

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: type[ParameterBase] | None = 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: 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 a ChannelTuple.

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:
  • KeyError – If this instrument already contains a submodule with this name.

  • TypeError – If the submodule that we are trying to add is not an instance of an Metadatable object.

property ancestors: tuple[InstrumentBase, ...]

Ancestors in the form of a list of InstrumentBase

The list starts with the current module then the parent and the parents parent 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 call super().ask(new_cmd). Subclasses that define a new hardware communication should instead override ask_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:

str

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.

close() None

Disconnect and irreversibly tear down the instrument.

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: float | None = 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_timetime.time() when init started. Default is self._t0, set at start of Instrument.__init__.

delegate_attr_dicts: ClassVar[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 of self.

delegate_attr_objects: ClassVar[list[str]] = []

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

device_clear() None

Clear the buffers of the device

error() tuple[int, str]

Return the first error message in the queue. It also clears it from the error queue.

Up to 20 errors can be stored in the instrument’s error queue. Error retrieval is first-in-first-out (FIFO).

If more than 20 errors have occurred, the most recent error stored in the queue is replaced with -350,”Queue overflow”. No additional errors are stored until you remove errors from the queue. If no errors have occurred when you read the error queue, the instrument responds with +0,”No error”.

Returns:

The error code and the error message.

static exist(name: str, instrument_class: type[Instrument] | None = 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: type[T] | None = None) T | Instrument

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:
  • KeyError – If no instrument of that name was found, or if its reference is invalid (dead).

  • TypeError – If a specific class was requested but a different type was found.

flush_error_queue(verbose: bool = True) None

Clear the instrument error queue, and prints it.

Parameters:

verbose – If true, the error messages are printed. Default: True.

property full_name: str

Full name of the instrument.

For an InstrumentModule this includes all parents separated by _

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_component(full_name: str) MetadatableWithName

Recursively get a component of the instrument by full_name.

Parameters:

full_name – The name of the component to get.

Returns:

The component with the given name.

Raises:

KeyError – If the component does not exist.

get_idn() dict[str, str | None]

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[T]

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.

property label: str

Nicely formatted label of the instrument.

load_metadata(metadata: Mapping[str, Any]) None

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

property name: str

Full name of the instrument

This is equivalent to full_name() for backwards compatibility.

property name_parts: list[str]

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs: ClassVar[list[str]] = []

A list of attribute names (strings) to not delegate to any other dictionary or object.

property parent: InstrumentBase | None

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. If False, 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: InstrumentBase

The topmost parent of this module.

For the root_instrument this is self.

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: str | None) 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.

property short_name: str

Short name of the instrument.

For an InstrumentModule this does not include any parent names.

snapshot(update: bool | None = False) dict[str, 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: bool | None = True, params_to_skip_update: Sequence[str] | None = 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:

dict

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 call super().write(new_cmd). Subclasses that define a new hardware communication should instead override write_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.

visabackend: str = visabackend
visa_handle: pyvisa.resources.MessageBasedResource = visa_handle

The VISA resource used by this instrument.

visalib: str | None = visalib
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, 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 via add_submodule().

log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
metadata: dict[str, Any] = {}
resource_manager = resource_manager

The VISA resource manager used by this instrument.

class qcodes.instrument_drivers.Keysight.Keysight33xxxOutputChannel(parent: Instrument, name: str, channum: int)[source]

Bases: InstrumentChannel

Class to hold the output channel of a Keysight 33xxxx waveform generator.

Parameters:
  • parent – The instrument to which the channel is attached.

  • name – The name of the channel

  • channum – The number of the channel in question (1-2)

Methods:

__getitem__(key)

Delegate instrument['name'] to parameter or function 'name'.

__getstate__()

Prevent pickling instruments, and give a nice error message.

__repr__()

Custom repr to give parent information

add_function(name, **kwargs)

Bind one Function to this instrument.

add_parameter(name[, parameter_class])

Bind one Parameter to this instrument.

add_submodule(name, submodule)

Bind one submodule to this instrument.

ask(cmd)

ask_raw(cmd)

call(func_name, *args)

Shortcut for calling a function from its name.

get(param_name)

Shortcut for getting a parameter from its name.

get_component(full_name)

Recursively get a component of the instrument by full_name.

invalidate_cache()

Invalidate the cache of all parameters on the instrument.

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

print_readable_snapshot([update, max_chars])

Prints a readable version of the snapshot.

set(param_name, value)

Shortcut for setting a parameter from its name and new value.

snapshot([update])

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class NumpyJSONEncoder supports).

validate_status([verbose])

Validate the values of all gettable parameters

write(cmd)

write_raw(cmd)

Attributes:

ancestors

Ancestors in the form of a list of InstrumentBase

delegate_attr_dicts

A list of names (strings) of dictionaries which are (or will be) attributes of self, whose keys should be treated as attributes of self.

delegate_attr_objects

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

full_name

Full name of the instrument.

label

Nicely formatted label of the instrument.

name

Full name of the instrument

name_parts

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs

A list of attribute names (strings) to not delegate to any other dictionary or object.

parent

The parent instrument.

root_instrument

The topmost parent of this module.

short_name

Short name of the instrument.

parameters

All the parameters supported by this instrument.

functions

All the functions supported by this instrument.

submodules

All the submodules of this instrument such as channel lists or logical groupings of parameters.

instrument_modules

All the InstrumentModule of this instrument Usually populated via add_submodule().

__getitem__(key: str) Callable[..., Any] | Parameter

Delegate instrument[‘name’] to parameter or function ‘name’.

__getstate__() None

Prevent pickling instruments, and give a nice error message.

__repr__() str

Custom repr to give parent information

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.

Note

We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.

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: type[ParameterBase] | None = 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: 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 a ChannelTuple.

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:
  • KeyError – If this instrument already contains a submodule with this name.

  • TypeError – If the submodule that we are trying to add is not an instance of an Metadatable object.

property ancestors: tuple[InstrumentBase, ...]

Ancestors in the form of a list of InstrumentBase

The list starts with the current module then the parent and the parents parent until the root instrument is reached.

ask(cmd: str) str
ask_raw(cmd: str) str
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: ClassVar[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 of self.

delegate_attr_objects: ClassVar[list[str]] = []

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

property full_name: str

Full name of the instrument.

For an InstrumentModule this includes all parents separated by _

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_component(full_name: str) MetadatableWithName

Recursively get a component of the instrument by full_name.

Parameters:

full_name – The name of the component to get.

Returns:

The component with the given name.

Raises:

KeyError – If the component does not exist.

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.

property label: str

Nicely formatted label of the instrument.

load_metadata(metadata: Mapping[str, Any]) None

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

property name: str

Full name of the instrument

This is equivalent to full_name() for backwards compatibility.

property name_parts: list[str]

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs: ClassVar[list[str]] = []

A list of attribute names (strings) to not delegate to any other dictionary or object.

property parent: InstrumentBase

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. If False, 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: InstrumentBase

The topmost parent of this module.

For the root_instrument this is self.

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.

property short_name: str

Short name of the instrument.

For an InstrumentModule this does not include any parent names.

snapshot(update: bool | None = False) dict[str, 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: bool | None = False, params_to_skip_update: Sequence[str] | None = 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. If False, 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:

dict

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_raw(cmd: str) None
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, 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 via add_submodule().

log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
metadata: dict[str, Any] = {}
class qcodes.instrument_drivers.Keysight.Keysight33xxxSyncChannel(parent: Instrument, name: str)[source]

Bases: InstrumentChannel

Class to hold the sync output of a Keysight 33xxxx waveform generator. Has very few parameters for single channel instruments.

Methods:

__getitem__(key)

Delegate instrument['name'] to parameter or function 'name'.

__getstate__()

Prevent pickling instruments, and give a nice error message.

__repr__()

Custom repr to give parent information

add_function(name, **kwargs)

Bind one Function to this instrument.

add_parameter(name[, parameter_class])

Bind one Parameter to this instrument.

add_submodule(name, submodule)

Bind one submodule to this instrument.

ask(cmd)

ask_raw(cmd)

call(func_name, *args)

Shortcut for calling a function from its name.

get(param_name)

Shortcut for getting a parameter from its name.

get_component(full_name)

Recursively get a component of the instrument by full_name.

invalidate_cache()

Invalidate the cache of all parameters on the instrument.

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

print_readable_snapshot([update, max_chars])

Prints a readable version of the snapshot.

set(param_name, value)

Shortcut for setting a parameter from its name and new value.

snapshot([update])

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class NumpyJSONEncoder supports).

validate_status([verbose])

Validate the values of all gettable parameters

write(cmd)

write_raw(cmd)

Attributes:

ancestors

Ancestors in the form of a list of InstrumentBase

delegate_attr_dicts

A list of names (strings) of dictionaries which are (or will be) attributes of self, whose keys should be treated as attributes of self.

delegate_attr_objects

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

full_name

Full name of the instrument.

label

Nicely formatted label of the instrument.

name

Full name of the instrument

name_parts

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs

A list of attribute names (strings) to not delegate to any other dictionary or object.

parent

The parent instrument.

root_instrument

The topmost parent of this module.

short_name

Short name of the instrument.

parameters

All the parameters supported by this instrument.

functions

All the functions supported by this instrument.

submodules

All the submodules of this instrument such as channel lists or logical groupings of parameters.

instrument_modules

All the InstrumentModule of this instrument Usually populated via add_submodule().

__getitem__(key: str) Callable[..., Any] | Parameter

Delegate instrument[‘name’] to parameter or function ‘name’.

__getstate__() None

Prevent pickling instruments, and give a nice error message.

__repr__() str

Custom repr to give parent information

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.

Note

We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.

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: type[ParameterBase] | None = 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: 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 a ChannelTuple.

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:
  • KeyError – If this instrument already contains a submodule with this name.

  • TypeError – If the submodule that we are trying to add is not an instance of an Metadatable object.

property ancestors: tuple[InstrumentBase, ...]

Ancestors in the form of a list of InstrumentBase

The list starts with the current module then the parent and the parents parent until the root instrument is reached.

ask(cmd: str) str
ask_raw(cmd: str) str
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: ClassVar[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 of self.

delegate_attr_objects: ClassVar[list[str]] = []

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

property full_name: str

Full name of the instrument.

For an InstrumentModule this includes all parents separated by _

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_component(full_name: str) MetadatableWithName

Recursively get a component of the instrument by full_name.

Parameters:

full_name – The name of the component to get.

Returns:

The component with the given name.

Raises:

KeyError – If the component does not exist.

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.

property label: str

Nicely formatted label of the instrument.

load_metadata(metadata: Mapping[str, Any]) None

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

property name: str

Full name of the instrument

This is equivalent to full_name() for backwards compatibility.

property name_parts: list[str]

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs: ClassVar[list[str]] = []

A list of attribute names (strings) to not delegate to any other dictionary or object.

property parent: InstrumentBase

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. If False, 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: InstrumentBase

The topmost parent of this module.

For the root_instrument this is self.

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.

property short_name: str

Short name of the instrument.

For an InstrumentModule this does not include any parent names.

snapshot(update: bool | None = False) dict[str, 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: bool | None = False, params_to_skip_update: Sequence[str] | None = 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. If False, 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:

dict

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_raw(cmd: str) None
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, 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 via add_submodule().

log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
metadata: dict[str, Any] = {}
class qcodes.instrument_drivers.Keysight.Keysight34410A(name: str, address: str, silent: bool = False, **kwargs: Any)[source]

Bases: _Keysight_344xxA

This is the qcodes driver for the Keysight 34410A Multimeter

Create an instance of the instrument.

Parameters:
  • name – Name used by QCoDeS. Appears in the DataSet

  • address – Visa-resolvable instrument address.

  • silent – If True, the connect_message of the instrument is supressed. Default: False

  • **kwargs – kwargs are forwarded to base class.

Methods:

__del__()

Close the instrument and remove its instance record.

__getitem__(key)

Delegate instrument['name'] to parameter or function 'name'.

__getstate__()

Prevent pickling instruments, and give a nice error message.

__repr__()

Simplified repr giving just the class and name.

abort_measurement()

Abort a measurement in progress, returning the instrument to the trigger idle state.

add_function(name, **kwargs)

Bind one Function to this instrument.

add_parameter(name[, parameter_class])

Bind one Parameter to this instrument.

add_submodule(name, submodule)

Bind one submodule to this instrument.

ask(cmd)

Write a command string to the hardware and return a response.

ask_raw(cmd)

Low-level interface to visa_handle.ask.

autorange_once()

Performs immediate autorange and then turns autoranging off.

call(func_name, *args)

Shortcut for calling a function from its name.

close()

Disconnect and irreversibly tear down the instrument.

close_all()

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.

connect_message([idn_param, begin_time])

Print a standard message on initial connection to an instrument.

decrease_range([range_value, decrease_by])

Decrease the voltage range by a certain amount with default of -1.

device_clear()

Clear the buffers of the device

error()

Return the first error message in the queue.

exist(name[, instrument_class])

Check if an instrument with a given names exists (i.e. is already instantiated).

fetch()

Waits for measurements to complete and copies all available measurements to the instrument's output buffer.

find_instrument(name[, instrument_class])

Find an existing instrument by name.

flush_error_queue([verbose])

Clear the instrument error queue, and prints it.

get(param_name)

Shortcut for getting a parameter from its name.

get_component(full_name)

Recursively get a component of the instrument by full_name.

get_idn()

Parse a standard VISA *IDN? response into an ID dict.

increase_range([range_value, increase_by])

Increases the voltage range by a certain amount with default of 1.

init_measurement()

Change the state of the triggering system from "idle" to "wait-for-trigger", and clear the previous set of measurements from reading memory.

instances()

Get all currently defined instances of this instrument class.

invalidate_cache()

Invalidate the cache of all parameters on the instrument.

is_valid(instr_instance)

Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a "valid" instrument.

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

print_readable_snapshot([update, max_chars])

Prints a readable version of the snapshot.

read()

Starts a new set of measurements, waits for all measurements to complete, and transfers all available measurements.

record_instance(instance)

Record (a weak ref to) an instance in a class's instance list.

remove_instance(instance)

Remove a particular instance from the record.

reset()

Reset the instrument to factory defaults.

set(param_name, value)

Shortcut for setting a parameter from its name and new value.

set_address(address)

Set the address for this instrument.

set_terminator(terminator)

Change the read terminator to use.

snapshot([update])

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class NumpyJSONEncoder supports).

validate_status([verbose])

Validate the values of all gettable parameters

write(cmd)

Write a command string with NO response to the hardware.

write_raw(cmd)

Low-level interface to visa_handle.write.

Attributes:

ancestors

Ancestors in the form of a list of InstrumentBase

delegate_attr_dicts

A list of names (strings) of dictionaries which are (or will be) attributes of self, whose keys should be treated as attributes of self.

delegate_attr_objects

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

full_name

Full name of the instrument.

label

Nicely formatted label of the instrument.

name

Full name of the instrument

name_parts

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs

A list of attribute names (strings) to not delegate to any other dictionary or object.

parent

The parent instrument.

root_instrument

The topmost parent of this module.

short_name

Short name of the instrument.

visa_handle

The VISA resource used by this instrument.

resource_manager

The VISA resource manager used by this instrument.

parameters

All the parameters supported by this instrument.

functions

All the functions supported by this instrument.

submodules

All the submodules of this instrument such as channel lists or logical groupings of parameters.

instrument_modules

All the InstrumentModule of this instrument Usually populated via add_submodule().

__del__() None

Close the instrument and remove its instance record.

__getitem__(key: str) Callable[..., Any] | Parameter

Delegate instrument[‘name’] to parameter or function ‘name’.

__getstate__() None

Prevent pickling instruments, and give a nice error message.

__repr__() str

Simplified repr giving just the class and name.

abort_measurement() None

Abort a measurement in progress, returning the instrument to the trigger idle state.

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.

Note

We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.

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: type[ParameterBase] | None = 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: 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 a ChannelTuple.

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:
  • KeyError – If this instrument already contains a submodule with this name.

  • TypeError – If the submodule that we are trying to add is not an instance of an Metadatable object.

property ancestors: tuple[InstrumentBase, ...]

Ancestors in the form of a list of InstrumentBase

The list starts with the current module then the parent and the parents parent 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 call super().ask(new_cmd). Subclasses that define a new hardware communication should instead override ask_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:

str

autorange_once() None

Performs immediate autorange and then turns autoranging off.

The value of the range parameter is also updated.

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.

close() None

Disconnect and irreversibly tear down the instrument.

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: float | None = 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_timetime.time() when init started. Default is self._t0, set at start of Instrument.__init__.

decrease_range(range_value: float | None = None, decrease_by: int = -1) None

Decrease the voltage range by a certain amount with default of -1. If limit is reached, the min range is used.

Parameters:
  • range_value – The desired voltage range needed. Expressed by power of 10^x range from -3 to 10

  • decrease_by – How much to decrease range by, default behavior is by a step of one.

delegate_attr_dicts: ClassVar[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 of self.

delegate_attr_objects: ClassVar[list[str]] = []

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

device_clear() None

Clear the buffers of the device

error() tuple[int, str]

Return the first error message in the queue. It also clears it from the error queue.

Up to 20 errors can be stored in the instrument’s error queue. Error retrieval is first-in-first-out (FIFO).

If more than 20 errors have occurred, the most recent error stored in the queue is replaced with -350,”Queue overflow”. No additional errors are stored until you remove errors from the queue. If no errors have occurred when you read the error queue, the instrument responds with +0,”No error”.

Returns:

The error code and the error message.

static exist(name: str, instrument_class: type[Instrument] | None = 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.

fetch() ndarray

Waits for measurements to complete and copies all available measurements to the instrument’s output buffer. The readings remain in reading memory.

This query does not erase measurements from the reading memory. You can call this method multiple times to retrieve the same data.

Returns:

a 1D numpy array of all measured values that are currently in the reading memory

classmethod find_instrument(name: str, instrument_class: type[T] | None = None) T | Instrument

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:
  • KeyError – If no instrument of that name was found, or if its reference is invalid (dead).

  • TypeError – If a specific class was requested but a different type was found.

flush_error_queue(verbose: bool = True) None

Clear the instrument error queue, and prints it.

Parameters:

verbose – If true, the error messages are printed. Default: True.

property full_name: str

Full name of the instrument.

For an InstrumentModule this includes all parents separated by _

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_component(full_name: str) MetadatableWithName

Recursively get a component of the instrument by full_name.

Parameters:

full_name – The name of the component to get.

Returns:

The component with the given name.

Raises:

KeyError – If the component does not exist.

get_idn() dict[str, str | None]

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.

increase_range(range_value: float | None = None, increase_by: int = 1) None

Increases the voltage range by a certain amount with default of 1. If limit is reached, the max range is used.

Parameters:
  • range_value – The desired voltage range needed. Expressed by power of 10^x range from -3 to 10

  • increase_by – How much to increase range by, default behavior is by a step of one.

init_measurement() None

Change the state of the triggering system from “idle” to “wait-for-trigger”, and clear the previous set of measurements from reading memory.

This method is an “overlapped” command. This means that after executing it, you can send other commands that do not affect the measurements.

Storing measurements in reading memory with this method is faster than sending measurements to the instrument’s output buffer using read method (“READ?” command) (provided you do not fetch, “FETCh?” command, until done).

classmethod instances() list[T]

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.

property label: str

Nicely formatted label of the instrument.

load_metadata(metadata: Mapping[str, Any]) None

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

property name: str

Full name of the instrument

This is equivalent to full_name() for backwards compatibility.

property name_parts: list[str]

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs: ClassVar[list[str]] = []

A list of attribute names (strings) to not delegate to any other dictionary or object.

property parent: InstrumentBase | None

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. If False, 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.

read() ndarray

Starts a new set of measurements, waits for all measurements to complete, and transfers all available measurements.

This method is similar to calling init_measurement() followed immediately by fetch().

Returns:

a 1D numpy array of all measured values

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

reset() None

Reset the instrument to factory defaults. Also updates the snapshot to reflect the new (default) values of parameters.

property root_instrument: InstrumentBase

The topmost parent of this module.

For the root_instrument this is self.

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: str | None) 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.

property short_name: str

Short name of the instrument.

For an InstrumentModule this does not include any parent names.

snapshot(update: bool | None = False) dict[str, 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: bool | None = True, params_to_skip_update: Sequence[str] | None = 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:

dict

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 call super().write(new_cmd). Subclasses that define a new hardware communication should instead override write_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.

visabackend: str = visabackend
visa_handle: pyvisa.resources.MessageBasedResource = visa_handle

The VISA resource used by this instrument.

visalib: str | None = visalib
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, 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 via add_submodule().

log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
metadata: dict[str, Any] = {}
resource_manager = resource_manager

The VISA resource manager used by this instrument.

class qcodes.instrument_drivers.Keysight.Keysight34411A(name: str, address: str, silent: bool = False, **kwargs: Any)[source]

Bases: _Keysight_344xxA

This is the qcodes driver for the Keysight 34411A Multimeter

Create an instance of the instrument.

Parameters:
  • name – Name used by QCoDeS. Appears in the DataSet

  • address – Visa-resolvable instrument address.

  • silent – If True, the connect_message of the instrument is supressed. Default: False

  • **kwargs – kwargs are forwarded to base class.

Methods:

__del__()

Close the instrument and remove its instance record.

__getitem__(key)

Delegate instrument['name'] to parameter or function 'name'.

__getstate__()

Prevent pickling instruments, and give a nice error message.

__repr__()

Simplified repr giving just the class and name.

abort_measurement()

Abort a measurement in progress, returning the instrument to the trigger idle state.

add_function(name, **kwargs)

Bind one Function to this instrument.

add_parameter(name[, parameter_class])

Bind one Parameter to this instrument.

add_submodule(name, submodule)

Bind one submodule to this instrument.

ask(cmd)

Write a command string to the hardware and return a response.

ask_raw(cmd)

Low-level interface to visa_handle.ask.

autorange_once()

Performs immediate autorange and then turns autoranging off.

call(func_name, *args)

Shortcut for calling a function from its name.

close()

Disconnect and irreversibly tear down the instrument.

close_all()

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.

connect_message([idn_param, begin_time])

Print a standard message on initial connection to an instrument.

decrease_range([range_value, decrease_by])

Decrease the voltage range by a certain amount with default of -1.

device_clear()

Clear the buffers of the device

error()

Return the first error message in the queue.

exist(name[, instrument_class])

Check if an instrument with a given names exists (i.e. is already instantiated).

fetch()

Waits for measurements to complete and copies all available measurements to the instrument's output buffer.

find_instrument(name[, instrument_class])

Find an existing instrument by name.

flush_error_queue([verbose])

Clear the instrument error queue, and prints it.

get(param_name)

Shortcut for getting a parameter from its name.

get_component(full_name)

Recursively get a component of the instrument by full_name.

get_idn()

Parse a standard VISA *IDN? response into an ID dict.

increase_range([range_value, increase_by])

Increases the voltage range by a certain amount with default of 1.

init_measurement()

Change the state of the triggering system from "idle" to "wait-for-trigger", and clear the previous set of measurements from reading memory.

instances()

Get all currently defined instances of this instrument class.

invalidate_cache()

Invalidate the cache of all parameters on the instrument.

is_valid(instr_instance)

Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a "valid" instrument.

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

print_readable_snapshot([update, max_chars])

Prints a readable version of the snapshot.

read()

Starts a new set of measurements, waits for all measurements to complete, and transfers all available measurements.

record_instance(instance)

Record (a weak ref to) an instance in a class's instance list.

remove_instance(instance)

Remove a particular instance from the record.

reset()

Reset the instrument to factory defaults.

set(param_name, value)

Shortcut for setting a parameter from its name and new value.

set_address(address)

Set the address for this instrument.

set_terminator(terminator)

Change the read terminator to use.

snapshot([update])

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class NumpyJSONEncoder supports).

validate_status([verbose])

Validate the values of all gettable parameters

write(cmd)

Write a command string with NO response to the hardware.

write_raw(cmd)

Low-level interface to visa_handle.write.

Attributes:

ancestors

Ancestors in the form of a list of InstrumentBase

delegate_attr_dicts

A list of names (strings) of dictionaries which are (or will be) attributes of self, whose keys should be treated as attributes of self.

delegate_attr_objects

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

full_name

Full name of the instrument.

label

Nicely formatted label of the instrument.

name

Full name of the instrument

name_parts

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs

A list of attribute names (strings) to not delegate to any other dictionary or object.

parent

The parent instrument.

root_instrument

The topmost parent of this module.

short_name

Short name of the instrument.

visa_handle

The VISA resource used by this instrument.

resource_manager

The VISA resource manager used by this instrument.

parameters

All the parameters supported by this instrument.

functions

All the functions supported by this instrument.

submodules

All the submodules of this instrument such as channel lists or logical groupings of parameters.

instrument_modules

All the InstrumentModule of this instrument Usually populated via add_submodule().

__del__() None

Close the instrument and remove its instance record.

__getitem__(key: str) Callable[..., Any] | Parameter

Delegate instrument[‘name’] to parameter or function ‘name’.

__getstate__() None

Prevent pickling instruments, and give a nice error message.

__repr__() str

Simplified repr giving just the class and name.

abort_measurement() None

Abort a measurement in progress, returning the instrument to the trigger idle state.

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.

Note

We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.

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: type[ParameterBase] | None = 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: 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 a ChannelTuple.

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:
  • KeyError – If this instrument already contains a submodule with this name.

  • TypeError – If the submodule that we are trying to add is not an instance of an Metadatable object.

property ancestors: tuple[InstrumentBase, ...]

Ancestors in the form of a list of InstrumentBase

The list starts with the current module then the parent and the parents parent 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 call super().ask(new_cmd). Subclasses that define a new hardware communication should instead override ask_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:

str

autorange_once() None

Performs immediate autorange and then turns autoranging off.

The value of the range parameter is also updated.

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.

close() None

Disconnect and irreversibly tear down the instrument.

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: float | None = 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_timetime.time() when init started. Default is self._t0, set at start of Instrument.__init__.

decrease_range(range_value: float | None = None, decrease_by: int = -1) None

Decrease the voltage range by a certain amount with default of -1. If limit is reached, the min range is used.

Parameters:
  • range_value – The desired voltage range needed. Expressed by power of 10^x range from -3 to 10

  • decrease_by – How much to decrease range by, default behavior is by a step of one.

delegate_attr_dicts: ClassVar[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 of self.

delegate_attr_objects: ClassVar[list[str]] = []

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

device_clear() None

Clear the buffers of the device

error() tuple[int, str]

Return the first error message in the queue. It also clears it from the error queue.

Up to 20 errors can be stored in the instrument’s error queue. Error retrieval is first-in-first-out (FIFO).

If more than 20 errors have occurred, the most recent error stored in the queue is replaced with -350,”Queue overflow”. No additional errors are stored until you remove errors from the queue. If no errors have occurred when you read the error queue, the instrument responds with +0,”No error”.

Returns:

The error code and the error message.

static exist(name: str, instrument_class: type[Instrument] | None = 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.

fetch() ndarray

Waits for measurements to complete and copies all available measurements to the instrument’s output buffer. The readings remain in reading memory.

This query does not erase measurements from the reading memory. You can call this method multiple times to retrieve the same data.

Returns:

a 1D numpy array of all measured values that are currently in the reading memory

classmethod find_instrument(name: str, instrument_class: type[T] | None = None) T | Instrument

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:
  • KeyError – If no instrument of that name was found, or if its reference is invalid (dead).

  • TypeError – If a specific class was requested but a different type was found.

flush_error_queue(verbose: bool = True) None

Clear the instrument error queue, and prints it.

Parameters:

verbose – If true, the error messages are printed. Default: True.

property full_name: str

Full name of the instrument.

For an InstrumentModule this includes all parents separated by _

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_component(full_name: str) MetadatableWithName

Recursively get a component of the instrument by full_name.

Parameters:

full_name – The name of the component to get.

Returns:

The component with the given name.

Raises:

KeyError – If the component does not exist.

get_idn() dict[str, str | None]

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.

increase_range(range_value: float | None = None, increase_by: int = 1) None

Increases the voltage range by a certain amount with default of 1. If limit is reached, the max range is used.

Parameters:
  • range_value – The desired voltage range needed. Expressed by power of 10^x range from -3 to 10

  • increase_by – How much to increase range by, default behavior is by a step of one.

init_measurement() None

Change the state of the triggering system from “idle” to “wait-for-trigger”, and clear the previous set of measurements from reading memory.

This method is an “overlapped” command. This means that after executing it, you can send other commands that do not affect the measurements.

Storing measurements in reading memory with this method is faster than sending measurements to the instrument’s output buffer using read method (“READ?” command) (provided you do not fetch, “FETCh?” command, until done).

classmethod instances() list[T]

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.

property label: str

Nicely formatted label of the instrument.

load_metadata(metadata: Mapping[str, Any]) None

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

property name: str

Full name of the instrument

This is equivalent to full_name() for backwards compatibility.

property name_parts: list[str]

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs: ClassVar[list[str]] = []

A list of attribute names (strings) to not delegate to any other dictionary or object.

property parent: InstrumentBase | None

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. If False, 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.

read() ndarray

Starts a new set of measurements, waits for all measurements to complete, and transfers all available measurements.

This method is similar to calling init_measurement() followed immediately by fetch().

Returns:

a 1D numpy array of all measured values

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

reset() None

Reset the instrument to factory defaults. Also updates the snapshot to reflect the new (default) values of parameters.

property root_instrument: InstrumentBase

The topmost parent of this module.

For the root_instrument this is self.

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: str | None) 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.

property short_name: str

Short name of the instrument.

For an InstrumentModule this does not include any parent names.

snapshot(update: bool | None = False) dict[str, 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: bool | None = True, params_to_skip_update: Sequence[str] | None = 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:

dict

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 call super().write(new_cmd). Subclasses that define a new hardware communication should instead override write_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.

visabackend: str = visabackend
visa_handle: pyvisa.resources.MessageBasedResource = visa_handle

The VISA resource used by this instrument.

visalib: str | None = visalib
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, 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 via add_submodule().

log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
metadata: dict[str, Any] = {}
resource_manager = resource_manager

The VISA resource manager used by this instrument.

class qcodes.instrument_drivers.Keysight.Keysight34460A(name: str, address: str, silent: bool = False, **kwargs: Any)[source]

Bases: _Keysight_344xxA

This is the qcodes driver for the Keysight 34460A Multimeter

Create an instance of the instrument.

Parameters:
  • name – Name used by QCoDeS. Appears in the DataSet

  • address – Visa-resolvable instrument address.

  • silent – If True, the connect_message of the instrument is supressed. Default: False

  • **kwargs – kwargs are forwarded to base class.

Methods:

__del__()

Close the instrument and remove its instance record.

__getitem__(key)

Delegate instrument['name'] to parameter or function 'name'.

__getstate__()

Prevent pickling instruments, and give a nice error message.

__repr__()

Simplified repr giving just the class and name.

abort_measurement()

Abort a measurement in progress, returning the instrument to the trigger idle state.

add_function(name, **kwargs)

Bind one Function to this instrument.

add_parameter(name[, parameter_class])

Bind one Parameter to this instrument.

add_submodule(name, submodule)

Bind one submodule to this instrument.

ask(cmd)

Write a command string to the hardware and return a response.

ask_raw(cmd)

Low-level interface to visa_handle.ask.

autorange_once()

Performs immediate autorange and then turns autoranging off.

call(func_name, *args)

Shortcut for calling a function from its name.

close()

Disconnect and irreversibly tear down the instrument.

close_all()

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.

connect_message([idn_param, begin_time])

Print a standard message on initial connection to an instrument.

decrease_range([range_value, decrease_by])

Decrease the voltage range by a certain amount with default of -1.

device_clear()

Clear the buffers of the device

error()

Return the first error message in the queue.

exist(name[, instrument_class])

Check if an instrument with a given names exists (i.e. is already instantiated).

fetch()

Waits for measurements to complete and copies all available measurements to the instrument's output buffer.

find_instrument(name[, instrument_class])

Find an existing instrument by name.

flush_error_queue([verbose])

Clear the instrument error queue, and prints it.

get(param_name)

Shortcut for getting a parameter from its name.

get_component(full_name)

Recursively get a component of the instrument by full_name.

get_idn()

Parse a standard VISA *IDN? response into an ID dict.

increase_range([range_value, increase_by])

Increases the voltage range by a certain amount with default of 1.

init_measurement()

Change the state of the triggering system from "idle" to "wait-for-trigger", and clear the previous set of measurements from reading memory.

instances()

Get all currently defined instances of this instrument class.

invalidate_cache()

Invalidate the cache of all parameters on the instrument.

is_valid(instr_instance)

Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a "valid" instrument.

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

print_readable_snapshot([update, max_chars])

Prints a readable version of the snapshot.

read()

Starts a new set of measurements, waits for all measurements to complete, and transfers all available measurements.

record_instance(instance)

Record (a weak ref to) an instance in a class's instance list.

remove_instance(instance)

Remove a particular instance from the record.

reset()

Reset the instrument to factory defaults.

set(param_name, value)

Shortcut for setting a parameter from its name and new value.

set_address(address)

Set the address for this instrument.

set_terminator(terminator)

Change the read terminator to use.

snapshot([update])

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class NumpyJSONEncoder supports).

validate_status([verbose])

Validate the values of all gettable parameters

write(cmd)

Write a command string with NO response to the hardware.

write_raw(cmd)

Low-level interface to visa_handle.write.

Attributes:

ancestors

Ancestors in the form of a list of InstrumentBase

delegate_attr_dicts

A list of names (strings) of dictionaries which are (or will be) attributes of self, whose keys should be treated as attributes of self.

delegate_attr_objects

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

full_name

Full name of the instrument.

label

Nicely formatted label of the instrument.

name

Full name of the instrument

name_parts

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs

A list of attribute names (strings) to not delegate to any other dictionary or object.

parent

The parent instrument.

root_instrument

The topmost parent of this module.

short_name

Short name of the instrument.

visa_handle

The VISA resource used by this instrument.

resource_manager

The VISA resource manager used by this instrument.

parameters

All the parameters supported by this instrument.

functions

All the functions supported by this instrument.

submodules

All the submodules of this instrument such as channel lists or logical groupings of parameters.

instrument_modules

All the InstrumentModule of this instrument Usually populated via add_submodule().

__del__() None

Close the instrument and remove its instance record.

__getitem__(key: str) Callable[..., Any] | Parameter

Delegate instrument[‘name’] to parameter or function ‘name’.

__getstate__() None

Prevent pickling instruments, and give a nice error message.

__repr__() str

Simplified repr giving just the class and name.

abort_measurement() None

Abort a measurement in progress, returning the instrument to the trigger idle state.

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.

Note

We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.

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: type[ParameterBase] | None = 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: 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 a ChannelTuple.

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:
  • KeyError – If this instrument already contains a submodule with this name.

  • TypeError – If the submodule that we are trying to add is not an instance of an Metadatable object.

property ancestors: tuple[InstrumentBase, ...]

Ancestors in the form of a list of InstrumentBase

The list starts with the current module then the parent and the parents parent 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 call super().ask(new_cmd). Subclasses that define a new hardware communication should instead override ask_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:

str

autorange_once() None

Performs immediate autorange and then turns autoranging off.

The value of the range parameter is also updated.

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.

close() None

Disconnect and irreversibly tear down the instrument.

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: float | None = 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_timetime.time() when init started. Default is self._t0, set at start of Instrument.__init__.

decrease_range(range_value: float | None = None, decrease_by: int = -1) None

Decrease the voltage range by a certain amount with default of -1. If limit is reached, the min range is used.

Parameters:
  • range_value – The desired voltage range needed. Expressed by power of 10^x range from -3 to 10

  • decrease_by – How much to decrease range by, default behavior is by a step of one.

delegate_attr_dicts: ClassVar[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 of self.

delegate_attr_objects: ClassVar[list[str]] = []

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

device_clear() None

Clear the buffers of the device

error() tuple[int, str]

Return the first error message in the queue. It also clears it from the error queue.

Up to 20 errors can be stored in the instrument’s error queue. Error retrieval is first-in-first-out (FIFO).

If more than 20 errors have occurred, the most recent error stored in the queue is replaced with -350,”Queue overflow”. No additional errors are stored until you remove errors from the queue. If no errors have occurred when you read the error queue, the instrument responds with +0,”No error”.

Returns:

The error code and the error message.

static exist(name: str, instrument_class: type[Instrument] | None = 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.

fetch() ndarray

Waits for measurements to complete and copies all available measurements to the instrument’s output buffer. The readings remain in reading memory.

This query does not erase measurements from the reading memory. You can call this method multiple times to retrieve the same data.

Returns:

a 1D numpy array of all measured values that are currently in the reading memory

classmethod find_instrument(name: str, instrument_class: type[T] | None = None) T | Instrument

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:
  • KeyError – If no instrument of that name was found, or if its reference is invalid (dead).

  • TypeError – If a specific class was requested but a different type was found.

flush_error_queue(verbose: bool = True) None

Clear the instrument error queue, and prints it.

Parameters:

verbose – If true, the error messages are printed. Default: True.

property full_name: str

Full name of the instrument.

For an InstrumentModule this includes all parents separated by _

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_component(full_name: str) MetadatableWithName

Recursively get a component of the instrument by full_name.

Parameters:

full_name – The name of the component to get.

Returns:

The component with the given name.

Raises:

KeyError – If the component does not exist.

get_idn() dict[str, str | None]

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.

increase_range(range_value: float | None = None, increase_by: int = 1) None

Increases the voltage range by a certain amount with default of 1. If limit is reached, the max range is used.

Parameters:
  • range_value – The desired voltage range needed. Expressed by power of 10^x range from -3 to 10

  • increase_by – How much to increase range by, default behavior is by a step of one.

init_measurement() None

Change the state of the triggering system from “idle” to “wait-for-trigger”, and clear the previous set of measurements from reading memory.

This method is an “overlapped” command. This means that after executing it, you can send other commands that do not affect the measurements.

Storing measurements in reading memory with this method is faster than sending measurements to the instrument’s output buffer using read method (“READ?” command) (provided you do not fetch, “FETCh?” command, until done).

classmethod instances() list[T]

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.

property label: str

Nicely formatted label of the instrument.

load_metadata(metadata: Mapping[str, Any]) None

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

property name: str

Full name of the instrument

This is equivalent to full_name() for backwards compatibility.

property name_parts: list[str]

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs: ClassVar[list[str]] = []

A list of attribute names (strings) to not delegate to any other dictionary or object.

property parent: InstrumentBase | None

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. If False, 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.

read() ndarray

Starts a new set of measurements, waits for all measurements to complete, and transfers all available measurements.

This method is similar to calling init_measurement() followed immediately by fetch().

Returns:

a 1D numpy array of all measured values

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

reset() None

Reset the instrument to factory defaults. Also updates the snapshot to reflect the new (default) values of parameters.

property root_instrument: InstrumentBase

The topmost parent of this module.

For the root_instrument this is self.

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: str | None) 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.

property short_name: str

Short name of the instrument.

For an InstrumentModule this does not include any parent names.

snapshot(update: bool | None = False) dict[str, 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: bool | None = True, params_to_skip_update: Sequence[str] | None = 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:

dict

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 call super().write(new_cmd). Subclasses that define a new hardware communication should instead override write_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.

visabackend: str = visabackend
visa_handle: pyvisa.resources.MessageBasedResource = visa_handle

The VISA resource used by this instrument.

visalib: str | None = visalib
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, 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 via add_submodule().

log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
metadata: dict[str, Any] = {}
resource_manager = resource_manager

The VISA resource manager used by this instrument.

class qcodes.instrument_drivers.Keysight.Keysight34461A(name: str, address: str, silent: bool = False, **kwargs: Any)[source]

Bases: _Keysight_344xxA

This is the qcodes driver for the Keysight 34461A Multimeter

Create an instance of the instrument.

Parameters:
  • name – Name used by QCoDeS. Appears in the DataSet

  • address – Visa-resolvable instrument address.

  • silent – If True, the connect_message of the instrument is supressed. Default: False

  • **kwargs – kwargs are forwarded to base class.

Methods:

__del__()

Close the instrument and remove its instance record.

__getitem__(key)

Delegate instrument['name'] to parameter or function 'name'.

__getstate__()

Prevent pickling instruments, and give a nice error message.

__repr__()

Simplified repr giving just the class and name.

abort_measurement()

Abort a measurement in progress, returning the instrument to the trigger idle state.

add_function(name, **kwargs)

Bind one Function to this instrument.

add_parameter(name[, parameter_class])

Bind one Parameter to this instrument.

add_submodule(name, submodule)

Bind one submodule to this instrument.

ask(cmd)

Write a command string to the hardware and return a response.

ask_raw(cmd)

Low-level interface to visa_handle.ask.

autorange_once()

Performs immediate autorange and then turns autoranging off.

call(func_name, *args)

Shortcut for calling a function from its name.

close()

Disconnect and irreversibly tear down the instrument.

close_all()

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.

connect_message([idn_param, begin_time])

Print a standard message on initial connection to an instrument.

decrease_range([range_value, decrease_by])

Decrease the voltage range by a certain amount with default of -1.

device_clear()

Clear the buffers of the device

error()

Return the first error message in the queue.

exist(name[, instrument_class])

Check if an instrument with a given names exists (i.e. is already instantiated).

fetch()

Waits for measurements to complete and copies all available measurements to the instrument's output buffer.

find_instrument(name[, instrument_class])

Find an existing instrument by name.

flush_error_queue([verbose])

Clear the instrument error queue, and prints it.

get(param_name)

Shortcut for getting a parameter from its name.

get_component(full_name)

Recursively get a component of the instrument by full_name.

get_idn()

Parse a standard VISA *IDN? response into an ID dict.

increase_range([range_value, increase_by])

Increases the voltage range by a certain amount with default of 1.

init_measurement()

Change the state of the triggering system from "idle" to "wait-for-trigger", and clear the previous set of measurements from reading memory.

instances()

Get all currently defined instances of this instrument class.

invalidate_cache()

Invalidate the cache of all parameters on the instrument.

is_valid(instr_instance)

Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a "valid" instrument.

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

print_readable_snapshot([update, max_chars])

Prints a readable version of the snapshot.

read()

Starts a new set of measurements, waits for all measurements to complete, and transfers all available measurements.

record_instance(instance)

Record (a weak ref to) an instance in a class's instance list.

remove_instance(instance)

Remove a particular instance from the record.

reset()

Reset the instrument to factory defaults.

set(param_name, value)

Shortcut for setting a parameter from its name and new value.

set_address(address)

Set the address for this instrument.

set_terminator(terminator)

Change the read terminator to use.

snapshot([update])

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class NumpyJSONEncoder supports).

validate_status([verbose])

Validate the values of all gettable parameters

write(cmd)

Write a command string with NO response to the hardware.

write_raw(cmd)

Low-level interface to visa_handle.write.

Attributes:

ancestors

Ancestors in the form of a list of InstrumentBase

delegate_attr_dicts

A list of names (strings) of dictionaries which are (or will be) attributes of self, whose keys should be treated as attributes of self.

delegate_attr_objects

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

full_name

Full name of the instrument.

label

Nicely formatted label of the instrument.

name

Full name of the instrument

name_parts

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs

A list of attribute names (strings) to not delegate to any other dictionary or object.

parent

The parent instrument.

root_instrument

The topmost parent of this module.

short_name

Short name of the instrument.

visa_handle

The VISA resource used by this instrument.

resource_manager

The VISA resource manager used by this instrument.

parameters

All the parameters supported by this instrument.

functions

All the functions supported by this instrument.

submodules

All the submodules of this instrument such as channel lists or logical groupings of parameters.

instrument_modules

All the InstrumentModule of this instrument Usually populated via add_submodule().

__del__() None

Close the instrument and remove its instance record.

__getitem__(key: str) Callable[..., Any] | Parameter

Delegate instrument[‘name’] to parameter or function ‘name’.

__getstate__() None

Prevent pickling instruments, and give a nice error message.

__repr__() str

Simplified repr giving just the class and name.

abort_measurement() None

Abort a measurement in progress, returning the instrument to the trigger idle state.

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.

Note

We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.

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: type[ParameterBase] | None = 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: 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 a ChannelTuple.

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:
  • KeyError – If this instrument already contains a submodule with this name.

  • TypeError – If the submodule that we are trying to add is not an instance of an Metadatable object.

property ancestors: tuple[InstrumentBase, ...]

Ancestors in the form of a list of InstrumentBase

The list starts with the current module then the parent and the parents parent 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 call super().ask(new_cmd). Subclasses that define a new hardware communication should instead override ask_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:

str

autorange_once() None

Performs immediate autorange and then turns autoranging off.

The value of the range parameter is also updated.

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.

close() None

Disconnect and irreversibly tear down the instrument.

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: float | None = 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_timetime.time() when init started. Default is self._t0, set at start of Instrument.__init__.

decrease_range(range_value: float | None = None, decrease_by: int = -1) None

Decrease the voltage range by a certain amount with default of -1. If limit is reached, the min range is used.

Parameters:
  • range_value – The desired voltage range needed. Expressed by power of 10^x range from -3 to 10

  • decrease_by – How much to decrease range by, default behavior is by a step of one.

delegate_attr_dicts: ClassVar[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 of self.

delegate_attr_objects: ClassVar[list[str]] = []

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

device_clear() None

Clear the buffers of the device

error() tuple[int, str]

Return the first error message in the queue. It also clears it from the error queue.

Up to 20 errors can be stored in the instrument’s error queue. Error retrieval is first-in-first-out (FIFO).

If more than 20 errors have occurred, the most recent error stored in the queue is replaced with -350,”Queue overflow”. No additional errors are stored until you remove errors from the queue. If no errors have occurred when you read the error queue, the instrument responds with +0,”No error”.

Returns:

The error code and the error message.

static exist(name: str, instrument_class: type[Instrument] | None = 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.

fetch() ndarray

Waits for measurements to complete and copies all available measurements to the instrument’s output buffer. The readings remain in reading memory.

This query does not erase measurements from the reading memory. You can call this method multiple times to retrieve the same data.

Returns:

a 1D numpy array of all measured values that are currently in the reading memory

classmethod find_instrument(name: str, instrument_class: type[T] | None = None) T | Instrument

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:
  • KeyError – If no instrument of that name was found, or if its reference is invalid (dead).

  • TypeError – If a specific class was requested but a different type was found.

flush_error_queue(verbose: bool = True) None

Clear the instrument error queue, and prints it.

Parameters:

verbose – If true, the error messages are printed. Default: True.

property full_name: str

Full name of the instrument.

For an InstrumentModule this includes all parents separated by _

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_component(full_name: str) MetadatableWithName

Recursively get a component of the instrument by full_name.

Parameters:

full_name – The name of the component to get.

Returns:

The component with the given name.

Raises:

KeyError – If the component does not exist.

get_idn() dict[str, str | None]

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.

increase_range(range_value: float | None = None, increase_by: int = 1) None

Increases the voltage range by a certain amount with default of 1. If limit is reached, the max range is used.

Parameters:
  • range_value – The desired voltage range needed. Expressed by power of 10^x range from -3 to 10

  • increase_by – How much to increase range by, default behavior is by a step of one.

init_measurement() None

Change the state of the triggering system from “idle” to “wait-for-trigger”, and clear the previous set of measurements from reading memory.

This method is an “overlapped” command. This means that after executing it, you can send other commands that do not affect the measurements.

Storing measurements in reading memory with this method is faster than sending measurements to the instrument’s output buffer using read method (“READ?” command) (provided you do not fetch, “FETCh?” command, until done).

classmethod instances() list[T]

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.

property label: str

Nicely formatted label of the instrument.

load_metadata(metadata: Mapping[str, Any]) None

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

property name: str

Full name of the instrument

This is equivalent to full_name() for backwards compatibility.

property name_parts: list[str]

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs: ClassVar[list[str]] = []

A list of attribute names (strings) to not delegate to any other dictionary or object.

property parent: InstrumentBase | None

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. If False, 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.

read() ndarray

Starts a new set of measurements, waits for all measurements to complete, and transfers all available measurements.

This method is similar to calling init_measurement() followed immediately by fetch().

Returns:

a 1D numpy array of all measured values

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

reset() None

Reset the instrument to factory defaults. Also updates the snapshot to reflect the new (default) values of parameters.

property root_instrument: InstrumentBase

The topmost parent of this module.

For the root_instrument this is self.

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: str | None) 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.

property short_name: str

Short name of the instrument.

For an InstrumentModule this does not include any parent names.

snapshot(update: bool | None = False) dict[str, 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: bool | None = True, params_to_skip_update: Sequence[str] | None = 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:

dict

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 call super().write(new_cmd). Subclasses that define a new hardware communication should instead override write_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.

visabackend: str = visabackend
visa_handle: pyvisa.resources.MessageBasedResource = visa_handle

The VISA resource used by this instrument.

visalib: str | None = visalib
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, 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 via add_submodule().

log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
metadata: dict[str, Any] = {}
resource_manager = resource_manager

The VISA resource manager used by this instrument.

class qcodes.instrument_drivers.Keysight.Keysight34465A(name: str, address: str, silent: bool = False, **kwargs: Any)[source]

Bases: _Keysight_344xxA

This is the qcodes driver for the Keysight 34465A Multimeter

Create an instance of the instrument.

Parameters:
  • name – Name used by QCoDeS. Appears in the DataSet

  • address – Visa-resolvable instrument address.

  • silent – If True, the connect_message of the instrument is supressed. Default: False

  • **kwargs – kwargs are forwarded to base class.

Methods:

__del__()

Close the instrument and remove its instance record.

__getitem__(key)

Delegate instrument['name'] to parameter or function 'name'.

__getstate__()

Prevent pickling instruments, and give a nice error message.

__repr__()

Simplified repr giving just the class and name.

abort_measurement()

Abort a measurement in progress, returning the instrument to the trigger idle state.

add_function(name, **kwargs)

Bind one Function to this instrument.

add_parameter(name[, parameter_class])

Bind one Parameter to this instrument.

add_submodule(name, submodule)

Bind one submodule to this instrument.

ask(cmd)

Write a command string to the hardware and return a response.

ask_raw(cmd)

Low-level interface to visa_handle.ask.

autorange_once()

Performs immediate autorange and then turns autoranging off.

call(func_name, *args)

Shortcut for calling a function from its name.

close()

Disconnect and irreversibly tear down the instrument.

close_all()

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.

connect_message([idn_param, begin_time])

Print a standard message on initial connection to an instrument.

decrease_range([range_value, decrease_by])

Decrease the voltage range by a certain amount with default of -1.

device_clear()

Clear the buffers of the device

error()

Return the first error message in the queue.

exist(name[, instrument_class])

Check if an instrument with a given names exists (i.e. is already instantiated).

fetch()

Waits for measurements to complete and copies all available measurements to the instrument's output buffer.

find_instrument(name[, instrument_class])

Find an existing instrument by name.

flush_error_queue([verbose])

Clear the instrument error queue, and prints it.

get(param_name)

Shortcut for getting a parameter from its name.

get_component(full_name)

Recursively get a component of the instrument by full_name.

get_idn()

Parse a standard VISA *IDN? response into an ID dict.

increase_range([range_value, increase_by])

Increases the voltage range by a certain amount with default of 1.

init_measurement()

Change the state of the triggering system from "idle" to "wait-for-trigger", and clear the previous set of measurements from reading memory.

instances()

Get all currently defined instances of this instrument class.

invalidate_cache()

Invalidate the cache of all parameters on the instrument.

is_valid(instr_instance)

Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a "valid" instrument.

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

print_readable_snapshot([update, max_chars])

Prints a readable version of the snapshot.

read()

Starts a new set of measurements, waits for all measurements to complete, and transfers all available measurements.

record_instance(instance)

Record (a weak ref to) an instance in a class's instance list.

remove_instance(instance)

Remove a particular instance from the record.

reset()

Reset the instrument to factory defaults.

set(param_name, value)

Shortcut for setting a parameter from its name and new value.

set_address(address)

Set the address for this instrument.

set_terminator(terminator)

Change the read terminator to use.

snapshot([update])

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class NumpyJSONEncoder supports).

validate_status([verbose])

Validate the values of all gettable parameters

write(cmd)

Write a command string with NO response to the hardware.

write_raw(cmd)

Low-level interface to visa_handle.write.

Attributes:

ancestors

Ancestors in the form of a list of InstrumentBase

delegate_attr_dicts

A list of names (strings) of dictionaries which are (or will be) attributes of self, whose keys should be treated as attributes of self.

delegate_attr_objects

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

full_name

Full name of the instrument.

label

Nicely formatted label of the instrument.

name

Full name of the instrument

name_parts

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs

A list of attribute names (strings) to not delegate to any other dictionary or object.

parent

The parent instrument.

root_instrument

The topmost parent of this module.

short_name

Short name of the instrument.

visa_handle

The VISA resource used by this instrument.

resource_manager

The VISA resource manager used by this instrument.

parameters

All the parameters supported by this instrument.

functions

All the functions supported by this instrument.

submodules

All the submodules of this instrument such as channel lists or logical groupings of parameters.

instrument_modules

All the InstrumentModule of this instrument Usually populated via add_submodule().

__del__() None

Close the instrument and remove its instance record.

__getitem__(key: str) Callable[..., Any] | Parameter

Delegate instrument[‘name’] to parameter or function ‘name’.

__getstate__() None

Prevent pickling instruments, and give a nice error message.

__repr__() str

Simplified repr giving just the class and name.

abort_measurement() None

Abort a measurement in progress, returning the instrument to the trigger idle state.

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.

Note

We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.

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: type[ParameterBase] | None = 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: 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 a ChannelTuple.

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:
  • KeyError – If this instrument already contains a submodule with this name.

  • TypeError – If the submodule that we are trying to add is not an instance of an Metadatable object.

property ancestors: tuple[InstrumentBase, ...]

Ancestors in the form of a list of InstrumentBase

The list starts with the current module then the parent and the parents parent 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 call super().ask(new_cmd). Subclasses that define a new hardware communication should instead override ask_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:

str

autorange_once() None

Performs immediate autorange and then turns autoranging off.

The value of the range parameter is also updated.

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.

close() None

Disconnect and irreversibly tear down the instrument.

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: float | None = 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_timetime.time() when init started. Default is self._t0, set at start of Instrument.__init__.

decrease_range(range_value: float | None = None, decrease_by: int = -1) None

Decrease the voltage range by a certain amount with default of -1. If limit is reached, the min range is used.

Parameters:
  • range_value – The desired voltage range needed. Expressed by power of 10^x range from -3 to 10

  • decrease_by – How much to decrease range by, default behavior is by a step of one.

delegate_attr_dicts: ClassVar[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 of self.

delegate_attr_objects: ClassVar[list[str]] = []

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

device_clear() None

Clear the buffers of the device

error() tuple[int, str]

Return the first error message in the queue. It also clears it from the error queue.

Up to 20 errors can be stored in the instrument’s error queue. Error retrieval is first-in-first-out (FIFO).

If more than 20 errors have occurred, the most recent error stored in the queue is replaced with -350,”Queue overflow”. No additional errors are stored until you remove errors from the queue. If no errors have occurred when you read the error queue, the instrument responds with +0,”No error”.

Returns:

The error code and the error message.

static exist(name: str, instrument_class: type[Instrument] | None = 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.

fetch() ndarray

Waits for measurements to complete and copies all available measurements to the instrument’s output buffer. The readings remain in reading memory.

This query does not erase measurements from the reading memory. You can call this method multiple times to retrieve the same data.

Returns:

a 1D numpy array of all measured values that are currently in the reading memory

classmethod find_instrument(name: str, instrument_class: type[T] | None = None) T | Instrument

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:
  • KeyError – If no instrument of that name was found, or if its reference is invalid (dead).

  • TypeError – If a specific class was requested but a different type was found.

flush_error_queue(verbose: bool = True) None

Clear the instrument error queue, and prints it.

Parameters:

verbose – If true, the error messages are printed. Default: True.

property full_name: str

Full name of the instrument.

For an InstrumentModule this includes all parents separated by _

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_component(full_name: str) MetadatableWithName

Recursively get a component of the instrument by full_name.

Parameters:

full_name – The name of the component to get.

Returns:

The component with the given name.

Raises:

KeyError – If the component does not exist.

get_idn() dict[str, str | None]

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.

increase_range(range_value: float | None = None, increase_by: int = 1) None

Increases the voltage range by a certain amount with default of 1. If limit is reached, the max range is used.

Parameters:
  • range_value – The desired voltage range needed. Expressed by power of 10^x range from -3 to 10

  • increase_by – How much to increase range by, default behavior is by a step of one.

init_measurement() None

Change the state of the triggering system from “idle” to “wait-for-trigger”, and clear the previous set of measurements from reading memory.

This method is an “overlapped” command. This means that after executing it, you can send other commands that do not affect the measurements.

Storing measurements in reading memory with this method is faster than sending measurements to the instrument’s output buffer using read method (“READ?” command) (provided you do not fetch, “FETCh?” command, until done).

classmethod instances() list[T]

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.

property label: str

Nicely formatted label of the instrument.

load_metadata(metadata: Mapping[str, Any]) None

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

property name: str

Full name of the instrument

This is equivalent to full_name() for backwards compatibility.

property name_parts: list[str]

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs: ClassVar[list[str]] = []

A list of attribute names (strings) to not delegate to any other dictionary or object.

property parent: InstrumentBase | None

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. If False, 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.

read() ndarray

Starts a new set of measurements, waits for all measurements to complete, and transfers all available measurements.

This method is similar to calling init_measurement() followed immediately by fetch().

Returns:

a 1D numpy array of all measured values

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

reset() None

Reset the instrument to factory defaults. Also updates the snapshot to reflect the new (default) values of parameters.

property root_instrument: InstrumentBase

The topmost parent of this module.

For the root_instrument this is self.

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: str | None) 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.

property short_name: str

Short name of the instrument.

For an InstrumentModule this does not include any parent names.

snapshot(update: bool | None = False) dict[str, 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: bool | None = True, params_to_skip_update: Sequence[str] | None = 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:

dict

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 call super().write(new_cmd). Subclasses that define a new hardware communication should instead override write_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.

visabackend: str = visabackend
visa_handle: pyvisa.resources.MessageBasedResource = visa_handle

The VISA resource used by this instrument.

visalib: str | None = visalib
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, 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 via add_submodule().

log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
metadata: dict[str, Any] = {}
resource_manager = resource_manager

The VISA resource manager used by this instrument.

class qcodes.instrument_drivers.Keysight.Keysight34470A(name: str, address: str, silent: bool = False, **kwargs: Any)[source]

Bases: _Keysight_344xxA

This is the qcodes driver for the Keysight 34470A Multimeter

Create an instance of the instrument.

Parameters:
  • name – Name used by QCoDeS. Appears in the DataSet

  • address – Visa-resolvable instrument address.

  • silent – If True, the connect_message of the instrument is supressed. Default: False

  • **kwargs – kwargs are forwarded to base class.

Methods:

__del__()

Close the instrument and remove its instance record.

__getitem__(key)

Delegate instrument['name'] to parameter or function 'name'.

__getstate__()

Prevent pickling instruments, and give a nice error message.

__repr__()

Simplified repr giving just the class and name.

abort_measurement()

Abort a measurement in progress, returning the instrument to the trigger idle state.

add_function(name, **kwargs)

Bind one Function to this instrument.

add_parameter(name[, parameter_class])

Bind one Parameter to this instrument.

add_submodule(name, submodule)

Bind one submodule to this instrument.

ask(cmd)

Write a command string to the hardware and return a response.

ask_raw(cmd)

Low-level interface to visa_handle.ask.

autorange_once()

Performs immediate autorange and then turns autoranging off.

call(func_name, *args)

Shortcut for calling a function from its name.

close()

Disconnect and irreversibly tear down the instrument.

close_all()

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.

connect_message([idn_param, begin_time])

Print a standard message on initial connection to an instrument.

decrease_range([range_value, decrease_by])

Decrease the voltage range by a certain amount with default of -1.

device_clear()

Clear the buffers of the device

error()

Return the first error message in the queue.

exist(name[, instrument_class])

Check if an instrument with a given names exists (i.e. is already instantiated).

fetch()

Waits for measurements to complete and copies all available measurements to the instrument's output buffer.

find_instrument(name[, instrument_class])

Find an existing instrument by name.

flush_error_queue([verbose])

Clear the instrument error queue, and prints it.

get(param_name)

Shortcut for getting a parameter from its name.

get_component(full_name)

Recursively get a component of the instrument by full_name.

get_idn()

Parse a standard VISA *IDN? response into an ID dict.

increase_range([range_value, increase_by])

Increases the voltage range by a certain amount with default of 1.

init_measurement()

Change the state of the triggering system from "idle" to "wait-for-trigger", and clear the previous set of measurements from reading memory.

instances()

Get all currently defined instances of this instrument class.

invalidate_cache()

Invalidate the cache of all parameters on the instrument.

is_valid(instr_instance)

Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a "valid" instrument.

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

print_readable_snapshot([update, max_chars])

Prints a readable version of the snapshot.

read()

Starts a new set of measurements, waits for all measurements to complete, and transfers all available measurements.

record_instance(instance)

Record (a weak ref to) an instance in a class's instance list.

remove_instance(instance)

Remove a particular instance from the record.

reset()

Reset the instrument to factory defaults.

set(param_name, value)

Shortcut for setting a parameter from its name and new value.

set_address(address)

Set the address for this instrument.

set_terminator(terminator)

Change the read terminator to use.

snapshot([update])

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class NumpyJSONEncoder supports).

validate_status([verbose])

Validate the values of all gettable parameters

write(cmd)

Write a command string with NO response to the hardware.

write_raw(cmd)

Low-level interface to visa_handle.write.

Attributes:

ancestors

Ancestors in the form of a list of InstrumentBase

delegate_attr_dicts

A list of names (strings) of dictionaries which are (or will be) attributes of self, whose keys should be treated as attributes of self.

delegate_attr_objects

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

full_name

Full name of the instrument.

label

Nicely formatted label of the instrument.

name

Full name of the instrument

name_parts

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs

A list of attribute names (strings) to not delegate to any other dictionary or object.

parent

The parent instrument.

root_instrument

The topmost parent of this module.

short_name

Short name of the instrument.

visa_handle

The VISA resource used by this instrument.

resource_manager

The VISA resource manager used by this instrument.

parameters

All the parameters supported by this instrument.

functions

All the functions supported by this instrument.

submodules

All the submodules of this instrument such as channel lists or logical groupings of parameters.

instrument_modules

All the InstrumentModule of this instrument Usually populated via add_submodule().

__del__() None

Close the instrument and remove its instance record.

__getitem__(key: str) Callable[..., Any] | Parameter

Delegate instrument[‘name’] to parameter or function ‘name’.

__getstate__() None

Prevent pickling instruments, and give a nice error message.

__repr__() str

Simplified repr giving just the class and name.

abort_measurement() None

Abort a measurement in progress, returning the instrument to the trigger idle state.

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.

Note

We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.

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: type[ParameterBase] | None = 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: 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 a ChannelTuple.

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:
  • KeyError – If this instrument already contains a submodule with this name.

  • TypeError – If the submodule that we are trying to add is not an instance of an Metadatable object.

property ancestors: tuple[InstrumentBase, ...]

Ancestors in the form of a list of InstrumentBase

The list starts with the current module then the parent and the parents parent 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 call super().ask(new_cmd). Subclasses that define a new hardware communication should instead override ask_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:

str

autorange_once() None

Performs immediate autorange and then turns autoranging off.

The value of the range parameter is also updated.

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.

close() None

Disconnect and irreversibly tear down the instrument.

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: float | None = 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_timetime.time() when init started. Default is self._t0, set at start of Instrument.__init__.

decrease_range(range_value: float | None = None, decrease_by: int = -1) None

Decrease the voltage range by a certain amount with default of -1. If limit is reached, the min range is used.

Parameters:
  • range_value – The desired voltage range needed. Expressed by power of 10^x range from -3 to 10

  • decrease_by – How much to decrease range by, default behavior is by a step of one.

delegate_attr_dicts: ClassVar[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 of self.

delegate_attr_objects: ClassVar[list[str]] = []

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

device_clear() None

Clear the buffers of the device

error() tuple[int, str]

Return the first error message in the queue. It also clears it from the error queue.

Up to 20 errors can be stored in the instrument’s error queue. Error retrieval is first-in-first-out (FIFO).

If more than 20 errors have occurred, the most recent error stored in the queue is replaced with -350,”Queue overflow”. No additional errors are stored until you remove errors from the queue. If no errors have occurred when you read the error queue, the instrument responds with +0,”No error”.

Returns:

The error code and the error message.

static exist(name: str, instrument_class: type[Instrument] | None = 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.

fetch() ndarray

Waits for measurements to complete and copies all available measurements to the instrument’s output buffer. The readings remain in reading memory.

This query does not erase measurements from the reading memory. You can call this method multiple times to retrieve the same data.

Returns:

a 1D numpy array of all measured values that are currently in the reading memory

classmethod find_instrument(name: str, instrument_class: type[T] | None = None) T | Instrument

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:
  • KeyError – If no instrument of that name was found, or if its reference is invalid (dead).

  • TypeError – If a specific class was requested but a different type was found.

flush_error_queue(verbose: bool = True) None

Clear the instrument error queue, and prints it.

Parameters:

verbose – If true, the error messages are printed. Default: True.

property full_name: str

Full name of the instrument.

For an InstrumentModule this includes all parents separated by _

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_component(full_name: str) MetadatableWithName

Recursively get a component of the instrument by full_name.

Parameters:

full_name – The name of the component to get.

Returns:

The component with the given name.

Raises:

KeyError – If the component does not exist.

get_idn() dict[str, str | None]

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.

increase_range(range_value: float | None = None, increase_by: int = 1) None

Increases the voltage range by a certain amount with default of 1. If limit is reached, the max range is used.

Parameters:
  • range_value – The desired voltage range needed. Expressed by power of 10^x range from -3 to 10

  • increase_by – How much to increase range by, default behavior is by a step of one.

init_measurement() None

Change the state of the triggering system from “idle” to “wait-for-trigger”, and clear the previous set of measurements from reading memory.

This method is an “overlapped” command. This means that after executing it, you can send other commands that do not affect the measurements.

Storing measurements in reading memory with this method is faster than sending measurements to the instrument’s output buffer using read method (“READ?” command) (provided you do not fetch, “FETCh?” command, until done).

classmethod instances() list[T]

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.

property label: str

Nicely formatted label of the instrument.

load_metadata(metadata: Mapping[str, Any]) None

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

property name: str

Full name of the instrument

This is equivalent to full_name() for backwards compatibility.

property name_parts: list[str]

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs: ClassVar[list[str]] = []

A list of attribute names (strings) to not delegate to any other dictionary or object.

property parent: InstrumentBase | None

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. If False, 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.

read() ndarray

Starts a new set of measurements, waits for all measurements to complete, and transfers all available measurements.

This method is similar to calling init_measurement() followed immediately by fetch().

Returns:

a 1D numpy array of all measured values

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

reset() None

Reset the instrument to factory defaults. Also updates the snapshot to reflect the new (default) values of parameters.

property root_instrument: InstrumentBase

The topmost parent of this module.

For the root_instrument this is self.

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: str | None) 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.

property short_name: str

Short name of the instrument.

For an InstrumentModule this does not include any parent names.

snapshot(update: bool | None = False) dict[str, 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: bool | None = True, params_to_skip_update: Sequence[str] | None = 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:

dict

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 call super().write(new_cmd). Subclasses that define a new hardware communication should instead override write_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.

visabackend: str = visabackend
visa_handle: pyvisa.resources.MessageBasedResource = visa_handle

The VISA resource used by this instrument.

visalib: str | None = visalib
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, 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 via add_submodule().

log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
metadata: dict[str, Any] = {}
resource_manager = resource_manager

The VISA resource manager used by this instrument.

class qcodes.instrument_drivers.Keysight.Keysight34934A(parent: VisaInstrument | InstrumentChannel, name: str, slot: int)[source]

Bases: Keysight34980ASwitchMatrixSubModule

Create an instance for module 34933A.

Parameters:
  • parent – the system which the module is installed on

  • name – user defined name for the module

  • slot – the slot the module is installed

Methods:

write(cmd)

When the module is safety interlocked, users can not make any connections.

validate_value(row, column)

to check if the row and column number is within the range of the module layout.

to_channel_list(paths[, wiring_config])

convert the (row, column) pair to a 4-digit channel number 'sxxx', where s is the slot number, xxx is generated from the numbering function.

get_numbering_function(rows, columns[, ...])

to select the correct numbering function based on the matrix layout.

__getitem__(key)

Delegate instrument['name'] to parameter or function 'name'.

__getstate__()

Prevent pickling instruments, and give a nice error message.

__repr__()

Custom repr to give parent information

add_function(name, **kwargs)

Bind one Function to this instrument.

add_parameter(name[, parameter_class])

Bind one Parameter to this instrument.

add_submodule(name, submodule)

Bind one submodule to this instrument.

are_closed(paths)

to check if a list of channels is closed/connected

are_open(paths)

to check if a list of channels is open/disconnected

ask(cmd)

ask_raw(cmd)

call(func_name, *args)

Shortcut for calling a function from its name.

connect(row, column)

to connect/close the specified channels

connect_paths(paths)

to connect/close the specified channels.

disconnect(row, column)

to disconnect/open the specified channels

disconnect_paths(paths)

to disconnect/open the specified channels.

get(param_name)

Shortcut for getting a parameter from its name.

get_component(full_name)

Recursively get a component of the instrument by full_name.

invalidate_cache()

Invalidate the cache of all parameters on the instrument.

is_closed(row, column)

to check if a channel is closed/connected

is_open(row, column)

to check if a channel is open/disconnected

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

print_readable_snapshot([update, max_chars])

Prints a readable version of the snapshot.

set(param_name, value)

Shortcut for setting a parameter from its name and new value.

snapshot([update])

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class NumpyJSONEncoder supports).

validate_status([verbose])

Validate the values of all gettable parameters

write_raw(cmd)

Attributes:

ancestors

Ancestors in the form of a list of InstrumentBase

delegate_attr_dicts

A list of names (strings) of dictionaries which are (or will be) attributes of self, whose keys should be treated as attributes of self.

delegate_attr_objects

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

full_name

Full name of the instrument.

label

Nicely formatted label of the instrument.

name

Full name of the instrument

name_parts

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs

A list of attribute names (strings) to not delegate to any other dictionary or object.

parent

The parent instrument.

root_instrument

The topmost parent of this module.

short_name

Short name of the instrument.

parameters

All the parameters supported by this instrument.

functions

All the functions supported by this instrument.

submodules

All the submodules of this instrument such as channel lists or logical groupings of parameters.

instrument_modules

All the InstrumentModule of this instrument Usually populated via add_submodule().

write(cmd: str) None[source]

When the module is safety interlocked, users can not make any connections. There will be no effect when try to connect any channels.

validate_value(row: int, column: int) None[source]

to check if the row and column number is within the range of the module layout.

Parameters:
  • row – row value

  • column – column value

to_channel_list(paths: list[tuple[int, int]], wiring_config: str | None = '') str[source]

convert the (row, column) pair to a 4-digit channel number ‘sxxx’, where s is the slot number, xxx is generated from the numbering function.

Parameters:
  • paths – list of channels to connect [(r1, c1), (r2, c2), (r3, c3)]

  • wiring_config – for 1-wire matrices, values are ‘MH’, ‘ML’; for 2-wire matrices, values are ‘M1H’, ‘M2H’, ‘M1L’, ‘M2L’

Returns:

in the format of ‘(@sxxx, sxxx, sxxx, sxxx)’, where sxxx is a 4-digit channel number

static get_numbering_function(rows: int, columns: int, wiring_config: str | None = '') Callable[[int, int], str][source]

to select the correct numbering function based on the matrix layout. On P168 of the user’s guide for Agilent 34934A High Density Matrix Module: http://literature.cdn.keysight.com/litweb/pdf/34980-90034.pdf there are eleven equations. This function here simplifies them to one.

Parameters:
  • rows – the total row number of the matrix module

  • columns – the total column number of the matrix module

  • wiring_config – wiring configuration for 1 or 2 wired matrices

Returns:

The numbering function to convert row and column in to a 3-digit number

__getitem__(key: str) Callable[..., Any] | Parameter

Delegate instrument[‘name’] to parameter or function ‘name’.

__getstate__() None

Prevent pickling instruments, and give a nice error message.

__repr__() str

Custom repr to give parent information

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.

Note

We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.

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: type[ParameterBase] | None = 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: 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 a ChannelTuple.

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:
  • KeyError – If this instrument already contains a submodule with this name.

  • TypeError – If the submodule that we are trying to add is not an instance of an Metadatable object.

property ancestors: tuple[InstrumentBase, ...]

Ancestors in the form of a list of InstrumentBase

The list starts with the current module then the parent and the parents parent until the root instrument is reached.

are_closed(paths: list[tuple[int, int]]) list[bool]

to check if a list of channels is closed/connected

Parameters:

paths – list of channels [(r1, c1), (r2, c2), (r3, c3)]

Returns:

a list of True and/or False True if the channel is closed/connected False if it’s open/disconnected.

are_open(paths: list[tuple[int, int]]) list[bool]

to check if a list of channels is open/disconnected

Parameters:

paths – list of channels [(r1, c1), (r2, c2), (r3, c3)]

Returns:

a list of True and/or False True if the channel is closed/connected False if it’s open/disconnected.

ask(cmd: str) str
ask_raw(cmd: str) str
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.

connect(row: int, column: int) None

to connect/close the specified channels

Parameters:
  • row – row number

  • column – column number

connect_paths(paths: list[tuple[int, int]]) None

to connect/close the specified channels.

Parameters:

paths – list of channels to connect [(r1, c1), (r2, c2), (r3, c3)]

delegate_attr_dicts: ClassVar[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 of self.

delegate_attr_objects: ClassVar[list[str]] = []

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

disconnect(row: int, column: int) None

to disconnect/open the specified channels

Parameters:
  • row – row number

  • column – column number

disconnect_paths(paths: list[tuple[int, int]]) None

to disconnect/open the specified channels.

Parameters:

paths – list of channels to connect [(r1, c1), (r2, c2), (r3, c3)]

property full_name: str

Full name of the instrument.

For an InstrumentModule this includes all parents separated by _

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_component(full_name: str) MetadatableWithName

Recursively get a component of the instrument by full_name.

Parameters:

full_name – The name of the component to get.

Returns:

The component with the given name.

Raises:

KeyError – If the component does not exist.

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.

is_closed(row: int, column: int) bool

to check if a channel is closed/connected

Parameters:
  • row – row number

  • column – column number

Returns:

True if the channel is closed/connected False if it’s open/disconnected.

is_open(row: int, column: int) bool

to check if a channel is open/disconnected

Parameters:
  • row – row number

  • column – column number

Returns:

True if the channel is open/disconnected False if it’s closed/connected.

property label: str

Nicely formatted label of the instrument.

load_metadata(metadata: Mapping[str, Any]) None

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

property name: str

Full name of the instrument

This is equivalent to full_name() for backwards compatibility.

property name_parts: list[str]

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs: ClassVar[list[str]] = []

A list of attribute names (strings) to not delegate to any other dictionary or object.

property parent: InstrumentBase

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. If False, 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: InstrumentBase

The topmost parent of this module.

For the root_instrument this is self.

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.

property short_name: str

Short name of the instrument.

For an InstrumentModule this does not include any parent names.

snapshot(update: bool | None = False) dict[str, 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: bool | None = False, params_to_skip_update: Sequence[str] | None = 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. If False, 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:

dict

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_raw(cmd: str) None
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, 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 via add_submodule().

log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
metadata: dict[str, Any] = {}
class qcodes.instrument_drivers.Keysight.Keysight34980A(name: str, address: str, terminator: str = '\n', **kwargs: Any)[source]

Bases: VisaInstrument

QCodes driver for 34980A switch/measure unit

Create an instance of the instrument.

Parameters:
  • name – Name of the instrument instance

  • address – Visa-resolvable instrument address.

  • terminator – Character to terminate messages with.

  • **kwargs – kwargs are forwarded to base class.

Methods:

get_status()

Queries status register

get_error()

Queries error queue

clear_status()

Clears status register and error queue of the instrument.

reset()

Performs an instrument reset.

ask(cmd)

Write a command string to the hardware and return a response.

write(cmd)

Write a command string with NO response to the hardware.

scan_slots()

Scan the occupied slots and make an object for each switch matrix module installed

disconnect_all([slot])

to open/disconnect all connections on select module

__del__()

Close the instrument and remove its instance record.

__getitem__(key)

Delegate instrument['name'] to parameter or function 'name'.

__getstate__()

Prevent pickling instruments, and give a nice error message.

__repr__()

Simplified repr giving just the class and name.

add_function(name, **kwargs)

Bind one Function to this instrument.

add_parameter(name[, parameter_class])

Bind one Parameter to this instrument.

add_submodule(name, submodule)

Bind one submodule to this instrument.

ask_raw(cmd)

Low-level interface to visa_handle.ask.

call(func_name, *args)

Shortcut for calling a function from its name.

close()

Disconnect and irreversibly tear down the instrument.

close_all()

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.

connect_message([idn_param, begin_time])

Print a standard message on initial connection to an instrument.

device_clear()

Clear the buffers of the device

exist(name[, instrument_class])

Check if an instrument with a given names exists (i.e. is already instantiated).

find_instrument(name[, instrument_class])

Find an existing instrument by name.

get(param_name)

Shortcut for getting a parameter from its name.

get_component(full_name)

Recursively get a component of the instrument by full_name.

get_idn()

Parse a standard VISA *IDN? response into an ID dict.

instances()

Get all currently defined instances of this instrument class.

invalidate_cache()

Invalidate the cache of all parameters on the instrument.

is_valid(instr_instance)

Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a "valid" instrument.

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

print_readable_snapshot([update, max_chars])

Prints a readable version of the snapshot.

record_instance(instance)

Record (a weak ref to) an instance in a class's instance list.

remove_instance(instance)

Remove a particular instance from the record.

set(param_name, value)

Shortcut for setting a parameter from its name and new value.

set_address(address)

Set the address for this instrument.

set_terminator(terminator)

Change the read terminator to use.

snapshot([update])

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class NumpyJSONEncoder supports).

validate_status([verbose])

Validate the values of all gettable parameters

write_raw(cmd)

Low-level interface to visa_handle.write.

Attributes:

system_slots_info

ancestors

Ancestors in the form of a list of InstrumentBase

delegate_attr_dicts

A list of names (strings) of dictionaries which are (or will be) attributes of self, whose keys should be treated as attributes of self.

delegate_attr_objects

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

full_name

Full name of the instrument.

label

Nicely formatted label of the instrument.

name

Full name of the instrument

name_parts

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs

A list of attribute names (strings) to not delegate to any other dictionary or object.

parent

The parent instrument.

root_instrument

The topmost parent of this module.

short_name

Short name of the instrument.

visa_handle

The VISA resource used by this instrument.

resource_manager

The VISA resource manager used by this instrument.

parameters

All the parameters supported by this instrument.

functions

All the functions supported by this instrument.

submodules

All the submodules of this instrument such as channel lists or logical groupings of parameters.

instrument_modules

All the InstrumentModule of this instrument Usually populated via add_submodule().

get_status() int[source]

Queries status register

Returns:

0 if there is no error

get_error() str[source]

Queries error queue

Returns:

error message, or ‘+0,”No error”’ if there is no error

clear_status() None[source]

Clears status register and error queue of the instrument.

reset() None[source]

Performs an instrument reset. Does not reset error queue!

ask(cmd: str) str[source]

Write a command string to the hardware and return a response.

Subclasses that transform cmd should override this method, and in it call super().ask(new_cmd). Subclasses that define a new hardware communication should instead override ask_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.

write(cmd: str) None[source]

Write a command string with NO response to the hardware.

Subclasses that transform cmd should override this method, and in it call super().write(new_cmd). Subclasses that define a new hardware communication should instead override write_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.

scan_slots() None[source]

Scan the occupied slots and make an object for each switch matrix module installed

property system_slots_info: dict[int, dict[str, str]]
disconnect_all(slot: int | None = None) None[source]

to open/disconnect all connections on select module

Parameters:

slot – slot number, between 1 and 8 (self._total_slot), default value is None, which means all slots

__del__() None

Close the instrument and remove its instance record.

__getitem__(key: str) Callable[..., Any] | Parameter

Delegate instrument[‘name’] to parameter or function ‘name’.

__getstate__() None

Prevent pickling instruments, and give a nice error message.

__repr__() str

Simplified repr giving just the class and 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.

Note

We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.

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: type[ParameterBase] | None = 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: 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 a ChannelTuple.

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:
  • KeyError – If this instrument already contains a submodule with this name.

  • TypeError – If the submodule that we are trying to add is not an instance of an Metadatable object.

property ancestors: tuple[InstrumentBase, ...]

Ancestors in the form of a list of InstrumentBase

The list starts with the current module then the parent and the parents parent until the root instrument is reached.

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:

str

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.

close() None

Disconnect and irreversibly tear down the instrument.

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: float | None = 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_timetime.time() when init started. Default is self._t0, set at start of Instrument.__init__.

delegate_attr_dicts: ClassVar[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 of self.

delegate_attr_objects: ClassVar[list[str]] = []

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

device_clear() None

Clear the buffers of the device

static exist(name: str, instrument_class: type[Instrument] | None = 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: type[T] | None = None) T | Instrument

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:
  • KeyError – If no instrument of that name was found, or if its reference is invalid (dead).

  • TypeError – If a specific class was requested but a different type was found.

property full_name: str

Full name of the instrument.

For an InstrumentModule this includes all parents separated by _

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_component(full_name: str) MetadatableWithName

Recursively get a component of the instrument by full_name.

Parameters:

full_name – The name of the component to get.

Returns:

The component with the given name.

Raises:

KeyError – If the component does not exist.

get_idn() dict[str, str | None]

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[T]

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.

property label: str

Nicely formatted label of the instrument.

load_metadata(metadata: Mapping[str, Any]) None

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

property name: str

Full name of the instrument

This is equivalent to full_name() for backwards compatibility.

property name_parts: list[str]

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs: ClassVar[list[str]] = []

A list of attribute names (strings) to not delegate to any other dictionary or object.

property parent: InstrumentBase | None

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. If False, 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: InstrumentBase

The topmost parent of this module.

For the root_instrument this is self.

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: str | None) 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.

property short_name: str

Short name of the instrument.

For an InstrumentModule this does not include any parent names.

snapshot(update: bool | None = False) dict[str, 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: bool | None = True, params_to_skip_update: Sequence[str] | None = 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:

dict

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_raw(cmd: str) None

Low-level interface to visa_handle.write.

Parameters:

cmd – The command to send to the instrument.

visabackend: str = visabackend
visa_handle: pyvisa.resources.MessageBasedResource = visa_handle

The VISA resource used by this instrument.

visalib: str | None = visalib
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, 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 via add_submodule().

log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
metadata: dict[str, Any] = {}
resource_manager = resource_manager

The VISA resource manager used by this instrument.

class qcodes.instrument_drivers.Keysight.Keysight34980ASwitchMatrixSubModule(parent: VisaInstrument | InstrumentChannel, name: str, slot: int)[source]

Bases: KeysightSubModule

A base class for Switch Matrix submodules for the 34980A systems.

Methods:

validate_value(row, column)

to check if the row and column number is within the range of the module layout.

to_channel_list(paths[, wiring_config])

convert the (row, column) pair to a 4-digit channel number 'sxxx', where s is the slot number, xxx is generated from the numbering function.

is_open(row, column)

to check if a channel is open/disconnected

is_closed(row, column)

to check if a channel is closed/connected

connect(row, column)

to connect/close the specified channels

disconnect(row, column)

to disconnect/open the specified channels

connect_paths(paths)

to connect/close the specified channels.

disconnect_paths(paths)

to disconnect/open the specified channels.

are_closed(paths)

to check if a list of channels is closed/connected

are_open(paths)

to check if a list of channels is open/disconnected

__getitem__(key)

Delegate instrument['name'] to parameter or function 'name'.

__getstate__()

Prevent pickling instruments, and give a nice error message.

__repr__()

Custom repr to give parent information

add_function(name, **kwargs)

Bind one Function to this instrument.

add_parameter(name[, parameter_class])

Bind one Parameter to this instrument.

add_submodule(name, submodule)

Bind one submodule to this instrument.

ask(cmd)

ask_raw(cmd)

call(func_name, *args)

Shortcut for calling a function from its name.

get(param_name)

Shortcut for getting a parameter from its name.

get_component(full_name)

Recursively get a component of the instrument by full_name.

invalidate_cache()

Invalidate the cache of all parameters on the instrument.

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

print_readable_snapshot([update, max_chars])

Prints a readable version of the snapshot.

set(param_name, value)

Shortcut for setting a parameter from its name and new value.

snapshot([update])

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class NumpyJSONEncoder supports).

validate_status([verbose])

Validate the values of all gettable parameters

write(cmd)

write_raw(cmd)

Attributes:

ancestors

Ancestors in the form of a list of InstrumentBase

delegate_attr_dicts

A list of names (strings) of dictionaries which are (or will be) attributes of self, whose keys should be treated as attributes of self.

delegate_attr_objects

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

full_name

Full name of the instrument.

label

Nicely formatted label of the instrument.

name

Full name of the instrument

name_parts

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs

A list of attribute names (strings) to not delegate to any other dictionary or object.

parent

The parent instrument.

root_instrument

The topmost parent of this module.

short_name

Short name of the instrument.

parameters

All the parameters supported by this instrument.

functions

All the functions supported by this instrument.

submodules

All the submodules of this instrument such as channel lists or logical groupings of parameters.

instrument_modules

All the InstrumentModule of this instrument Usually populated via add_submodule().

validate_value(row: int, column: int) None[source]

to check if the row and column number is within the range of the module layout.

Parameters:
  • row – row value

  • column – column value

to_channel_list(paths: list[tuple[int, int]], wiring_config: str | None = None) str[source]

convert the (row, column) pair to a 4-digit channel number ‘sxxx’, where s is the slot number, xxx is generated from the numbering function. This may be different for different modules.

Parameters:
  • paths – list of channels to connect [(r1, c1), (r2, c2), (r3, c3)]

  • wiring_config – for 1-wire matrices, values are ‘MH’, ‘ML’; for 2-wire matrices, values are ‘M1H’, ‘M2H’, ‘M1L’, ‘M2L’

Returns:

in the format of ‘(@sxxx, sxxx, sxxx, sxxx)’, where sxxx is a 4-digit channel number

is_open(row: int, column: int) bool[source]

to check if a channel is open/disconnected

Parameters:
  • row – row number

  • column – column number

Returns:

True if the channel is open/disconnected False if it’s closed/connected.

is_closed(row: int, column: int) bool[source]

to check if a channel is closed/connected

Parameters:
  • row – row number

  • column – column number

Returns:

True if the channel is closed/connected False if it’s open/disconnected.

connect(row: int, column: int) None[source]

to connect/close the specified channels

Parameters:
  • row – row number

  • column – column number

disconnect(row: int, column: int) None[source]

to disconnect/open the specified channels

Parameters:
  • row – row number

  • column – column number

connect_paths(paths: list[tuple[int, int]]) None[source]

to connect/close the specified channels.

Parameters:

paths – list of channels to connect [(r1, c1), (r2, c2), (r3, c3)]

disconnect_paths(paths: list[tuple[int, int]]) None[source]

to disconnect/open the specified channels.

Parameters:

paths – list of channels to connect [(r1, c1), (r2, c2), (r3, c3)]

are_closed(paths: list[tuple[int, int]]) list[bool][source]

to check if a list of channels is closed/connected

Parameters:

paths – list of channels [(r1, c1), (r2, c2), (r3, c3)]

Returns:

a list of True and/or False True if the channel is closed/connected False if it’s open/disconnected.

are_open(paths: list[tuple[int, int]]) list[bool][source]

to check if a list of channels is open/disconnected

Parameters:

paths – list of channels [(r1, c1), (r2, c2), (r3, c3)]

Returns:

a list of True and/or False True if the channel is closed/connected False if it’s open/disconnected.

__getitem__(key: str) Callable[..., Any] | Parameter

Delegate instrument[‘name’] to parameter or function ‘name’.

__getstate__() None

Prevent pickling instruments, and give a nice error message.

__repr__() str

Custom repr to give parent information

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.

Note

We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.

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: type[ParameterBase] | None = 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: 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 a ChannelTuple.

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:
  • KeyError – If this instrument already contains a submodule with this name.

  • TypeError – If the submodule that we are trying to add is not an instance of an Metadatable object.

property ancestors: tuple[InstrumentBase, ...]

Ancestors in the form of a list of InstrumentBase

The list starts with the current module then the parent and the parents parent until the root instrument is reached.

ask(cmd: str) str
ask_raw(cmd: str) str
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: ClassVar[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 of self.

delegate_attr_objects: ClassVar[list[str]] = []

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

property full_name: str

Full name of the instrument.

For an InstrumentModule this includes all parents separated by _

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_component(full_name: str) MetadatableWithName

Recursively get a component of the instrument by full_name.

Parameters:

full_name – The name of the component to get.

Returns:

The component with the given name.

Raises:

KeyError – If the component does not exist.

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.

property label: str

Nicely formatted label of the instrument.

load_metadata(metadata: Mapping[str, Any]) None

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

property name: str

Full name of the instrument

This is equivalent to full_name() for backwards compatibility.

property name_parts: list[str]

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs: ClassVar[list[str]] = []

A list of attribute names (strings) to not delegate to any other dictionary or object.

property parent: InstrumentBase

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. If False, 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: InstrumentBase

The topmost parent of this module.

For the root_instrument this is self.

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.

property short_name: str

Short name of the instrument.

For an InstrumentModule this does not include any parent names.

snapshot(update: bool | None = False) dict[str, 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: bool | None = False, params_to_skip_update: Sequence[str] | None = 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. If False, 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:

dict

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_raw(cmd: str) None
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, 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 via add_submodule().

log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
metadata: dict[str, Any] = {}
class qcodes.instrument_drivers.Keysight.KeysightB1500(name: str, address: str, **kwargs: Any)[source]

Bases: VisaInstrument

Driver for Keysight B1500 Semiconductor Parameter Analyzer.

For the list of supported modules, refer to from_model_name().

Attributes:

calibration_time_out

ancestors

Ancestors in the form of a list of InstrumentBase

delegate_attr_dicts

A list of names (strings) of dictionaries which are (or will be) attributes of self, whose keys should be treated as attributes of self.

delegate_attr_objects

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

full_name

Full name of the instrument.

label

Nicely formatted label of the instrument.

name

Full name of the instrument

name_parts

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs

A list of attribute names (strings) to not delegate to any other dictionary or object.

parent

The parent instrument.

root_instrument

The topmost parent of this module.

short_name

Short name of the instrument.

visa_handle

The VISA resource used by this instrument.

resource_manager

The VISA resource manager used by this instrument.

parameters

All the parameters supported by this instrument.

functions

All the functions supported by this instrument.

submodules

All the submodules of this instrument such as channel lists or logical groupings of parameters.

instrument_modules

All the InstrumentModule of this instrument Usually populated via add_submodule().

Methods:

write(cmd)

Extend write method from the super to ask for error message each time a write command is called.

add_module(name, module)

reset()

Performs an instrument reset.

get_status()

from_model_name(model, slot_nr, parent[, name])

Creates the correct instance of instrument module by model name.

enable_channels([channels])

Enable specified channels.

disable_channels([channels])

Disable specified channels.

parse_spot_measurement_response()

Extract measured value and accompanying metadata from the string and return them as a dictionary.

parse_module_query_response()

Extract installed module information from the given string and return the information as a dictionary.

use_nplc_for_high_speed_adc([n])

Set the high-speed ADC to NPLC mode, with optionally defining number of averaging samples via argument n.

use_nplc_for_high_resolution_adc([n])

Set the high-resolution ADC to NPLC mode, with optionally defining the number of PLCs per sample via argument n.

use_manual_mode_for_high_speed_adc([n])

Set the high-speed ADC to manual mode, with optionally defining number of averaging samples via argument n.

self_calibration([slot])

Performs the self calibration of the specified module (SMU) and returns the result.

error_message([mode])

This method reads one error code from the head of the error queue and removes that code from the queue.

clear_buffer_of_error_message()

This method clears the error message stored in buffer when the error_message command is executed.

clear_timer_count([chnum])

This command clears the timer count.

set_measurement_mode(mode[, channels])

This method specifies the measurement mode and the channels used for measurements.

get_measurement_mode()

This method gets the measurement mode(MM) and the channels used for measurements.

get_response_format_and_mode()

This method queries the the data output format and mode.

enable_smu_filters(enable_filter[, channels])

This methods sets the connection mode of a SMU filter for each channel.

__del__()

Close the instrument and remove its instance record.

__getitem__(key)

Delegate instrument['name'] to parameter or function 'name'.

__getstate__()

Prevent pickling instruments, and give a nice error message.

__repr__()

Simplified repr giving just the class and name.

add_function(name, **kwargs)

Bind one Function to this instrument.

add_parameter(name[, parameter_class])

Bind one Parameter to this instrument.

add_submodule(name, submodule)

Bind one submodule to this instrument.

ask(cmd)

Write a command string to the hardware and return a response.

ask_raw(cmd)

Low-level interface to visa_handle.ask.

call(func_name, *args)

Shortcut for calling a function from its name.

close()

Disconnect and irreversibly tear down the instrument.

close_all()

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.

connect_message([idn_param, begin_time])

Print a standard message on initial connection to an instrument.

device_clear()

Clear the buffers of the device

exist(name[, instrument_class])

Check if an instrument with a given names exists (i.e. is already instantiated).

find_instrument(name[, instrument_class])

Find an existing instrument by name.

get(param_name)

Shortcut for getting a parameter from its name.

get_component(full_name)

Recursively get a component of the instrument by full_name.

get_idn()

Parse a standard VISA *IDN? response into an ID dict.

instances()

Get all currently defined instances of this instrument class.

invalidate_cache()

Invalidate the cache of all parameters on the instrument.

is_valid(instr_instance)

Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a "valid" instrument.

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

print_readable_snapshot([update, max_chars])

Prints a readable version of the snapshot.

record_instance(instance)

Record (a weak ref to) an instance in a class's instance list.

remove_instance(instance)

Remove a particular instance from the record.

set(param_name, value)

Shortcut for setting a parameter from its name and new value.

set_address(address)

Set the address for this instrument.

set_terminator(terminator)

Change the read terminator to use.

snapshot([update])

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class NumpyJSONEncoder supports).

validate_status([verbose])

Validate the values of all gettable parameters

write_raw(cmd)

Low-level interface to visa_handle.write.

calibration_time_out = 60
by_slot: dict[constants.SlotNr, B1500Module] = {}
by_channel: dict[constants.ChNr, B1500Module] = {}
by_kind: dict[constants.ModuleKind, list[B1500Module]] = defaultdict(list)
write(cmd: str) None[source]

Extend write method from the super to ask for error message each time a write command is called.

add_module(name: str, module: B1500Module) None[source]
reset() None[source]

Performs an instrument reset.

This does not reset error queue!

get_status() int[source]
static from_model_name(model: str, slot_nr: int, parent: KeysightB1500, name: str | None = None) B1500Module[source]

Creates the correct instance of instrument module by model name.

Parameters:
  • model – Model name such as ‘B1517A’

  • slot_nr – Slot number of this module (not channel number)

  • parent – Reference to B1500 mainframe instance

  • name – Name of the instrument instance to create. If None (Default), then the name is autogenerated from the instrument class.

Returns:

A specific instance of B1500Module

enable_channels(channels: Sequence[ChNr | int] | None = None) None[source]

Enable specified channels.

If channels is omitted or None, then all channels are enabled.

disable_channels(channels: Sequence[ChNr | int] | None = None) None[source]

Disable specified channels.

If channels is omitted or None, then all channels are disabled.

parse_spot_measurement_response() SpotResponse

Extract measured value and accompanying metadata from the string and return them as a dictionary.

Parameters:

response – Response str to spot measurement query.

Returns:

Dictionary with measured value and associated metadata (e.g. timestamp, channel number, etc.)

parse_module_query_response() dict[SlotNr, str]

Extract installed module information from the given string and return the information as a dictionary.

Parameters:

response – Response str to UNT? 0 query.

Returns:

Dictionary from slot numbers to model name strings.

use_nplc_for_high_speed_adc(n: int | None = None) None[source]

Set the high-speed ADC to NPLC mode, with optionally defining number of averaging samples via argument n.

Parameters:

n

Value that defines the number of averaging samples given by the following formula:

Number of averaging samples = n / 128.

n=1 to 100. Default setting is 1 (if None is passed).

The Keysight B1500 gets 128 samples in a power line cycle, repeats this for the times you specify, and performs averaging to get the measurement data. (For more info see Table 4-21.). Note that the integration time will not be updated if a non-integer value is written to the B1500.

use_nplc_for_high_resolution_adc(n: int | None = None) None[source]

Set the high-resolution ADC to NPLC mode, with optionally defining the number of PLCs per sample via argument n.

Parameters:

n

Value that defines the integration time given by the following formula:

Integration time = n / power line frequency.

n=1 to 100. Default setting is 1 (if None is passed). (For more info see Table 4-21.). Note that the integration time will not be updated if a non-integer value is written to the B1500.

use_manual_mode_for_high_speed_adc(n: int | None = None) None[source]

Set the high-speed ADC to manual mode, with optionally defining number of averaging samples via argument n.

Use n=1 to disable averaging (n=None uses the default setting from the instrument which is also n=1).

Parameters:

n – Number of averaging samples, between 1 and 1023. Default setting is 1. (For more info see Table 4-21.) Note that the integration time will not be updated if a non-integer value is written to the B1500.

self_calibration(slot: SlotNr | int | None = None) CALResponse[source]

Performs the self calibration of the specified module (SMU) and returns the result. Failed modules are disabled, and can only be enabled by the RCV command.

Calibration takes about 30 seconds (the visa timeout for it is controlled by calibration_time_out attribute).

Execution Conditions: No SMU may be in the high voltage state (forcing more than ±42 V, or voltage compliance set to more than ±42 V). Before starting the calibration, open the measurement terminals.

Parameters:

slot – Slot number of the slot that installs the module to perform the self-calibration. For Ex: constants.SlotNr.ALL, MAINFRAME, SLOT01, SLOT02 …SLOT10 If not specified, the calibration is performed for all the modules and the mainframe.

error_message(mode: Mode | int | None = None) str[source]

This method reads one error code from the head of the error queue and removes that code from the queue. The read error is returned as the response of this method.

Parameters:

mode – If no valued passed returns both the error value and the error message. See constants.ERRX.Mode for possible arguments.

Returns:

In the default case response message contains an error message and a custom message containing additional information such as the slot number. They are separated by a semicolon (;). For example, if the error 305 occurs on the slot 1, this method returns the following response. 305,”Excess current in HPSMU.; SLOT1” If no error occurred, this command returns 0,”No Error.”

clear_buffer_of_error_message() None[source]

This method clears the error message stored in buffer when the error_message command is executed.

clear_timer_count(chnum: int | None = None) None[source]

This command clears the timer count. This command is effective for all measurement modes, regardless of the TSC setting. This command is not effective for the 4 byte binary data output format (FMT3 and FMT4).

Parameters:

chnum – SMU or MFCMU channel number. Integer expression. 1 to 10. See Table 4-1 on page 16 of 2016 manual. If chnum is specified, this command clears the timer count once at the source output start by the DV, DI, or DCV command for the specified channel. The channel output switch of the specified channel must be ON when the timer count is cleared.

If chnum is not specified, this command clears the timer count immediately,

set_measurement_mode(mode: Mode | int, channels: Sequence[ChNr | int] | None = None) None[source]

This method specifies the measurement mode and the channels used for measurements. This method must be entered to specify the measurement mode. For the high speed spot measurements, do not use this method. NOTE Order of the channels are important. The SMU which is setup to run the sweep goes first.

Parameters:
  • mode – Measurement mode. See constants.MM.Mode for all possible modes

  • channels – Measurement channel number. See constants.ChannelList for all possible channels.

get_measurement_mode() dict[str, Mode | list[int]][source]

This method gets the measurement mode(MM) and the channels used for measurements. It outputs a dictionary with ‘mode’ and ‘channels’ as keys.

get_response_format_and_mode() dict[str, Format | Mode][source]

This method queries the the data output format and mode.

enable_smu_filters(enable_filter: bool, channels: Sequence[ChNr | int] | None = None) None[source]

This methods sets the connection mode of a SMU filter for each channel. A filter is mounted on the SMU. It assures clean source output with no spikes or overshooting. A maximum of ten channels can be set.

Parameters:
  • enable_filter – Status of the filter. False: Disconnect (initial setting). True: Connect.

  • channels – SMU channel number. Specify channel from constants.ChNr If you do not specify chnum, the FL command sets the same mode for all channels.

__del__() None

Close the instrument and remove its instance record.

__getitem__(key: str) Callable[..., Any] | Parameter

Delegate instrument[‘name’] to parameter or function ‘name’.

__getstate__() None

Prevent pickling instruments, and give a nice error message.

__repr__() str

Simplified repr giving just the class and 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.

Note

We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.

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: type[ParameterBase] | None = 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: 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 a ChannelTuple.

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:
  • KeyError – If this instrument already contains a submodule with this name.

  • TypeError – If the submodule that we are trying to add is not an instance of an Metadatable object.

property ancestors: tuple[InstrumentBase, ...]

Ancestors in the form of a list of InstrumentBase

The list starts with the current module then the parent and the parents parent 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 call super().ask(new_cmd). Subclasses that define a new hardware communication should instead override ask_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:

str

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.

close() None

Disconnect and irreversibly tear down the instrument.

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: float | None = 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_timetime.time() when init started. Default is self._t0, set at start of Instrument.__init__.

delegate_attr_dicts: ClassVar[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 of self.

delegate_attr_objects: ClassVar[list[str]] = []

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

device_clear() None

Clear the buffers of the device

static exist(name: str, instrument_class: type[Instrument] | None = 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: type[T] | None = None) T | Instrument

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:
  • KeyError – If no instrument of that name was found, or if its reference is invalid (dead).

  • TypeError – If a specific class was requested but a different type was found.

property full_name: str

Full name of the instrument.

For an InstrumentModule this includes all parents separated by _

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_component(full_name: str) MetadatableWithName

Recursively get a component of the instrument by full_name.

Parameters:

full_name – The name of the component to get.

Returns:

The component with the given name.

Raises:

KeyError – If the component does not exist.

get_idn() dict[str, str | None]

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[T]

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.

property label: str

Nicely formatted label of the instrument.

load_metadata(metadata: Mapping[str, Any]) None

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

property name: str

Full name of the instrument

This is equivalent to full_name() for backwards compatibility.

property name_parts: list[str]

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs: ClassVar[list[str]] = []

A list of attribute names (strings) to not delegate to any other dictionary or object.

property parent: InstrumentBase | None

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. If False, 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: InstrumentBase

The topmost parent of this module.

For the root_instrument this is self.

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: str | None) 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.

property short_name: str

Short name of the instrument.

For an InstrumentModule this does not include any parent names.

snapshot(update: bool | None = False) dict[str, 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: bool | None = True, params_to_skip_update: Sequence[str] | None = 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:

dict

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_raw(cmd: str) None

Low-level interface to visa_handle.write.

Parameters:

cmd – The command to send to the instrument.

visabackend: str = visabackend
visa_handle: pyvisa.resources.MessageBasedResource = visa_handle

The VISA resource used by this instrument.

visalib: str | None = visalib
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, 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 via add_submodule().

log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
metadata: dict[str, Any] = {}
resource_manager = resource_manager

The VISA resource manager used by this instrument.

class qcodes.instrument_drivers.Keysight.KeysightB1500CVSweepMeasurement(name: str, instrument: KeysightB1520A, **kwargs: Any)[source]

Bases: MultiParameter, StatusMixin

CV sweep measurement outputs a list of primary (capacitance) and secondary parameter (disipation).

Parameters:
  • name – Name of the Parameter.

  • instrument – Instrument to which this parameter communicates to.

Attributes:

instrument

Return the first instrument that this parameter is bound to.

root_instrument

Return the fundamental instrument that this parameter belongs too.

param1

Data, statuses, etc.

param2

Data, statuses, etc.

ac_voltage

Data, statuses, etc.

dc_voltage

Data, statuses, etc.

abstract

full_name

Name of the parameter including the name of the instrument and submodule that the parameter may be bound to.

full_names

Names of the parameter components including the name of the instrument and submodule that the parameter may be bound to.

gettable

Is it allowed to call get on this parameter?

inter_delay

Delay time between consecutive set operations.

name

Name of the parameter.

name_parts

List of the parts that make up the full name of this parameter

post_delay

Delay time after start of set operation, for each set.

raw_value

Note that this property will be deprecated soon.

register_name

Name that will be used to register this parameter in a dataset By default, this returns full_name or the value of the register_name argument if it was passed at initialization.

setpoint_full_names

Full names of setpoints including instrument names, if available

settable

Is it allowed to call set on this parameter?

short_name

Short name of the parameter.

short_names

short_names is identical to names i.e. the names of the parameter parts but does not add the instrument name.

snapshot_value

If True the value of the parameter will be included in the snapshot.

step

Stepsize that this Parameter uses during set operation.

underlying_instrument

Returns an instance of the underlying hardware instrument that this parameter communicates with, per this parameter's implementation.

validators

Tuple of all validators associated with the parameter.

vals

The first validator of the parameter.

Methods:

get_raw()

get_raw is called to perform the actual data acquisition from the instrument.

update_name_label_unit_from_impedance_model([model])

__str__()

Include the instrument name with the Parameter name if possible.

add_validator(vals)

Add a validator for the parameter.

extra_validator(vals)

Contextmanager to to temporarily add a validator to the parameter within the given context.

get_ramp_values(value[, step])

Return values to sweep from current value to target value.

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

remove_validator()

Remove the last validator added to the parameter and return it.

restore_at_exit([allow_changes])

Use a context manager to restore the value of a parameter after a with block.

set_raw(value)

set_raw is called to perform the actual setting of a parameter on the instrument.

set_to(value[, allow_changes])

Use a context manager to temporarily set a parameter to a value.

snapshot([update])

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

State of the parameter as a JSON-compatible dict (everything that the custom JSON encoder class NumpyJSONEncoder supports).

status_summary()

validate(value)

Validate the value supplied.

property instrument: InstrumentBase | None

Return the first instrument that this parameter is bound to. E.g if this is bound to a channel it will return the channel and not the instrument that the channel is bound too. Use root_instrument() to get the real instrument.

property root_instrument: InstrumentBase | None

Return the fundamental instrument that this parameter belongs too. E.g if the parameter is bound to a channel this will return the fundamental instrument that that channel belongs to. Use instrument() to get the channel.

param1

Data, statuses, etc. of the first measured parameter

param2

Data, statuses, etc. of the second measured parameter

ac_voltage

Data, statuses, etc. of the AC voltage that the measured parameters were measured for

dc_voltage

Data, statuses, etc. of the AC voltage that the measured parameters were measured for

power_line_frequency: int
get_raw() tuple[tuple[float, ...], tuple[float, ...]][source]

get_raw is called to perform the actual data acquisition from the instrument. This method should either be overwritten to perform the desired operation or alternatively for Parameter a suitable method is automatically generated if get_cmd is supplied to the parameter constructor. The method is automatically wrapped to provide a get method on the parameter instance.

update_name_label_unit_from_impedance_model(model: MeasurementMode | None = None) None[source]
__str__() str

Include the instrument name with the Parameter name if possible.

property abstract: bool | None
add_validator(vals: Validator) None

Add a validator for the parameter. The parameter is validated against all validators in reverse order of how they are added.

Parameters:

vals – Validator to add to the parameter.

extra_validator(vals: Validator) Generator[None, None, None]

Contextmanager to to temporarily add a validator to the parameter within the given context. The validator is removed from the parameter when the context ends.

property full_name: str

Name of the parameter including the name of the instrument and submodule that the parameter may be bound to. The names are separated by underscores, like this: instrument_submodule_parameter.

property full_names: tuple[str, ...]

Names of the parameter components including the name of the instrument and submodule that the parameter may be bound to. The name parts are separated by underscores, like this: instrument_submodule_parameter

get_ramp_values(value: float | Sized, step: float | None = None) Sequence[float | Sized]

Return values to sweep from current value to target value. This method can be overridden to have a custom sweep behaviour. It can even be overridden by a generator.

Parameters:
  • value – target value

  • step – maximum step size

Returns:

List of stepped values, including target value.

property gettable: bool

Is it allowed to call get on this parameter?

property inter_delay: float

Delay time between consecutive set operations. The actual time will not be shorter than this, but may be longer if the underlying set call takes longer.

Typically used in conjunction with step to create an effective ramp rate, but can also be used without a step to enforce a delay between sets.

Getter:

Returns the current inter_delay.

Setter:

Sets the value of the inter_delay.

Raises:
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 parameter. This is identical to short_name().

property name_parts: list[str]

List of the parts that make up the full name of this parameter

property post_delay: float

Delay time after start of set operation, for each set. The actual time will not be shorter than this, but may be longer if the underlying set call takes longer.

Typically used in conjunction with step to create an effective ramp rate, but can also be used without a step to enforce a delay after every set. One might think of post_delay as how long a set operation is supposed to take. For example, there might be an instrument that needs extra time after setting a parameter although the command for setting the parameter returns quickly.

Getter:

Returns the current post_delay.

Setter:

Sets the value of the post_delay.

Raises:
property raw_value: Any

Note that this property will be deprecated soon. Use cache.raw_value instead.

Represents the cached raw value of the parameter.

Getter:

Returns the cached raw value of the parameter.

property register_name: str

Name that will be used to register this parameter in a dataset By default, this returns full_name or the value of the register_name argument if it was passed at initialization.

remove_validator() Validator | None

Remove the last validator added to the parameter and return it. Returns None if there are no validators associated with the parameter.

Returns:

The last validator added to the parameter or None if there are no validators associated with the parameter.

restore_at_exit(allow_changes: bool = True) _SetParamContext

Use a context manager to restore the value of a parameter after a with block.

By default, the parameter value may be changed inside the block, but this can be prevented with allow_changes=False. This can be useful, for example, for debugging a complex measurement that unintentionally modifies a parameter.

Example

>>> p = Parameter("p", set_cmd=None, get_cmd=None)
>>> p.set(2)
>>> with p.restore_at_exit():
...     p.set(3)
...     print(f"value inside with block: {p.get()}")  # prints 3
>>> print(f"value after with block: {p.get()}")  # prints 2
>>> with p.restore_at_exit(allow_changes=False):
...     p.set(5)  # raises an exception
set_raw(value: Any) None

set_raw is called to perform the actual setting of a parameter on the instrument. This method should either be overwritten to perform the desired operation or alternatively for Parameter a suitable method is automatically generated if set_cmd is supplied to the parameter constructor. The method is automatically wrapped to provide a set method on the parameter instance.

set_to(value: Any, allow_changes: bool = False) _SetParamContext

Use a context manager to temporarily set a parameter to a value. By default, the parameter value cannot be changed inside the context. This may be overridden with allow_changes=True.

Examples

>>> from qcodes.parameters import Parameter
>>> p = Parameter("p", set_cmd=None, get_cmd=None)
>>> p.set(2)
>>> with p.set_to(3):
...     print(f"p value in with block {p.get()}")  # prints 3
...     p.set(5)  # raises an exception
>>> print(f"p value outside with block {p.get()}")  # prints 2
>>> with p.set_to(3, allow_changes=True):
...     p.set(5)  # now this works
>>> print(f"value after second block: {p.get()}")  # still prints 2
property setpoint_full_names: Sequence[Sequence[str]] | None

Full names of setpoints including instrument names, if available

property settable: bool

Is it allowed to call set on this parameter?

property short_name: str

Short name of the parameter. This is without the name of the instrument or submodule that the parameter may be bound to. For full name refer to full_name().

property short_names: tuple[str, ...]

short_names is identical to names i.e. the names of the parameter parts but does not add the instrument name.

It exists for consistency with instruments and other parameters.

snapshot(update: bool | None = False) dict[str, 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: bool | None = True, params_to_skip_update: Sequence[str] | None = None) dict[Any, Any]

State of the parameter as a JSON-compatible dict (everything that the custom JSON encoder class NumpyJSONEncoder supports).

If the parameter has been initiated with snapshot_value=False, the snapshot will NOT include the value and raw_value of the parameter.

Parameters:
  • update – If True, update the state by calling parameter.get() unless snapshot_get of the parameter is False. If update is None, use the current value from the cache unless the cache is invalid. If False, never call parameter.get().

  • params_to_skip_update – No effect but may be passed from superclass

Returns:

base snapshot

property snapshot_value: bool

If True the value of the parameter will be included in the snapshot.

status_summary() dict[str, str]
property step: float | None

Stepsize that this Parameter uses during set operation. Stepsize must be a positive number or None. If step is a positive number, this is the maximum value change allowed in one hardware call, so a single set can result in many calls to the hardware if the starting value is far from the target. All but the final change will attempt to change by +/- step exactly. If step is None stepping will not be used.

Getter:

Returns the current stepsize.

Setter:

Sets the value of the step.

Raises:
  • TypeError – if step is set to not numeric or None

  • ValueError – if step is set to negative

  • TypeError – if step is set to not integer or None for an integer parameter

  • TypeError – if step is set to not a number on None

property underlying_instrument: InstrumentBase | None

Returns an instance of the underlying hardware instrument that this parameter communicates with, per this parameter’s implementation.

This is useful in the case where a parameter does not belongs to an instrument instance that represents a real hardware instrument but actually uses a real hardware instrument in its implementation (e.g. via calls to one or more parameters of that real hardware instrument). This is also useful when a parameter does belong to an instrument instance but that instance does not represent the real hardware instrument that the parameter interacts with: hence root_instrument of the parameter cannot be the hardware_instrument, however underlying_instrument can be implemented to return the hardware_instrument.

By default it returns the root_instrument of the parameter.

validate(value: Any) None

Validate the value supplied.

Parameters:

value – value to validate

Raises:
  • TypeError – If the value is of the wrong type.

  • ValueError – If the value is outside the bounds specified by the validator.

property validators: tuple[Validator, ...]

Tuple of all validators associated with the parameter.

Getter:

All validators associated with the parameter.

property vals: Validator | None

The first validator of the parameter. None if no validators are set for this parameter.

Getter:

Returns the first validator or None if no validators.

Setter:

Sets the first validator. Set to None to remove the first validator.

Raises:

RuntimeError – If removing the first validator when more than one validator is set.

cache: _CacheProtocol
get_latest: GetLatest
get: Callable[..., ParamDataType]
set: Callable[..., None]
metadata: dict[str, Any]
class qcodes.instrument_drivers.Keysight.KeysightB1500CVSweeper(parent: KeysightB1520A, name: str, **kwargs: Any)[source]

Bases: InstrumentChannel

Methods:

__getitem__(key)

Delegate instrument['name'] to parameter or function 'name'.

__getstate__()

Prevent pickling instruments, and give a nice error message.

__repr__()

Custom repr to give parent information

add_function(name, **kwargs)

Bind one Function to this instrument.

add_parameter(name[, parameter_class])

Bind one Parameter to this instrument.

add_submodule(name, submodule)

Bind one submodule to this instrument.

ask(cmd)

ask_raw(cmd)

call(func_name, *args)

Shortcut for calling a function from its name.

get(param_name)

Shortcut for getting a parameter from its name.

get_component(full_name)

Recursively get a component of the instrument by full_name.

invalidate_cache()

Invalidate the cache of all parameters on the instrument.

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

print_readable_snapshot([update, max_chars])

Prints a readable version of the snapshot.

set(param_name, value)

Shortcut for setting a parameter from its name and new value.

snapshot([update])

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class NumpyJSONEncoder supports).

validate_status([verbose])

Validate the values of all gettable parameters

write(cmd)

write_raw(cmd)

Attributes:

ancestors

Ancestors in the form of a list of InstrumentBase

delegate_attr_dicts

A list of names (strings) of dictionaries which are (or will be) attributes of self, whose keys should be treated as attributes of self.

delegate_attr_objects

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

full_name

Full name of the instrument.

label

Nicely formatted label of the instrument.

name

Full name of the instrument

name_parts

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs

A list of attribute names (strings) to not delegate to any other dictionary or object.

parent

The parent instrument.

root_instrument

The topmost parent of this module.

short_name

Short name of the instrument.

parameters

All the parameters supported by this instrument.

functions

All the functions supported by this instrument.

submodules

All the submodules of this instrument such as channel lists or logical groupings of parameters.

instrument_modules

All the InstrumentModule of this instrument Usually populated via add_submodule().

__getitem__(key: str) Callable[..., Any] | Parameter

Delegate instrument[‘name’] to parameter or function ‘name’.

__getstate__() None

Prevent pickling instruments, and give a nice error message.

__repr__() str

Custom repr to give parent information

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.

Note

We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.

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: type[ParameterBase] | None = 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: 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 a ChannelTuple.

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:
  • KeyError – If this instrument already contains a submodule with this name.

  • TypeError – If the submodule that we are trying to add is not an instance of an Metadatable object.

property ancestors: tuple[InstrumentBase, ...]

Ancestors in the form of a list of InstrumentBase

The list starts with the current module then the parent and the parents parent until the root instrument is reached.

ask(cmd: str) str
ask_raw(cmd: str) str
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: ClassVar[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 of self.

delegate_attr_objects: ClassVar[list[str]] = []

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

property full_name: str

Full name of the instrument.

For an InstrumentModule this includes all parents separated by _

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_component(full_name: str) MetadatableWithName

Recursively get a component of the instrument by full_name.

Parameters:

full_name – The name of the component to get.

Returns:

The component with the given name.

Raises:

KeyError – If the component does not exist.

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.

property label: str

Nicely formatted label of the instrument.

load_metadata(metadata: Mapping[str, Any]) None

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

property name: str

Full name of the instrument

This is equivalent to full_name() for backwards compatibility.

property name_parts: list[str]

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs: ClassVar[list[str]] = []

A list of attribute names (strings) to not delegate to any other dictionary or object.

property parent: InstrumentBase

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. If False, 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: InstrumentBase

The topmost parent of this module.

For the root_instrument this is self.

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.

property short_name: str

Short name of the instrument.

For an InstrumentModule this does not include any parent names.

snapshot(update: bool | None = False) dict[str, 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: bool | None = False, params_to_skip_update: Sequence[str] | None = 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. If False, 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:

dict

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_raw(cmd: str) None
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, 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 via add_submodule().

log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
metadata: dict[str, Any] = {}
class qcodes.instrument_drivers.Keysight.KeysightB1500Correction(parent: KeysightB1520A, name: str, **kwargs: Any)[source]

Bases: InstrumentChannel

A Keysight B1520A CMU submodule for performing open/short/load corrections.

Methods:

enable(corr)

This command enables the open/short/load correction.

disable(corr)

This command disables an open/short/load correction.

is_enabled(corr)

Query instrument to see if a correction of the given type is enabled.

set_reference_values(corr, mode, primary, ...)

This command disables the open/short/load correction function and defines the calibration value or the reference value of the open/short/load standard.

get_reference_values(corr)

This command returns the calibration values or the reference values of the open/short/load standard.

perform(corr)

Perform Open/Short/Load corrections using this method.

perform_and_enable(corr)

Perform the correction AND enable it.

__getitem__(key)

Delegate instrument['name'] to parameter or function 'name'.

__getstate__()

Prevent pickling instruments, and give a nice error message.

__repr__()

Custom repr to give parent information

add_function(name, **kwargs)

Bind one Function to this instrument.

add_parameter(name[, parameter_class])

Bind one Parameter to this instrument.

add_submodule(name, submodule)

Bind one submodule to this instrument.

ask(cmd)

ask_raw(cmd)

call(func_name, *args)

Shortcut for calling a function from its name.

get(param_name)

Shortcut for getting a parameter from its name.

get_component(full_name)

Recursively get a component of the instrument by full_name.

invalidate_cache()

Invalidate the cache of all parameters on the instrument.

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

print_readable_snapshot([update, max_chars])

Prints a readable version of the snapshot.

set(param_name, value)

Shortcut for setting a parameter from its name and new value.

snapshot([update])

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class NumpyJSONEncoder supports).

validate_status([verbose])

Validate the values of all gettable parameters

write(cmd)

write_raw(cmd)

Attributes:

ancestors

Ancestors in the form of a list of InstrumentBase

delegate_attr_dicts

A list of names (strings) of dictionaries which are (or will be) attributes of self, whose keys should be treated as attributes of self.

delegate_attr_objects

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

full_name

Full name of the instrument.

label

Nicely formatted label of the instrument.

name

Full name of the instrument

name_parts

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs

A list of attribute names (strings) to not delegate to any other dictionary or object.

parent

The parent instrument.

root_instrument

The topmost parent of this module.

short_name

Short name of the instrument.

parameters

All the parameters supported by this instrument.

functions

All the functions supported by this instrument.

submodules

All the submodules of this instrument such as channel lists or logical groupings of parameters.

instrument_modules

All the InstrumentModule of this instrument Usually populated via add_submodule().

enable(corr: CalibrationType) None[source]

This command enables the open/short/load correction. Before enabling a correction, perform the corresponding correction data measurement by using the perform().

Parameters:

corr – Depending on the the correction you want to perform, set this to OPEN, SHORT or LOAD. For ex: In case of open correction corr = constants.CalibrationType.OPEN.

disable(corr: CalibrationType) None[source]

This command disables an open/short/load correction.

Parameters:

corr – Correction type as in constants.CalibrationType

is_enabled(corr: CalibrationType) Response[source]

Query instrument to see if a correction of the given type is enabled.

Parameters:

corr – Correction type as in constants.CalibrationType

set_reference_values(corr: CalibrationType, mode: Mode, primary: float, secondary: float) None[source]

This command disables the open/short/load correction function and defines the calibration value or the reference value of the open/short/load standard. Any previously measured correction data will be invalid after calling this method.

Parameters:
  • corr – Correction mode from constants.CalibrationType. OPEN for Open correction SHORT for Short correction LOAD for Load correction.

  • mode – Measurement mode from constants.DCORR.Mode Cp-G (for open correction) Ls-Rs (for short or load correction).

  • primary – Primary reference value of the standard. Cp value for the open standard. in F. Ls value for the short or load standard. in H.

  • secondary – Secondary reference value of the standard. G value for the open standard. in S. Rs value for the short or load standard. in Ω.

get_reference_values(corr: CalibrationType) str[source]

This command returns the calibration values or the reference values of the open/short/load standard.

Parameters:

corr – Correction mode from constants.CalibrationType. OPEN for Open correction SHORT for Short correction LOAD for Load correction.

Returns:

A human-readable string with the correction mode constants.DCORR.Mode and its reference values

perform(corr: CalibrationType) Response[source]

Perform Open/Short/Load corrections using this method. Refer to the example notebook to understand how each of the corrections are performed.

Before executing this method, set the oscillator level of the MFCMU.

If you use the correction standard, execute the set_reference_values() method (corresponds to the DCORR command) before this method because the calibration value or the reference value of the standard must be defined before performing the correction.

Parameters:

corr – Depending on the the correction you want to perform, set this to OPEN, SHORT or LOAD. For ex: In case of open correction corr = constants.CalibrationType.OPEN.

Returns:

Status of correction data measurement in the form of constants.CORR.Response

perform_and_enable(corr: CalibrationType) str[source]

Perform the correction AND enable it. It is equivalent to calling perform() and enable() methods sequentially.

Returns:

A human readable string with status of the operation.

__getitem__(key: str) Callable[..., Any] | Parameter

Delegate instrument[‘name’] to parameter or function ‘name’.

__getstate__() None

Prevent pickling instruments, and give a nice error message.

__repr__() str

Custom repr to give parent information

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.

Note

We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.

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: type[ParameterBase] | None = 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: 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 a ChannelTuple.

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:
  • KeyError – If this instrument already contains a submodule with this name.

  • TypeError – If the submodule that we are trying to add is not an instance of an Metadatable object.

property ancestors: tuple[InstrumentBase, ...]

Ancestors in the form of a list of InstrumentBase

The list starts with the current module then the parent and the parents parent until the root instrument is reached.

ask(cmd: str) str
ask_raw(cmd: str) str
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: ClassVar[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 of self.

delegate_attr_objects: ClassVar[list[str]] = []

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

property full_name: str

Full name of the instrument.

For an InstrumentModule this includes all parents separated by _

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_component(full_name: str) MetadatableWithName

Recursively get a component of the instrument by full_name.

Parameters:

full_name – The name of the component to get.

Returns:

The component with the given name.

Raises:

KeyError – If the component does not exist.

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.

property label: str

Nicely formatted label of the instrument.

load_metadata(metadata: Mapping[str, Any]) None

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

property name: str

Full name of the instrument

This is equivalent to full_name() for backwards compatibility.

property name_parts: list[str]

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs: ClassVar[list[str]] = []

A list of attribute names (strings) to not delegate to any other dictionary or object.

property parent: InstrumentBase

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. If False, 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: InstrumentBase

The topmost parent of this module.

For the root_instrument this is self.

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.

property short_name: str

Short name of the instrument.

For an InstrumentModule this does not include any parent names.

snapshot(update: bool | None = False) dict[str, 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: bool | None = False, params_to_skip_update: Sequence[str] | None = 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. If False, 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:

dict

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_raw(cmd: str) None
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, 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 via add_submodule().

log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
metadata: dict[str, Any] = {}
class qcodes.instrument_drivers.Keysight.KeysightB1500FrequencyList(parent: KeysightB1500Correction, name: str, chnum: int, **kwargs: Any)[source]

Bases: InstrumentChannel

A frequency list for open/short/load correction for Keysight B1520A CMU.

Methods:

clear()

Remove all frequencies in the list for data correction.

clear_and_set_default()

Remove all frequencies in the list for data correction AND set the default frequency list.

__getitem__(key)

Delegate instrument['name'] to parameter or function 'name'.

__getstate__()

Prevent pickling instruments, and give a nice error message.

__repr__()

Custom repr to give parent information

add_function(name, **kwargs)

Bind one Function to this instrument.

add_parameter(name[, parameter_class])

Bind one Parameter to this instrument.

add_submodule(name, submodule)

Bind one submodule to this instrument.

ask(cmd)

ask_raw(cmd)

call(func_name, *args)

Shortcut for calling a function from its name.

get(param_name)

Shortcut for getting a parameter from its name.

get_component(full_name)

Recursively get a component of the instrument by full_name.

invalidate_cache()

Invalidate the cache of all parameters on the instrument.

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

print_readable_snapshot([update, max_chars])

Prints a readable version of the snapshot.

set(param_name, value)

Shortcut for setting a parameter from its name and new value.

snapshot([update])

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class NumpyJSONEncoder supports).

validate_status([verbose])

Validate the values of all gettable parameters

write(cmd)

write_raw(cmd)

add(freq)

Append MFCMU output frequency for data correction in the list.

query([index])

Query the frequency list for CMU data correction.

Attributes:

ancestors

Ancestors in the form of a list of InstrumentBase

delegate_attr_dicts

A list of names (strings) of dictionaries which are (or will be) attributes of self, whose keys should be treated as attributes of self.

delegate_attr_objects

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

full_name

Full name of the instrument.

label

Nicely formatted label of the instrument.

name

Full name of the instrument

name_parts

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs

A list of attribute names (strings) to not delegate to any other dictionary or object.

parent

The parent instrument.

root_instrument

The topmost parent of this module.

short_name

Short name of the instrument.

parameters

All the parameters supported by this instrument.

functions

All the functions supported by this instrument.

submodules

All the submodules of this instrument such as channel lists or logical groupings of parameters.

instrument_modules

All the InstrumentModule of this instrument Usually populated via add_submodule().

clear() None[source]

Remove all frequencies in the list for data correction.

clear_and_set_default() None[source]

Remove all frequencies in the list for data correction AND set the default frequency list.

For the list of default frequencies, refer to the documentation of the CLCORR command in the programming manual.

__getitem__(key: str) Callable[..., Any] | Parameter

Delegate instrument[‘name’] to parameter or function ‘name’.

__getstate__() None

Prevent pickling instruments, and give a nice error message.

__repr__() str

Custom repr to give parent information

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.

Note

We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.

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: type[ParameterBase] | None = 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: 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 a ChannelTuple.

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:
  • KeyError – If this instrument already contains a submodule with this name.

  • TypeError – If the submodule that we are trying to add is not an instance of an Metadatable object.

property ancestors: tuple[InstrumentBase, ...]

Ancestors in the form of a list of InstrumentBase

The list starts with the current module then the parent and the parents parent until the root instrument is reached.

ask(cmd: str) str
ask_raw(cmd: str) str
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: ClassVar[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 of self.

delegate_attr_objects: ClassVar[list[str]] = []

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

property full_name: str

Full name of the instrument.

For an InstrumentModule this includes all parents separated by _

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_component(full_name: str) MetadatableWithName

Recursively get a component of the instrument by full_name.

Parameters:

full_name – The name of the component to get.

Returns:

The component with the given name.

Raises:

KeyError – If the component does not exist.

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.

property label: str

Nicely formatted label of the instrument.

load_metadata(metadata: Mapping[str, Any]) None

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

property name: str

Full name of the instrument

This is equivalent to full_name() for backwards compatibility.

property name_parts: list[str]

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs: ClassVar[list[str]] = []

A list of attribute names (strings) to not delegate to any other dictionary or object.

property parent: InstrumentBase

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. If False, 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: InstrumentBase

The topmost parent of this module.

For the root_instrument this is self.

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.

property short_name: str

Short name of the instrument.

For an InstrumentModule this does not include any parent names.

snapshot(update: bool | None = False) dict[str, 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: bool | None = False, params_to_skip_update: Sequence[str] | None = 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. If False, 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:

dict

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_raw(cmd: str) None
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, 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 via add_submodule().

log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
metadata: dict[str, Any] = {}
add(freq: float) None[source]

Append MFCMU output frequency for data correction in the list.

The frequency value can be given with a certain resolution as per Table 4-18 in the programming manual (year 2016).

query(index: int | None = None) float[source]

Query the frequency list for CMU data correction.

If index is None, the query returns a total number of frequencies in the list. If index is given, then the query returns the frequency value from the list at that index.

class qcodes.instrument_drivers.Keysight.KeysightB1500IVSweeper(parent: KeysightB1517A, name: str, **kwargs: Any)[source]

Bases: InstrumentChannel

Methods:

__getitem__(key)

Delegate instrument['name'] to parameter or function 'name'.

__getstate__()

Prevent pickling instruments, and give a nice error message.

__repr__()

Custom repr to give parent information

add_function(name, **kwargs)

Bind one Function to this instrument.

add_parameter(name[, parameter_class])

Bind one Parameter to this instrument.

add_submodule(name, submodule)

Bind one submodule to this instrument.

ask(cmd)

ask_raw(cmd)

call(func_name, *args)

Shortcut for calling a function from its name.

get(param_name)

Shortcut for getting a parameter from its name.

get_component(full_name)

Recursively get a component of the instrument by full_name.

invalidate_cache()

Invalidate the cache of all parameters on the instrument.

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

print_readable_snapshot([update, max_chars])

Prints a readable version of the snapshot.

set(param_name, value)

Shortcut for setting a parameter from its name and new value.

snapshot([update])

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class NumpyJSONEncoder supports).

validate_status([verbose])

Validate the values of all gettable parameters

write(cmd)

write_raw(cmd)

Attributes:

ancestors

Ancestors in the form of a list of InstrumentBase

delegate_attr_dicts

A list of names (strings) of dictionaries which are (or will be) attributes of self, whose keys should be treated as attributes of self.

delegate_attr_objects

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

full_name

Full name of the instrument.

label

Nicely formatted label of the instrument.

name

Full name of the instrument

name_parts

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs

A list of attribute names (strings) to not delegate to any other dictionary or object.

parent

The parent instrument.

root_instrument

The topmost parent of this module.

short_name

Short name of the instrument.

parameters

All the parameters supported by this instrument.

functions

All the functions supported by this instrument.

submodules

All the submodules of this instrument such as channel lists or logical groupings of parameters.

instrument_modules

All the InstrumentModule of this instrument Usually populated via add_submodule().

__getitem__(key: str) Callable[..., Any] | Parameter

Delegate instrument[‘name’] to parameter or function ‘name’.

__getstate__() None

Prevent pickling instruments, and give a nice error message.

__repr__() str

Custom repr to give parent information

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.

Note

We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.

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: type[ParameterBase] | None = 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: 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 a ChannelTuple.

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:
  • KeyError – If this instrument already contains a submodule with this name.

  • TypeError – If the submodule that we are trying to add is not an instance of an Metadatable object.

property ancestors: tuple[InstrumentBase, ...]

Ancestors in the form of a list of InstrumentBase

The list starts with the current module then the parent and the parents parent until the root instrument is reached.

ask(cmd: str) str
ask_raw(cmd: str) str
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: ClassVar[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 of self.

delegate_attr_objects: ClassVar[list[str]] = []

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

property full_name: str

Full name of the instrument.

For an InstrumentModule this includes all parents separated by _

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_component(full_name: str) MetadatableWithName

Recursively get a component of the instrument by full_name.

Parameters:

full_name – The name of the component to get.

Returns:

The component with the given name.

Raises:

KeyError – If the component does not exist.

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.

property label: str

Nicely formatted label of the instrument.

load_metadata(metadata: Mapping[str, Any]) None

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

property name: str

Full name of the instrument

This is equivalent to full_name() for backwards compatibility.

property name_parts: list[str]

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs: ClassVar[list[str]] = []

A list of attribute names (strings) to not delegate to any other dictionary or object.

property parent: InstrumentBase

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. If False, 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: InstrumentBase

The topmost parent of this module.

For the root_instrument this is self.

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.

property short_name: str

Short name of the instrument.

For an InstrumentModule this does not include any parent names.

snapshot(update: bool | None = False) dict[str, 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: bool | None = False, params_to_skip_update: Sequence[str] | None = 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. If False, 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:

dict

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_raw(cmd: str) None
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, 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 via add_submodule().

log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
metadata: dict[str, Any] = {}
class qcodes.instrument_drivers.Keysight.KeysightB1511B(parent: qcodes.instrument_drivers.Keysight.keysightb1500.KeysightB1500, name: str | None, slot_nr: int, **kwargs: Any)[source]

Bases: KeysightB1517A

Driver for Keysight B1511B Source/Monitor Unit module for B1500 Semiconductor Parameter Analyzer.

Parameters:
  • parent – mainframe B1500 instance that this module belongs to

  • name – Name of the instrument instance to create. If None (Default), then the name is autogenerated from the instrument class.

  • slot_nr – Slot number of this module (not channel number)

  • asu_present – Flag to acknowledge ASU presence

Attributes:

MODULE_KIND

ancestors

Ancestors in the form of a list of InstrumentBase

asu_present

delegate_attr_dicts

A list of names (strings) of dictionaries which are (or will be) attributes of self, whose keys should be treated as attributes of self.

delegate_attr_objects

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

full_name

Full name of the instrument.

label

Nicely formatted label of the instrument.

name

Full name of the instrument

name_parts

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs

A list of attribute names (strings) to not delegate to any other dictionary or object.

parent

The parent instrument.

root_instrument

The topmost parent of this module.

short_name

Short name of the instrument.

parameters

All the parameters supported by this instrument.

functions

All the functions supported by this instrument.

submodules

All the submodules of this instrument such as channel lists or logical groupings of parameters.

instrument_modules

All the InstrumentModule of this instrument Usually populated via add_submodule().

Methods:

__getitem__(key)

Delegate instrument['name'] to parameter or function 'name'.

__getstate__()

Prevent pickling instruments, and give a nice error message.

__repr__()

Custom repr to give parent information

add_function(name, **kwargs)

Bind one Function to this instrument.

add_parameter(name[, parameter_class])

Bind one Parameter to this instrument.

add_submodule(name, submodule)

Bind one submodule to this instrument.

ask(cmd)

ask_raw(cmd)

call(func_name, *args)

Shortcut for calling a function from its name.

clear_timer_count()

This command clears the timer count.

disable_outputs()

Disables all outputs of this module by opening the output relays of its channels.

enable_outputs()

Enables all outputs of this module by closing the output relays of its channels.

get(param_name)

Shortcut for getting a parameter from its name.

get_component(full_name)

Recursively get a component of the instrument by full_name.

i_measure_range_config(i_measure_range)

Configure measuring current

invalidate_cache()

Invalidate the cache of all parameters on the instrument.

is_enabled()

Check if channels of this module are enabled.

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

parse_module_query_response()

Extract installed module information from the given string and return the information as a dictionary.

parse_spot_measurement_response()

Extract measured value and accompanying metadata from the string and return them as a dictionary.

print_readable_snapshot([update, max_chars])

Prints a readable version of the snapshot.

set(param_name, value)

Shortcut for setting a parameter from its name and new value.

set_average_samples_for_high_speed_adc([...])

This command sets the number of averaging samples of the high-speed ADC (A/D converter).

setup_staircase_sweep(v_start, v_end, n_steps)

Setup the staircase sweep measurement using the same set of commands (in the same order) as given in the programming manual - see pages 3-19 and 3-20.

snapshot([update])

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class NumpyJSONEncoder supports).

source_config(output_range[, compliance, ...])

Configure sourcing voltage/current

timing_parameters(h_bias, interval, number)

This command sets the timing parameters of the sampling measurement mode (MM.Mode.SAMPLING, 10).

use_high_resolution_adc()

Use high-resolution ADC type for this module/channel

use_high_speed_adc()

Use high-speed ADC type for this module/channel

v_measure_range_config(v_measure_range)

Configure measuring voltage

validate_status([verbose])

Validate the values of all gettable parameters

write(cmd)

write_raw(cmd)

MODULE_KIND: ModuleKind = 'SMU'
__getitem__(key: str) Callable[..., Any] | Parameter

Delegate instrument[‘name’] to parameter or function ‘name’.

__getstate__() None

Prevent pickling instruments, and give a nice error message.

__repr__() str

Custom repr to give parent information

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.

Note

We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.

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: type[ParameterBase] | None = 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: 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 a ChannelTuple.

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:
  • KeyError – If this instrument already contains a submodule with this name.

  • TypeError – If the submodule that we are trying to add is not an instance of an Metadatable object.

property ancestors: tuple[InstrumentBase, ...]

Ancestors in the form of a list of InstrumentBase

The list starts with the current module then the parent and the parents parent until the root instrument is reached.

ask(cmd: str) str
ask_raw(cmd: str) str
property asu_present: bool
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.

clear_timer_count() None

This command clears the timer count. This command is effective for all measurement modes, regardless of the TSC setting. This command is not effective for the 4 byte binary data output format (FMT3 and FMT4).

delegate_attr_dicts: ClassVar[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 of self.

delegate_attr_objects: ClassVar[list[str]] = []

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

disable_outputs() None

Disables all outputs of this module by opening the output relays of its channels.

enable_outputs() None

Enables all outputs of this module by closing the output relays of its channels.

property full_name: str

Full name of the instrument.

For an InstrumentModule this includes all parents separated by _

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_component(full_name: str) MetadatableWithName

Recursively get a component of the instrument by full_name.

Parameters:

full_name – The name of the component to get.

Returns:

The component with the given name.

Raises:

KeyError – If the component does not exist.

i_measure_range_config(i_measure_range: IMeasRange) None

Configure measuring current

Parameters:

i_measure_range – current measurement range

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.

is_enabled() bool

Check if channels of this module are enabled.

Returns:

True if all channels of this module are enabled. False, otherwise.

property label: str

Nicely formatted label of the instrument.

load_metadata(metadata: Mapping[str, Any]) None

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

property name: str

Full name of the instrument

This is equivalent to full_name() for backwards compatibility.

property name_parts: list[str]

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs: ClassVar[list[str]] = []

A list of attribute names (strings) to not delegate to any other dictionary or object.

property parent: InstrumentBase

The parent instrument. By default, this is None. Any SubInstrument should subclass this to return the parent instrument.

parse_module_query_response() dict[SlotNr, str]

Extract installed module information from the given string and return the information as a dictionary.

Parameters:

response – Response str to UNT? 0 query.

Returns:

Dictionary from slot numbers to model name strings.

parse_spot_measurement_response() SpotResponse

Extract measured value and accompanying metadata from the string and return them as a dictionary.

Parameters:

response – Response str to spot measurement query.

Returns:

Dictionary with measured value and associated metadata (e.g. timestamp, channel number, etc.)

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. If False, 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: InstrumentBase

The topmost parent of this module.

For the root_instrument this is self.

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_average_samples_for_high_speed_adc(number: int = 1, mode: Mode = Mode.AUTO) None

This command sets the number of averaging samples of the high-speed ADC (A/D converter). This command is not effective for the high-resolution ADC. Also, this command is not effective for the measurements using pulse.

Parameters:
  • number – 1 to 1023, or -1 to -100. Initial setting is 1. For positive number input, this value specifies the number of samples depended on the mode value. For negative number input, this parameter specifies the number of power line cycles (PLC) for one point measurement. The Keysight B1500 gets 128 samples in 1 PLC. If number is negative it ignores the mode argument.

  • mode – Averaging mode. Integer expression. This parameter is meaningless for negative number. constants.AV.Mode.AUTO: Auto mode (default setting). Number of samples = number x initial number. constants.AV.Mode.MANUAL: Manual mode. Number of samples = number

setup_staircase_sweep(v_start: float, v_end: float, n_steps: int, post_sweep_voltage_val: Post | int = Post.STOP, av_coef: int = -1, enable_filter: bool = True, v_src_range: VOutputRange | IOutputRange = VOutputRange.AUTO, i_comp: float = 1e-05, i_meas_range: VMeasRange | IMeasRange | None = IMeasRange.FIX_10uA, hold_time: float = 0, delay: float = 0, step_delay: float = 0, measure_delay: float = 0, abort_enabled: Abort | int = Abort.ENABLED, sweep_mode: SweepMode | int = SweepMode.LINEAR) None

Setup the staircase sweep measurement using the same set of commands (in the same order) as given in the programming manual - see pages 3-19 and 3-20.

Parameters:
  • v_start – starting voltage of staircase sweep

  • v_end – ending voltage of staircase sweep

  • n_steps – number of measurement points (uniformly distributed between v_start and v_end)

  • post_sweep_voltage_val – voltage to hold at end of sweep (i.e. start or end val). Sweep chan will also output this voltage if an abort condition is encountered during the sweep

  • av_coef – coefficient to use for av command to set ADC averaging. Negative value implies NPLC mode with absolute value of av_coeff the NPLC setting to use. Positive value implies auto mode and must be set to >= 4

  • enable_filter – turn SMU filter on or off

  • v_src_range – range setting to use for voltage source

  • i_comp – current compliance level

  • i_meas_range – current measurement range

  • hold_time – time (in s) to wait before starting very first measurement in sweep

  • delay – time (in s) after starting to force a step output and before starting a step measurement

  • step_delay – time (in s) after starting a step measurement before next step in staircase. If step_delay is < measurement time, B1500 waits until measurement complete and then forces the next step value.

  • measure_delay – time (in s) after receiving a start step measurement trigger and before starting a step measurement

  • abort_enabled – Enbale abort

  • sweep_mode – Linear, log, linear-2-way or log-2-way

property short_name: str

Short name of the instrument.

For an InstrumentModule this does not include any parent names.

snapshot(update: bool | None = False) dict[str, 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: bool | None = False, params_to_skip_update: Sequence[str] | None = 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. If False, 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:

dict

source_config(output_range: VOutputRange | IOutputRange, compliance: float | int | None = None, compl_polarity: CompliancePolarityMode | None = None, min_compliance_range: VMeasRange | IMeasRange | None = None) None

Configure sourcing voltage/current

Parameters:
  • output_range – voltage/current output range

  • compliance – voltage/current compliance value

  • compl_polarity – compliance polarity mode

  • min_compliance_range – minimum voltage/current compliance output range

timing_parameters(h_bias: float, interval: float, number: int, h_base: float | None = None) None

This command sets the timing parameters of the sampling measurement mode (MM.Mode.SAMPLING, 10).

Refer to the programming guide for more information about the MT command, especially for notes on sampling operation and about setting interval < 0.002 s.

Parameters:
  • h_bias – Time since the bias value output until the first sampling point. Numeric expression. in seconds. 0 (initial setting) to 655.35 s, resolution 0.01 s. The following values are also available for interval < 0.002 s. |h_bias| will be the time since the sampling start until the bias value output. -0.09 to -0.0001 s, resolution 0.0001 s.

  • interval – Interval of the sampling. Numeric expression, 0.0001 to 65.535, in seconds. Initial value is 0.002. Resolution is 0.001 at interval < 0.002. Linear sampling of interval < 0.002 in 0.00001 resolution is available only when the following formula is satisfied. interval >= 0.0001 + 0.00002 * (number of measurement channels-1)

  • number – Number of samples. Integer expression. 1 to the following value. Initial value is 1000. For the linear sampling: 100001 / (number of measurement channels). For the log sampling: 1 + (number of data for 11 decades)

  • h_base – Hold time of the base value output until the bias value output. Numeric expression. in seconds. 0 (initial setting) to 655.35 s, resolution 0.01 s.

use_high_resolution_adc() None

Use high-resolution ADC type for this module/channel

use_high_speed_adc() None

Use high-speed ADC type for this module/channel

v_measure_range_config(v_measure_range: VMeasRange) None

Configure measuring voltage

Parameters:

v_measure_range – voltage measurement range

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_raw(cmd: str) None
setup_fnc_already_run: bool = False
power_line_frequency: int = 50
channels: tuple[ChNr, ...] = (ChNr(slot_nr),)
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, 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 via add_submodule().

log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
metadata: dict[str, Any] = {}
class qcodes.instrument_drivers.Keysight.KeysightB1517A(parent: KeysightB1500, name: str | None, slot_nr: int, **kwargs: Any)[source]

Bases: B1500Module

Driver for Keysight B1517A Source/Monitor Unit module for B1500 Semiconductor Parameter Analyzer.

Parameters:
  • parent – mainframe B1500 instance that this module belongs to

  • name – Name of the instrument instance to create. If None (Default), then the name is autogenerated from the instrument class.

  • slot_nr – Slot number of this module (not channel number)

Attributes:

MODULE_KIND

ancestors

Ancestors in the form of a list of InstrumentBase

delegate_attr_dicts

A list of names (strings) of dictionaries which are (or will be) attributes of self, whose keys should be treated as attributes of self.

delegate_attr_objects

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

full_name

Full name of the instrument.

label

Nicely formatted label of the instrument.

name

Full name of the instrument

name_parts

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs

A list of attribute names (strings) to not delegate to any other dictionary or object.

parent

The parent instrument.

root_instrument

The topmost parent of this module.

short_name

Short name of the instrument.

parameters

All the parameters supported by this instrument.

functions

All the functions supported by this instrument.

submodules

All the submodules of this instrument such as channel lists or logical groupings of parameters.

instrument_modules

All the InstrumentModule of this instrument Usually populated via add_submodule().

Methods:

source_config(output_range[, compliance, ...])

Configure sourcing voltage/current

v_measure_range_config(v_measure_range)

Configure measuring voltage

__getitem__(key)

Delegate instrument['name'] to parameter or function 'name'.

__getstate__()

Prevent pickling instruments, and give a nice error message.

__repr__()

Custom repr to give parent information

add_function(name, **kwargs)

Bind one Function to this instrument.

add_parameter(name[, parameter_class])

Bind one Parameter to this instrument.

add_submodule(name, submodule)

Bind one submodule to this instrument.

ask(cmd)

ask_raw(cmd)

call(func_name, *args)

Shortcut for calling a function from its name.

clear_timer_count()

This command clears the timer count.

disable_outputs()

Disables all outputs of this module by opening the output relays of its channels.

enable_outputs()

Enables all outputs of this module by closing the output relays of its channels.

get(param_name)

Shortcut for getting a parameter from its name.

get_component(full_name)

Recursively get a component of the instrument by full_name.

i_measure_range_config(i_measure_range)

Configure measuring current

invalidate_cache()

Invalidate the cache of all parameters on the instrument.

is_enabled()

Check if channels of this module are enabled.

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

parse_module_query_response()

Extract installed module information from the given string and return the information as a dictionary.

parse_spot_measurement_response()

Extract measured value and accompanying metadata from the string and return them as a dictionary.

print_readable_snapshot([update, max_chars])

Prints a readable version of the snapshot.

set(param_name, value)

Shortcut for setting a parameter from its name and new value.

snapshot([update])

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class NumpyJSONEncoder supports).

validate_status([verbose])

Validate the values of all gettable parameters

write(cmd)

write_raw(cmd)

timing_parameters(h_bias, interval, number)

This command sets the timing parameters of the sampling measurement mode (MM.Mode.SAMPLING, 10).

use_high_speed_adc()

Use high-speed ADC type for this module/channel

use_high_resolution_adc()

Use high-resolution ADC type for this module/channel

set_average_samples_for_high_speed_adc([...])

This command sets the number of averaging samples of the high-speed ADC (A/D converter).

setup_staircase_sweep(v_start, v_end, n_steps)

Setup the staircase sweep measurement using the same set of commands (in the same order) as given in the programming manual - see pages 3-19 and 3-20.

MODULE_KIND: ModuleKind = 'SMU'
channels: tuple[ChNr, ...] = (ChNr(slot_nr),)
setup_fnc_already_run: bool = False
power_line_frequency: int = 50
source_config(output_range: VOutputRange | IOutputRange, compliance: float | int | None = None, compl_polarity: CompliancePolarityMode | None = None, min_compliance_range: VMeasRange | IMeasRange | None = None) None[source]

Configure sourcing voltage/current

Parameters:
  • output_range – voltage/current output range

  • compliance – voltage/current compliance value

  • compl_polarity – compliance polarity mode

  • min_compliance_range – minimum voltage/current compliance output range

v_measure_range_config(v_measure_range: VMeasRange) None[source]

Configure measuring voltage

Parameters:

v_measure_range – voltage measurement range

__getitem__(key: str) Callable[..., Any] | Parameter

Delegate instrument[‘name’] to parameter or function ‘name’.

__getstate__() None

Prevent pickling instruments, and give a nice error message.

__repr__() str

Custom repr to give parent information

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.

Note

We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.

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: type[ParameterBase] | None = 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: 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 a ChannelTuple.

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:
  • KeyError – If this instrument already contains a submodule with this name.

  • TypeError – If the submodule that we are trying to add is not an instance of an Metadatable object.

property ancestors: tuple[InstrumentBase, ...]

Ancestors in the form of a list of InstrumentBase

The list starts with the current module then the parent and the parents parent until the root instrument is reached.

ask(cmd: str) str
ask_raw(cmd: str) str
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.

clear_timer_count() None

This command clears the timer count. This command is effective for all measurement modes, regardless of the TSC setting. This command is not effective for the 4 byte binary data output format (FMT3 and FMT4).

delegate_attr_dicts: ClassVar[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 of self.

delegate_attr_objects: ClassVar[list[str]] = []

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

disable_outputs() None

Disables all outputs of this module by opening the output relays of its channels.

enable_outputs() None

Enables all outputs of this module by closing the output relays of its channels.

property full_name: str

Full name of the instrument.

For an InstrumentModule this includes all parents separated by _

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_component(full_name: str) MetadatableWithName

Recursively get a component of the instrument by full_name.

Parameters:

full_name – The name of the component to get.

Returns:

The component with the given name.

Raises:

KeyError – If the component does not exist.

i_measure_range_config(i_measure_range: IMeasRange) None[source]

Configure measuring current

Parameters:

i_measure_range – current measurement range

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.

is_enabled() bool

Check if channels of this module are enabled.

Returns:

True if all channels of this module are enabled. False, otherwise.

property label: str

Nicely formatted label of the instrument.

load_metadata(metadata: Mapping[str, Any]) None

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

property name: str

Full name of the instrument

This is equivalent to full_name() for backwards compatibility.

property name_parts: list[str]

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs: ClassVar[list[str]] = []

A list of attribute names (strings) to not delegate to any other dictionary or object.

property parent: InstrumentBase

The parent instrument. By default, this is None. Any SubInstrument should subclass this to return the parent instrument.

parse_module_query_response() dict[SlotNr, str]

Extract installed module information from the given string and return the information as a dictionary.

Parameters:

response – Response str to UNT? 0 query.

Returns:

Dictionary from slot numbers to model name strings.

parse_spot_measurement_response() SpotResponse

Extract measured value and accompanying metadata from the string and return them as a dictionary.

Parameters:

response – Response str to spot measurement query.

Returns:

Dictionary with measured value and associated metadata (e.g. timestamp, channel number, etc.)

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. If False, 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: InstrumentBase

The topmost parent of this module.

For the root_instrument this is self.

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.

property short_name: str

Short name of the instrument.

For an InstrumentModule this does not include any parent names.

snapshot(update: bool | None = False) dict[str, 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: bool | None = False, params_to_skip_update: Sequence[str] | None = 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. If False, 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:

dict

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_raw(cmd: str) None
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, 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 via add_submodule().

log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
metadata: dict[str, Any] = {}
timing_parameters(h_bias: float, interval: float, number: int, h_base: float | None = None) None[source]

This command sets the timing parameters of the sampling measurement mode (MM.Mode.SAMPLING, 10).

Refer to the programming guide for more information about the MT command, especially for notes on sampling operation and about setting interval < 0.002 s.

Parameters:
  • h_bias – Time since the bias value output until the first sampling point. Numeric expression. in seconds. 0 (initial setting) to 655.35 s, resolution 0.01 s. The following values are also available for interval < 0.002 s. |h_bias| will be the time since the sampling start until the bias value output. -0.09 to -0.0001 s, resolution 0.0001 s.

  • interval – Interval of the sampling. Numeric expression, 0.0001 to 65.535, in seconds. Initial value is 0.002. Resolution is 0.001 at interval < 0.002. Linear sampling of interval < 0.002 in 0.00001 resolution is available only when the following formula is satisfied. interval >= 0.0001 + 0.00002 * (number of measurement channels-1)

  • number – Number of samples. Integer expression. 1 to the following value. Initial value is 1000. For the linear sampling: 100001 / (number of measurement channels). For the log sampling: 1 + (number of data for 11 decades)

  • h_base – Hold time of the base value output until the bias value output. Numeric expression. in seconds. 0 (initial setting) to 655.35 s, resolution 0.01 s.

use_high_speed_adc() None[source]

Use high-speed ADC type for this module/channel

use_high_resolution_adc() None[source]

Use high-resolution ADC type for this module/channel

set_average_samples_for_high_speed_adc(number: int = 1, mode: Mode = Mode.AUTO) None[source]

This command sets the number of averaging samples of the high-speed ADC (A/D converter). This command is not effective for the high-resolution ADC. Also, this command is not effective for the measurements using pulse.

Parameters:
  • number – 1 to 1023, or -1 to -100. Initial setting is 1. For positive number input, this value specifies the number of samples depended on the mode value. For negative number input, this parameter specifies the number of power line cycles (PLC) for one point measurement. The Keysight B1500 gets 128 samples in 1 PLC. If number is negative it ignores the mode argument.

  • mode – Averaging mode. Integer expression. This parameter is meaningless for negative number. constants.AV.Mode.AUTO: Auto mode (default setting). Number of samples = number x initial number. constants.AV.Mode.MANUAL: Manual mode. Number of samples = number

setup_staircase_sweep(v_start: float, v_end: float, n_steps: int, post_sweep_voltage_val: Post | int = Post.STOP, av_coef: int = -1, enable_filter: bool = True, v_src_range: VOutputRange | IOutputRange = VOutputRange.AUTO, i_comp: float = 1e-05, i_meas_range: VMeasRange | IMeasRange | None = IMeasRange.FIX_10uA, hold_time: float = 0, delay: float = 0, step_delay: float = 0, measure_delay: float = 0, abort_enabled: Abort | int = Abort.ENABLED, sweep_mode: SweepMode | int = SweepMode.LINEAR) None[source]

Setup the staircase sweep measurement using the same set of commands (in the same order) as given in the programming manual - see pages 3-19 and 3-20.

Parameters:
  • v_start – starting voltage of staircase sweep

  • v_end – ending voltage of staircase sweep

  • n_steps – number of measurement points (uniformly distributed between v_start and v_end)

  • post_sweep_voltage_val – voltage to hold at end of sweep (i.e. start or end val). Sweep chan will also output this voltage if an abort condition is encountered during the sweep

  • av_coef – coefficient to use for av command to set ADC averaging. Negative value implies NPLC mode with absolute value of av_coeff the NPLC setting to use. Positive value implies auto mode and must be set to >= 4

  • enable_filter – turn SMU filter on or off

  • v_src_range – range setting to use for voltage source

  • i_comp – current compliance level

  • i_meas_range – current measurement range

  • hold_time – time (in s) to wait before starting very first measurement in sweep

  • delay – time (in s) after starting to force a step output and before starting a step measurement

  • step_delay – time (in s) after starting a step measurement before next step in staircase. If step_delay is < measurement time, B1500 waits until measurement complete and then forces the next step value.

  • measure_delay – time (in s) after receiving a start step measurement trigger and before starting a step measurement

  • abort_enabled – Enbale abort

  • sweep_mode – Linear, log, linear-2-way or log-2-way

class qcodes.instrument_drivers.Keysight.KeysightB1520A(parent: KeysightB1500, name: str | None, slot_nr: int, **kwargs: Any)[source]

Bases: B1500Module

Driver for Keysight B1520A Capacitance Measurement Unit module for B1500 Semiconductor Parameter Analyzer.

Parameters:
  • parent – mainframe B1500 instance that this module belongs to

  • name – Name of the instrument instance to create. If None (Default), then the name is autogenerated from the instrument class.

  • slot_nr – Slot number of this module (not channel number)

Attributes:

phase_compensation_timeout

MODULE_KIND

ancestors

Ancestors in the form of a list of InstrumentBase

delegate_attr_dicts

A list of names (strings) of dictionaries which are (or will be) attributes of self, whose keys should be treated as attributes of self.

delegate_attr_objects

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

full_name

Full name of the instrument.

label

Nicely formatted label of the instrument.

name

Full name of the instrument

name_parts

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs

A list of attribute names (strings) to not delegate to any other dictionary or object.

parent

The parent instrument.

root_instrument

The topmost parent of this module.

short_name

Short name of the instrument.

parameters

All the parameters supported by this instrument.

functions

All the functions supported by this instrument.

submodules

All the submodules of this instrument such as channel lists or logical groupings of parameters.

instrument_modules

All the InstrumentModule of this instrument Usually populated via add_submodule().

Methods:

phase_compensation([mode])

Performs the MFCMU phase compensation, sets the compensation data to the KeysightB1500, and returns the execution results.

abort()

Aborts currently running operation and the subsequent execution.

setup_staircase_cv(v_start, v_end, n_steps, ...)

Convenience function which requires all inputs to properly setup a CV sweep measurement.

__getitem__(key)

Delegate instrument['name'] to parameter or function 'name'.

__getstate__()

Prevent pickling instruments, and give a nice error message.

__repr__()

Custom repr to give parent information

add_function(name, **kwargs)

Bind one Function to this instrument.

add_parameter(name[, parameter_class])

Bind one Parameter to this instrument.

add_submodule(name, submodule)

Bind one submodule to this instrument.

ask(cmd)

ask_raw(cmd)

call(func_name, *args)

Shortcut for calling a function from its name.

clear_timer_count()

This command clears the timer count.

disable_outputs()

Disables all outputs of this module by opening the output relays of its channels.

enable_outputs()

Enables all outputs of this module by closing the output relays of its channels.

get(param_name)

Shortcut for getting a parameter from its name.

get_component(full_name)

Recursively get a component of the instrument by full_name.

invalidate_cache()

Invalidate the cache of all parameters on the instrument.

is_enabled()

Check if channels of this module are enabled.

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

parse_module_query_response()

Extract installed module information from the given string and return the information as a dictionary.

parse_spot_measurement_response()

Extract measured value and accompanying metadata from the string and return them as a dictionary.

print_readable_snapshot([update, max_chars])

Prints a readable version of the snapshot.

set(param_name, value)

Shortcut for setting a parameter from its name and new value.

snapshot([update])

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class NumpyJSONEncoder supports).

validate_status([verbose])

Validate the values of all gettable parameters

write(cmd)

write_raw(cmd)

phase_compensation_timeout = 60
MODULE_KIND: ModuleKind = 'CMU'
channels: tuple[ChNr, ...] = (ChNr(slot_nr),)
phase_compensation(mode: Mode | int | None = None) Response[source]

Performs the MFCMU phase compensation, sets the compensation data to the KeysightB1500, and returns the execution results.

This method resets the MFCMU. Before executing this method, set the phase compensation mode to manual by using phase_compensation_mode parameter, and open the measurement terminals at the end of the device side. The execution of this method will take about 30 seconds (the visa timeout for it is controlled by phase_compensation_timeout attribute). The compensation data is cleared by turning the KeysightB1500 off.

Parameters:

mode

Command operation mode constants.ADJQuery.Mode.

  • 0: Use the last phase compensation data without measurement.

  • 1: Perform the phase compensation data measurement.

If the mode parameter is not set, mode=1 is assumed by the instrument.

Returns:

Status result of performing the phase compensation as constants.ADJQuery.Response

abort() None[source]

Aborts currently running operation and the subsequent execution. This does not abort the timeout process. Only when the kernel is free this command is executed and the further commands are aborted.

setup_staircase_cv(v_start: float, v_end: float, n_steps: int, freq: float, ac_rms: float, post_sweep_voltage_condition: Post | int = Post.STOP, adc_mode: Mode | int = Mode.PLC, adc_coef: int = 5, imp_model: MeasurementMode | int = MeasurementMode.Cp_D, ranging_mode: RangingMode | int = RangingMode.AUTO, fixed_range_val: int | None = None, hold_delay: float = 0, delay: float = 0, step_delay: float = 0, trigger_delay: float = 0, measure_delay: float = 0, abort_enabled: Abort | int = Abort.ENABLED, sweep_mode: SweepMode | int = SweepMode.LINEAR, volt_monitor: bool = True) None[source]

Convenience function which requires all inputs to properly setup a CV sweep measurement. Function sets parameters in the order given in the programming example in the manual. Returns error status after setting all params.

Parameters:
  • v_start – Starting voltage for sweep

  • v_end – End voltage for sweep

  • n_steps – Number of steps in the sweep

  • freq – frequency

  • ac_rms – AC voltage

  • post_sweep_voltage_condition – Source output value after the measurement is normally completed.

  • adc_mode – Sets the number of averaging samples or the averaging time set to the A/D converter of the MFCMU.

  • adc_coef – the number of averaging samples or the averaging time.

  • imp_model – specifies the units of the parameter measured by the MFCMU.

  • ranging_mode – Auto range or Fixed range

  • fixed_range_val – Integer 0 or more. Available measurement ranges depend on the output signal frequency. See measurement_range_for_non_auto parameter for more info.

  • hold_delay – Hold time (in seconds) that is the wait time after starting measurement and before starting delay time for the first step 0 to 655.35, with 10 ms resolution.

  • delay – Delay time (in seconds) that is the wait time after starting to force a step output and before starting a step measurement.

  • step_delay – Step delay time (in seconds) that is the wait time after starting a step measurement and before starting to force the next step output. 0 to 1, with 0.1 ms resolution. If step_delay is shorter than the measurement time, the B1500 waits until the measurement completes, then forces the next step output.

  • trigger_delay – Step source trigger delay time (in seconds) that is the wait time after completing a step output setup and before sending a step output setup completion trigger. 0 to delay, with 0.1 ms resolution.

  • measure_delay – Step measurement trigger delay time (in seconds) that is the wait time after receiving a start step measurement trigger and before starting a step measurement. 0 to 65.535, with 0.1 ms resolution.

  • abort_enabled – Boolean, enables or disables the automatic abort function for the CV sweep measurement.

  • sweep_mode – Linear sweep, log sweep, linear 2 way sweep or log 2 way sweep

  • volt_monitor – Accepts Boolean. If True, CV sweep measurement outputs 4 parameter; primary parameter(for ex Capacitance), secondary parameter(for ex Dissipation), ac source voltage and dc source voltage. If False, the measurement only outputs primary and secondary parameter.

__getitem__(key: str) Callable[..., Any] | Parameter

Delegate instrument[‘name’] to parameter or function ‘name’.

__getstate__() None

Prevent pickling instruments, and give a nice error message.

__repr__() str

Custom repr to give parent information

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.

Note

We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.

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: type[ParameterBase] | None = 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: 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 a ChannelTuple.

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:
  • KeyError – If this instrument already contains a submodule with this name.

  • TypeError – If the submodule that we are trying to add is not an instance of an Metadatable object.

property ancestors: tuple[InstrumentBase, ...]

Ancestors in the form of a list of InstrumentBase

The list starts with the current module then the parent and the parents parent until the root instrument is reached.

ask(cmd: str) str
ask_raw(cmd: str) str
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.

clear_timer_count() None

This command clears the timer count. This command is effective for all measurement modes, regardless of the TSC setting. This command is not effective for the 4 byte binary data output format (FMT3 and FMT4).

delegate_attr_dicts: ClassVar[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 of self.

delegate_attr_objects: ClassVar[list[str]] = []

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

disable_outputs() None

Disables all outputs of this module by opening the output relays of its channels.

enable_outputs() None

Enables all outputs of this module by closing the output relays of its channels.

property full_name: str

Full name of the instrument.

For an InstrumentModule this includes all parents separated by _

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_component(full_name: str) MetadatableWithName

Recursively get a component of the instrument by full_name.

Parameters:

full_name – The name of the component to get.

Returns:

The component with the given name.

Raises:

KeyError – If the component does not exist.

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.

is_enabled() bool

Check if channels of this module are enabled.

Returns:

True if all channels of this module are enabled. False, otherwise.

property label: str

Nicely formatted label of the instrument.

load_metadata(metadata: Mapping[str, Any]) None

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

property name: str

Full name of the instrument

This is equivalent to full_name() for backwards compatibility.

property name_parts: list[str]

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs: ClassVar[list[str]] = []

A list of attribute names (strings) to not delegate to any other dictionary or object.

property parent: InstrumentBase

The parent instrument. By default, this is None. Any SubInstrument should subclass this to return the parent instrument.

parse_module_query_response() dict[SlotNr, str]

Extract installed module information from the given string and return the information as a dictionary.

Parameters:

response – Response str to UNT? 0 query.

Returns:

Dictionary from slot numbers to model name strings.

parse_spot_measurement_response() SpotResponse

Extract measured value and accompanying metadata from the string and return them as a dictionary.

Parameters:

response – Response str to spot measurement query.

Returns:

Dictionary with measured value and associated metadata (e.g. timestamp, channel number, etc.)

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. If False, 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: InstrumentBase

The topmost parent of this module.

For the root_instrument this is self.

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.

property short_name: str

Short name of the instrument.

For an InstrumentModule this does not include any parent names.

snapshot(update: bool | None = False) dict[str, 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: bool | None = False, params_to_skip_update: Sequence[str] | None = 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. If False, 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:

dict

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_raw(cmd: str) None
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, 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 via add_submodule().

log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
metadata: dict[str, Any] = {}
class qcodes.instrument_drivers.Keysight.KeysightB1530A(parent: KeysightB1500, name: str | None, slot_nr: int, **kwargs: Any)[source]

Bases: B1500Module

Driver for Keysight B1530A Waveform Generator/Fast Measurement Unit module for B1500 Semiconductor Parameter Analyzer.

Warning

At the moment this driver implements no functionality of the module.

Parameters:
  • parent – mainframe B1500 instance that this module belongs to

  • name – Name of the instrument instance to create. If None (Default), then the name is autogenerated from the instrument class.

  • slot_nr – Slot number of this module (not channel number)

Attributes:

MODULE_KIND

ancestors

Ancestors in the form of a list of InstrumentBase

delegate_attr_dicts

A list of names (strings) of dictionaries which are (or will be) attributes of self, whose keys should be treated as attributes of self.

delegate_attr_objects

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

full_name

Full name of the instrument.

label

Nicely formatted label of the instrument.

name

Full name of the instrument

name_parts

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs

A list of attribute names (strings) to not delegate to any other dictionary or object.

parent

The parent instrument.

root_instrument

The topmost parent of this module.

short_name

Short name of the instrument.

parameters

All the parameters supported by this instrument.

functions

All the functions supported by this instrument.

submodules

All the submodules of this instrument such as channel lists or logical groupings of parameters.

instrument_modules

All the InstrumentModule of this instrument Usually populated via add_submodule().

Methods:

__getitem__(key)

Delegate instrument['name'] to parameter or function 'name'.

__getstate__()

Prevent pickling instruments, and give a nice error message.

__repr__()

Custom repr to give parent information

add_function(name, **kwargs)

Bind one Function to this instrument.

add_parameter(name[, parameter_class])

Bind one Parameter to this instrument.

add_submodule(name, submodule)

Bind one submodule to this instrument.

ask(cmd)

ask_raw(cmd)

call(func_name, *args)

Shortcut for calling a function from its name.

clear_timer_count()

This command clears the timer count.

disable_outputs()

Disables all outputs of this module by opening the output relays of its channels.

enable_outputs()

Enables all outputs of this module by closing the output relays of its channels.

get(param_name)

Shortcut for getting a parameter from its name.

get_component(full_name)

Recursively get a component of the instrument by full_name.

invalidate_cache()

Invalidate the cache of all parameters on the instrument.

is_enabled()

Check if channels of this module are enabled.

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

parse_module_query_response()

Extract installed module information from the given string and return the information as a dictionary.

parse_spot_measurement_response()

Extract measured value and accompanying metadata from the string and return them as a dictionary.

print_readable_snapshot([update, max_chars])

Prints a readable version of the snapshot.

set(param_name, value)

Shortcut for setting a parameter from its name and new value.

snapshot([update])

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class NumpyJSONEncoder supports).

validate_status([verbose])

Validate the values of all gettable parameters

write(cmd)

write_raw(cmd)

MODULE_KIND: ModuleKind = 'WGFMU'
channels: tuple[ChNr, ...] = (ChNr(slot_nr), ChNr(int(f"{slot_nr:d}02")))
__getitem__(key: str) Callable[..., Any] | Parameter

Delegate instrument[‘name’] to parameter or function ‘name’.

__getstate__() None

Prevent pickling instruments, and give a nice error message.

__repr__() str

Custom repr to give parent information

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.

Note

We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.

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: type[ParameterBase] | None = 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: 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 a ChannelTuple.

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:
  • KeyError – If this instrument already contains a submodule with this name.

  • TypeError – If the submodule that we are trying to add is not an instance of an Metadatable object.

property ancestors: tuple[InstrumentBase, ...]

Ancestors in the form of a list of InstrumentBase

The list starts with the current module then the parent and the parents parent until the root instrument is reached.

ask(cmd: str) str
ask_raw(cmd: str) str
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.

clear_timer_count() None

This command clears the timer count. This command is effective for all measurement modes, regardless of the TSC setting. This command is not effective for the 4 byte binary data output format (FMT3 and FMT4).

delegate_attr_dicts: ClassVar[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 of self.

delegate_attr_objects: ClassVar[list[str]] = []

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

disable_outputs() None

Disables all outputs of this module by opening the output relays of its channels.

enable_outputs() None

Enables all outputs of this module by closing the output relays of its channels.

property full_name: str

Full name of the instrument.

For an InstrumentModule this includes all parents separated by _

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_component(full_name: str) MetadatableWithName

Recursively get a component of the instrument by full_name.

Parameters:

full_name – The name of the component to get.

Returns:

The component with the given name.

Raises:

KeyError – If the component does not exist.

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.

is_enabled() bool

Check if channels of this module are enabled.

Returns:

True if all channels of this module are enabled. False, otherwise.

property label: str

Nicely formatted label of the instrument.

load_metadata(metadata: Mapping[str, Any]) None

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

property name: str

Full name of the instrument

This is equivalent to full_name() for backwards compatibility.

property name_parts: list[str]

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs: ClassVar[list[str]] = []

A list of attribute names (strings) to not delegate to any other dictionary or object.

property parent: InstrumentBase

The parent instrument. By default, this is None. Any SubInstrument should subclass this to return the parent instrument.

parse_module_query_response() dict[SlotNr, str]

Extract installed module information from the given string and return the information as a dictionary.

Parameters:

response – Response str to UNT? 0 query.

Returns:

Dictionary from slot numbers to model name strings.

parse_spot_measurement_response() SpotResponse

Extract measured value and accompanying metadata from the string and return them as a dictionary.

Parameters:

response – Response str to spot measurement query.

Returns:

Dictionary with measured value and associated metadata (e.g. timestamp, channel number, etc.)

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. If False, 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: InstrumentBase

The topmost parent of this module.

For the root_instrument this is self.

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.

property short_name: str

Short name of the instrument.

For an InstrumentModule this does not include any parent names.

snapshot(update: bool | None = False) dict[str, 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: bool | None = False, params_to_skip_update: Sequence[str] | None = 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. If False, 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:

dict

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_raw(cmd: str) None
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, 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 via add_submodule().

log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
metadata: dict[str, Any] = {}
class qcodes.instrument_drivers.Keysight.KeysightB2200(name: str, address: str, **kwargs: Any)[source]

Bases: KeysightB220X

QCodes driver for B2200

Methods:

__del__()

Close the instrument and remove its instance record.

__getitem__(key)

Delegate instrument['name'] to parameter or function 'name'.

__getstate__()

Prevent pickling instruments, and give a nice error message.

__repr__()

Simplified repr giving just the class and name.

add_function(name, **kwargs)

Bind one Function to this instrument.

add_parameter(name[, parameter_class])

Bind one Parameter to this instrument.

add_submodule(name, submodule)

Bind one submodule to this instrument.

ask(cmd)

Write a command string to the hardware and return a response.

ask_raw(cmd)

Low-level interface to visa_handle.ask.

bias_disable_all_outputs()

Removes all outputs from list of ports that will be connected to GND input if port is unused and bias mode is enabled.

bias_disable_output(output)

Removes output from list of ports that will be connected to bias input if port is unused and bias mode is enabled.

bias_enable_all_outputs()

Adds all outputs to list of ports that will be connected to bias input if port is unused and bias mode is enabled.

bias_enable_output(output)

Adds output to list of ports that will be connected to bias input if port is unused and bias mode is enabled.

call(func_name, *args)

Shortcut for calling a function from its name.

clear_status()

Clears status register and error queue of the instrument.

close()

Disconnect and irreversibly tear down the instrument.

close_all()

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.

connect(input_ch, output_ch)

Connect given input/output pair.

connect_message([idn_param, begin_time])

Print a standard message on initial connection to an instrument.

connect_paths(paths)

couple_port_autodetect()

Autodetect Kelvin connections on Input ports

device_clear()

Clear the buffers of the device

disconnect(input_ch, output_ch)

Disconnect given Input/Output pair.

disconnect_all()

opens all connections.

disconnect_paths(paths)

exist(name[, instrument_class])

Check if an instrument with a given names exists (i.e. is already instantiated).

find_instrument(name[, instrument_class])

Find an existing instrument by name.

get(param_name)

Shortcut for getting a parameter from its name.

get_component(full_name)

Recursively get a component of the instrument by full_name.

get_idn()

Parse a standard VISA *IDN? response into an ID dict.

gnd_disable_all_outputs()

Removes all outputs from list of ports that will be connected to GND input if port is unused and bias mode is enabled.

gnd_disable_output(output)

Removes output from list of ports that will be connected to GND input if port is unused and bias mode is enabled.

gnd_enable_all_outputs()

Adds all outputs to list of ports that will be connected to GND input if port is unused and bias mode is enabled.

gnd_enable_output(output)

Adds output to list of ports that will be connected to GND input if port is unused and bias mode is enabled.

instances()

Get all currently defined instances of this instrument class.

invalidate_cache()

Invalidate the cache of all parameters on the instrument.

is_valid(instr_instance)

Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a "valid" instrument.

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

parse_channel_list(channel_list)

Generate a set of (input, output) tuples from a SCPI channel list string.

print_readable_snapshot([update, max_chars])

Prints a readable version of the snapshot.

record_instance(instance)

Record (a weak ref to) an instance in a class's instance list.

remove_instance(instance)

Remove a particular instance from the record.

reset()

Performs an instrument reset.

set(param_name, value)

Shortcut for setting a parameter from its name and new value.

set_address(address)

Set the address for this instrument.

set_terminator(terminator)

Change the read terminator to use.

snapshot([update])

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class NumpyJSONEncoder supports).

to_channel_list(paths)

validate_status([verbose])

Validate the values of all gettable parameters

write(cmd)

Write a command string with NO response to the hardware.

write_raw(cmd)

Low-level interface to visa_handle.write.

Attributes:

ancestors

Ancestors in the form of a list of InstrumentBase

delegate_attr_dicts

A list of names (strings) of dictionaries which are (or will be) attributes of self, whose keys should be treated as attributes of self.

delegate_attr_objects

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

full_name

Full name of the instrument.

label

Nicely formatted label of the instrument.

name

Full name of the instrument

name_parts

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs

A list of attribute names (strings) to not delegate to any other dictionary or object.

parent

The parent instrument.

root_instrument

The topmost parent of this module.

short_name

Short name of the instrument.

visa_handle

The VISA resource used by this instrument.

resource_manager

The VISA resource manager used by this instrument.

parameters

All the parameters supported by this instrument.

functions

All the functions supported by this instrument.

submodules

All the submodules of this instrument such as channel lists or logical groupings of parameters.

instrument_modules

All the InstrumentModule of this instrument Usually populated via add_submodule().

__del__() None

Close the instrument and remove its instance record.

__getitem__(key: str) Callable[..., Any] | Parameter

Delegate instrument[‘name’] to parameter or function ‘name’.

__getstate__() None

Prevent pickling instruments, and give a nice error message.

__repr__() str

Simplified repr giving just the class and 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.

Note

We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.

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: type[ParameterBase] | None = 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: 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 a ChannelTuple.

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:
  • KeyError – If this instrument already contains a submodule with this name.

  • TypeError – If the submodule that we are trying to add is not an instance of an Metadatable object.

property ancestors: tuple[InstrumentBase, ...]

Ancestors in the form of a list of InstrumentBase

The list starts with the current module then the parent and the parents parent 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 call super().ask(new_cmd). Subclasses that define a new hardware communication should instead override ask_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:

str

bias_disable_all_outputs() None

Removes all outputs from list of ports that will be connected to GND input if port is unused and bias mode is enabled.

bias_disable_output(output: int) None

Removes output from list of ports that will be connected to bias input if port is unused and bias mode is enabled.

Parameters:

output – int 1-48

bias_enable_all_outputs() None

Adds all outputs to list of ports that will be connected to bias input if port is unused and bias mode is enabled.

bias_enable_output(output: int) None

Adds output to list of ports that will be connected to bias input if port is unused and bias mode is enabled.

Parameters:

output – int 1-48

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.

clear_status() None

Clears status register and error queue of the instrument.

close() None

Disconnect and irreversibly tear down the instrument.

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(input_ch: int, output_ch: int) None

Connect given input/output pair.

Parameters:
  • input_ch – Input channel number 1-14

  • output_ch – Output channel number 1-48

connect_message(idn_param: str = 'IDN', begin_time: float | None = 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_timetime.time() when init started. Default is self._t0, set at start of Instrument.__init__.

connect_paths(paths: Sequence[tuple[int, int]]) None
couple_port_autodetect() None

Autodetect Kelvin connections on Input ports

This will detect Kelvin connections on the input ports and enable couple mode for found kelvin connections. Kelvin connections must use input pairs that can be couple-enabled in order to be autodetected.

{(1, 2), (3, 4), (5, 6), (7, 8), (9, 10), (11, 12), (13, 14)}

Also refer to the manual for more information.

delegate_attr_dicts: ClassVar[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 of self.

delegate_attr_objects: ClassVar[list[str]] = []

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

device_clear() None

Clear the buffers of the device

disconnect(input_ch: int, output_ch: int) None

Disconnect given Input/Output pair.

Parameters:
  • input_ch – Input channel number 1-14

  • output_ch – Output channel number 1-48

disconnect_all() None

opens all connections.

If ground or bias mode is enabled it will connect all outputs to the GND or Bias Port

disconnect_paths(paths: Sequence[tuple[int, int]]) None
static exist(name: str, instrument_class: type[Instrument] | None = 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: type[T] | None = None) T | Instrument

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:
  • KeyError – If no instrument of that name was found, or if its reference is invalid (dead).

  • TypeError – If a specific class was requested but a different type was found.

property full_name: str

Full name of the instrument.

For an InstrumentModule this includes all parents separated by _

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_component(full_name: str) MetadatableWithName

Recursively get a component of the instrument by full_name.

Parameters:

full_name – The name of the component to get.

Returns:

The component with the given name.

Raises:

KeyError – If the component does not exist.

get_idn() dict[str, str | None]

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.

gnd_disable_all_outputs() None

Removes all outputs from list of ports that will be connected to GND input if port is unused and bias mode is enabled.

gnd_disable_output(output: int) None

Removes output from list of ports that will be connected to GND input if port is unused and bias mode is enabled.

Parameters:

output – int 1-48

gnd_enable_all_outputs() None

Adds all outputs to list of ports that will be connected to GND input if port is unused and bias mode is enabled.

gnd_enable_output(output: int) None

Adds output to list of ports that will be connected to GND input if port is unused and bias mode is enabled.

Parameters:

output – int 1-48

classmethod instances() list[T]

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.

property label: str

Nicely formatted label of the instrument.

load_metadata(metadata: Mapping[str, Any]) None

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

property name: str

Full name of the instrument

This is equivalent to full_name() for backwards compatibility.

property name_parts: list[str]

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs: ClassVar[list[str]] = []

A list of attribute names (strings) to not delegate to any other dictionary or object.

property parent: InstrumentBase | None

The parent instrument. By default, this is None. Any SubInstrument should subclass this to return the parent instrument.

static parse_channel_list(channel_list: str) set[tuple[int, int]]

Generate a set of (input, output) tuples from a SCPI channel list string.

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. If False, 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

reset() None

Performs an instrument reset.

Does not reset error queue!

property root_instrument: InstrumentBase

The topmost parent of this module.

For the root_instrument this is self.

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: str | None) 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.

property short_name: str

Short name of the instrument.

For an InstrumentModule this does not include any parent names.

snapshot(update: bool | None = False) dict[str, 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: bool | None = True, params_to_skip_update: Sequence[str] | None = 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:

dict

to_channel_list(paths: Sequence[tuple[int, int]]) str
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 call super().write(new_cmd). Subclasses that define a new hardware communication should instead override write_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.

visabackend: str = visabackend
visa_handle: pyvisa.resources.MessageBasedResource = visa_handle

The VISA resource used by this instrument.

visalib: str | None = visalib
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, 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 via add_submodule().

log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
metadata: dict[str, Any] = {}
resource_manager = resource_manager

The VISA resource manager used by this instrument.

class qcodes.instrument_drivers.Keysight.KeysightB2201(name: str, address: str, **kwargs: Any)[source]

Bases: KeysightB220X

QCodes driver for B2201

Methods:

__del__()

Close the instrument and remove its instance record.

__getitem__(key)

Delegate instrument['name'] to parameter or function 'name'.

__getstate__()

Prevent pickling instruments, and give a nice error message.

__repr__()

Simplified repr giving just the class and name.

add_function(name, **kwargs)

Bind one Function to this instrument.

add_parameter(name[, parameter_class])

Bind one Parameter to this instrument.

add_submodule(name, submodule)

Bind one submodule to this instrument.

ask(cmd)

Write a command string to the hardware and return a response.

ask_raw(cmd)

Low-level interface to visa_handle.ask.

bias_disable_all_outputs()

Removes all outputs from list of ports that will be connected to GND input if port is unused and bias mode is enabled.

bias_disable_output(output)

Removes output from list of ports that will be connected to bias input if port is unused and bias mode is enabled.

bias_enable_all_outputs()

Adds all outputs to list of ports that will be connected to bias input if port is unused and bias mode is enabled.

bias_enable_output(output)

Adds output to list of ports that will be connected to bias input if port is unused and bias mode is enabled.

call(func_name, *args)

Shortcut for calling a function from its name.

clear_status()

Clears status register and error queue of the instrument.

close()

Disconnect and irreversibly tear down the instrument.

close_all()

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.

connect(input_ch, output_ch)

Connect given input/output pair.

connect_message([idn_param, begin_time])

Print a standard message on initial connection to an instrument.

connect_paths(paths)

couple_port_autodetect()

Autodetect Kelvin connections on Input ports

device_clear()

Clear the buffers of the device

disconnect(input_ch, output_ch)

Disconnect given Input/Output pair.

disconnect_all()

opens all connections.

disconnect_paths(paths)

exist(name[, instrument_class])

Check if an instrument with a given names exists (i.e. is already instantiated).

find_instrument(name[, instrument_class])

Find an existing instrument by name.

get(param_name)

Shortcut for getting a parameter from its name.

get_component(full_name)

Recursively get a component of the instrument by full_name.

get_idn()

Parse a standard VISA *IDN? response into an ID dict.

gnd_disable_all_outputs()

Removes all outputs from list of ports that will be connected to GND input if port is unused and bias mode is enabled.

gnd_disable_output(output)

Removes output from list of ports that will be connected to GND input if port is unused and bias mode is enabled.

gnd_enable_all_outputs()

Adds all outputs to list of ports that will be connected to GND input if port is unused and bias mode is enabled.

gnd_enable_output(output)

Adds output to list of ports that will be connected to GND input if port is unused and bias mode is enabled.

instances()

Get all currently defined instances of this instrument class.

invalidate_cache()

Invalidate the cache of all parameters on the instrument.

is_valid(instr_instance)

Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a "valid" instrument.

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

parse_channel_list(channel_list)

Generate a set of (input, output) tuples from a SCPI channel list string.

print_readable_snapshot([update, max_chars])

Prints a readable version of the snapshot.

record_instance(instance)

Record (a weak ref to) an instance in a class's instance list.

remove_instance(instance)

Remove a particular instance from the record.

reset()

Performs an instrument reset.

set(param_name, value)

Shortcut for setting a parameter from its name and new value.

set_address(address)

Set the address for this instrument.

set_terminator(terminator)

Change the read terminator to use.

snapshot([update])

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class NumpyJSONEncoder supports).

to_channel_list(paths)

validate_status([verbose])

Validate the values of all gettable parameters

write(cmd)

Write a command string with NO response to the hardware.

write_raw(cmd)

Low-level interface to visa_handle.write.

Attributes:

ancestors

Ancestors in the form of a list of InstrumentBase

delegate_attr_dicts

A list of names (strings) of dictionaries which are (or will be) attributes of self, whose keys should be treated as attributes of self.

delegate_attr_objects

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

full_name

Full name of the instrument.

label

Nicely formatted label of the instrument.

name

Full name of the instrument

name_parts

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs

A list of attribute names (strings) to not delegate to any other dictionary or object.

parent

The parent instrument.

root_instrument

The topmost parent of this module.

short_name

Short name of the instrument.

visa_handle

The VISA resource used by this instrument.

resource_manager

The VISA resource manager used by this instrument.

parameters

All the parameters supported by this instrument.

functions

All the functions supported by this instrument.

submodules

All the submodules of this instrument such as channel lists or logical groupings of parameters.

instrument_modules

All the InstrumentModule of this instrument Usually populated via add_submodule().

__del__() None

Close the instrument and remove its instance record.

__getitem__(key: str) Callable[..., Any] | Parameter

Delegate instrument[‘name’] to parameter or function ‘name’.

__getstate__() None

Prevent pickling instruments, and give a nice error message.

__repr__() str

Simplified repr giving just the class and 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.

Note

We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.

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: type[ParameterBase] | None = 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: 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 a ChannelTuple.

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:
  • KeyError – If this instrument already contains a submodule with this name.

  • TypeError – If the submodule that we are trying to add is not an instance of an Metadatable object.

property ancestors: tuple[InstrumentBase, ...]

Ancestors in the form of a list of InstrumentBase

The list starts with the current module then the parent and the parents parent 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 call super().ask(new_cmd). Subclasses that define a new hardware communication should instead override ask_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:

str

bias_disable_all_outputs() None

Removes all outputs from list of ports that will be connected to GND input if port is unused and bias mode is enabled.

bias_disable_output(output: int) None

Removes output from list of ports that will be connected to bias input if port is unused and bias mode is enabled.

Parameters:

output – int 1-48

bias_enable_all_outputs() None

Adds all outputs to list of ports that will be connected to bias input if port is unused and bias mode is enabled.

bias_enable_output(output: int) None

Adds output to list of ports that will be connected to bias input if port is unused and bias mode is enabled.

Parameters:

output – int 1-48

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.

clear_status() None

Clears status register and error queue of the instrument.

close() None

Disconnect and irreversibly tear down the instrument.

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(input_ch: int, output_ch: int) None

Connect given input/output pair.

Parameters:
  • input_ch – Input channel number 1-14

  • output_ch – Output channel number 1-48

connect_message(idn_param: str = 'IDN', begin_time: float | None = 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_timetime.time() when init started. Default is self._t0, set at start of Instrument.__init__.

connect_paths(paths: Sequence[tuple[int, int]]) None
couple_port_autodetect() None

Autodetect Kelvin connections on Input ports

This will detect Kelvin connections on the input ports and enable couple mode for found kelvin connections. Kelvin connections must use input pairs that can be couple-enabled in order to be autodetected.

{(1, 2), (3, 4), (5, 6), (7, 8), (9, 10), (11, 12), (13, 14)}

Also refer to the manual for more information.

delegate_attr_dicts: ClassVar[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 of self.

delegate_attr_objects: ClassVar[list[str]] = []

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

device_clear() None

Clear the buffers of the device

disconnect(input_ch: int, output_ch: int) None

Disconnect given Input/Output pair.

Parameters:
  • input_ch – Input channel number 1-14

  • output_ch – Output channel number 1-48

disconnect_all() None

opens all connections.

If ground or bias mode is enabled it will connect all outputs to the GND or Bias Port

disconnect_paths(paths: Sequence[tuple[int, int]]) None
static exist(name: str, instrument_class: type[Instrument] | None = 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: type[T] | None = None) T | Instrument

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:
  • KeyError – If no instrument of that name was found, or if its reference is invalid (dead).

  • TypeError – If a specific class was requested but a different type was found.

property full_name: str

Full name of the instrument.

For an InstrumentModule this includes all parents separated by _

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_component(full_name: str) MetadatableWithName

Recursively get a component of the instrument by full_name.

Parameters:

full_name – The name of the component to get.

Returns:

The component with the given name.

Raises:

KeyError – If the component does not exist.

get_idn() dict[str, str | None]

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.

gnd_disable_all_outputs() None

Removes all outputs from list of ports that will be connected to GND input if port is unused and bias mode is enabled.

gnd_disable_output(output: int) None

Removes output from list of ports that will be connected to GND input if port is unused and bias mode is enabled.

Parameters:

output – int 1-48

gnd_enable_all_outputs() None

Adds all outputs to list of ports that will be connected to GND input if port is unused and bias mode is enabled.

gnd_enable_output(output: int) None

Adds output to list of ports that will be connected to GND input if port is unused and bias mode is enabled.

Parameters:

output – int 1-48

classmethod instances() list[T]

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.

property label: str

Nicely formatted label of the instrument.

load_metadata(metadata: Mapping[str, Any]) None

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

property name: str

Full name of the instrument

This is equivalent to full_name() for backwards compatibility.

property name_parts: list[str]

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs: ClassVar[list[str]] = []

A list of attribute names (strings) to not delegate to any other dictionary or object.

property parent: InstrumentBase | None

The parent instrument. By default, this is None. Any SubInstrument should subclass this to return the parent instrument.

static parse_channel_list(channel_list: str) set[tuple[int, int]]

Generate a set of (input, output) tuples from a SCPI channel list string.

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. If False, 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

reset() None

Performs an instrument reset.

Does not reset error queue!

property root_instrument: InstrumentBase

The topmost parent of this module.

For the root_instrument this is self.

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: str | None) 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.

property short_name: str

Short name of the instrument.

For an InstrumentModule this does not include any parent names.

snapshot(update: bool | None = False) dict[str, 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: bool | None = True, params_to_skip_update: Sequence[str] | None = 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:

dict

to_channel_list(paths: Sequence[tuple[int, int]]) str
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 call super().write(new_cmd). Subclasses that define a new hardware communication should instead override write_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.

visabackend: str = visabackend
visa_handle: pyvisa.resources.MessageBasedResource = visa_handle

The VISA resource used by this instrument.

visalib: str | None = visalib
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, 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 via add_submodule().

log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
metadata: dict[str, Any] = {}
resource_manager = resource_manager

The VISA resource manager used by this instrument.

class qcodes.instrument_drivers.Keysight.KeysightB2962A(name: str, address: str, **kwargs: Any)[source]

Bases: VisaInstrument

This is the qcodes driver for the Keysight B2962A 6.5 Digit Low Noise Power Source

Status: alpha-version.

Todo

  • Implement any remaining parameters supported by the device

  • Similar drivers have special handlers to map return values of 9.9e+37 to inf, is this needed?

Methods:

get_idn()

Parse a standard VISA *IDN? response into an ID dict.

__del__()

Close the instrument and remove its instance record.

__getitem__(key)

Delegate instrument['name'] to parameter or function 'name'.

__getstate__()

Prevent pickling instruments, and give a nice error message.

__repr__()

Simplified repr giving just the class and name.

add_function(name, **kwargs)

Bind one Function to this instrument.

add_parameter(name[, parameter_class])

Bind one Parameter to this instrument.

add_submodule(name, submodule)

Bind one submodule to this instrument.

ask(cmd)

Write a command string to the hardware and return a response.

ask_raw(cmd)

Low-level interface to visa_handle.ask.

call(func_name, *args)

Shortcut for calling a function from its name.

close()

Disconnect and irreversibly tear down the instrument.

close_all()

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.

connect_message([idn_param, begin_time])

Print a standard message on initial connection to an instrument.

device_clear()

Clear the buffers of the device

exist(name[, instrument_class])

Check if an instrument with a given names exists (i.e. is already instantiated).

find_instrument(name[, instrument_class])

Find an existing instrument by name.

get(param_name)

Shortcut for getting a parameter from its name.

get_component(full_name)

Recursively get a component of the instrument by full_name.

instances()

Get all currently defined instances of this instrument class.

invalidate_cache()

Invalidate the cache of all parameters on the instrument.

is_valid(instr_instance)

Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a "valid" instrument.

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

print_readable_snapshot([update, max_chars])

Prints a readable version of the snapshot.

record_instance(instance)

Record (a weak ref to) an instance in a class's instance list.

remove_instance(instance)

Remove a particular instance from the record.

set(param_name, value)

Shortcut for setting a parameter from its name and new value.

set_address(address)

Set the address for this instrument.

set_terminator(terminator)

Change the read terminator to use.

snapshot([update])

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class NumpyJSONEncoder supports).

validate_status([verbose])

Validate the values of all gettable parameters

write(cmd)

Write a command string with NO response to the hardware.

write_raw(cmd)

Low-level interface to visa_handle.write.

Attributes:

ancestors

Ancestors in the form of a list of InstrumentBase

delegate_attr_dicts

A list of names (strings) of dictionaries which are (or will be) attributes of self, whose keys should be treated as attributes of self.

delegate_attr_objects

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

full_name

Full name of the instrument.

label

Nicely formatted label of the instrument.

name

Full name of the instrument

name_parts

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs

A list of attribute names (strings) to not delegate to any other dictionary or object.

parent

The parent instrument.

root_instrument

The topmost parent of this module.

short_name

Short name of the instrument.

visa_handle

The VISA resource used by this instrument.

resource_manager

The VISA resource manager used by this instrument.

parameters

All the parameters supported by this instrument.

functions

All the functions supported by this instrument.

submodules

All the submodules of this instrument such as channel lists or logical groupings of parameters.

instrument_modules

All the InstrumentModule of this instrument Usually populated via add_submodule().

get_idn() dict[str, str | None][source]

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.

__del__() None

Close the instrument and remove its instance record.

__getitem__(key: str) Callable[..., Any] | Parameter

Delegate instrument[‘name’] to parameter or function ‘name’.

__getstate__() None

Prevent pickling instruments, and give a nice error message.

__repr__() str

Simplified repr giving just the class and 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.

Note

We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.

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: type[ParameterBase] | None = 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: 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 a ChannelTuple.

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:
  • KeyError – If this instrument already contains a submodule with this name.

  • TypeError – If the submodule that we are trying to add is not an instance of an Metadatable object.

property ancestors: tuple[InstrumentBase, ...]

Ancestors in the form of a list of InstrumentBase

The list starts with the current module then the parent and the parents parent 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 call super().ask(new_cmd). Subclasses that define a new hardware communication should instead override ask_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:

str

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.

close() None

Disconnect and irreversibly tear down the instrument.

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: float | None = 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_timetime.time() when init started. Default is self._t0, set at start of Instrument.__init__.

delegate_attr_dicts: ClassVar[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 of self.

delegate_attr_objects: ClassVar[list[str]] = []

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

device_clear() None

Clear the buffers of the device

static exist(name: str, instrument_class: type[Instrument] | None = 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: type[T] | None = None) T | Instrument

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:
  • KeyError – If no instrument of that name was found, or if its reference is invalid (dead).

  • TypeError – If a specific class was requested but a different type was found.

property full_name: str

Full name of the instrument.

For an InstrumentModule this includes all parents separated by _

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_component(full_name: str) MetadatableWithName

Recursively get a component of the instrument by full_name.

Parameters:

full_name – The name of the component to get.

Returns:

The component with the given name.

Raises:

KeyError – If the component does not exist.

classmethod instances() list[T]

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.

property label: str

Nicely formatted label of the instrument.

load_metadata(metadata: Mapping[str, Any]) None

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

property name: str

Full name of the instrument

This is equivalent to full_name() for backwards compatibility.

property name_parts: list[str]

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs: ClassVar[list[str]] = []

A list of attribute names (strings) to not delegate to any other dictionary or object.

property parent: InstrumentBase | None

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. If False, 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: InstrumentBase

The topmost parent of this module.

For the root_instrument this is self.

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: str | None) 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.

property short_name: str

Short name of the instrument.

For an InstrumentModule this does not include any parent names.

snapshot(update: bool | None = False) dict[str, 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: bool | None = True, params_to_skip_update: Sequence[str] | None = 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:

dict

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 call super().write(new_cmd). Subclasses that define a new hardware communication should instead override write_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.

visabackend: str = visabackend
visa_handle: pyvisa.resources.MessageBasedResource = visa_handle

The VISA resource used by this instrument.

visalib: str | None = visalib
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, 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 via add_submodule().

log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
metadata: dict[str, Any] = {}
resource_manager = resource_manager

The VISA resource manager used by this instrument.

class qcodes.instrument_drivers.Keysight.KeysightB2962AChannel(parent: Instrument, name: str, chan: int)[source]

Bases: InstrumentChannel

Parameters:
  • parent – The instrument to which the channel is attached.

  • name – The name of the channel

  • chan – The number of the channel in question (1-2)

Methods:

__getitem__(key)

Delegate instrument['name'] to parameter or function 'name'.

__getstate__()

Prevent pickling instruments, and give a nice error message.

__repr__()

Custom repr to give parent information

add_function(name, **kwargs)

Bind one Function to this instrument.

add_parameter(name[, parameter_class])

Bind one Parameter to this instrument.

add_submodule(name, submodule)

Bind one submodule to this instrument.

ask(cmd)

ask_raw(cmd)

call(func_name, *args)

Shortcut for calling a function from its name.

get(param_name)

Shortcut for getting a parameter from its name.

get_component(full_name)

Recursively get a component of the instrument by full_name.

invalidate_cache()

Invalidate the cache of all parameters on the instrument.

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

print_readable_snapshot([update, max_chars])

Prints a readable version of the snapshot.

set(param_name, value)

Shortcut for setting a parameter from its name and new value.

snapshot([update])

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class NumpyJSONEncoder supports).

validate_status([verbose])

Validate the values of all gettable parameters

write(cmd)

write_raw(cmd)

Attributes:

ancestors

Ancestors in the form of a list of InstrumentBase

delegate_attr_dicts

A list of names (strings) of dictionaries which are (or will be) attributes of self, whose keys should be treated as attributes of self.

delegate_attr_objects

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

full_name

Full name of the instrument.

label

Nicely formatted label of the instrument.

name

Full name of the instrument

name_parts

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs

A list of attribute names (strings) to not delegate to any other dictionary or object.

parent

The parent instrument.

root_instrument

The topmost parent of this module.

short_name

Short name of the instrument.

parameters

All the parameters supported by this instrument.

functions

All the functions supported by this instrument.

submodules

All the submodules of this instrument such as channel lists or logical groupings of parameters.

instrument_modules

All the InstrumentModule of this instrument Usually populated via add_submodule().

__getitem__(key: str) Callable[..., Any] | Parameter

Delegate instrument[‘name’] to parameter or function ‘name’.

__getstate__() None

Prevent pickling instruments, and give a nice error message.

__repr__() str

Custom repr to give parent information

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.

Note

We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.

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: type[ParameterBase] | None = 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: 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 a ChannelTuple.

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:
  • KeyError – If this instrument already contains a submodule with this name.

  • TypeError – If the submodule that we are trying to add is not an instance of an Metadatable object.

property ancestors: tuple[InstrumentBase, ...]

Ancestors in the form of a list of InstrumentBase

The list starts with the current module then the parent and the parents parent until the root instrument is reached.

ask(cmd: str) str
ask_raw(cmd: str) str
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: ClassVar[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 of self.

delegate_attr_objects: ClassVar[list[str]] = []

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

property full_name: str

Full name of the instrument.

For an InstrumentModule this includes all parents separated by _

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_component(full_name: str) MetadatableWithName

Recursively get a component of the instrument by full_name.

Parameters:

full_name – The name of the component to get.

Returns:

The component with the given name.

Raises:

KeyError – If the component does not exist.

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.

property label: str

Nicely formatted label of the instrument.

load_metadata(metadata: Mapping[str, Any]) None

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

property name: str

Full name of the instrument

This is equivalent to full_name() for backwards compatibility.

property name_parts: list[str]

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs: ClassVar[list[str]] = []

A list of attribute names (strings) to not delegate to any other dictionary or object.

property parent: InstrumentBase

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. If False, 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: InstrumentBase

The topmost parent of this module.

For the root_instrument this is self.

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.

property short_name: str

Short name of the instrument.

For an InstrumentModule this does not include any parent names.

snapshot(update: bool | None = False) dict[str, 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: bool | None = False, params_to_skip_update: Sequence[str] | None = 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. If False, 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:

dict

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_raw(cmd: str) None
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, 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 via add_submodule().

log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
metadata: dict[str, Any] = {}
class qcodes.instrument_drivers.Keysight.KeysightE4980A(name: str, address: str, terminator: str = '\n', **kwargs: Any)[source]

Bases: VisaInstrument

QCodes driver for E4980A Precision LCR Meter

Create an instance of the instrument.

Parameters:
  • name – Name of the instrument instance

  • address – Visa-resolvable instrument address.

  • terminator – Character to terminate messages with.

  • **kwargs – kwargs are forwarded to base class.

Attributes:

correction

measure_impedance

measurement

ancestors

Ancestors in the form of a list of InstrumentBase

delegate_attr_dicts

A list of names (strings) of dictionaries which are (or will be) attributes of self, whose keys should be treated as attributes of self.

delegate_attr_objects

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

full_name

Full name of the instrument.

label

Nicely formatted label of the instrument.

name

Full name of the instrument

name_parts

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs

A list of attribute names (strings) to not delegate to any other dictionary or object.

parent

The parent instrument.

root_instrument

The topmost parent of this module.

short_name

Short name of the instrument.

visa_handle

The VISA resource used by this instrument.

resource_manager

The VISA resource manager used by this instrument.

parameters

All the parameters supported by this instrument.

functions

All the functions supported by this instrument.

submodules

All the submodules of this instrument such as channel lists or logical groupings of parameters.

instrument_modules

All the InstrumentModule of this instrument Usually populated via add_submodule().

Methods:

__del__()

Close the instrument and remove its instance record.

__getitem__(key)

Delegate instrument['name'] to parameter or function 'name'.

__getstate__()

Prevent pickling instruments, and give a nice error message.

__repr__()

Simplified repr giving just the class and name.

add_function(name, **kwargs)

Bind one Function to this instrument.

add_parameter(name[, parameter_class])

Bind one Parameter to this instrument.

add_submodule(name, submodule)

Bind one submodule to this instrument.

ask(cmd)

Write a command string to the hardware and return a response.

ask_raw(cmd)

Low-level interface to visa_handle.ask.

call(func_name, *args)

Shortcut for calling a function from its name.

close()

Disconnect and irreversibly tear down the instrument.

close_all()

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.

connect_message([idn_param, begin_time])

Print a standard message on initial connection to an instrument.

device_clear()

Clear the buffers of the device

exist(name[, instrument_class])

Check if an instrument with a given names exists (i.e. is already instantiated).

find_instrument(name[, instrument_class])

Find an existing instrument by name.

get(param_name)

Shortcut for getting a parameter from its name.

get_component(full_name)

Recursively get a component of the instrument by full_name.

get_idn()

Parse a standard VISA *IDN? response into an ID dict.

instances()

Get all currently defined instances of this instrument class.

invalidate_cache()

Invalidate the cache of all parameters on the instrument.

is_valid(instr_instance)

Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a "valid" instrument.

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

print_readable_snapshot([update, max_chars])

Prints a readable version of the snapshot.

record_instance(instance)

Record (a weak ref to) an instance in a class's instance list.

remove_instance(instance)

Remove a particular instance from the record.

set(param_name, value)

Shortcut for setting a parameter from its name and new value.

set_address(address)

Set the address for this instrument.

set_terminator(terminator)

Change the read terminator to use.

snapshot([update])

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class NumpyJSONEncoder supports).

validate_status([verbose])

Validate the values of all gettable parameters

write(cmd)

Write a command string with NO response to the hardware.

write_raw(cmd)

Low-level interface to visa_handle.write.

system_errors()

Returns the oldest unread error message from the event log and removes it from the log.

clear_status()

Clears the following:

reset()

Resets the instrument settings.

property correction: KeysightE4980ACorrection
property measure_impedance: KeysightE4980AMeasurementPair
property measurement: KeysightE4980AMeasurementPair
__del__() None

Close the instrument and remove its instance record.

__getitem__(key: str) Callable[..., Any] | Parameter

Delegate instrument[‘name’] to parameter or function ‘name’.

__getstate__() None

Prevent pickling instruments, and give a nice error message.

__repr__() str

Simplified repr giving just the class and 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.

Note

We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.

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: type[ParameterBase] | None = 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: 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 a ChannelTuple.

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:
  • KeyError – If this instrument already contains a submodule with this name.

  • TypeError – If the submodule that we are trying to add is not an instance of an Metadatable object.

property ancestors: tuple[InstrumentBase, ...]

Ancestors in the form of a list of InstrumentBase

The list starts with the current module then the parent and the parents parent 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 call super().ask(new_cmd). Subclasses that define a new hardware communication should instead override ask_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:

str

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.

close() None

Disconnect and irreversibly tear down the instrument.

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: float | None = 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_timetime.time() when init started. Default is self._t0, set at start of Instrument.__init__.

delegate_attr_dicts: ClassVar[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 of self.

delegate_attr_objects: ClassVar[list[str]] = []

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

device_clear() None

Clear the buffers of the device

static exist(name: str, instrument_class: type[Instrument] | None = 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: type[T] | None = None) T | Instrument

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:
  • KeyError – If no instrument of that name was found, or if its reference is invalid (dead).

  • TypeError – If a specific class was requested but a different type was found.

property full_name: str

Full name of the instrument.

For an InstrumentModule this includes all parents separated by _

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_component(full_name: str) MetadatableWithName

Recursively get a component of the instrument by full_name.

Parameters:

full_name – The name of the component to get.

Returns:

The component with the given name.

Raises:

KeyError – If the component does not exist.

get_idn() dict[str, str | None]

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[T]

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.

property label: str

Nicely formatted label of the instrument.

load_metadata(metadata: Mapping[str, Any]) None

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

property name: str

Full name of the instrument

This is equivalent to full_name() for backwards compatibility.

property name_parts: list[str]

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs: ClassVar[list[str]] = []

A list of attribute names (strings) to not delegate to any other dictionary or object.

property parent: InstrumentBase | None

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. If False, 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: InstrumentBase

The topmost parent of this module.

For the root_instrument this is self.

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: str | None) 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.

property short_name: str

Short name of the instrument.

For an InstrumentModule this does not include any parent names.

snapshot(update: bool | None = False) dict[str, 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: bool | None = True, params_to_skip_update: Sequence[str] | None = 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:

dict

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 call super().write(new_cmd). Subclasses that define a new hardware communication should instead override write_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.

visabackend: str = visabackend
visa_handle: pyvisa.resources.MessageBasedResource = visa_handle

The VISA resource used by this instrument.

visalib: str | None = visalib
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, 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 via add_submodule().

log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
metadata: dict[str, Any] = {}
resource_manager = resource_manager

The VISA resource manager used by this instrument.

system_errors() str[source]

Returns the oldest unread error message from the event log and removes it from the log.

clear_status() None[source]
Clears the following:

Error Queue Status Byte Register Standard Event Status Register Operation Status Event Register Questionable Status Event Register (No Query)

reset() None[source]

Resets the instrument settings.

class qcodes.instrument_drivers.Keysight.KeysightE4980ACorrection(parent: VisaInstrument, name: str)[source]

Bases: InstrumentChannel

Module for correction settings.

Methods:

__getitem__(key)

Delegate instrument['name'] to parameter or function 'name'.

__getstate__()

Prevent pickling instruments, and give a nice error message.

__repr__()

Custom repr to give parent information

add_function(name, **kwargs)

Bind one Function to this instrument.

add_parameter(name[, parameter_class])

Bind one Parameter to this instrument.

add_submodule(name, submodule)

Bind one submodule to this instrument.

ask(cmd)

ask_raw(cmd)

call(func_name, *args)

Shortcut for calling a function from its name.

get(param_name)

Shortcut for getting a parameter from its name.

get_component(full_name)

Recursively get a component of the instrument by full_name.

invalidate_cache()

Invalidate the cache of all parameters on the instrument.

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

print_readable_snapshot([update, max_chars])

Prints a readable version of the snapshot.

set(param_name, value)

Shortcut for setting a parameter from its name and new value.

snapshot([update])

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class NumpyJSONEncoder supports).

validate_status([verbose])

Validate the values of all gettable parameters

write(cmd)

write_raw(cmd)

Attributes:

ancestors

Ancestors in the form of a list of InstrumentBase

delegate_attr_dicts

A list of names (strings) of dictionaries which are (or will be) attributes of self, whose keys should be treated as attributes of self.

delegate_attr_objects

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

full_name

Full name of the instrument.

label

Nicely formatted label of the instrument.

name

Full name of the instrument

name_parts

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs

A list of attribute names (strings) to not delegate to any other dictionary or object.

parent

The parent instrument.

root_instrument

The topmost parent of this module.

short_name

Short name of the instrument.

parameters

All the parameters supported by this instrument.

functions

All the functions supported by this instrument.

submodules

All the submodules of this instrument such as channel lists or logical groupings of parameters.

instrument_modules

All the InstrumentModule of this instrument Usually populated via add_submodule().

__getitem__(key: str) Callable[..., Any] | Parameter

Delegate instrument[‘name’] to parameter or function ‘name’.

__getstate__() None

Prevent pickling instruments, and give a nice error message.

__repr__() str

Custom repr to give parent information

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.

Note

We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.

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: type[ParameterBase] | None = 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: 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 a ChannelTuple.

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:
  • KeyError – If this instrument already contains a submodule with this name.

  • TypeError – If the submodule that we are trying to add is not an instance of an Metadatable object.

property ancestors: tuple[InstrumentBase, ...]

Ancestors in the form of a list of InstrumentBase

The list starts with the current module then the parent and the parents parent until the root instrument is reached.

ask(cmd: str) str
ask_raw(cmd: str) str
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: ClassVar[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 of self.

delegate_attr_objects: ClassVar[list[str]] = []

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

property full_name: str

Full name of the instrument.

For an InstrumentModule this includes all parents separated by _

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_component(full_name: str) MetadatableWithName

Recursively get a component of the instrument by full_name.

Parameters:

full_name – The name of the component to get.

Returns:

The component with the given name.

Raises:

KeyError – If the component does not exist.

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.

property label: str

Nicely formatted label of the instrument.

load_metadata(metadata: Mapping[str, Any]) None

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

property name: str

Full name of the instrument

This is equivalent to full_name() for backwards compatibility.

property name_parts: list[str]

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs: ClassVar[list[str]] = []

A list of attribute names (strings) to not delegate to any other dictionary or object.

property parent: InstrumentBase

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. If False, 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: InstrumentBase

The topmost parent of this module.

For the root_instrument this is self.

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.

property short_name: str

Short name of the instrument.

For an InstrumentModule this does not include any parent names.

snapshot(update: bool | None = False) dict[str, 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: bool | None = False, params_to_skip_update: Sequence[str] | None = 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. If False, 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:

dict

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_raw(cmd: str) None
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, 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 via add_submodule().

log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
metadata: dict[str, Any] = {}
class qcodes.instrument_drivers.Keysight.KeysightE4980AMeasurementPair(name: str, names: Sequence[str], units: Sequence[str], **kwargs: Any)[source]

Bases: MultiParameter

Data class for E4980A measurement, which will always return two items at once.

The two items are for two different parameters, depending on the measurement function. Hence, the names of the two attributes are created from the “names” tuple of the measurement functions.

Examples

To create a measurement data with capacitance=1.2, and dissipation_factor=3.4.

>>> data = KeysightE4980AMeasurementPair(name="CPD",
                            names=("capacitance", "dissipation_factor"),
                            units=("F", ""))
>>> data.set((1.2, 3.4))
>>> data.get()
(1.2, 3.4)

Attributes:

value

abstract

full_name

Name of the parameter including the name of the instrument and submodule that the parameter may be bound to.

full_names

Names of the parameter components including the name of the instrument and submodule that the parameter may be bound to.

gettable

Is it allowed to call get on this parameter?

instrument

Return the first instrument that this parameter is bound to.

inter_delay

Delay time between consecutive set operations.

name

Name of the parameter.

name_parts

List of the parts that make up the full name of this parameter

post_delay

Delay time after start of set operation, for each set.

raw_value

Note that this property will be deprecated soon.

register_name

Name that will be used to register this parameter in a dataset By default, this returns full_name or the value of the register_name argument if it was passed at initialization.

root_instrument

Return the fundamental instrument that this parameter belongs too.

setpoint_full_names

Full names of setpoints including instrument names, if available

settable

Is it allowed to call set on this parameter?

short_name

Short name of the parameter.

short_names

short_names is identical to names i.e. the names of the parameter parts but does not add the instrument name.

snapshot_value

If True the value of the parameter will be included in the snapshot.

step

Stepsize that this Parameter uses during set operation.

underlying_instrument

Returns an instance of the underlying hardware instrument that this parameter communicates with, per this parameter's implementation.

validators

Tuple of all validators associated with the parameter.

vals

The first validator of the parameter.

Methods:

set_raw(value)

set_raw is called to perform the actual setting of a parameter on the instrument.

get_raw()

get_raw is called to perform the actual data acquisition from the instrument.

__str__()

Include the instrument name with the Parameter name if possible.

add_validator(vals)

Add a validator for the parameter.

extra_validator(vals)

Contextmanager to to temporarily add a validator to the parameter within the given context.

get_ramp_values(value[, step])

Return values to sweep from current value to target value.

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

remove_validator()

Remove the last validator added to the parameter and return it.

restore_at_exit([allow_changes])

Use a context manager to restore the value of a parameter after a with block.

set_to(value[, allow_changes])

Use a context manager to temporarily set a parameter to a value.

snapshot([update])

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

State of the parameter as a JSON-compatible dict (everything that the custom JSON encoder class NumpyJSONEncoder supports).

validate(value)

Validate the value supplied.

value: tuple[float, float] = (0.0, 0.0)
set_raw(value: tuple[float, float]) None[source]

set_raw is called to perform the actual setting of a parameter on the instrument. This method should either be overwritten to perform the desired operation or alternatively for Parameter a suitable method is automatically generated if set_cmd is supplied to the parameter constructor. The method is automatically wrapped to provide a set method on the parameter instance.

get_raw() tuple[Any, ...][source]

get_raw is called to perform the actual data acquisition from the instrument. This method should either be overwritten to perform the desired operation or alternatively for Parameter a suitable method is automatically generated if get_cmd is supplied to the parameter constructor. The method is automatically wrapped to provide a get method on the parameter instance.

__str__() str

Include the instrument name with the Parameter name if possible.

property abstract: bool | None
add_validator(vals: Validator) None

Add a validator for the parameter. The parameter is validated against all validators in reverse order of how they are added.

Parameters:

vals – Validator to add to the parameter.

extra_validator(vals: Validator) Generator[None, None, None]

Contextmanager to to temporarily add a validator to the parameter within the given context. The validator is removed from the parameter when the context ends.

property full_name: str

Name of the parameter including the name of the instrument and submodule that the parameter may be bound to. The names are separated by underscores, like this: instrument_submodule_parameter.

property full_names: tuple[str, ...]

Names of the parameter components including the name of the instrument and submodule that the parameter may be bound to. The name parts are separated by underscores, like this: instrument_submodule_parameter

get_ramp_values(value: float | Sized, step: float | None = None) Sequence[float | Sized]

Return values to sweep from current value to target value. This method can be overridden to have a custom sweep behaviour. It can even be overridden by a generator.

Parameters:
  • value – target value

  • step – maximum step size

Returns:

List of stepped values, including target value.

property gettable: bool

Is it allowed to call get on this parameter?

property instrument: InstrumentBase | None

Return the first instrument that this parameter is bound to. E.g if this is bound to a channel it will return the channel and not the instrument that the channel is bound too. Use root_instrument() to get the real instrument.

property inter_delay: float

Delay time between consecutive set operations. The actual time will not be shorter than this, but may be longer if the underlying set call takes longer.

Typically used in conjunction with step to create an effective ramp rate, but can also be used without a step to enforce a delay between sets.

Getter:

Returns the current inter_delay.

Setter:

Sets the value of the inter_delay.

Raises:
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 parameter. This is identical to short_name().

property name_parts: list[str]

List of the parts that make up the full name of this parameter

property post_delay: float

Delay time after start of set operation, for each set. The actual time will not be shorter than this, but may be longer if the underlying set call takes longer.

Typically used in conjunction with step to create an effective ramp rate, but can also be used without a step to enforce a delay after every set. One might think of post_delay as how long a set operation is supposed to take. For example, there might be an instrument that needs extra time after setting a parameter although the command for setting the parameter returns quickly.

Getter:

Returns the current post_delay.

Setter:

Sets the value of the post_delay.

Raises:
property raw_value: Any

Note that this property will be deprecated soon. Use cache.raw_value instead.

Represents the cached raw value of the parameter.

Getter:

Returns the cached raw value of the parameter.

property register_name: str

Name that will be used to register this parameter in a dataset By default, this returns full_name or the value of the register_name argument if it was passed at initialization.

remove_validator() Validator | None

Remove the last validator added to the parameter and return it. Returns None if there are no validators associated with the parameter.

Returns:

The last validator added to the parameter or None if there are no validators associated with the parameter.

restore_at_exit(allow_changes: bool = True) _SetParamContext

Use a context manager to restore the value of a parameter after a with block.

By default, the parameter value may be changed inside the block, but this can be prevented with allow_changes=False. This can be useful, for example, for debugging a complex measurement that unintentionally modifies a parameter.

Example

>>> p = Parameter("p", set_cmd=None, get_cmd=None)
>>> p.set(2)
>>> with p.restore_at_exit():
...     p.set(3)
...     print(f"value inside with block: {p.get()}")  # prints 3
>>> print(f"value after with block: {p.get()}")  # prints 2
>>> with p.restore_at_exit(allow_changes=False):
...     p.set(5)  # raises an exception
property root_instrument: InstrumentBase | None

Return the fundamental instrument that this parameter belongs too. E.g if the parameter is bound to a channel this will return the fundamental instrument that that channel belongs to. Use instrument() to get the channel.

set_to(value: Any, allow_changes: bool = False) _SetParamContext

Use a context manager to temporarily set a parameter to a value. By default, the parameter value cannot be changed inside the context. This may be overridden with allow_changes=True.

Examples

>>> from qcodes.parameters import Parameter
>>> p = Parameter("p", set_cmd=None, get_cmd=None)
>>> p.set(2)
>>> with p.set_to(3):
...     print(f"p value in with block {p.get()}")  # prints 3
...     p.set(5)  # raises an exception
>>> print(f"p value outside with block {p.get()}")  # prints 2
>>> with p.set_to(3, allow_changes=True):
...     p.set(5)  # now this works
>>> print(f"value after second block: {p.get()}")  # still prints 2
property setpoint_full_names: Sequence[Sequence[str]] | None

Full names of setpoints including instrument names, if available

property settable: bool

Is it allowed to call set on this parameter?

property short_name: str

Short name of the parameter. This is without the name of the instrument or submodule that the parameter may be bound to. For full name refer to full_name().

property short_names: tuple[str, ...]

short_names is identical to names i.e. the names of the parameter parts but does not add the instrument name.

It exists for consistency with instruments and other parameters.

snapshot(update: bool | None = False) dict[str, 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: bool | None = True, params_to_skip_update: Sequence[str] | None = None) dict[Any, Any]

State of the parameter as a JSON-compatible dict (everything that the custom JSON encoder class NumpyJSONEncoder supports).

If the parameter has been initiated with snapshot_value=False, the snapshot will NOT include the value and raw_value of the parameter.

Parameters:
  • update – If True, update the state by calling parameter.get() unless snapshot_get of the parameter is False. If update is None, use the current value from the cache unless the cache is invalid. If False, never call parameter.get().

  • params_to_skip_update – No effect but may be passed from superclass

Returns:

base snapshot

property snapshot_value: bool

If True the value of the parameter will be included in the snapshot.

property step: float | None

Stepsize that this Parameter uses during set operation. Stepsize must be a positive number or None. If step is a positive number, this is the maximum value change allowed in one hardware call, so a single set can result in many calls to the hardware if the starting value is far from the target. All but the final change will attempt to change by +/- step exactly. If step is None stepping will not be used.

Getter:

Returns the current stepsize.

Setter:

Sets the value of the step.

Raises:
  • TypeError – if step is set to not numeric or None

  • ValueError – if step is set to negative

  • TypeError – if step is set to not integer or None for an integer parameter

  • TypeError – if step is set to not a number on None

property underlying_instrument: InstrumentBase | None

Returns an instance of the underlying hardware instrument that this parameter communicates with, per this parameter’s implementation.

This is useful in the case where a parameter does not belongs to an instrument instance that represents a real hardware instrument but actually uses a real hardware instrument in its implementation (e.g. via calls to one or more parameters of that real hardware instrument). This is also useful when a parameter does belong to an instrument instance but that instance does not represent the real hardware instrument that the parameter interacts with: hence root_instrument of the parameter cannot be the hardware_instrument, however underlying_instrument can be implemented to return the hardware_instrument.

By default it returns the root_instrument of the parameter.

validate(value: Any) None

Validate the value supplied.

Parameters:

value – value to validate

Raises:
  • TypeError – If the value is of the wrong type.

  • ValueError – If the value is outside the bounds specified by the validator.

property validators: tuple[Validator, ...]

Tuple of all validators associated with the parameter.

Getter:

All validators associated with the parameter.

property vals: Validator | None

The first validator of the parameter. None if no validators are set for this parameter.

Getter:

Returns the first validator or None if no validators.

Setter:

Sets the first validator. Set to None to remove the first validator.

Raises:

RuntimeError – If removing the first validator when more than one validator is set.

cache: _CacheProtocol
get_latest: GetLatest
get: Callable[..., ParamDataType]
set: Callable[..., None]
metadata: dict[str, Any]
class qcodes.instrument_drivers.Keysight.KeysightE4980AMeasurements[source]

Bases: object

All the measurement function for E4980A LCR meter. See user’s guide P353 https://literature.cdn.keysight.com/litweb/pdf/E4980-90230.pdf?id=789356

Attributes:

CPD(*args, **kwargs)

CPQ(*args, **kwargs)

CPG(*args, **kwargs)

CPRP(*args, **kwargs)

CSD(*args, **kwargs)

CSQ(*args, **kwargs)

CSRS(*args, **kwargs)

LPD(*args, **kwargs)

LPQ(*args, **kwargs)

LPG(*args, **kwargs)

LPRP(*args, **kwargs)

LSD(*args, **kwargs)

LSQ(*args, **kwargs)

LSRS(*args, **kwargs)

LSRD(*args, **kwargs)

RX(*args, **kwargs)

ZTD(*args, **kwargs)

ZTR(*args, **kwargs)

GB(*args, **kwargs)

YTD(*args, **kwargs)

YTR(*args, **kwargs)

VDID(*args, **kwargs)

CPD(*args: Any, **kwargs: Any) Any | None = <qcodes.instrument_drivers.Keysight.keysight_e4980a.KeysightE4980AMeasurementPair: CPD at 140265265964944>
CPQ(*args: Any, **kwargs: Any) Any | None = <qcodes.instrument_drivers.Keysight.keysight_e4980a.KeysightE4980AMeasurementPair: CPQ at 140265272494800>
CPG(*args: Any, **kwargs: Any) Any | None = <qcodes.instrument_drivers.Keysight.keysight_e4980a.KeysightE4980AMeasurementPair: CPG at 140265283847056>
CPRP(*args: Any, **kwargs: Any) Any | None = <qcodes.instrument_drivers.Keysight.keysight_e4980a.KeysightE4980AMeasurementPair: CPRP at 140265265968272>
CSD(*args: Any, **kwargs: Any) Any | None = <qcodes.instrument_drivers.Keysight.keysight_e4980a.KeysightE4980AMeasurementPair: CSD at 140265265968848>
CSQ(*args: Any, **kwargs: Any) Any | None = <qcodes.instrument_drivers.Keysight.keysight_e4980a.KeysightE4980AMeasurementPair: CSQ at 140265265965264>
CSRS(*args: Any, **kwargs: Any) Any | None = <qcodes.instrument_drivers.Keysight.keysight_e4980a.KeysightE4980AMeasurementPair: CSRS at 140265265970000>
LPD(*args: Any, **kwargs: Any) Any | None = <qcodes.instrument_drivers.Keysight.keysight_e4980a.KeysightE4980AMeasurementPair: LPD at 140265265970576>
LPQ(*args: Any, **kwargs: Any) Any | None = <qcodes.instrument_drivers.Keysight.keysight_e4980a.KeysightE4980AMeasurementPair: LPQ at 140265265965072>
LPG(*args: Any, **kwargs: Any) Any | None = <qcodes.instrument_drivers.Keysight.keysight_e4980a.KeysightE4980AMeasurementPair: LPG at 140265265969424>
LPRP(*args: Any, **kwargs: Any) Any | None = <qcodes.instrument_drivers.Keysight.keysight_e4980a.KeysightE4980AMeasurementPair: LPRP at 140265265988752>
LSD(*args: Any, **kwargs: Any) Any | None = <qcodes.instrument_drivers.Keysight.keysight_e4980a.KeysightE4980AMeasurementPair: LSD at 140265265989392>
LSQ(*args: Any, **kwargs: Any) Any | None = <qcodes.instrument_drivers.Keysight.keysight_e4980a.KeysightE4980AMeasurementPair: LSQ at 140265265990032>
LSRS(*args: Any, **kwargs: Any) Any | None = <qcodes.instrument_drivers.Keysight.keysight_e4980a.KeysightE4980AMeasurementPair: LSRS at 140265265990800>
LSRD(*args: Any, **kwargs: Any) Any | None = <qcodes.instrument_drivers.Keysight.keysight_e4980a.KeysightE4980AMeasurementPair: LSRD at 140265265991504>
RX(*args: Any, **kwargs: Any) Any | None = <qcodes.instrument_drivers.Keysight.keysight_e4980a.KeysightE4980AMeasurementPair: RX at 140265265992144>
ZTD(*args: Any, **kwargs: Any) Any | None = <qcodes.instrument_drivers.Keysight.keysight_e4980a.KeysightE4980AMeasurementPair: ZTD at 140265265992848>
ZTR(*args: Any, **kwargs: Any) Any | None = <qcodes.instrument_drivers.Keysight.keysight_e4980a.KeysightE4980AMeasurementPair: ZTR at 140265265993552>
GB(*args: Any, **kwargs: Any) Any | None = <qcodes.instrument_drivers.Keysight.keysight_e4980a.KeysightE4980AMeasurementPair: GB at 140265265994256>
YTD(*args: Any, **kwargs: Any) Any | None = <qcodes.instrument_drivers.Keysight.keysight_e4980a.KeysightE4980AMeasurementPair: YTD at 140265265994960>
YTR(*args: Any, **kwargs: Any) Any | None = <qcodes.instrument_drivers.Keysight.keysight_e4980a.KeysightE4980AMeasurementPair: YTR at 140265265995728>
VDID(*args: Any, **kwargs: Any) Any | None = <qcodes.instrument_drivers.Keysight.keysight_e4980a.KeysightE4980AMeasurementPair: VDID at 140265265996368>
class qcodes.instrument_drivers.Keysight.KeysightInfiniium(name: str, address: str, timeout: float = 20, channels: int = 4, silence_pyvisapy_warning: bool = False, **kwargs: Any)[source]

Bases: VisaInstrument

This is the QCoDeS driver for the Keysight Infiniium oscilloscopes

Initialises the oscilloscope.

Parameters:
  • name – Name of the instrument used by QCoDeS

  • address – Instrument address as used by VISA

  • timeout – Visa timeout, in secs.

  • channels – The number of channels on the scope.

  • silence_pyvisapy_warning – Don’t warn about pyvisa-py at startup

  • **kwargs – kwargs are forwarded to base class.

Methods:

__del__()

Close the instrument and remove its instance record.

__getitem__(key)

Delegate instrument['name'] to parameter or function 'name'.

__getstate__()

Prevent pickling instruments, and give a nice error message.

__repr__()

Simplified repr giving just the class and name.

add_function(name, **kwargs)

Bind one Function to this instrument.

add_parameter(name[, parameter_class])

Bind one Parameter to this instrument.

add_submodule(name, submodule)

Bind one submodule to this instrument.

ask(cmd)

Write a command string to the hardware and return a response.

ask_raw(cmd)

Low-level interface to visa_handle.ask.

call(func_name, *args)

Shortcut for calling a function from its name.

close()

Disconnect and irreversibly tear down the instrument.

close_all()

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.

connect_message([idn_param, begin_time])

Print a standard message on initial connection to an instrument.

device_clear()

Clear the buffers of the device

exist(name[, instrument_class])

Check if an instrument with a given names exists (i.e. is already instantiated).

find_instrument(name[, instrument_class])

Find an existing instrument by name.

get(param_name)

Shortcut for getting a parameter from its name.

get_component(full_name)

Recursively get a component of the instrument by full_name.

get_idn()

Parse a standard VISA *IDN? response into an ID dict.

instances()

Get all currently defined instances of this instrument class.

invalidate_cache()

Invalidate the cache of all parameters on the instrument.

is_valid(instr_instance)

Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a "valid" instrument.

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

print_readable_snapshot([update, max_chars])

Prints a readable version of the snapshot.

record_instance(instance)

Record (a weak ref to) an instance in a class's instance list.

remove_instance(instance)

Remove a particular instance from the record.

run()

Set the scope in run mode.

set(param_name, value)

Shortcut for setting a parameter from its name and new value.

set_address(address)

Set the address for this instrument.

set_terminator(terminator)

Change the read terminator to use.

snapshot([update])

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class NumpyJSONEncoder supports).

validate_status([verbose])

Validate the values of all gettable parameters

write(cmd)

Write a command string with NO response to the hardware.

write_raw(cmd)

Low-level interface to visa_handle.write.

stop()

Set the scope in stop mode.

single()

Take a single acquisition

update_all_setpoints()

Update the setpoints for all enabled channels.

digitize([timeout])

Digitize a full waveform and block until the acquisition is complete.

Attributes:

ancestors

Ancestors in the form of a list of InstrumentBase

delegate_attr_dicts

A list of names (strings) of dictionaries which are (or will be) attributes of self, whose keys should be treated as attributes of self.

delegate_attr_objects

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

full_name

Full name of the instrument.

label

Nicely formatted label of the instrument.

name

Full name of the instrument

name_parts

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs

A list of attribute names (strings) to not delegate to any other dictionary or object.

parent

The parent instrument.

root_instrument

The topmost parent of this module.

short_name

Short name of the instrument.

visa_handle

The VISA resource used by this instrument.

resource_manager

The VISA resource manager used by this instrument.

parameters

All the parameters supported by this instrument.

functions

All the functions supported by this instrument.

submodules

All the submodules of this instrument such as channel lists or logical groupings of parameters.

instrument_modules

All the InstrumentModule of this instrument Usually populated via add_submodule().

run_mode: Parameter = Parameter( name="run_mode", instrument=self, label="run mode", get_cmd=":RST?", vals=vals.Enum("RUN", "STOP", "SING"), )
timebase_range: Parameter = Parameter( name="timebase_range", instrument=self, label="Range of the time axis", unit="s", get_cmd=":TIM:RANG?", set_cmd=":TIM:RANG {}", vals=vals.Numbers(5e-12, 20), get_parser=float, )
timebase_position: Parameter = Parameter( name="timebase_position", instrument=self, label="Offset of the time axis", unit="s", get_cmd=":TIM:POS?", set_cmd=":TIM:POS {}", vals=vals.Numbers(), get_parser=float, )
timebase_roll_enabled: Parameter = Parameter( name="timebase_roll_enabled", instrument=self, label="Is rolling mode enabled", get_cmd=":TIM:ROLL:ENABLE?", set_cmd=":TIM:ROLL:ENABLE {}", val_mapping={True: 1, False: 0}, )
trigger_mode: Parameter = Parameter( name="trigger_mode", instrument=self, label="Trigger mode", get_cmd=":TRIG:MODE?", )
trigger_sweep: Parameter = Parameter( name="trigger_sweep", instrument=self, label="Trigger sweep mode", get_cmd=":TRIG:SWE?", set_cmd=":TRIG:SWE {}", vals=vals.Enum("AUTO", "TRIG"), )
trigger_state: Parameter = Parameter( name="trigger_state", instrument=self, label="Trigger state", get_cmd=":AST?", vals=vals.Enum("ARM", "TRIG", "ATRIG", "ADONE"), snapshot_value=False, )
trigger_edge_source: Parameter = Parameter( name="trigger_edge_source", instrument=self, label="Source channel for the edge trigger", get_cmd=":TRIGger:EDGE:SOURce?", set_cmd=":TRIGger:EDGE:SOURce {}", vals=vals.Enum( *( [f"CHAN{i}" for i in range(1, 4 + 1)] + [f"DIG{i}" for i in range(16 + 1)] + ["AUX", "LINE"] ) ), )
trigger_edge_slope: Parameter = Parameter( name="trigger_edge_slope", instrument=self, label="slope of the edge trigger", get_cmd=":TRIGger:EDGE:SLOPe?", set_cmd=":TRIGger:EDGE:SLOPe {}", vals=vals.Enum("POS", "POSITIVE", "NEG", "NEGATIVE", "EITH"), )
trigger_level_aux: Parameter = Parameter( name="trigger_level_aux", instrument=self, label="Trigger level AUX", unit="V", get_cmd=":TRIGger:LEVel? AUX", set_cmd=":TRIGger:LEVel AUX,{}", get_parser=float, vals=vals.Numbers(), )
acquire_points: Parameter = Parameter( name="acquire_points", instrument=self, label="sample points", get_cmd=":ACQ:POIN?", set_cmd=":ACQ:POIN {}", get_parser=int, vals=vals.Numbers(min_value=self.min_pts, max_value=self.max_pts), )
sample_rate: Parameter = Parameter( name="sample_rate", instrument=self, label="sample rate", get_cmd=":ACQ:SRAT?", set_cmd=":ACQ:SRAT {}", unit="Hz", get_parser=float, vals=vals.Numbers(min_value=self.min_srat, max_value=self.max_srat), )
bandwidth: Parameter = Parameter( name="bandwidth", instrument=self, label="bandwidth", get_cmd=":ACQ:BAND?", set_cmd=":ACQ:BAND {}", unit="Hz", get_parser=float, vals=vals.Numbers(min_value=self.min_bw, max_value=self.max_bw), )
acquire_interpolate: Parameter = Parameter( name="acquire_interpolate", instrument=self, get_cmd=":ACQ:INTerpolate?", set_cmd=":ACQuire:INTerpolate {}", vals=vals.Enum(0, 1, "INT1", "INT2", "INT4", "INT8", "INT16", "INT32"), )
acquire_mode: Parameter = Parameter( name="acquire_mode", instrument=self, label="Acquisition mode", get_cmd="ACQuire:MODE?", set_cmd="ACQuire:MODE {}", vals=vals.Enum( "ETIMe", "RTIMe", "PDETect", "HRESolution", "SEGMented", "SEGPdetect", "SEGHres", ), )
average: Parameter = Parameter( name="average", instrument=self, label="Averages", get_cmd=self._get_avg, set_cmd=self._set_avg, vals=vals.Ints(min_value=1, max_value=10486575), )
auto_digitize: Parameter = Parameter( name="auto_digitize", instrument=self, label="Auto digitize", set_cmd=None, get_cmd=None, val_mapping=create_on_off_val_mapping(), docstring=( "Digitize before each waveform download. " "If you need to acquire from multiple channels simultaneously " "or you wish to acquire with the scope running freely, " "set this value to False." ), initial_value=True, )
cache_setpoints: Parameter = Parameter( name="cache_setpoints", instrument=self, label="Cache setpoints", set_cmd=None, get_cmd=None, val_mapping=create_on_off_val_mapping(), docstring=( "Cache setpoints. If false, the preamble is queried before each" " acquisition, which may add latency to measurements. If you" " are taking repeated measurements, set this to True and update" " setpoints manually by calling `instr.chX.update_setpoints()`." ), initial_value=False, )
__del__() None

Close the instrument and remove its instance record.

__getitem__(key: str) Callable[..., Any] | Parameter

Delegate instrument[‘name’] to parameter or function ‘name’.

__getstate__() None

Prevent pickling instruments, and give a nice error message.

__repr__() str

Simplified repr giving just the class and 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.

Note

We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.

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: type[ParameterBase] | None = 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: 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 a ChannelTuple.

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:
  • KeyError – If this instrument already contains a submodule with this name.

  • TypeError – If the submodule that we are trying to add is not an instance of an Metadatable object.

property ancestors: tuple[InstrumentBase, ...]

Ancestors in the form of a list of InstrumentBase

The list starts with the current module then the parent and the parents parent 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 call super().ask(new_cmd). Subclasses that define a new hardware communication should instead override ask_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:

str

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.

close() None

Disconnect and irreversibly tear down the instrument.

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: float | None = 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_timetime.time() when init started. Default is self._t0, set at start of Instrument.__init__.

delegate_attr_dicts: ClassVar[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 of self.

delegate_attr_objects: ClassVar[list[str]] = []

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

device_clear() None

Clear the buffers of the device

static exist(name: str, instrument_class: type[Instrument] | None = 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: type[T] | None = None) T | Instrument

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:
  • KeyError – If no instrument of that name was found, or if its reference is invalid (dead).

  • TypeError – If a specific class was requested but a different type was found.

property full_name: str

Full name of the instrument.

For an InstrumentModule this includes all parents separated by _

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_component(full_name: str) MetadatableWithName

Recursively get a component of the instrument by full_name.

Parameters:

full_name – The name of the component to get.

Returns:

The component with the given name.

Raises:

KeyError – If the component does not exist.

get_idn() dict[str, str | None]

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[T]

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.

property label: str

Nicely formatted label of the instrument.

load_metadata(metadata: Mapping[str, Any]) None

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

property name: str

Full name of the instrument

This is equivalent to full_name() for backwards compatibility.

property name_parts: list[str]

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs: ClassVar[list[str]] = []

A list of attribute names (strings) to not delegate to any other dictionary or object.

property parent: InstrumentBase | None

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. If False, 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: InstrumentBase

The topmost parent of this module.

For the root_instrument this is self.

run() None[source]

Set the scope in run mode.

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: str | None) 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.

property short_name: str

Short name of the instrument.

For an InstrumentModule this does not include any parent names.

snapshot(update: bool | None = False) dict[str, 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: bool | None = True, params_to_skip_update: Sequence[str] | None = 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:

dict

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 call super().write(new_cmd). Subclasses that define a new hardware communication should instead override write_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.

visabackend: str = visabackend
visa_handle: pyvisa.resources.MessageBasedResource = visa_handle

The VISA resource used by this instrument.

visalib: str | None = visalib
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, 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 via add_submodule().

log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
metadata: dict[str, Any] = {}
resource_manager = resource_manager

The VISA resource manager used by this instrument.

stop() None[source]

Set the scope in stop mode.

single() None[source]

Take a single acquisition

update_all_setpoints() None[source]

Update the setpoints for all enabled channels. This method may be run at the beginning of a measurement rather than looping through each channel manually.

digitize(timeout: int | None = None) None[source]

Digitize a full waveform and block until the acquisition is complete.

Warning: If using pyvisa_py as your visa library, this will not work with acquisitions longer than a single timeout period. If you require long acquisitions either use Keysight/NI Visa or set timeout to be longer than the expected acquisition time.

class qcodes.instrument_drivers.Keysight.KeysightInfiniiumBoundMeasurement(parent: KeysightInfiniiumChannel | KeysightInfiniiumFunction, name: str, **kwargs: Any)[source]

Bases: AbstractMeasurementSubsystem

Initialize measurement subsystem bound to a specific channel

Methods:

__getitem__(key)

Delegate instrument['name'] to parameter or function 'name'.

__getstate__()

Prevent pickling instruments, and give a nice error message.

__repr__()

Custom repr to give parent information

add_function(name, **kwargs)

Bind one Function to this instrument.

add_parameter(name[, parameter_class])

Bind one Parameter to this instrument.

add_submodule(name, submodule)

Bind one submodule to this instrument.

ask(cmd)

ask_raw(cmd)

call(func_name, *args)

Shortcut for calling a function from its name.

get(param_name)

Shortcut for getting a parameter from its name.

get_component(full_name)

Recursively get a component of the instrument by full_name.

invalidate_cache()

Invalidate the cache of all parameters on the instrument.

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

print_readable_snapshot([update, max_chars])

Prints a readable version of the snapshot.

set(param_name, value)

Shortcut for setting a parameter from its name and new value.

snapshot([update])

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class NumpyJSONEncoder supports).

validate_status([verbose])

Validate the values of all gettable parameters

write(cmd)

write_raw(cmd)

Attributes:

ancestors

Ancestors in the form of a list of InstrumentBase

delegate_attr_dicts

A list of names (strings) of dictionaries which are (or will be) attributes of self, whose keys should be treated as attributes of self.

delegate_attr_objects

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

full_name

Full name of the instrument.

label

Nicely formatted label of the instrument.

name

Full name of the instrument

name_parts

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs

A list of attribute names (strings) to not delegate to any other dictionary or object.

parent

The parent instrument.

root_instrument

The topmost parent of this module.

short_name

Short name of the instrument.

parameters

All the parameters supported by this instrument.

functions

All the functions supported by this instrument.

submodules

All the submodules of this instrument such as channel lists or logical groupings of parameters.

instrument_modules

All the InstrumentModule of this instrument Usually populated via add_submodule().

__getitem__(key: str) Callable[..., Any] | Parameter

Delegate instrument[‘name’] to parameter or function ‘name’.

__getstate__() None

Prevent pickling instruments, and give a nice error message.

__repr__() str

Custom repr to give parent information

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.

Note

We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.

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: type[ParameterBase] | None = 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: 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 a ChannelTuple.

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:
  • KeyError – If this instrument already contains a submodule with this name.

  • TypeError – If the submodule that we are trying to add is not an instance of an Metadatable object.

property ancestors: tuple[InstrumentBase, ...]

Ancestors in the form of a list of InstrumentBase

The list starts with the current module then the parent and the parents parent until the root instrument is reached.

ask(cmd: str) str
ask_raw(cmd: str) str
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: ClassVar[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 of self.

delegate_attr_objects: ClassVar[list[str]] = []

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

property full_name: str

Full name of the instrument.

For an InstrumentModule this includes all parents separated by _

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_component(full_name: str) MetadatableWithName

Recursively get a component of the instrument by full_name.

Parameters:

full_name – The name of the component to get.

Returns:

The component with the given name.

Raises:

KeyError – If the component does not exist.

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.

property label: str

Nicely formatted label of the instrument.

load_metadata(metadata: Mapping[str, Any]) None

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

property name: str

Full name of the instrument

This is equivalent to full_name() for backwards compatibility.

property name_parts: list[str]

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs: ClassVar[list[str]] = []

A list of attribute names (strings) to not delegate to any other dictionary or object.

property parent: InstrumentBase

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. If False, 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: InstrumentBase

The topmost parent of this module.

For the root_instrument this is self.

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.

property short_name: str

Short name of the instrument.

For an InstrumentModule this does not include any parent names.

snapshot(update: bool | None = False) dict[str, 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: bool | None = False, params_to_skip_update: Sequence[str] | None = 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. If False, 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:

dict

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_raw(cmd: str) None
amplitude: Parameter = Parameter( name="amplitude", instrument=self, label="Voltage amplitude", get_cmd=self._create_query("VAMP"), get_parser=float, unit="V", snapshot_value=False, )
average: Parameter = Parameter( name="average", instrument=self, label="Voltage average", get_cmd=self._create_query("VAV", "DISP"), get_parser=float, unit="V", snapshot_value=False, )
base: Parameter = Parameter( name="base", instrument=self, label="Statistical base", get_cmd=self._create_query("VBAS"), get_parser=float, unit="V", snapshot_value=False, )
vlow: Parameter = Parameter( name="vlow", instrument=self, label="Lower threshold voltage", get_cmd=self._create_query("VLOW"), get_parser=float, unit="V", snapshot_value=False, )
vmid: Parameter = Parameter( name="vmid", instrument=self, label="Middle threshold voltage", get_cmd=self._create_query("VMID"), get_parser=float, unit="V", snapshot_value=False, )
vup: Parameter = Parameter( name="vup", instrument=self, label="Upper threshold voltage", get_cmd=self._create_query("VUPP"), get_parser=float, unit="V", snapshot_value=False, )
vmin: Parameter = Parameter( name="vmin", instrument=self, label="Voltage minimum", get_cmd=self._create_query("VMIN"), get_parser=float, unit="V", snapshot_value=False, )
vmax: Parameter = Parameter( name="vmax", instrument=self, label="Voltage maximum", get_cmd=self._create_query("VMAX"), get_parser=float, unit="V", snapshot_value=False, )
overshoot: Parameter = Parameter( name="overshoot", instrument=self, label="Voltage overshoot", get_cmd=self._create_query("VOV"), get_parser=float, unit="V", snapshot_value=False, )
vrms: Parameter = Parameter( name="vrms", instrument=self, label="Voltage RMS", get_cmd=self._create_query("VRMS", "CYCL,AC"), get_parser=float, unit="V_rms", snapshot_value=False, )
vrms_dc: Parameter = Parameter( name="vrms_dc", instrument=self, label="Voltage RMS with DC Component", get_cmd=self._create_query("VRMS", "CYCL,DC"), get_parser=float, unit="V_rms", snapshot_value=False, )
rise_time: Parameter = Parameter( name="rise_time", instrument=self, label="Rise time", get_cmd=self._create_query("RIS"), get_parser=float, unit="s", snapshot_value=False, )
fall_time: Parameter = Parameter( name="fall_time", instrument=self, label="Fall time", get_cmd=self._create_query("FALL"), get_parser=float, unit="s", snapshot_value=False, )
duty_cycle: Parameter = Parameter( name="duty_cycle", instrument=self, label="Duty Cycle", get_cmd=self._create_query("DUTY"), get_parser=float, unit="%", snapshot_value=False, )
period: Parameter = Parameter( name="period", instrument=self, label="Period", get_cmd=self._create_query("PER"), get_parser=float, unit="s", snapshot_value=False, )
frequency: Parameter = Parameter( name="frequency", instrument=self, label="Signal frequency", get_cmd=self._create_query("FREQ"), get_parser=float, unit="Hz", docstring=""" measure the frequency of the first complete cycle on the screen using the mid-threshold levels of the waveform """, snapshot_value=False, )
slew_rate: Parameter = Parameter( name="slew_rate", instrument=self, label="Slew rate", get_cmd=self._create_query("SLEW"), get_parser=float, unit="S", snapshot_value=False, )
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, 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 via add_submodule().

log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
metadata: dict[str, Any] = {}
class qcodes.instrument_drivers.Keysight.KeysightInfiniiumChannel(parent: KeysightInfiniium, name: str, channel: int, **kwargs: Any)[source]

Bases: InstrumentChannel

Initialize an infiniium channel.

Attributes:

channel

channel_name

ancestors

Ancestors in the form of a list of InstrumentBase

delegate_attr_dicts

A list of names (strings) of dictionaries which are (or will be) attributes of self, whose keys should be treated as attributes of self.

delegate_attr_objects

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

full_name

Full name of the instrument.

label

Nicely formatted label of the instrument.

name

Full name of the instrument

name_parts

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs

A list of attribute names (strings) to not delegate to any other dictionary or object.

parent

The parent instrument.

root_instrument

The topmost parent of this module.

short_name

Short name of the instrument.

parameters

All the parameters supported by this instrument.

functions

All the functions supported by this instrument.

submodules

All the submodules of this instrument such as channel lists or logical groupings of parameters.

instrument_modules

All the InstrumentModule of this instrument Usually populated via add_submodule().

Methods:

update_setpoints()

Update time axis and offsets for this channel.

__getitem__(key)

Delegate instrument['name'] to parameter or function 'name'.

__getstate__()

Prevent pickling instruments, and give a nice error message.

__repr__()

Custom repr to give parent information

add_function(name, **kwargs)

Bind one Function to this instrument.

add_parameter(name[, parameter_class])

Bind one Parameter to this instrument.

add_submodule(name, submodule)

Bind one submodule to this instrument.

ask(cmd)

ask_raw(cmd)

call(func_name, *args)

Shortcut for calling a function from its name.

get(param_name)

Shortcut for getting a parameter from its name.

get_component(full_name)

Recursively get a component of the instrument by full_name.

invalidate_cache()

Invalidate the cache of all parameters on the instrument.

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

print_readable_snapshot([update, max_chars])

Prints a readable version of the snapshot.

set(param_name, value)

Shortcut for setting a parameter from its name and new value.

snapshot([update])

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class NumpyJSONEncoder supports).

validate_status([verbose])

Validate the values of all gettable parameters

write(cmd)

write_raw(cmd)

display: Parameter = Parameter( name="display", instrument=self, label=f"Channel {channel} display on/off", set_cmd=f"CHAN{channel}:DISP {{}}", get_cmd=f"CHAN{channel}:DISP?", val_mapping=create_on_off_val_mapping(on_val=1, off_val=0), )
offset: Parameter = Parameter( name="offset", instrument=self, label=f"Channel {channel} offset", set_cmd=f"CHAN{channel}:OFFS {{}}", unit="V", get_cmd=f"CHAN{channel}:OFFS?", get_parser=float, )
range: Parameter = Parameter( name="range", instrument=self, label=f"Channel {channel} range", unit="V", set_cmd=f"CHAN{channel}:RANG {{}}", get_cmd=f"CHAN{channel}:RANG?", get_parser=float, vals=vals.Numbers(), )
trigger_level: Parameter = Parameter( name="trigger_level", instrument=self, label=f"Channel {channel} trigger level", unit="V", set_cmd=f":TRIG:LEV CHAN{channel},{{}}", get_cmd=f":TRIG:LEV? CHAN{channel}", get_parser=float, vals=vals.Numbers(), )
property channel: int
property channel_name: str
update_setpoints() None[source]

Update time axis and offsets for this channel. Calling this function is required when instr.cache_setpoints is True whenever the scope parameters are changed.

__getitem__(key: str) Callable[..., Any] | Parameter

Delegate instrument[‘name’] to parameter or function ‘name’.

__getstate__() None

Prevent pickling instruments, and give a nice error message.

__repr__() str

Custom repr to give parent information

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.

Note

We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.

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: type[ParameterBase] | None = 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: 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 a ChannelTuple.

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:
  • KeyError – If this instrument already contains a submodule with this name.

  • TypeError – If the submodule that we are trying to add is not an instance of an Metadatable object.

property ancestors: tuple[InstrumentBase, ...]

Ancestors in the form of a list of InstrumentBase

The list starts with the current module then the parent and the parents parent until the root instrument is reached.

ask(cmd: str) str
ask_raw(cmd: str) str
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: ClassVar[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 of self.

delegate_attr_objects: ClassVar[list[str]] = []

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

property full_name: str

Full name of the instrument.

For an InstrumentModule this includes all parents separated by _

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_component(full_name: str) MetadatableWithName

Recursively get a component of the instrument by full_name.

Parameters:

full_name – The name of the component to get.

Returns:

The component with the given name.

Raises:

KeyError – If the component does not exist.

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.

property label: str

Nicely formatted label of the instrument.

load_metadata(metadata: Mapping[str, Any]) None

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

property name: str

Full name of the instrument

This is equivalent to full_name() for backwards compatibility.

property name_parts: list[str]

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs: ClassVar[list[str]] = []

A list of attribute names (strings) to not delegate to any other dictionary or object.

property parent: InstrumentBase

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. If False, 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: InstrumentBase

The topmost parent of this module.

For the root_instrument this is self.

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.

property short_name: str

Short name of the instrument.

For an InstrumentModule this does not include any parent names.

snapshot(update: bool | None = False) dict[str, 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: bool | None = False, params_to_skip_update: Sequence[str] | None = 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. If False, 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:

dict

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_raw(cmd: str) None
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, 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 via add_submodule().

log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
metadata: dict[str, Any] = {}
class qcodes.instrument_drivers.Keysight.KeysightInfiniiumFunction(parent: KeysightInfiniium, name: str, channel: int, **kwargs: Any)[source]

Bases: InstrumentChannel

Initialize an infiniium channel.

Attributes:

channel

channel_name

ancestors

Ancestors in the form of a list of InstrumentBase

delegate_attr_dicts

A list of names (strings) of dictionaries which are (or will be) attributes of self, whose keys should be treated as attributes of self.

delegate_attr_objects

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

full_name

Full name of the instrument.

label

Nicely formatted label of the instrument.

name

Full name of the instrument

name_parts

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs

A list of attribute names (strings) to not delegate to any other dictionary or object.

parent

The parent instrument.

root_instrument

The topmost parent of this module.

short_name

Short name of the instrument.

parameters

All the parameters supported by this instrument.

functions

All the functions supported by this instrument.

submodules

All the submodules of this instrument such as channel lists or logical groupings of parameters.

instrument_modules

All the InstrumentModule of this instrument Usually populated via add_submodule().

Methods:

__getitem__(key)

Delegate instrument['name'] to parameter or function 'name'.

__getstate__()

Prevent pickling instruments, and give a nice error message.

__repr__()

Custom repr to give parent information

add_function(name, **kwargs)

Bind one Function to this instrument.

add_parameter(name[, parameter_class])

Bind one Parameter to this instrument.

add_submodule(name, submodule)

Bind one submodule to this instrument.

ask(cmd)

ask_raw(cmd)

call(func_name, *args)

Shortcut for calling a function from its name.

get(param_name)

Shortcut for getting a parameter from its name.

get_component(full_name)

Recursively get a component of the instrument by full_name.

invalidate_cache()

Invalidate the cache of all parameters on the instrument.

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

print_readable_snapshot([update, max_chars])

Prints a readable version of the snapshot.

set(param_name, value)

Shortcut for setting a parameter from its name and new value.

snapshot([update])

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class NumpyJSONEncoder supports).

validate_status([verbose])

Validate the values of all gettable parameters

write(cmd)

write_raw(cmd)

function: Parameter = Parameter( name="function", instrument=self, label=f"Function {channel} function", get_cmd=self._get_func, vals=vals.Strings(), )
source: Parameter = Parameter( name="source", instrument=self, label=f"Function {channel} source", get_cmd=f"FUNC{channel}?", )
points: Parameter = Parameter( name="points", instrument=self, label=f"Function {channel} points", get_cmd=self._get_points, )
property channel: int
property channel_name: str
__getitem__(key: str) Callable[..., Any] | Parameter

Delegate instrument[‘name’] to parameter or function ‘name’.

__getstate__() None

Prevent pickling instruments, and give a nice error message.

__repr__() str

Custom repr to give parent information

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.

Note

We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.

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: type[ParameterBase] | None = 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: 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 a ChannelTuple.

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:
  • KeyError – If this instrument already contains a submodule with this name.

  • TypeError – If the submodule that we are trying to add is not an instance of an Metadatable object.

property ancestors: tuple[InstrumentBase, ...]

Ancestors in the form of a list of InstrumentBase

The list starts with the current module then the parent and the parents parent until the root instrument is reached.

ask(cmd: str) str
ask_raw(cmd: str) str
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: ClassVar[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 of self.

delegate_attr_objects: ClassVar[list[str]] = []

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

property full_name: str

Full name of the instrument.

For an InstrumentModule this includes all parents separated by _

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_component(full_name: str) MetadatableWithName

Recursively get a component of the instrument by full_name.

Parameters:

full_name – The name of the component to get.

Returns:

The component with the given name.

Raises:

KeyError – If the component does not exist.

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.

property label: str

Nicely formatted label of the instrument.

load_metadata(metadata: Mapping[str, Any]) None

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

property name: str

Full name of the instrument

This is equivalent to full_name() for backwards compatibility.

property name_parts: list[str]

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs: ClassVar[list[str]] = []

A list of attribute names (strings) to not delegate to any other dictionary or object.

property parent: InstrumentBase

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. If False, 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: InstrumentBase

The topmost parent of this module.

For the root_instrument this is self.

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.

property short_name: str

Short name of the instrument.

For an InstrumentModule this does not include any parent names.

snapshot(update: bool | None = False) dict[str, 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: bool | None = False, params_to_skip_update: Sequence[str] | None = 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. If False, 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:

dict

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_raw(cmd: str) None
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, 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 via add_submodule().

log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
metadata: dict[str, Any] = {}
class qcodes.instrument_drivers.Keysight.KeysightInfiniiumUnboundMeasurement(parent: KeysightInfiniium, name: str, **kwargs: Any)[source]

Bases: AbstractMeasurementSubsystem

Initialize measurement subsystem where target is set by the parameter source.

Methods:

__getitem__(key)

Delegate instrument['name'] to parameter or function 'name'.

__getstate__()

Prevent pickling instruments, and give a nice error message.

__repr__()

Custom repr to give parent information

add_function(name, **kwargs)

Bind one Function to this instrument.

add_parameter(name[, parameter_class])

Bind one Parameter to this instrument.

add_submodule(name, submodule)

Bind one submodule to this instrument.

ask(cmd)

ask_raw(cmd)

call(func_name, *args)

Shortcut for calling a function from its name.

get(param_name)

Shortcut for getting a parameter from its name.

get_component(full_name)

Recursively get a component of the instrument by full_name.

invalidate_cache()

Invalidate the cache of all parameters on the instrument.

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

print_readable_snapshot([update, max_chars])

Prints a readable version of the snapshot.

set(param_name, value)

Shortcut for setting a parameter from its name and new value.

snapshot([update])

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class NumpyJSONEncoder supports).

validate_status([verbose])

Validate the values of all gettable parameters

write(cmd)

write_raw(cmd)

Attributes:

ancestors

Ancestors in the form of a list of InstrumentBase

delegate_attr_dicts

A list of names (strings) of dictionaries which are (or will be) attributes of self, whose keys should be treated as attributes of self.

delegate_attr_objects

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

full_name

Full name of the instrument.

label

Nicely formatted label of the instrument.

name

Full name of the instrument

name_parts

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs

A list of attribute names (strings) to not delegate to any other dictionary or object.

parent

The parent instrument.

root_instrument

The topmost parent of this module.

short_name

Short name of the instrument.

parameters

All the parameters supported by this instrument.

functions

All the functions supported by this instrument.

submodules

All the submodules of this instrument such as channel lists or logical groupings of parameters.

instrument_modules

All the InstrumentModule of this instrument Usually populated via add_submodule().

__getitem__(key: str) Callable[..., Any] | Parameter

Delegate instrument[‘name’] to parameter or function ‘name’.

__getstate__() None

Prevent pickling instruments, and give a nice error message.

__repr__() str

Custom repr to give parent information

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.

Note

We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.

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: type[ParameterBase] | None = 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: 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 a ChannelTuple.

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:
  • KeyError – If this instrument already contains a submodule with this name.

  • TypeError – If the submodule that we are trying to add is not an instance of an Metadatable object.

property ancestors: tuple[InstrumentBase, ...]

Ancestors in the form of a list of InstrumentBase

The list starts with the current module then the parent and the parents parent until the root instrument is reached.

ask(cmd: str) str
ask_raw(cmd: str) str
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: ClassVar[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 of self.

delegate_attr_objects: ClassVar[list[str]] = []

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

property full_name: str

Full name of the instrument.

For an InstrumentModule this includes all parents separated by _

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_component(full_name: str) MetadatableWithName

Recursively get a component of the instrument by full_name.

Parameters:

full_name – The name of the component to get.

Returns:

The component with the given name.

Raises:

KeyError – If the component does not exist.

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.

property label: str

Nicely formatted label of the instrument.

load_metadata(metadata: Mapping[str, Any]) None

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

property name: str

Full name of the instrument

This is equivalent to full_name() for backwards compatibility.

property name_parts: list[str]

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs: ClassVar[list[str]] = []

A list of attribute names (strings) to not delegate to any other dictionary or object.

property parent: InstrumentBase

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. If False, 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: InstrumentBase

The topmost parent of this module.

For the root_instrument this is self.

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.

property short_name: str

Short name of the instrument.

For an InstrumentModule this does not include any parent names.

snapshot(update: bool | None = False) dict[str, 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: bool | None = False, params_to_skip_update: Sequence[str] | None = 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. If False, 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:

dict

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_raw(cmd: str) None
amplitude: Parameter = Parameter( name="amplitude", instrument=self, label="Voltage amplitude", get_cmd=self._create_query("VAMP"), get_parser=float, unit="V", snapshot_value=False, )
average: Parameter = Parameter( name="average", instrument=self, label="Voltage average", get_cmd=self._create_query("VAV", "DISP"), get_parser=float, unit="V", snapshot_value=False, )
base: Parameter = Parameter( name="base", instrument=self, label="Statistical base", get_cmd=self._create_query("VBAS"), get_parser=float, unit="V", snapshot_value=False, )
vlow: Parameter = Parameter( name="vlow", instrument=self, label="Lower threshold voltage", get_cmd=self._create_query("VLOW"), get_parser=float, unit="V", snapshot_value=False, )
vmid: Parameter = Parameter( name="vmid", instrument=self, label="Middle threshold voltage", get_cmd=self._create_query("VMID"), get_parser=float, unit="V", snapshot_value=False, )
vup: Parameter = Parameter( name="vup", instrument=self, label="Upper threshold voltage", get_cmd=self._create_query("VUPP"), get_parser=float, unit="V", snapshot_value=False, )
vmin: Parameter = Parameter( name="vmin", instrument=self, label="Voltage minimum", get_cmd=self._create_query("VMIN"), get_parser=float, unit="V", snapshot_value=False, )
vmax: Parameter = Parameter( name="vmax", instrument=self, label="Voltage maximum", get_cmd=self._create_query("VMAX"), get_parser=float, unit="V", snapshot_value=False, )
overshoot: Parameter = Parameter( name="overshoot", instrument=self, label="Voltage overshoot", get_cmd=self._create_query("VOV"), get_parser=float, unit="V", snapshot_value=False, )
vrms: Parameter = Parameter( name="vrms", instrument=self, label="Voltage RMS", get_cmd=self._create_query("VRMS", "CYCL,AC"), get_parser=float, unit="V_rms", snapshot_value=False, )
vrms_dc: Parameter = Parameter( name="vrms_dc", instrument=self, label="Voltage RMS with DC Component", get_cmd=self._create_query("VRMS", "CYCL,DC"), get_parser=float, unit="V_rms", snapshot_value=False, )
rise_time: Parameter = Parameter( name="rise_time", instrument=self, label="Rise time", get_cmd=self._create_query("RIS"), get_parser=float, unit="s", snapshot_value=False, )
fall_time: Parameter = Parameter( name="fall_time", instrument=self, label="Fall time", get_cmd=self._create_query("FALL"), get_parser=float, unit="s", snapshot_value=False, )
duty_cycle: Parameter = Parameter( name="duty_cycle", instrument=self, label="Duty Cycle", get_cmd=self._create_query("DUTY"), get_parser=float, unit="%", snapshot_value=False, )
period: Parameter = Parameter( name="period", instrument=self, label="Period", get_cmd=self._create_query("PER"), get_parser=float, unit="s", snapshot_value=False, )
frequency: Parameter = Parameter( name="frequency", instrument=self, label="Signal frequency", get_cmd=self._create_query("FREQ"), get_parser=float, unit="Hz", docstring=""" measure the frequency of the first complete cycle on the screen using the mid-threshold levels of the waveform """, snapshot_value=False, )
slew_rate: Parameter = Parameter( name="slew_rate", instrument=self, label="Slew rate", get_cmd=self._create_query("SLEW"), get_parser=float, unit="S", snapshot_value=False, )
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, 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 via add_submodule().

log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
metadata: dict[str, Any] = {}
class qcodes.instrument_drivers.Keysight.KeysightM9336A(name: str, address: str, options: str = '', dll_path: str = 'C:\\Program Files\\IVI Foundation\\IVI\\Bin\\KtMAwg_64.dll', **kwargs: Any)[source]

Bases: Instrument

AWG Driver for the Keysight M9336A PXIe I/Q Arbitrary Waveform Generator. This driver provides a simple wrapper around the IVI-C drivers from Keysight. The output configuration, gain can be controlled and a waveform can be loaded from a file.

Methods:

get_idn()

generates the *IDN dictionary for qcodes

get_errors()

close()

Irreversibly stop this instrument and free its resources.

__del__()

Close the instrument and remove its instance record.

__getitem__(key)

Delegate instrument['name'] to parameter or function 'name'.

__getstate__()

Prevent pickling instruments, and give a nice error message.

__repr__()

Simplified repr giving just the class and name.

add_function(name, **kwargs)

Bind one Function to this instrument.

add_parameter(name[, parameter_class])

Bind one Parameter to this instrument.

add_submodule(name, submodule)

Bind one submodule to this instrument.

ask(cmd)

Write a command string to the hardware and return a response.

ask_raw(cmd)

Low level method to write to the hardware and return a response.

call(func_name, *args)

Shortcut for calling a function from its name.

close_all()

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.

connect_message([idn_param, begin_time])

Print a standard message on initial connection to an instrument.

exist(name[, instrument_class])

Check if an instrument with a given names exists (i.e. is already instantiated).

find_instrument(name[, instrument_class])

Find an existing instrument by name.

get(param_name)

Shortcut for getting a parameter from its name.

get_component(full_name)

Recursively get a component of the instrument by full_name.

instances()

Get all currently defined instances of this instrument class.

invalidate_cache()

Invalidate the cache of all parameters on the instrument.

is_valid(instr_instance)

Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a "valid" instrument.

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

print_readable_snapshot([update, max_chars])

Prints a readable version of the snapshot.

record_instance(instance)

Record (a weak ref to) an instance in a class's instance list.

remove_instance(instance)

Remove a particular instance from the record.

set(param_name, value)

Shortcut for setting a parameter from its name and new value.

snapshot([update])

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class NumpyJSONEncoder supports).

validate_status([verbose])

Validate the values of all gettable parameters

write(cmd)

Write a command string with NO response to the hardware.

write_raw(cmd)

Low level method to write a command string to the hardware.

Attributes:

ancestors

Ancestors in the form of a list of InstrumentBase

delegate_attr_dicts

A list of names (strings) of dictionaries which are (or will be) attributes of self, whose keys should be treated as attributes of self.

delegate_attr_objects

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

full_name

Full name of the instrument.

label

Nicely formatted label of the instrument.

name

Full name of the instrument

name_parts

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs

A list of attribute names (strings) to not delegate to any other dictionary or object.

parent

The parent instrument.

root_instrument

The topmost parent of this module.

short_name

Short name of the instrument.

parameters

All the parameters supported by this instrument.

functions

All the functions supported by this instrument.

submodules

All the submodules of this instrument such as channel lists or logical groupings of parameters.

instrument_modules

All the InstrumentModule of this instrument Usually populated via add_submodule().

get_idn() dict[str, str | None][source]

generates the *IDN dictionary for qcodes

get_errors() dict[int, str][source]
close() None[source]

Irreversibly stop this instrument and free its resources.

Subclasses should override this if they have other specific resources to close.

__del__() None

Close the instrument and remove its instance record.

__getitem__(key: str) Callable[..., Any] | Parameter

Delegate instrument[‘name’] to parameter or function ‘name’.

__getstate__() None

Prevent pickling instruments, and give a nice error message.

__repr__() str

Simplified repr giving just the class and 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.

Note

We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.

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: type[ParameterBase] | None = 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: 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 a ChannelTuple.

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:
  • KeyError – If this instrument already contains a submodule with this name.

  • TypeError – If the submodule that we are trying to add is not an instance of an Metadatable object.

property ancestors: tuple[InstrumentBase, ...]

Ancestors in the form of a list of InstrumentBase

The list starts with the current module then the parent and the parents parent 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 call super().ask(new_cmd). Subclasses that define a new hardware communication should instead override ask_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 method to write to the hardware and return a response.

Subclasses that define a new hardware communication should override this method. Subclasses that transform cmd should instead override ask.

Parameters:

cmd – The string to send to 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.

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: float | None = 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_timetime.time() when init started. Default is self._t0, set at start of Instrument.__init__.

delegate_attr_dicts: ClassVar[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 of self.

delegate_attr_objects: ClassVar[list[str]] = []

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

static exist(name: str, instrument_class: type[Instrument] | None = 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: type[T] | None = None) T | Instrument

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:
  • KeyError – If no instrument of that name was found, or if its reference is invalid (dead).

  • TypeError – If a specific class was requested but a different type was found.

property full_name: str

Full name of the instrument.

For an InstrumentModule this includes all parents separated by _

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_component(full_name: str) MetadatableWithName

Recursively get a component of the instrument by full_name.

Parameters:

full_name – The name of the component to get.

Returns:

The component with the given name.

Raises:

KeyError – If the component does not exist.

classmethod instances() list[T]

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.

property label: str

Nicely formatted label of the instrument.

load_metadata(metadata: Mapping[str, Any]) None

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

property name: str

Full name of the instrument

This is equivalent to full_name() for backwards compatibility.

property name_parts: list[str]

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs: ClassVar[list[str]] = []

A list of attribute names (strings) to not delegate to any other dictionary or object.

property parent: InstrumentBase | None

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. If False, 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: InstrumentBase

The topmost parent of this module.

For the root_instrument this is self.

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.

property short_name: str

Short name of the instrument.

For an InstrumentModule this does not include any parent names.

snapshot(update: bool | None = False) dict[str, 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: bool | None = False, params_to_skip_update: Sequence[str] | None = 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. If False, 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:

dict

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 call super().write(new_cmd). Subclasses that define a new hardware communication should instead override write_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 method to write a command string to the hardware.

Subclasses that define a new hardware communication should override this method. Subclasses that transform cmd should instead override write.

Parameters:

cmd – The string 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, 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 via add_submodule().

log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
metadata: dict[str, Any] = {}
class qcodes.instrument_drivers.Keysight.KeysightM9336AAWGChannel(parent: KeysightM9336A, name: str, chan: int)[source]

Bases: InstrumentChannel

Represent the three channels of the Keysight KTM Awg driver. The channels can be independently controlled and programmed with seperate waveforms.

Methods:

load_waveform(filename)

clear_waveform()

play_waveform()

stop_waveform()

__getitem__(key)

Delegate instrument['name'] to parameter or function 'name'.

__getstate__()

Prevent pickling instruments, and give a nice error message.

__repr__()

Custom repr to give parent information

add_function(name, **kwargs)

Bind one Function to this instrument.

add_parameter(name[, parameter_class])

Bind one Parameter to this instrument.

add_submodule(name, submodule)

Bind one submodule to this instrument.

ask(cmd)

ask_raw(cmd)

call(func_name, *args)

Shortcut for calling a function from its name.

get(param_name)

Shortcut for getting a parameter from its name.

get_component(full_name)

Recursively get a component of the instrument by full_name.

invalidate_cache()

Invalidate the cache of all parameters on the instrument.

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

print_readable_snapshot([update, max_chars])

Prints a readable version of the snapshot.

set(param_name, value)

Shortcut for setting a parameter from its name and new value.

snapshot([update])

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class NumpyJSONEncoder supports).

validate_status([verbose])

Validate the values of all gettable parameters

write(cmd)

write_raw(cmd)

Attributes:

ancestors

Ancestors in the form of a list of InstrumentBase

delegate_attr_dicts

A list of names (strings) of dictionaries which are (or will be) attributes of self, whose keys should be treated as attributes of self.

delegate_attr_objects

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

full_name

Full name of the instrument.

label

Nicely formatted label of the instrument.

name

Full name of the instrument

name_parts

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs

A list of attribute names (strings) to not delegate to any other dictionary or object.

parent

The parent instrument.

root_instrument

The topmost parent of this module.

short_name

Short name of the instrument.

parameters

All the parameters supported by this instrument.

functions

All the functions supported by this instrument.

submodules

All the submodules of this instrument such as channel lists or logical groupings of parameters.

instrument_modules

All the InstrumentModule of this instrument Usually populated via add_submodule().

load_waveform(filename: str) None[source]
clear_waveform() None[source]
play_waveform() None[source]
stop_waveform() None[source]
__getitem__(key: str) Callable[..., Any] | Parameter

Delegate instrument[‘name’] to parameter or function ‘name’.

__getstate__() None

Prevent pickling instruments, and give a nice error message.

__repr__() str

Custom repr to give parent information

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.

Note

We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.

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: type[ParameterBase] | None = 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: 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 a ChannelTuple.

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:
  • KeyError – If this instrument already contains a submodule with this name.

  • TypeError – If the submodule that we are trying to add is not an instance of an Metadatable object.

property ancestors: tuple[InstrumentBase, ...]

Ancestors in the form of a list of InstrumentBase

The list starts with the current module then the parent and the parents parent until the root instrument is reached.

ask(cmd: str) str
ask_raw(cmd: str) str
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: ClassVar[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 of self.

delegate_attr_objects: ClassVar[list[str]] = []

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

property full_name: str

Full name of the instrument.

For an InstrumentModule this includes all parents separated by _

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_component(full_name: str) MetadatableWithName

Recursively get a component of the instrument by full_name.

Parameters:

full_name – The name of the component to get.

Returns:

The component with the given name.

Raises:

KeyError – If the component does not exist.

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.

property label: str

Nicely formatted label of the instrument.

load_metadata(metadata: Mapping[str, Any]) None

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

property name: str

Full name of the instrument

This is equivalent to full_name() for backwards compatibility.

property name_parts: list[str]

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs: ClassVar[list[str]] = []

A list of attribute names (strings) to not delegate to any other dictionary or object.

property parent: InstrumentBase

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. If False, 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: InstrumentBase

The topmost parent of this module.

For the root_instrument this is self.

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.

property short_name: str

Short name of the instrument.

For an InstrumentModule this does not include any parent names.

snapshot(update: bool | None = False) dict[str, 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: bool | None = False, params_to_skip_update: Sequence[str] | None = 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. If False, 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:

dict

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_raw(cmd: str) None
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, 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 via add_submodule().

log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
metadata: dict[str, Any] = {}
class qcodes.instrument_drivers.Keysight.KeysightM960x(name: str, address: str, options: str = '', dll_path: str = 'C:\\Program Files\\IVI Foundation\\IVI\\Bin\\KtM960x_64.dll', **kwargs: Any)[source]

Bases: Instrument

Provide a wrapper for the Keysight KtM960x DAC. This driver provides an interface into the IVI-C driver provided by Keysight. The .dll is installed by default into C:Program FilesIVI FoundationIVIBinKtM960x_64.dll but a different path can be supplied to the constructor

Methods:

get_idn()

generates the *IDN dictionary for qcodes

get_errors()

close()

Irreversibly stop this instrument and free its resources.

__del__()

Close the instrument and remove its instance record.

__getitem__(key)

Delegate instrument['name'] to parameter or function 'name'.

__getstate__()

Prevent pickling instruments, and give a nice error message.

__repr__()

Simplified repr giving just the class and name.

add_function(name, **kwargs)

Bind one Function to this instrument.

add_parameter(name[, parameter_class])

Bind one Parameter to this instrument.

add_submodule(name, submodule)

Bind one submodule to this instrument.

ask(cmd)

Write a command string to the hardware and return a response.

ask_raw(cmd)

Low level method to write to the hardware and return a response.

call(func_name, *args)

Shortcut for calling a function from its name.

close_all()

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.

connect_message([idn_param, begin_time])

Print a standard message on initial connection to an instrument.

exist(name[, instrument_class])

Check if an instrument with a given names exists (i.e. is already instantiated).

find_instrument(name[, instrument_class])

Find an existing instrument by name.

get(param_name)

Shortcut for getting a parameter from its name.

get_component(full_name)

Recursively get a component of the instrument by full_name.

instances()

Get all currently defined instances of this instrument class.

invalidate_cache()

Invalidate the cache of all parameters on the instrument.

is_valid(instr_instance)

Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a "valid" instrument.

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

print_readable_snapshot([update, max_chars])

Prints a readable version of the snapshot.

record_instance(instance)

Record (a weak ref to) an instance in a class's instance list.

remove_instance(instance)

Remove a particular instance from the record.

set(param_name, value)

Shortcut for setting a parameter from its name and new value.

snapshot([update])

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class NumpyJSONEncoder supports).

validate_status([verbose])

Validate the values of all gettable parameters

write(cmd)

Write a command string with NO response to the hardware.

write_raw(cmd)

Low level method to write a command string to the hardware.

Attributes:

ancestors

Ancestors in the form of a list of InstrumentBase

delegate_attr_dicts

A list of names (strings) of dictionaries which are (or will be) attributes of self, whose keys should be treated as attributes of self.

delegate_attr_objects

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

full_name

Full name of the instrument.

label

Nicely formatted label of the instrument.

name

Full name of the instrument

name_parts

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs

A list of attribute names (strings) to not delegate to any other dictionary or object.

parent

The parent instrument.

root_instrument

The topmost parent of this module.

short_name

Short name of the instrument.

parameters

All the parameters supported by this instrument.

functions

All the functions supported by this instrument.

submodules

All the submodules of this instrument such as channel lists or logical groupings of parameters.

instrument_modules

All the InstrumentModule of this instrument Usually populated via add_submodule().

get_idn() dict[str, str | None][source]

generates the *IDN dictionary for qcodes

get_errors() dict[int, str][source]
close() None[source]

Irreversibly stop this instrument and free its resources.

Subclasses should override this if they have other specific resources to close.

__del__() None

Close the instrument and remove its instance record.

__getitem__(key: str) Callable[..., Any] | Parameter

Delegate instrument[‘name’] to parameter or function ‘name’.

__getstate__() None

Prevent pickling instruments, and give a nice error message.

__repr__() str

Simplified repr giving just the class and 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.

Note

We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.

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: type[ParameterBase] | None = 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: 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 a ChannelTuple.

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:
  • KeyError – If this instrument already contains a submodule with this name.

  • TypeError – If the submodule that we are trying to add is not an instance of an Metadatable object.

property ancestors: tuple[InstrumentBase, ...]

Ancestors in the form of a list of InstrumentBase

The list starts with the current module then the parent and the parents parent 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 call super().ask(new_cmd). Subclasses that define a new hardware communication should instead override ask_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 method to write to the hardware and return a response.

Subclasses that define a new hardware communication should override this method. Subclasses that transform cmd should instead override ask.

Parameters:

cmd – The string to send to 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.

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: float | None = 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_timetime.time() when init started. Default is self._t0, set at start of Instrument.__init__.

delegate_attr_dicts: ClassVar[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 of self.

delegate_attr_objects: ClassVar[list[str]] = []

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

static exist(name: str, instrument_class: type[Instrument] | None = 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: type[T] | None = None) T | Instrument

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:
  • KeyError – If no instrument of that name was found, or if its reference is invalid (dead).

  • TypeError – If a specific class was requested but a different type was found.

property full_name: str

Full name of the instrument.

For an InstrumentModule this includes all parents separated by _

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_component(full_name: str) MetadatableWithName

Recursively get a component of the instrument by full_name.

Parameters:

full_name – The name of the component to get.

Returns:

The component with the given name.

Raises:

KeyError – If the component does not exist.

classmethod instances() list[T]

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.

property label: str

Nicely formatted label of the instrument.

load_metadata(metadata: Mapping[str, Any]) None

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

property name: str

Full name of the instrument

This is equivalent to full_name() for backwards compatibility.

property name_parts: list[str]

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs: ClassVar[list[str]] = []

A list of attribute names (strings) to not delegate to any other dictionary or object.

property parent: InstrumentBase | None

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. If False, 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: InstrumentBase

The topmost parent of this module.

For the root_instrument this is self.

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.

property short_name: str

Short name of the instrument.

For an InstrumentModule this does not include any parent names.

snapshot(update: bool | None = False) dict[str, 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: bool | None = False, params_to_skip_update: Sequence[str] | None = 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. If False, 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:

dict

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 call super().write(new_cmd). Subclasses that define a new hardware communication should instead override write_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 method to write a command string to the hardware.

Subclasses that define a new hardware communication should override this method. Subclasses that transform cmd should instead override write.

Parameters:

cmd – The string 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, 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 via add_submodule().

log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
metadata: dict[str, Any] = {}
class qcodes.instrument_drivers.Keysight.KeysightN5173B(name: str, address: str, **kwargs: Any)[source]

Bases: KeysightN5183B

Methods:

__del__()

Close the instrument and remove its instance record.

__getitem__(key)

Delegate instrument['name'] to parameter or function 'name'.

__getstate__()

Prevent pickling instruments, and give a nice error message.

__repr__()

Simplified repr giving just the class and name.

add_function(name, **kwargs)

Bind one Function to this instrument.

add_parameter(name[, parameter_class])

Bind one Parameter to this instrument.

add_submodule(name, submodule)

Bind one submodule to this instrument.

ask(cmd)

Write a command string to the hardware and return a response.

ask_raw(cmd)

Low-level interface to visa_handle.ask.

call(func_name, *args)

Shortcut for calling a function from its name.

close()

Disconnect and irreversibly tear down the instrument.

close_all()

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.

connect_message([idn_param, begin_time])

Print a standard message on initial connection to an instrument.

device_clear()

Clear the buffers of the device

exist(name[, instrument_class])

Check if an instrument with a given names exists (i.e. is already instantiated).

find_instrument(name[, instrument_class])

Find an existing instrument by name.

get(param_name)

Shortcut for getting a parameter from its name.

get_component(full_name)

Recursively get a component of the instrument by full_name.

get_idn()

Parse a standard VISA *IDN? response into an ID dict.

instances()

Get all currently defined instances of this instrument class.

invalidate_cache()

Invalidate the cache of all parameters on the instrument.

is_valid(instr_instance)

Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a "valid" instrument.

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

print_readable_snapshot([update, max_chars])

Prints a readable version of the snapshot.

record_instance(instance)

Record (a weak ref to) an instance in a class's instance list.

remove_instance(instance)

Remove a particular instance from the record.

set(param_name, value)

Shortcut for setting a parameter from its name and new value.

set_address(address)

Set the address for this instrument.

set_terminator(terminator)

Change the read terminator to use.

snapshot([update])

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class NumpyJSONEncoder supports).

validate_status([verbose])

Validate the values of all gettable parameters

write(cmd)

Write a command string with NO response to the hardware.

write_raw(cmd)

Low-level interface to visa_handle.write.

Attributes:

ancestors

Ancestors in the form of a list of InstrumentBase

delegate_attr_dicts

A list of names (strings) of dictionaries which are (or will be) attributes of self, whose keys should be treated as attributes of self.

delegate_attr_objects

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

full_name

Full name of the instrument.

label

Nicely formatted label of the instrument.

name

Full name of the instrument

name_parts

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs

A list of attribute names (strings) to not delegate to any other dictionary or object.

parent

The parent instrument.

root_instrument

The topmost parent of this module.

short_name

Short name of the instrument.

visa_handle

The VISA resource used by this instrument.

resource_manager

The VISA resource manager used by this instrument.

parameters

All the parameters supported by this instrument.

functions

All the functions supported by this instrument.

submodules

All the submodules of this instrument such as channel lists or logical groupings of parameters.

instrument_modules

All the InstrumentModule of this instrument Usually populated via add_submodule().

__del__() None

Close the instrument and remove its instance record.

__getitem__(key: str) Callable[..., Any] | Parameter

Delegate instrument[‘name’] to parameter or function ‘name’.

__getstate__() None

Prevent pickling instruments, and give a nice error message.

__repr__() str

Simplified repr giving just the class and 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.

Note

We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.

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: type[ParameterBase] | None = 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: 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 a ChannelTuple.

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:
  • KeyError – If this instrument already contains a submodule with this name.

  • TypeError – If the submodule that we are trying to add is not an instance of an Metadatable object.

property ancestors: tuple[InstrumentBase, ...]

Ancestors in the form of a list of InstrumentBase

The list starts with the current module then the parent and the parents parent 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 call super().ask(new_cmd). Subclasses that define a new hardware communication should instead override ask_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:

str

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.

close() None

Disconnect and irreversibly tear down the instrument.

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: float | None = 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_timetime.time() when init started. Default is self._t0, set at start of Instrument.__init__.

delegate_attr_dicts: ClassVar[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 of self.

delegate_attr_objects: ClassVar[list[str]] = []

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

device_clear() None

Clear the buffers of the device

static exist(name: str, instrument_class: type[Instrument] | None = 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: type[T] | None = None) T | Instrument

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:
  • KeyError – If no instrument of that name was found, or if its reference is invalid (dead).

  • TypeError – If a specific class was requested but a different type was found.

property full_name: str

Full name of the instrument.

For an InstrumentModule this includes all parents separated by _

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_component(full_name: str) MetadatableWithName

Recursively get a component of the instrument by full_name.

Parameters:

full_name – The name of the component to get.

Returns:

The component with the given name.

Raises:

KeyError – If the component does not exist.

get_idn() dict[str, str | None]

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[T]

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.

property label: str

Nicely formatted label of the instrument.

load_metadata(metadata: Mapping[str, Any]) None

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

property name: str

Full name of the instrument

This is equivalent to full_name() for backwards compatibility.

property name_parts: list[str]

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs: ClassVar[list[str]] = []

A list of attribute names (strings) to not delegate to any other dictionary or object.

property parent: InstrumentBase | None

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. If False, 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: InstrumentBase

The topmost parent of this module.

For the root_instrument this is self.

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: str | None) 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.

property short_name: str

Short name of the instrument.

For an InstrumentModule this does not include any parent names.

snapshot(update: bool | None = False) dict[str, 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: bool | None = True, params_to_skip_update: Sequence[str] | None = 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:

dict

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 call super().write(new_cmd). Subclasses that define a new hardware communication should instead override write_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.

visabackend: str = visabackend
visa_handle: pyvisa.resources.MessageBasedResource = visa_handle

The VISA resource used by this instrument.

visalib: str | None = visalib
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, 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 via add_submodule().

log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
metadata: dict[str, Any] = {}
resource_manager = resource_manager

The VISA resource manager used by this instrument.

class qcodes.instrument_drivers.Keysight.KeysightN5183B(name: str, address: str, **kwargs: Any)[source]

Bases: N51x1

Methods:

__del__()

Close the instrument and remove its instance record.

__getitem__(key)

Delegate instrument['name'] to parameter or function 'name'.

__getstate__()

Prevent pickling instruments, and give a nice error message.

__repr__()

Simplified repr giving just the class and name.

add_function(name, **kwargs)

Bind one Function to this instrument.

add_parameter(name[, parameter_class])

Bind one Parameter to this instrument.

add_submodule(name, submodule)

Bind one submodule to this instrument.

ask(cmd)

Write a command string to the hardware and return a response.

ask_raw(cmd)

Low-level interface to visa_handle.ask.

call(func_name, *args)

Shortcut for calling a function from its name.

close()

Disconnect and irreversibly tear down the instrument.

close_all()

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.

connect_message([idn_param, begin_time])

Print a standard message on initial connection to an instrument.

device_clear()

Clear the buffers of the device

exist(name[, instrument_class])

Check if an instrument with a given names exists (i.e. is already instantiated).

find_instrument(name[, instrument_class])

Find an existing instrument by name.

get(param_name)

Shortcut for getting a parameter from its name.

get_component(full_name)

Recursively get a component of the instrument by full_name.

get_idn()

Parse a standard VISA *IDN? response into an ID dict.

instances()

Get all currently defined instances of this instrument class.

invalidate_cache()

Invalidate the cache of all parameters on the instrument.

is_valid(instr_instance)

Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a "valid" instrument.

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

print_readable_snapshot([update, max_chars])

Prints a readable version of the snapshot.

record_instance(instance)

Record (a weak ref to) an instance in a class's instance list.

remove_instance(instance)

Remove a particular instance from the record.

set(param_name, value)

Shortcut for setting a parameter from its name and new value.

set_address(address)

Set the address for this instrument.

set_terminator(terminator)

Change the read terminator to use.

snapshot([update])

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class NumpyJSONEncoder supports).

validate_status([verbose])

Validate the values of all gettable parameters

write(cmd)

Write a command string with NO response to the hardware.

write_raw(cmd)

Low-level interface to visa_handle.write.

Attributes:

ancestors

Ancestors in the form of a list of InstrumentBase

delegate_attr_dicts

A list of names (strings) of dictionaries which are (or will be) attributes of self, whose keys should be treated as attributes of self.

delegate_attr_objects

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

full_name

Full name of the instrument.

label

Nicely formatted label of the instrument.

name

Full name of the instrument

name_parts

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs

A list of attribute names (strings) to not delegate to any other dictionary or object.

parent

The parent instrument.

root_instrument

The topmost parent of this module.

short_name

Short name of the instrument.

visa_handle

The VISA resource used by this instrument.

resource_manager

The VISA resource manager used by this instrument.

parameters

All the parameters supported by this instrument.

functions

All the functions supported by this instrument.

submodules

All the submodules of this instrument such as channel lists or logical groupings of parameters.

instrument_modules

All the InstrumentModule of this instrument Usually populated via add_submodule().

__del__() None

Close the instrument and remove its instance record.

__getitem__(key: str) Callable[..., Any] | Parameter

Delegate instrument[‘name’] to parameter or function ‘name’.

__getstate__() None

Prevent pickling instruments, and give a nice error message.

__repr__() str

Simplified repr giving just the class and 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.

Note

We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.

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: type[ParameterBase] | None = 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: 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 a ChannelTuple.

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:
  • KeyError – If this instrument already contains a submodule with this name.

  • TypeError – If the submodule that we are trying to add is not an instance of an Metadatable object.

property ancestors: tuple[InstrumentBase, ...]

Ancestors in the form of a list of InstrumentBase

The list starts with the current module then the parent and the parents parent 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 call super().ask(new_cmd). Subclasses that define a new hardware communication should instead override ask_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:

str

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.

close() None

Disconnect and irreversibly tear down the instrument.

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: float | None = 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_timetime.time() when init started. Default is self._t0, set at start of Instrument.__init__.

delegate_attr_dicts: ClassVar[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 of self.

delegate_attr_objects: ClassVar[list[str]] = []

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

device_clear() None

Clear the buffers of the device

static exist(name: str, instrument_class: type[Instrument] | None = 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: type[T] | None = None) T | Instrument

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:
  • KeyError – If no instrument of that name was found, or if its reference is invalid (dead).

  • TypeError – If a specific class was requested but a different type was found.

property full_name: str

Full name of the instrument.

For an InstrumentModule this includes all parents separated by _

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_component(full_name: str) MetadatableWithName

Recursively get a component of the instrument by full_name.

Parameters:

full_name – The name of the component to get.

Returns:

The component with the given name.

Raises:

KeyError – If the component does not exist.

get_idn() dict[str, str | None]

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[T]

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.

property label: str

Nicely formatted label of the instrument.

load_metadata(metadata: Mapping[str, Any]) None

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

property name: str

Full name of the instrument

This is equivalent to full_name() for backwards compatibility.

property name_parts: list[str]

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs: ClassVar[list[str]] = []

A list of attribute names (strings) to not delegate to any other dictionary or object.

property parent: InstrumentBase | None

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. If False, 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: InstrumentBase

The topmost parent of this module.

For the root_instrument this is self.

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: str | None) 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.

property short_name: str

Short name of the instrument.

For an InstrumentModule this does not include any parent names.

snapshot(update: bool | None = False) dict[str, 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: bool | None = True, params_to_skip_update: Sequence[str] | None = 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:

dict

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 call super().write(new_cmd). Subclasses that define a new hardware communication should instead override write_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.

visabackend: str = visabackend
visa_handle: pyvisa.resources.MessageBasedResource = visa_handle

The VISA resource used by this instrument.

visalib: str | None = visalib
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, 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 via add_submodule().

log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
metadata: dict[str, Any] = {}
resource_manager = resource_manager

The VISA resource manager used by this instrument.

class qcodes.instrument_drivers.Keysight.KeysightN5222B(name: str, address: str, **kwargs: Any)[source]

Bases: PNABase

Driver for Keysight PNA N5222B.

Methods:

__del__()

Close the instrument and remove its instance record.

__getitem__(key)

Delegate instrument['name'] to parameter or function 'name'.

__getstate__()

Prevent pickling instruments, and give a nice error message.

__repr__()

Simplified repr giving just the class and name.

add_function(name, **kwargs)

Bind one Function to this instrument.

add_parameter(name[, parameter_class])

Bind one Parameter to this instrument.

add_submodule(name, submodule)

Bind one submodule to this instrument.

ask(cmd)

Write a command string to the hardware and return a response.

ask_raw(cmd)

Low-level interface to visa_handle.ask.

averages_off()

Turn off trace averaging

averages_on()

Turn on trace averaging

call(func_name, *args)

Shortcut for calling a function from its name.

close()

Disconnect and irreversibly tear down the instrument.

close_all()

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.

connect_message([idn_param, begin_time])

Print a standard message on initial connection to an instrument.

device_clear()

Clear the buffers of the device

exist(name[, instrument_class])

Check if an instrument with a given names exists (i.e. is already instantiated).

find_instrument(name[, instrument_class])

Find an existing instrument by name.

get(param_name)

Shortcut for getting a parameter from its name.

get_component(full_name)

Recursively get a component of the instrument by full_name.

get_idn()

Parse a standard VISA *IDN? response into an ID dict.

get_options()

get_trace_catalog()

Get the trace catalog, that is a list of trace and sweep types from the PNA.

instances()

Get all currently defined instances of this instrument class.

invalidate_cache()

Invalidate the cache of all parameters on the instrument.

is_valid(instr_instance)

Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a "valid" instrument.

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

print_readable_snapshot([update, max_chars])

Prints a readable version of the snapshot.

record_instance(instance)

Record (a weak ref to) an instance in a class's instance list.

remove_instance(instance)

Remove a particular instance from the record.

reset_averages()

Reset averaging

select_trace_by_name(trace_name)

Select a trace on the PNA by name.

set(param_name, value)

Shortcut for setting a parameter from its name and new value.

set_address(address)

Set the address for this instrument.

set_terminator(terminator)

Change the read terminator to use.

snapshot([update])

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class NumpyJSONEncoder supports).

validate_status([verbose])

Validate the values of all gettable parameters

write(cmd)

Write a command string with NO response to the hardware.

write_raw(cmd)

Low-level interface to visa_handle.write.

Attributes:

ancestors

Ancestors in the form of a list of InstrumentBase

delegate_attr_dicts

A list of names (strings) of dictionaries which are (or will be) attributes of self, whose keys should be treated as attributes of self.

delegate_attr_objects

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

full_name

Full name of the instrument.

label

Nicely formatted label of the instrument.

name

Full name of the instrument

name_parts

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs

A list of attribute names (strings) to not delegate to any other dictionary or object.

parent

The parent instrument.

root_instrument

The topmost parent of this module.

short_name

Short name of the instrument.

traces

Update channel list with active traces and return the new list

visa_handle

The VISA resource used by this instrument.

resource_manager

The VISA resource manager used by this instrument.

parameters

All the parameters supported by this instrument.

functions

All the functions supported by this instrument.

submodules

All the submodules of this instrument such as channel lists or logical groupings of parameters.

instrument_modules

All the InstrumentModule of this instrument Usually populated via add_submodule().

__del__() None

Close the instrument and remove its instance record.

__getitem__(key: str) Callable[..., Any] | Parameter

Delegate instrument[‘name’] to parameter or function ‘name’.

__getstate__() None

Prevent pickling instruments, and give a nice error message.

__repr__() str

Simplified repr giving just the class and 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.

Note

We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.

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: type[ParameterBase] | None = 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: 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 a ChannelTuple.

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:
  • KeyError – If this instrument already contains a submodule with this name.

  • TypeError – If the submodule that we are trying to add is not an instance of an Metadatable object.

property ancestors: tuple[InstrumentBase, ...]

Ancestors in the form of a list of InstrumentBase

The list starts with the current module then the parent and the parents parent 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 call super().ask(new_cmd). Subclasses that define a new hardware communication should instead override ask_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:

str

averages_off() None

Turn off trace averaging

averages_on() None

Turn on trace averaging

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.

close() None

Disconnect and irreversibly tear down the instrument.

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: float | None = 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_timetime.time() when init started. Default is self._t0, set at start of Instrument.__init__.

delegate_attr_dicts: ClassVar[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 of self.

delegate_attr_objects: ClassVar[list[str]] = []

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

device_clear() None

Clear the buffers of the device

static exist(name: str, instrument_class: type[Instrument] | None = 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: type[T] | None = None) T | Instrument

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:
  • KeyError – If no instrument of that name was found, or if its reference is invalid (dead).

  • TypeError – If a specific class was requested but a different type was found.

property full_name: str

Full name of the instrument.

For an InstrumentModule this includes all parents separated by _

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_component(full_name: str) MetadatableWithName

Recursively get a component of the instrument by full_name.

Parameters:

full_name – The name of the component to get.

Returns:

The component with the given name.

Raises:

KeyError – If the component does not exist.

get_idn() dict[str, str | None]

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.

get_options() Sequence[str]
get_trace_catalog() str

Get the trace catalog, that is a list of trace and sweep types from the PNA.

The format of the returned trace is:

trace_name,trace_type,trace_name,trace_type…

classmethod instances() list[T]

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.

property label: str

Nicely formatted label of the instrument.

load_metadata(metadata: Mapping[str, Any]) None

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

property name: str

Full name of the instrument

This is equivalent to full_name() for backwards compatibility.

property name_parts: list[str]

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs: ClassVar[list[str]] = []

A list of attribute names (strings) to not delegate to any other dictionary or object.

property parent: InstrumentBase | None

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. If False, 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

reset_averages() None

Reset averaging

property root_instrument: InstrumentBase

The topmost parent of this module.

For the root_instrument this is self.

select_trace_by_name(trace_name: str) int

Select a trace on the PNA by name.

Returns:

The trace number of the selected trace

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: str | None) 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.

property short_name: str

Short name of the instrument.

For an InstrumentModule this does not include any parent names.

snapshot(update: bool | None = False) dict[str, 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: bool | None = True, params_to_skip_update: Sequence[str] | None = 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:

dict

property traces: ChannelList

Update channel list with active traces and return the new list

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 call super().write(new_cmd). Subclasses that define a new hardware communication should instead override write_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.

visabackend: str = visabackend
visa_handle: pyvisa.resources.MessageBasedResource = visa_handle

The VISA resource used by this instrument.

visalib: str | None = visalib
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, 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 via add_submodule().

log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
metadata: dict[str, Any] = {}
resource_manager = resource_manager

The VISA resource manager used by this instrument.

class qcodes.instrument_drivers.Keysight.KeysightN5230C(name: str, address: str, **kwargs: Any)[source]

Bases: PNABase

Methods:

__del__()

Close the instrument and remove its instance record.

__getitem__(key)

Delegate instrument['name'] to parameter or function 'name'.

__getstate__()

Prevent pickling instruments, and give a nice error message.

__repr__()

Simplified repr giving just the class and name.

add_function(name, **kwargs)

Bind one Function to this instrument.

add_parameter(name[, parameter_class])

Bind one Parameter to this instrument.

add_submodule(name, submodule)

Bind one submodule to this instrument.

ask(cmd)

Write a command string to the hardware and return a response.

ask_raw(cmd)

Low-level interface to visa_handle.ask.

averages_off()

Turn off trace averaging

averages_on()

Turn on trace averaging

call(func_name, *args)

Shortcut for calling a function from its name.

close()

Disconnect and irreversibly tear down the instrument.

close_all()

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.

connect_message([idn_param, begin_time])

Print a standard message on initial connection to an instrument.

device_clear()

Clear the buffers of the device

exist(name[, instrument_class])

Check if an instrument with a given names exists (i.e. is already instantiated).

find_instrument(name[, instrument_class])

Find an existing instrument by name.

get(param_name)

Shortcut for getting a parameter from its name.

get_component(full_name)

Recursively get a component of the instrument by full_name.

get_idn()

Parse a standard VISA *IDN? response into an ID dict.

get_options()

get_trace_catalog()

Get the trace catalog, that is a list of trace and sweep types from the PNA.

instances()

Get all currently defined instances of this instrument class.

invalidate_cache()

Invalidate the cache of all parameters on the instrument.

is_valid(instr_instance)

Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a "valid" instrument.

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

print_readable_snapshot([update, max_chars])

Prints a readable version of the snapshot.

record_instance(instance)

Record (a weak ref to) an instance in a class's instance list.

remove_instance(instance)

Remove a particular instance from the record.

reset_averages()

Reset averaging

select_trace_by_name(trace_name)

Select a trace on the PNA by name.

set(param_name, value)

Shortcut for setting a parameter from its name and new value.

set_address(address)

Set the address for this instrument.

set_terminator(terminator)

Change the read terminator to use.

snapshot([update])

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class NumpyJSONEncoder supports).

validate_status([verbose])

Validate the values of all gettable parameters

write(cmd)

Write a command string with NO response to the hardware.

write_raw(cmd)

Low-level interface to visa_handle.write.

Attributes:

ancestors

Ancestors in the form of a list of InstrumentBase

delegate_attr_dicts

A list of names (strings) of dictionaries which are (or will be) attributes of self, whose keys should be treated as attributes of self.

delegate_attr_objects

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

full_name

Full name of the instrument.

label

Nicely formatted label of the instrument.

name

Full name of the instrument

name_parts

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs

A list of attribute names (strings) to not delegate to any other dictionary or object.

parent

The parent instrument.

root_instrument

The topmost parent of this module.

short_name

Short name of the instrument.

traces

Update channel list with active traces and return the new list

visa_handle

The VISA resource used by this instrument.

resource_manager

The VISA resource manager used by this instrument.

parameters

All the parameters supported by this instrument.

functions

All the functions supported by this instrument.

submodules

All the submodules of this instrument such as channel lists or logical groupings of parameters.

instrument_modules

All the InstrumentModule of this instrument Usually populated via add_submodule().

__del__() None

Close the instrument and remove its instance record.

__getitem__(key: str) Callable[..., Any] | Parameter

Delegate instrument[‘name’] to parameter or function ‘name’.

__getstate__() None

Prevent pickling instruments, and give a nice error message.

__repr__() str

Simplified repr giving just the class and 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.

Note

We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.

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: type[ParameterBase] | None = 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: 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 a ChannelTuple.

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:
  • KeyError – If this instrument already contains a submodule with this name.

  • TypeError – If the submodule that we are trying to add is not an instance of an Metadatable object.

property ancestors: tuple[InstrumentBase, ...]

Ancestors in the form of a list of InstrumentBase

The list starts with the current module then the parent and the parents parent 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 call super().ask(new_cmd). Subclasses that define a new hardware communication should instead override ask_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:

str

averages_off() None

Turn off trace averaging

averages_on() None

Turn on trace averaging

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.

close() None

Disconnect and irreversibly tear down the instrument.

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: float | None = 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_timetime.time() when init started. Default is self._t0, set at start of Instrument.__init__.

delegate_attr_dicts: ClassVar[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 of self.

delegate_attr_objects: ClassVar[list[str]] = []

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

device_clear() None

Clear the buffers of the device

static exist(name: str, instrument_class: type[Instrument] | None = 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: type[T] | None = None) T | Instrument

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:
  • KeyError – If no instrument of that name was found, or if its reference is invalid (dead).

  • TypeError – If a specific class was requested but a different type was found.

property full_name: str

Full name of the instrument.

For an InstrumentModule this includes all parents separated by _

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_component(full_name: str) MetadatableWithName

Recursively get a component of the instrument by full_name.

Parameters:

full_name – The name of the component to get.

Returns:

The component with the given name.

Raises:

KeyError – If the component does not exist.

get_idn() dict[str, str | None]

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.

get_options() Sequence[str]
get_trace_catalog() str

Get the trace catalog, that is a list of trace and sweep types from the PNA.

The format of the returned trace is:

trace_name,trace_type,trace_name,trace_type…

classmethod instances() list[T]

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.

property label: str

Nicely formatted label of the instrument.

load_metadata(metadata: Mapping[str, Any]) None

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

property name: str

Full name of the instrument

This is equivalent to full_name() for backwards compatibility.

property name_parts: list[str]

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs: ClassVar[list[str]] = []

A list of attribute names (strings) to not delegate to any other dictionary or object.

property parent: InstrumentBase | None

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. If False, 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

reset_averages() None

Reset averaging

property root_instrument: InstrumentBase

The topmost parent of this module.

For the root_instrument this is self.

select_trace_by_name(trace_name: str) int

Select a trace on the PNA by name.

Returns:

The trace number of the selected trace

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: str | None) 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.

property short_name: str

Short name of the instrument.

For an InstrumentModule this does not include any parent names.

snapshot(update: bool | None = False) dict[str, 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: bool | None = True, params_to_skip_update: Sequence[str] | None = 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:

dict

property traces: ChannelList

Update channel list with active traces and return the new list

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 call super().write(new_cmd). Subclasses that define a new hardware communication should instead override write_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.

visabackend: str = visabackend
visa_handle: pyvisa.resources.MessageBasedResource = visa_handle

The VISA resource used by this instrument.

visalib: str | None = visalib
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, 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 via add_submodule().

log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
metadata: dict[str, Any] = {}
resource_manager = resource_manager

The VISA resource manager used by this instrument.

class qcodes.instrument_drivers.Keysight.KeysightN5232B(name: str, address: str, **kwargs: Any)[source]

Bases: PNABase

Methods:

__del__()

Close the instrument and remove its instance record.

__getitem__(key)

Delegate instrument['name'] to parameter or function 'name'.

__getstate__()

Prevent pickling instruments, and give a nice error message.

__repr__()

Simplified repr giving just the class and name.

add_function(name, **kwargs)

Bind one Function to this instrument.

add_parameter(name[, parameter_class])

Bind one Parameter to this instrument.

add_submodule(name, submodule)

Bind one submodule to this instrument.

ask(cmd)

Write a command string to the hardware and return a response.

ask_raw(cmd)

Low-level interface to visa_handle.ask.

averages_off()

Turn off trace averaging

averages_on()

Turn on trace averaging

call(func_name, *args)

Shortcut for calling a function from its name.

close()

Disconnect and irreversibly tear down the instrument.

close_all()

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.

connect_message([idn_param, begin_time])

Print a standard message on initial connection to an instrument.

device_clear()

Clear the buffers of the device

exist(name[, instrument_class])

Check if an instrument with a given names exists (i.e. is already instantiated).

find_instrument(name[, instrument_class])

Find an existing instrument by name.

get(param_name)

Shortcut for getting a parameter from its name.

get_component(full_name)

Recursively get a component of the instrument by full_name.

get_idn()

Parse a standard VISA *IDN? response into an ID dict.

get_options()

get_trace_catalog()

Get the trace catalog, that is a list of trace and sweep types from the PNA.

instances()

Get all currently defined instances of this instrument class.

invalidate_cache()

Invalidate the cache of all parameters on the instrument.

is_valid(instr_instance)

Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a "valid" instrument.

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

print_readable_snapshot([update, max_chars])

Prints a readable version of the snapshot.

record_instance(instance)

Record (a weak ref to) an instance in a class's instance list.

remove_instance(instance)

Remove a particular instance from the record.

reset_averages()

Reset averaging

select_trace_by_name(trace_name)

Select a trace on the PNA by name.

set(param_name, value)

Shortcut for setting a parameter from its name and new value.

set_address(address)

Set the address for this instrument.

set_terminator(terminator)

Change the read terminator to use.

snapshot([update])

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class NumpyJSONEncoder supports).

validate_status([verbose])

Validate the values of all gettable parameters

write(cmd)

Write a command string with NO response to the hardware.

write_raw(cmd)

Low-level interface to visa_handle.write.

Attributes:

ancestors

Ancestors in the form of a list of InstrumentBase

delegate_attr_dicts

A list of names (strings) of dictionaries which are (or will be) attributes of self, whose keys should be treated as attributes of self.

delegate_attr_objects

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

full_name

Full name of the instrument.

label

Nicely formatted label of the instrument.

name

Full name of the instrument

name_parts

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs

A list of attribute names (strings) to not delegate to any other dictionary or object.

parent

The parent instrument.

root_instrument

The topmost parent of this module.

short_name

Short name of the instrument.

traces

Update channel list with active traces and return the new list

visa_handle

The VISA resource used by this instrument.

resource_manager

The VISA resource manager used by this instrument.

parameters

All the parameters supported by this instrument.

functions

All the functions supported by this instrument.

submodules

All the submodules of this instrument such as channel lists or logical groupings of parameters.

instrument_modules

All the InstrumentModule of this instrument Usually populated via add_submodule().

__del__() None

Close the instrument and remove its instance record.

__getitem__(key: str) Callable[..., Any] | Parameter

Delegate instrument[‘name’] to parameter or function ‘name’.

__getstate__() None

Prevent pickling instruments, and give a nice error message.

__repr__() str

Simplified repr giving just the class and 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.

Note

We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.

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: type[ParameterBase] | None = 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: 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 a ChannelTuple.

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:
  • KeyError – If this instrument already contains a submodule with this name.

  • TypeError – If the submodule that we are trying to add is not an instance of an Metadatable object.

property ancestors: tuple[InstrumentBase, ...]

Ancestors in the form of a list of InstrumentBase

The list starts with the current module then the parent and the parents parent 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 call super().ask(new_cmd). Subclasses that define a new hardware communication should instead override ask_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:

str

averages_off() None

Turn off trace averaging

averages_on() None

Turn on trace averaging

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.

close() None

Disconnect and irreversibly tear down the instrument.

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: float | None = 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_timetime.time() when init started. Default is self._t0, set at start of Instrument.__init__.

delegate_attr_dicts: ClassVar[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 of self.

delegate_attr_objects: ClassVar[list[str]] = []

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

device_clear() None

Clear the buffers of the device

static exist(name: str, instrument_class: type[Instrument] | None = 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: type[T] | None = None) T | Instrument

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:
  • KeyError – If no instrument of that name was found, or if its reference is invalid (dead).

  • TypeError – If a specific class was requested but a different type was found.

property full_name: str

Full name of the instrument.

For an InstrumentModule this includes all parents separated by _

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_component(full_name: str) MetadatableWithName

Recursively get a component of the instrument by full_name.

Parameters:

full_name – The name of the component to get.

Returns:

The component with the given name.

Raises:

KeyError – If the component does not exist.

get_idn() dict[str, str | None]

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.

get_options() Sequence[str]
get_trace_catalog() str

Get the trace catalog, that is a list of trace and sweep types from the PNA.

The format of the returned trace is:

trace_name,trace_type,trace_name,trace_type…

classmethod instances() list[T]

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.

property label: str

Nicely formatted label of the instrument.

load_metadata(metadata: Mapping[str, Any]) None

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

property name: str

Full name of the instrument

This is equivalent to full_name() for backwards compatibility.

property name_parts: list[str]

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs: ClassVar[list[str]] = []

A list of attribute names (strings) to not delegate to any other dictionary or object.

property parent: InstrumentBase | None

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. If False, 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

reset_averages() None

Reset averaging

property root_instrument: InstrumentBase

The topmost parent of this module.

For the root_instrument this is self.

select_trace_by_name(trace_name: str) int

Select a trace on the PNA by name.

Returns:

The trace number of the selected trace

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: str | None) 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.

property short_name: str

Short name of the instrument.

For an InstrumentModule this does not include any parent names.

snapshot(update: bool | None = False) dict[str, 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: bool | None = True, params_to_skip_update: Sequence[str] | None = 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:

dict

property traces: ChannelList

Update channel list with active traces and return the new list

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 call super().write(new_cmd). Subclasses that define a new hardware communication should instead override write_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.

visabackend: str = visabackend
visa_handle: pyvisa.resources.MessageBasedResource = visa_handle

The VISA resource used by this instrument.

visalib: str | None = visalib
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, 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 via add_submodule().

log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
metadata: dict[str, Any] = {}
resource_manager = resource_manager

The VISA resource manager used by this instrument.

class qcodes.instrument_drivers.Keysight.KeysightN5245A(name: str, address: str, **kwargs: Any)[source]

Bases: PNAxBase

Methods:

__del__()

Close the instrument and remove its instance record.

__getitem__(key)

Delegate instrument['name'] to parameter or function 'name'.

__getstate__()

Prevent pickling instruments, and give a nice error message.

__repr__()

Simplified repr giving just the class and name.

add_function(name, **kwargs)

Bind one Function to this instrument.

add_parameter(name[, parameter_class])

Bind one Parameter to this instrument.

add_submodule(name, submodule)

Bind one submodule to this instrument.

ask(cmd)

Write a command string to the hardware and return a response.

ask_raw(cmd)

Low-level interface to visa_handle.ask.

averages_off()

Turn off trace averaging

averages_on()

Turn on trace averaging

call(func_name, *args)

Shortcut for calling a function from its name.

close()

Disconnect and irreversibly tear down the instrument.

close_all()

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.

connect_message([idn_param, begin_time])

Print a standard message on initial connection to an instrument.

device_clear()

Clear the buffers of the device

exist(name[, instrument_class])

Check if an instrument with a given names exists (i.e. is already instantiated).

find_instrument(name[, instrument_class])

Find an existing instrument by name.

get(param_name)

Shortcut for getting a parameter from its name.

get_component(full_name)

Recursively get a component of the instrument by full_name.

get_idn()

Parse a standard VISA *IDN? response into an ID dict.

get_options()

get_trace_catalog()

Get the trace catalog, that is a list of trace and sweep types from the PNA.

instances()

Get all currently defined instances of this instrument class.

invalidate_cache()

Invalidate the cache of all parameters on the instrument.

is_valid(instr_instance)

Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a "valid" instrument.

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

print_readable_snapshot([update, max_chars])

Prints a readable version of the snapshot.

record_instance(instance)

Record (a weak ref to) an instance in a class's instance list.

remove_instance(instance)

Remove a particular instance from the record.

reset_averages()

Reset averaging

select_trace_by_name(trace_name)

Select a trace on the PNA by name.

set(param_name, value)

Shortcut for setting a parameter from its name and new value.

set_address(address)

Set the address for this instrument.

set_terminator(terminator)

Change the read terminator to use.

snapshot([update])

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class NumpyJSONEncoder supports).

validate_status([verbose])

Validate the values of all gettable parameters

write(cmd)

Write a command string with NO response to the hardware.

write_raw(cmd)

Low-level interface to visa_handle.write.

Attributes:

ancestors

Ancestors in the form of a list of InstrumentBase

delegate_attr_dicts

A list of names (strings) of dictionaries which are (or will be) attributes of self, whose keys should be treated as attributes of self.

delegate_attr_objects

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

full_name

Full name of the instrument.

label

Nicely formatted label of the instrument.

name

Full name of the instrument

name_parts

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs

A list of attribute names (strings) to not delegate to any other dictionary or object.

parent

The parent instrument.

root_instrument

The topmost parent of this module.

short_name

Short name of the instrument.

traces

Update channel list with active traces and return the new list

visa_handle

The VISA resource used by this instrument.

resource_manager

The VISA resource manager used by this instrument.

parameters

All the parameters supported by this instrument.

functions

All the functions supported by this instrument.

submodules

All the submodules of this instrument such as channel lists or logical groupings of parameters.

instrument_modules

All the InstrumentModule of this instrument Usually populated via add_submodule().

__del__() None

Close the instrument and remove its instance record.

__getitem__(key: str) Callable[..., Any] | Parameter

Delegate instrument[‘name’] to parameter or function ‘name’.

__getstate__() None

Prevent pickling instruments, and give a nice error message.

__repr__() str

Simplified repr giving just the class and 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.

Note

We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.

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: type[ParameterBase] | None = 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: 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 a ChannelTuple.

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:
  • KeyError – If this instrument already contains a submodule with this name.

  • TypeError – If the submodule that we are trying to add is not an instance of an Metadatable object.

property ancestors: tuple[InstrumentBase, ...]

Ancestors in the form of a list of InstrumentBase

The list starts with the current module then the parent and the parents parent 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 call super().ask(new_cmd). Subclasses that define a new hardware communication should instead override ask_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:

str

averages_off() None

Turn off trace averaging

averages_on() None

Turn on trace averaging

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.

close() None

Disconnect and irreversibly tear down the instrument.

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: float | None = 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_timetime.time() when init started. Default is self._t0, set at start of Instrument.__init__.

delegate_attr_dicts: ClassVar[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 of self.

delegate_attr_objects: ClassVar[list[str]] = []

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

device_clear() None

Clear the buffers of the device

static exist(name: str, instrument_class: type[Instrument] | None = 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: type[T] | None = None) T | Instrument

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:
  • KeyError – If no instrument of that name was found, or if its reference is invalid (dead).

  • TypeError – If a specific class was requested but a different type was found.

property full_name: str

Full name of the instrument.

For an InstrumentModule this includes all parents separated by _

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_component(full_name: str) MetadatableWithName

Recursively get a component of the instrument by full_name.

Parameters:

full_name – The name of the component to get.

Returns:

The component with the given name.

Raises:

KeyError – If the component does not exist.

get_idn() dict[str, str | None]

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.

get_options() Sequence[str]
get_trace_catalog() str

Get the trace catalog, that is a list of trace and sweep types from the PNA.

The format of the returned trace is:

trace_name,trace_type,trace_name,trace_type…

classmethod instances() list[T]

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.

property label: str

Nicely formatted label of the instrument.

load_metadata(metadata: Mapping[str, Any]) None

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

property name: str

Full name of the instrument

This is equivalent to full_name() for backwards compatibility.

property name_parts: list[str]

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs: ClassVar[list[str]] = []

A list of attribute names (strings) to not delegate to any other dictionary or object.

property parent: InstrumentBase | None

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. If False, 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

reset_averages() None

Reset averaging

property root_instrument: InstrumentBase

The topmost parent of this module.

For the root_instrument this is self.

select_trace_by_name(trace_name: str) int

Select a trace on the PNA by name.

Returns:

The trace number of the selected trace

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: str | None) 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.

property short_name: str

Short name of the instrument.

For an InstrumentModule this does not include any parent names.

snapshot(update: bool | None = False) dict[str, 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: bool | None = True, params_to_skip_update: Sequence[str] | None = 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:

dict

property traces: ChannelList

Update channel list with active traces and return the new list

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 call super().write(new_cmd). Subclasses that define a new hardware communication should instead override write_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.

visabackend: str = visabackend
visa_handle: pyvisa.resources.MessageBasedResource = visa_handle

The VISA resource used by this instrument.

visalib: str | None = visalib
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, 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 via add_submodule().

log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
metadata: dict[str, Any] = {}
resource_manager = resource_manager

The VISA resource manager used by this instrument.

class qcodes.instrument_drivers.Keysight.KeysightN6705B(name: str, address: str, **kwargs: Any)[source]

Bases: VisaInstrument

Methods:

get_idn()

Parse a standard VISA *IDN? response into an ID dict.

__del__()

Close the instrument and remove its instance record.

__getitem__(key)

Delegate instrument['name'] to parameter or function 'name'.

__getstate__()

Prevent pickling instruments, and give a nice error message.

__repr__()

Simplified repr giving just the class and name.

add_function(name, **kwargs)

Bind one Function to this instrument.

add_parameter(name[, parameter_class])

Bind one Parameter to this instrument.

add_submodule(name, submodule)

Bind one submodule to this instrument.

ask(cmd)

Write a command string to the hardware and return a response.

ask_raw(cmd)

Low-level interface to visa_handle.ask.

call(func_name, *args)

Shortcut for calling a function from its name.

close()

Disconnect and irreversibly tear down the instrument.

close_all()

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.

connect_message([idn_param, begin_time])

Print a standard message on initial connection to an instrument.

device_clear()

Clear the buffers of the device

exist(name[, instrument_class])

Check if an instrument with a given names exists (i.e. is already instantiated).

find_instrument(name[, instrument_class])

Find an existing instrument by name.

get(param_name)

Shortcut for getting a parameter from its name.

get_component(full_name)

Recursively get a component of the instrument by full_name.

instances()

Get all currently defined instances of this instrument class.

invalidate_cache()

Invalidate the cache of all parameters on the instrument.

is_valid(instr_instance)

Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a "valid" instrument.

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

print_readable_snapshot([update, max_chars])

Prints a readable version of the snapshot.

record_instance(instance)

Record (a weak ref to) an instance in a class's instance list.

remove_instance(instance)

Remove a particular instance from the record.

set(param_name, value)

Shortcut for setting a parameter from its name and new value.

set_address(address)

Set the address for this instrument.

set_terminator(terminator)

Change the read terminator to use.

snapshot([update])

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class NumpyJSONEncoder supports).

validate_status([verbose])

Validate the values of all gettable parameters

write(cmd)

Write a command string with NO response to the hardware.

write_raw(cmd)

Low-level interface to visa_handle.write.

Attributes:

ancestors

Ancestors in the form of a list of InstrumentBase

delegate_attr_dicts

A list of names (strings) of dictionaries which are (or will be) attributes of self, whose keys should be treated as attributes of self.

delegate_attr_objects

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

full_name

Full name of the instrument.

label

Nicely formatted label of the instrument.

name

Full name of the instrument

name_parts

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs

A list of attribute names (strings) to not delegate to any other dictionary or object.

parent

The parent instrument.

root_instrument

The topmost parent of this module.

short_name

Short name of the instrument.

visa_handle

The VISA resource used by this instrument.

resource_manager

The VISA resource manager used by this instrument.

parameters

All the parameters supported by this instrument.

functions

All the functions supported by this instrument.

submodules

All the submodules of this instrument such as channel lists or logical groupings of parameters.

instrument_modules

All the InstrumentModule of this instrument Usually populated via add_submodule().

channels: list[KeysightN6705BChannel] = []
get_idn() dict[str, str | None][source]

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.

__del__() None

Close the instrument and remove its instance record.

__getitem__(key: str) Callable[..., Any] | Parameter

Delegate instrument[‘name’] to parameter or function ‘name’.

__getstate__() None

Prevent pickling instruments, and give a nice error message.

__repr__() str

Simplified repr giving just the class and 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.

Note

We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.

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: type[ParameterBase] | None = 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: 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 a ChannelTuple.

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:
  • KeyError – If this instrument already contains a submodule with this name.

  • TypeError – If the submodule that we are trying to add is not an instance of an Metadatable object.

property ancestors: tuple[InstrumentBase, ...]

Ancestors in the form of a list of InstrumentBase

The list starts with the current module then the parent and the parents parent 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 call super().ask(new_cmd). Subclasses that define a new hardware communication should instead override ask_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:

str

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.

close() None

Disconnect and irreversibly tear down the instrument.

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: float | None = 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_timetime.time() when init started. Default is self._t0, set at start of Instrument.__init__.

delegate_attr_dicts: ClassVar[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 of self.

delegate_attr_objects: ClassVar[list[str]] = []

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

device_clear() None

Clear the buffers of the device

static exist(name: str, instrument_class: type[Instrument] | None = 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: type[T] | None = None) T | Instrument

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:
  • KeyError – If no instrument of that name was found, or if its reference is invalid (dead).

  • TypeError – If a specific class was requested but a different type was found.

property full_name: str

Full name of the instrument.

For an InstrumentModule this includes all parents separated by _

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_component(full_name: str) MetadatableWithName

Recursively get a component of the instrument by full_name.

Parameters:

full_name – The name of the component to get.

Returns:

The component with the given name.

Raises:

KeyError – If the component does not exist.

classmethod instances() list[T]

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.

property label: str

Nicely formatted label of the instrument.

load_metadata(metadata: Mapping[str, Any]) None

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

property name: str

Full name of the instrument

This is equivalent to full_name() for backwards compatibility.

property name_parts: list[str]

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs: ClassVar[list[str]] = []

A list of attribute names (strings) to not delegate to any other dictionary or object.

property parent: InstrumentBase | None

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. If False, 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: InstrumentBase

The topmost parent of this module.

For the root_instrument this is self.

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: str | None) 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.

property short_name: str

Short name of the instrument.

For an InstrumentModule this does not include any parent names.

snapshot(update: bool | None = False) dict[str, 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: bool | None = True, params_to_skip_update: Sequence[str] | None = 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:

dict

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 call super().write(new_cmd). Subclasses that define a new hardware communication should instead override write_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.

visabackend: str = visabackend
visa_handle: pyvisa.resources.MessageBasedResource = visa_handle

The VISA resource used by this instrument.

visalib: str | None = visalib
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, 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 via add_submodule().

log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
metadata: dict[str, Any] = {}
resource_manager = resource_manager

The VISA resource manager used by this instrument.

class qcodes.instrument_drivers.Keysight.KeysightN6705BChannel(parent: Instrument, name: str, chan: int)[source]

Bases: InstrumentChannel

Methods:

__getitem__(key)

Delegate instrument['name'] to parameter or function 'name'.

__getstate__()

Prevent pickling instruments, and give a nice error message.

__repr__()

Custom repr to give parent information

add_function(name, **kwargs)

Bind one Function to this instrument.

add_parameter(name[, parameter_class])

Bind one Parameter to this instrument.

add_submodule(name, submodule)

Bind one submodule to this instrument.

ask(cmd)

ask_raw(cmd)

call(func_name, *args)

Shortcut for calling a function from its name.

get(param_name)

Shortcut for getting a parameter from its name.

get_component(full_name)

Recursively get a component of the instrument by full_name.

invalidate_cache()

Invalidate the cache of all parameters on the instrument.

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

print_readable_snapshot([update, max_chars])

Prints a readable version of the snapshot.

set(param_name, value)

Shortcut for setting a parameter from its name and new value.

snapshot([update])

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class NumpyJSONEncoder supports).

validate_status([verbose])

Validate the values of all gettable parameters

write(cmd)

write_raw(cmd)

Attributes:

ancestors

Ancestors in the form of a list of InstrumentBase

delegate_attr_dicts

A list of names (strings) of dictionaries which are (or will be) attributes of self, whose keys should be treated as attributes of self.

delegate_attr_objects

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

full_name

Full name of the instrument.

label

Nicely formatted label of the instrument.

name

Full name of the instrument

name_parts

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs

A list of attribute names (strings) to not delegate to any other dictionary or object.

parent

The parent instrument.

root_instrument

The topmost parent of this module.

short_name

Short name of the instrument.

parameters

All the parameters supported by this instrument.

functions

All the functions supported by this instrument.

submodules

All the submodules of this instrument such as channel lists or logical groupings of parameters.

instrument_modules

All the InstrumentModule of this instrument Usually populated via add_submodule().

__getitem__(key: str) Callable[..., Any] | Parameter

Delegate instrument[‘name’] to parameter or function ‘name’.

__getstate__() None

Prevent pickling instruments, and give a nice error message.

__repr__() str

Custom repr to give parent information

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.

Note

We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.

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: type[ParameterBase] | None = 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: 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 a ChannelTuple.

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:
  • KeyError – If this instrument already contains a submodule with this name.

  • TypeError – If the submodule that we are trying to add is not an instance of an Metadatable object.

property ancestors: tuple[InstrumentBase, ...]

Ancestors in the form of a list of InstrumentBase

The list starts with the current module then the parent and the parents parent until the root instrument is reached.

ask(cmd: str) str
ask_raw(cmd: str) str
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: ClassVar[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 of self.

delegate_attr_objects: ClassVar[list[str]] = []

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

property full_name: str

Full name of the instrument.

For an InstrumentModule this includes all parents separated by _

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_component(full_name: str) MetadatableWithName

Recursively get a component of the instrument by full_name.

Parameters:

full_name – The name of the component to get.

Returns:

The component with the given name.

Raises:

KeyError – If the component does not exist.

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.

property label: str

Nicely formatted label of the instrument.

load_metadata(metadata: Mapping[str, Any]) None

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

property name: str

Full name of the instrument

This is equivalent to full_name() for backwards compatibility.

property name_parts: list[str]

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs: ClassVar[list[str]] = []

A list of attribute names (strings) to not delegate to any other dictionary or object.

property parent: InstrumentBase

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. If False, 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: InstrumentBase

The topmost parent of this module.

For the root_instrument this is self.

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.

property short_name: str

Short name of the instrument.

For an InstrumentModule this does not include any parent names.

snapshot(update: bool | None = False) dict[str, 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: bool | None = False, params_to_skip_update: Sequence[str] | None = 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. If False, 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:

dict

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_raw(cmd: str) None
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, 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 via add_submodule().

log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
metadata: dict[str, Any] = {}
class qcodes.instrument_drivers.Keysight.KeysightN9030B(name: str, address: str, **kwargs: Any)[source]

Bases: VisaInstrument

Driver for Keysight N9030B PXA signal analyzer. Keysight N9030B PXA signal analyzer is part of Keysight X-Series Multi-touch Signal Analyzers. This driver allows Swept SA measurements in Spectrum Analyzer mode and Log Plot measurements in Phase Noise mode of the instrument.

Parameters:
  • name

  • address

Methods:

available_modes()

Returns present and licensed modes for the instrument.

available_meas()

Gives available measurement with a given mode for the instrument

options()

Returns installed options numbers.

reset()

Reset the instrument by sending the RST command

abort()

Aborts the measurement

__del__()

Close the instrument and remove its instance record.

__getitem__(key)

Delegate instrument['name'] to parameter or function 'name'.

__getstate__()

Prevent pickling instruments, and give a nice error message.

__repr__()

Simplified repr giving just the class and name.

add_function(name, **kwargs)

Bind one Function to this instrument.

add_parameter(name[, parameter_class])

Bind one Parameter to this instrument.

add_submodule(name, submodule)

Bind one submodule to this instrument.

ask(cmd)

Write a command string to the hardware and return a response.

ask_raw(cmd)

Low-level interface to visa_handle.ask.

call(func_name, *args)

Shortcut for calling a function from its name.

close()

Disconnect and irreversibly tear down the instrument.

close_all()

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.

connect_message([idn_param, begin_time])

Print a standard message on initial connection to an instrument.

device_clear()

Clear the buffers of the device

exist(name[, instrument_class])

Check if an instrument with a given names exists (i.e. is already instantiated).

find_instrument(name[, instrument_class])

Find an existing instrument by name.

get(param_name)

Shortcut for getting a parameter from its name.

get_component(full_name)

Recursively get a component of the instrument by full_name.

get_idn()

Parse a standard VISA *IDN? response into an ID dict.

instances()

Get all currently defined instances of this instrument class.

invalidate_cache()

Invalidate the cache of all parameters on the instrument.

is_valid(instr_instance)

Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a "valid" instrument.

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

print_readable_snapshot([update, max_chars])

Prints a readable version of the snapshot.

record_instance(instance)

Record (a weak ref to) an instance in a class's instance list.

remove_instance(instance)

Remove a particular instance from the record.

set(param_name, value)

Shortcut for setting a parameter from its name and new value.

set_address(address)

Set the address for this instrument.

set_terminator(terminator)

Change the read terminator to use.

snapshot([update])

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class NumpyJSONEncoder supports).

validate_status([verbose])

Validate the values of all gettable parameters

write(cmd)

Write a command string with NO response to the hardware.

write_raw(cmd)

Low-level interface to visa_handle.write.

Attributes:

ancestors

Ancestors in the form of a list of InstrumentBase

delegate_attr_dicts

A list of names (strings) of dictionaries which are (or will be) attributes of self, whose keys should be treated as attributes of self.

delegate_attr_objects

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

full_name

Full name of the instrument.

label

Nicely formatted label of the instrument.

name

Full name of the instrument

name_parts

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs

A list of attribute names (strings) to not delegate to any other dictionary or object.

parent

The parent instrument.

root_instrument

The topmost parent of this module.

short_name

Short name of the instrument.

visa_handle

The VISA resource used by this instrument.

resource_manager

The VISA resource manager used by this instrument.

parameters

All the parameters supported by this instrument.

functions

All the functions supported by this instrument.

submodules

All the submodules of this instrument such as channel lists or logical groupings of parameters.

instrument_modules

All the InstrumentModule of this instrument Usually populated via add_submodule().

available_modes() tuple[str, ...][source]

Returns present and licensed modes for the instrument.

available_meas() tuple[str, ...][source]

Gives available measurement with a given mode for the instrument

options() tuple[str, ...][source]

Returns installed options numbers.

reset() None[source]

Reset the instrument by sending the RST command

abort() None[source]

Aborts the measurement

__del__() None

Close the instrument and remove its instance record.

__getitem__(key: str) Callable[..., Any] | Parameter

Delegate instrument[‘name’] to parameter or function ‘name’.

__getstate__() None

Prevent pickling instruments, and give a nice error message.

__repr__() str

Simplified repr giving just the class and 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.

Note

We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.

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: type[ParameterBase] | None = 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: 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 a ChannelTuple.

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:
  • KeyError – If this instrument already contains a submodule with this name.

  • TypeError – If the submodule that we are trying to add is not an instance of an Metadatable object.

property ancestors: tuple[InstrumentBase, ...]

Ancestors in the form of a list of InstrumentBase

The list starts with the current module then the parent and the parents parent 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 call super().ask(new_cmd). Subclasses that define a new hardware communication should instead override ask_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:

str

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.

close() None

Disconnect and irreversibly tear down the instrument.

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: float | None = 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_timetime.time() when init started. Default is self._t0, set at start of Instrument.__init__.

delegate_attr_dicts: ClassVar[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 of self.

delegate_attr_objects: ClassVar[list[str]] = []

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

device_clear() None

Clear the buffers of the device

static exist(name: str, instrument_class: type[Instrument] | None = 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: type[T] | None = None) T | Instrument

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:
  • KeyError – If no instrument of that name was found, or if its reference is invalid (dead).

  • TypeError – If a specific class was requested but a different type was found.

property full_name: str

Full name of the instrument.

For an InstrumentModule this includes all parents separated by _

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_component(full_name: str) MetadatableWithName

Recursively get a component of the instrument by full_name.

Parameters:

full_name – The name of the component to get.

Returns:

The component with the given name.

Raises:

KeyError – If the component does not exist.

get_idn() dict[str, str | None]

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[T]

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.

property label: str

Nicely formatted label of the instrument.

load_metadata(metadata: Mapping[str, Any]) None

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

property name: str

Full name of the instrument

This is equivalent to full_name() for backwards compatibility.

property name_parts: list[str]

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs: ClassVar[list[str]] = []

A list of attribute names (strings) to not delegate to any other dictionary or object.

property parent: InstrumentBase | None

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. If False, 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: InstrumentBase

The topmost parent of this module.

For the root_instrument this is self.

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: str | None) 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.

property short_name: str

Short name of the instrument.

For an InstrumentModule this does not include any parent names.

snapshot(update: bool | None = False) dict[str, 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: bool | None = True, params_to_skip_update: Sequence[str] | None = 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:

dict

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 call super().write(new_cmd). Subclasses that define a new hardware communication should instead override write_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.

visabackend: str = visabackend
visa_handle: pyvisa.resources.MessageBasedResource = visa_handle

The VISA resource used by this instrument.

visalib: str | None = visalib
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, 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 via add_submodule().

log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
metadata: dict[str, Any] = {}
resource_manager = resource_manager

The VISA resource manager used by this instrument.

class qcodes.instrument_drivers.Keysight.KeysightN9030BPhaseNoiseMode(parent: KeysightN9030B, name: str, *arg: Any, **kwargs: Any)[source]

Bases: InstrumentChannel

Phase Noise Mode for Keysight N9030B instrument.

Methods:

setup_log_plot_sweep(start_offset, ...)

Sets up the Log Plot measurement sweep for Phase Noise Mode.

autotune()

On autotune, the measurement automatically searches for and tunes to the strongest signal in the full span of the analyzer.

__getitem__(key)

Delegate instrument['name'] to parameter or function 'name'.

__getstate__()

Prevent pickling instruments, and give a nice error message.

__repr__()

Custom repr to give parent information

add_function(name, **kwargs)

Bind one Function to this instrument.

add_parameter(name[, parameter_class])

Bind one Parameter to this instrument.

add_submodule(name, submodule)

Bind one submodule to this instrument.

ask(cmd)

ask_raw(cmd)

call(func_name, *args)

Shortcut for calling a function from its name.

get(param_name)

Shortcut for getting a parameter from its name.

get_component(full_name)

Recursively get a component of the instrument by full_name.

invalidate_cache()

Invalidate the cache of all parameters on the instrument.

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

print_readable_snapshot([update, max_chars])

Prints a readable version of the snapshot.

set(param_name, value)

Shortcut for setting a parameter from its name and new value.

snapshot([update])

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class NumpyJSONEncoder supports).

validate_status([verbose])

Validate the values of all gettable parameters

write(cmd)

write_raw(cmd)

Attributes:

ancestors

Ancestors in the form of a list of InstrumentBase

delegate_attr_dicts

A list of names (strings) of dictionaries which are (or will be) attributes of self, whose keys should be treated as attributes of self.

delegate_attr_objects

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

full_name

Full name of the instrument.

label

Nicely formatted label of the instrument.

name

Full name of the instrument

name_parts

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs

A list of attribute names (strings) to not delegate to any other dictionary or object.

parent

The parent instrument.

root_instrument

The topmost parent of this module.

short_name

Short name of the instrument.

parameters

All the parameters supported by this instrument.

functions

All the functions supported by this instrument.

submodules

All the submodules of this instrument such as channel lists or logical groupings of parameters.

instrument_modules

All the InstrumentModule of this instrument Usually populated via add_submodule().

setup_log_plot_sweep(start_offset: float, stop_offset: float, npts: int) None[source]

Sets up the Log Plot measurement sweep for Phase Noise Mode.

autotune() None[source]

On autotune, the measurement automatically searches for and tunes to the strongest signal in the full span of the analyzer.

__getitem__(key: str) Callable[..., Any] | Parameter

Delegate instrument[‘name’] to parameter or function ‘name’.

__getstate__() None

Prevent pickling instruments, and give a nice error message.

__repr__() str

Custom repr to give parent information

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.

Note

We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.

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: type[ParameterBase] | None = 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: 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 a ChannelTuple.

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:
  • KeyError – If this instrument already contains a submodule with this name.

  • TypeError – If the submodule that we are trying to add is not an instance of an Metadatable object.

property ancestors: tuple[InstrumentBase, ...]

Ancestors in the form of a list of InstrumentBase

The list starts with the current module then the parent and the parents parent until the root instrument is reached.

ask(cmd: str) str
ask_raw(cmd: str) str
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: ClassVar[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 of self.

delegate_attr_objects: ClassVar[list[str]] = []

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

property full_name: str

Full name of the instrument.

For an InstrumentModule this includes all parents separated by _

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_component(full_name: str) MetadatableWithName

Recursively get a component of the instrument by full_name.

Parameters:

full_name – The name of the component to get.

Returns:

The component with the given name.

Raises:

KeyError – If the component does not exist.

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.

property label: str

Nicely formatted label of the instrument.

load_metadata(metadata: Mapping[str, Any]) None

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

property name: str

Full name of the instrument

This is equivalent to full_name() for backwards compatibility.

property name_parts: list[str]

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs: ClassVar[list[str]] = []

A list of attribute names (strings) to not delegate to any other dictionary or object.

property parent: InstrumentBase

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. If False, 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: InstrumentBase

The topmost parent of this module.

For the root_instrument this is self.

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.

property short_name: str

Short name of the instrument.

For an InstrumentModule this does not include any parent names.

snapshot(update: bool | None = False) dict[str, 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: bool | None = False, params_to_skip_update: Sequence[str] | None = 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. If False, 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:

dict

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_raw(cmd: str) None
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, 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 via add_submodule().

log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
metadata: dict[str, Any] = {}
class qcodes.instrument_drivers.Keysight.KeysightN9030BSpectrumAnalyzerMode(parent: KeysightN9030B, name: str, *arg: Any, additional_wait: int = 1, **kwargs: Any)[source]

Bases: InstrumentChannel

Spectrum Analyzer Mode for Keysight N9030B instrument.

Methods:

update_trace()

Updates all frequency parameters together when one is changed

setup_swept_sa_sweep(start, stop, npts)

Sets up the Swept SA measurement sweep for Spectrum Analyzer Mode.

autotune()

Autotune quickly get to the most likely signal of interest, and position it optimally on the display.

__getitem__(key)

Delegate instrument['name'] to parameter or function 'name'.

__getstate__()

Prevent pickling instruments, and give a nice error message.

__repr__()

Custom repr to give parent information

add_function(name, **kwargs)

Bind one Function to this instrument.

add_parameter(name[, parameter_class])

Bind one Parameter to this instrument.

add_submodule(name, submodule)

Bind one submodule to this instrument.

ask(cmd)

ask_raw(cmd)

call(func_name, *args)

Shortcut for calling a function from its name.

get(param_name)

Shortcut for getting a parameter from its name.

get_component(full_name)

Recursively get a component of the instrument by full_name.

invalidate_cache()

Invalidate the cache of all parameters on the instrument.

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

print_readable_snapshot([update, max_chars])

Prints a readable version of the snapshot.

set(param_name, value)

Shortcut for setting a parameter from its name and new value.

snapshot([update])

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class NumpyJSONEncoder supports).

validate_status([verbose])

Validate the values of all gettable parameters

write(cmd)

write_raw(cmd)

Attributes:

ancestors

Ancestors in the form of a list of InstrumentBase

delegate_attr_dicts

A list of names (strings) of dictionaries which are (or will be) attributes of self, whose keys should be treated as attributes of self.

delegate_attr_objects

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

full_name

Full name of the instrument.

label

Nicely formatted label of the instrument.

name

Full name of the instrument

name_parts

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs

A list of attribute names (strings) to not delegate to any other dictionary or object.

parent

The parent instrument.

root_instrument

The topmost parent of this module.

short_name

Short name of the instrument.

parameters

All the parameters supported by this instrument.

functions

All the functions supported by this instrument.

submodules

All the submodules of this instrument such as channel lists or logical groupings of parameters.

instrument_modules

All the InstrumentModule of this instrument Usually populated via add_submodule().

update_trace() None[source]

Updates all frequency parameters together when one is changed

setup_swept_sa_sweep(start: float, stop: float, npts: int) None[source]

Sets up the Swept SA measurement sweep for Spectrum Analyzer Mode.

autotune() None[source]

Autotune quickly get to the most likely signal of interest, and position it optimally on the display.

__getitem__(key: str) Callable[..., Any] | Parameter

Delegate instrument[‘name’] to parameter or function ‘name’.

__getstate__() None

Prevent pickling instruments, and give a nice error message.

__repr__() str

Custom repr to give parent information

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.

Note

We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.

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: type[ParameterBase] | None = 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: 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 a ChannelTuple.

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:
  • KeyError – If this instrument already contains a submodule with this name.

  • TypeError – If the submodule that we are trying to add is not an instance of an Metadatable object.

property ancestors: tuple[InstrumentBase, ...]

Ancestors in the form of a list of InstrumentBase

The list starts with the current module then the parent and the parents parent until the root instrument is reached.

ask(cmd: str) str
ask_raw(cmd: str) str
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: ClassVar[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 of self.

delegate_attr_objects: ClassVar[list[str]] = []

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

property full_name: str

Full name of the instrument.

For an InstrumentModule this includes all parents separated by _

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_component(full_name: str) MetadatableWithName

Recursively get a component of the instrument by full_name.

Parameters:

full_name – The name of the component to get.

Returns:

The component with the given name.

Raises:

KeyError – If the component does not exist.

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.

property label: str

Nicely formatted label of the instrument.

load_metadata(metadata: Mapping[str, Any]) None

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

property name: str

Full name of the instrument

This is equivalent to full_name() for backwards compatibility.

property name_parts: list[str]

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs: ClassVar[list[str]] = []

A list of attribute names (strings) to not delegate to any other dictionary or object.

property parent: InstrumentBase

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. If False, 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: InstrumentBase

The topmost parent of this module.

For the root_instrument this is self.

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.

property short_name: str

Short name of the instrument.

For an InstrumentModule this does not include any parent names.

snapshot(update: bool | None = False) dict[str, 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: bool | None = False, params_to_skip_update: Sequence[str] | None = 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. If False, 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:

dict

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_raw(cmd: str) None
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, 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 via add_submodule().

log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
metadata: dict[str, Any] = {}
class qcodes.instrument_drivers.Keysight.KeysightP9374A(name: str, address: str, **kwargs: Any)[source]

Bases: PNAxBase

Methods:

__del__()

Close the instrument and remove its instance record.

__getitem__(key)

Delegate instrument['name'] to parameter or function 'name'.

__getstate__()

Prevent pickling instruments, and give a nice error message.

__repr__()

Simplified repr giving just the class and name.

add_function(name, **kwargs)

Bind one Function to this instrument.

add_parameter(name[, parameter_class])

Bind one Parameter to this instrument.

add_submodule(name, submodule)

Bind one submodule to this instrument.

ask(cmd)

Write a command string to the hardware and return a response.

ask_raw(cmd)

Low-level interface to visa_handle.ask.

averages_off()

Turn off trace averaging

averages_on()

Turn on trace averaging

call(func_name, *args)

Shortcut for calling a function from its name.

close()

Disconnect and irreversibly tear down the instrument.

close_all()

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.

connect_message([idn_param, begin_time])

Print a standard message on initial connection to an instrument.

device_clear()

Clear the buffers of the device

exist(name[, instrument_class])

Check if an instrument with a given names exists (i.e. is already instantiated).

find_instrument(name[, instrument_class])

Find an existing instrument by name.

get(param_name)

Shortcut for getting a parameter from its name.

get_component(full_name)

Recursively get a component of the instrument by full_name.

get_idn()

Parse a standard VISA *IDN? response into an ID dict.

get_options()

get_trace_catalog()

Get the trace catalog, that is a list of trace and sweep types from the PNA.

instances()

Get all currently defined instances of this instrument class.

invalidate_cache()

Invalidate the cache of all parameters on the instrument.

is_valid(instr_instance)

Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a "valid" instrument.

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

print_readable_snapshot([update, max_chars])

Prints a readable version of the snapshot.

record_instance(instance)

Record (a weak ref to) an instance in a class's instance list.

remove_instance(instance)

Remove a particular instance from the record.

reset_averages()

Reset averaging

select_trace_by_name(trace_name)

Select a trace on the PNA by name.

set(param_name, value)

Shortcut for setting a parameter from its name and new value.

set_address(address)

Set the address for this instrument.

set_terminator(terminator)

Change the read terminator to use.

snapshot([update])

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class NumpyJSONEncoder supports).

validate_status([verbose])

Validate the values of all gettable parameters

write(cmd)

Write a command string with NO response to the hardware.

write_raw(cmd)

Low-level interface to visa_handle.write.

Attributes:

ancestors

Ancestors in the form of a list of InstrumentBase

delegate_attr_dicts

A list of names (strings) of dictionaries which are (or will be) attributes of self, whose keys should be treated as attributes of self.

delegate_attr_objects

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

full_name

Full name of the instrument.

label

Nicely formatted label of the instrument.

name

Full name of the instrument

name_parts

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs

A list of attribute names (strings) to not delegate to any other dictionary or object.

parent

The parent instrument.

root_instrument

The topmost parent of this module.

short_name

Short name of the instrument.

traces

Update channel list with active traces and return the new list

visa_handle

The VISA resource used by this instrument.

resource_manager

The VISA resource manager used by this instrument.

parameters

All the parameters supported by this instrument.

functions

All the functions supported by this instrument.

submodules

All the submodules of this instrument such as channel lists or logical groupings of parameters.

instrument_modules

All the InstrumentModule of this instrument Usually populated via add_submodule().

__del__() None

Close the instrument and remove its instance record.

__getitem__(key: str) Callable[..., Any] | Parameter

Delegate instrument[‘name’] to parameter or function ‘name’.

__getstate__() None

Prevent pickling instruments, and give a nice error message.

__repr__() str

Simplified repr giving just the class and 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.

Note

We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.

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: type[ParameterBase] | None = 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: 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 a ChannelTuple.

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:
  • KeyError – If this instrument already contains a submodule with this name.

  • TypeError – If the submodule that we are trying to add is not an instance of an Metadatable object.

property ancestors: tuple[InstrumentBase, ...]

Ancestors in the form of a list of InstrumentBase

The list starts with the current module then the parent and the parents parent 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 call super().ask(new_cmd). Subclasses that define a new hardware communication should instead override ask_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:

str

averages_off() None

Turn off trace averaging

averages_on() None

Turn on trace averaging

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.

close() None

Disconnect and irreversibly tear down the instrument.

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: float | None = 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_timetime.time() when init started. Default is self._t0, set at start of Instrument.__init__.

delegate_attr_dicts: ClassVar[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 of self.

delegate_attr_objects: ClassVar[list[str]] = []

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

device_clear() None

Clear the buffers of the device

static exist(name: str, instrument_class: type[Instrument] | None = 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: type[T] | None = None) T | Instrument

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:
  • KeyError – If no instrument of that name was found, or if its reference is invalid (dead).

  • TypeError – If a specific class was requested but a different type was found.

property full_name: str

Full name of the instrument.

For an InstrumentModule this includes all parents separated by _

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_component(full_name: str) MetadatableWithName

Recursively get a component of the instrument by full_name.

Parameters:

full_name – The name of the component to get.

Returns:

The component with the given name.

Raises:

KeyError – If the component does not exist.

get_idn() dict[str, str | None]

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.

get_options() Sequence[str]
get_trace_catalog() str

Get the trace catalog, that is a list of trace and sweep types from the PNA.

The format of the returned trace is:

trace_name,trace_type,trace_name,trace_type…

classmethod instances() list[T]

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.

property label: str

Nicely formatted label of the instrument.

load_metadata(metadata: Mapping[str, Any]) None

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

property name: str

Full name of the instrument

This is equivalent to full_name() for backwards compatibility.

property name_parts: list[str]

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs: ClassVar[list[str]] = []

A list of attribute names (strings) to not delegate to any other dictionary or object.

property parent: InstrumentBase | None

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. If False, 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

reset_averages() None

Reset averaging

property root_instrument: InstrumentBase

The topmost parent of this module.

For the root_instrument this is self.

select_trace_by_name(trace_name: str) int

Select a trace on the PNA by name.

Returns:

The trace number of the selected trace

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: str | None) 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.

property short_name: str

Short name of the instrument.

For an InstrumentModule this does not include any parent names.

snapshot(update: bool | None = False) dict[str, 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: bool | None = True, params_to_skip_update: Sequence[str] | None = 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:

dict

property traces: ChannelList

Update channel list with active traces and return the new list

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 call super().write(new_cmd). Subclasses that define a new hardware communication should instead override write_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.

visabackend: str = visabackend
visa_handle: pyvisa.resources.MessageBasedResource = visa_handle

The VISA resource used by this instrument.

visalib: str | None = visalib
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, 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 via add_submodule().

log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
metadata: dict[str, Any] = {}
resource_manager = resource_manager

The VISA resource manager used by this instrument.

class qcodes.instrument_drivers.Keysight.KeysightPNAPort(parent: PNABase, name: str, port: int, min_power: int | float, max_power: int | float, **kwargs: Any)[source]

Bases: InstrumentChannel

Allow operations on individual PNA ports. Note: This can be expanded to include a large number of extra parameters…

Methods:

__getitem__(key)

Delegate instrument['name'] to parameter or function 'name'.

__getstate__()

Prevent pickling instruments, and give a nice error message.

__repr__()

Custom repr to give parent information

add_function(name, **kwargs)

Bind one Function to this instrument.

add_parameter(name[, parameter_class])

Bind one Parameter to this instrument.

add_submodule(name, submodule)

Bind one submodule to this instrument.

ask(cmd)

ask_raw(cmd)

call(func_name, *args)

Shortcut for calling a function from its name.

get(param_name)

Shortcut for getting a parameter from its name.

get_component(full_name)

Recursively get a component of the instrument by full_name.

invalidate_cache()

Invalidate the cache of all parameters on the instrument.

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

print_readable_snapshot([update, max_chars])

Prints a readable version of the snapshot.

set(param_name, value)

Shortcut for setting a parameter from its name and new value.

snapshot([update])

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class NumpyJSONEncoder supports).

validate_status([verbose])

Validate the values of all gettable parameters

write(cmd)

write_raw(cmd)

Attributes:

ancestors

Ancestors in the form of a list of InstrumentBase

delegate_attr_dicts

A list of names (strings) of dictionaries which are (or will be) attributes of self, whose keys should be treated as attributes of self.

delegate_attr_objects

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

full_name

Full name of the instrument.

label

Nicely formatted label of the instrument.

name

Full name of the instrument

name_parts

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs

A list of attribute names (strings) to not delegate to any other dictionary or object.

parent

The parent instrument.

root_instrument

The topmost parent of this module.

short_name

Short name of the instrument.

parameters

All the parameters supported by this instrument.

functions

All the functions supported by this instrument.

submodules

All the submodules of this instrument such as channel lists or logical groupings of parameters.

instrument_modules

All the InstrumentModule of this instrument Usually populated via add_submodule().

__getitem__(key: str) Callable[..., Any] | Parameter

Delegate instrument[‘name’] to parameter or function ‘name’.

__getstate__() None

Prevent pickling instruments, and give a nice error message.

__repr__() str

Custom repr to give parent information

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.

Note

We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.

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: type[ParameterBase] | None = 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: 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 a ChannelTuple.

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:
  • KeyError – If this instrument already contains a submodule with this name.

  • TypeError – If the submodule that we are trying to add is not an instance of an Metadatable object.

property ancestors: tuple[InstrumentBase, ...]

Ancestors in the form of a list of InstrumentBase

The list starts with the current module then the parent and the parents parent until the root instrument is reached.

ask(cmd: str) str
ask_raw(cmd: str) str
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: ClassVar[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 of self.

delegate_attr_objects: ClassVar[list[str]] = []

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

property full_name: str

Full name of the instrument.

For an InstrumentModule this includes all parents separated by _

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_component(full_name: str) MetadatableWithName

Recursively get a component of the instrument by full_name.

Parameters:

full_name – The name of the component to get.

Returns:

The component with the given name.

Raises:

KeyError – If the component does not exist.

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.

property label: str

Nicely formatted label of the instrument.

load_metadata(metadata: Mapping[str, Any]) None

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

property name: str

Full name of the instrument

This is equivalent to full_name() for backwards compatibility.

property name_parts: list[str]

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs: ClassVar[list[str]] = []

A list of attribute names (strings) to not delegate to any other dictionary or object.

property parent: InstrumentBase

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. If False, 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: InstrumentBase

The topmost parent of this module.

For the root_instrument this is self.

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.

property short_name: str

Short name of the instrument.

For an InstrumentModule this does not include any parent names.

snapshot(update: bool | None = False) dict[str, 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: bool | None = False, params_to_skip_update: Sequence[str] | None = 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. If False, 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:

dict

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_raw(cmd: str) None
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, 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 via add_submodule().

log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
metadata: dict[str, Any] = {}
class qcodes.instrument_drivers.Keysight.KeysightPNATrace(parent: PNABase, name: str, trace_name: str, trace_num: int, **kwargs: Any)[source]

Bases: InstrumentChannel

Allow operations on individual PNA traces.

Methods:

run_sweep()

Run a set of sweeps on the network analyzer.

write(cmd)

Select correct trace before querying

ask(cmd)

Select correct trace before querying

__getitem__(key)

Delegate instrument['name'] to parameter or function 'name'.

__getstate__()

Prevent pickling instruments, and give a nice error message.

__repr__()

Custom repr to give parent information

add_function(name, **kwargs)

Bind one Function to this instrument.

add_parameter(name[, parameter_class])

Bind one Parameter to this instrument.

add_submodule(name, submodule)

Bind one submodule to this instrument.

ask_raw(cmd)

call(func_name, *args)

Shortcut for calling a function from its name.

get(param_name)

Shortcut for getting a parameter from its name.

get_component(full_name)

Recursively get a component of the instrument by full_name.

invalidate_cache()

Invalidate the cache of all parameters on the instrument.

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

print_readable_snapshot([update, max_chars])

Prints a readable version of the snapshot.

set(param_name, value)

Shortcut for setting a parameter from its name and new value.

snapshot([update])

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class NumpyJSONEncoder supports).

validate_status([verbose])

Validate the values of all gettable parameters

write_raw(cmd)

Attributes:

ancestors

Ancestors in the form of a list of InstrumentBase

delegate_attr_dicts

A list of names (strings) of dictionaries which are (or will be) attributes of self, whose keys should be treated as attributes of self.

delegate_attr_objects

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

full_name

Full name of the instrument.

label

Nicely formatted label of the instrument.

name

Full name of the instrument

name_parts

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs

A list of attribute names (strings) to not delegate to any other dictionary or object.

parent

The parent instrument.

root_instrument

The topmost parent of this module.

short_name

Short name of the instrument.

parameters

All the parameters supported by this instrument.

functions

All the functions supported by this instrument.

submodules

All the submodules of this instrument such as channel lists or logical groupings of parameters.

instrument_modules

All the InstrumentModule of this instrument Usually populated via add_submodule().

run_sweep() str[source]

Run a set of sweeps on the network analyzer. Note that this will run all traces on the current channel.

write(cmd: str) None[source]

Select correct trace before querying

ask(cmd: str) str[source]

Select correct trace before querying

__getitem__(key: str) Callable[..., Any] | Parameter

Delegate instrument[‘name’] to parameter or function ‘name’.

__getstate__() None

Prevent pickling instruments, and give a nice error message.

__repr__() str

Custom repr to give parent information

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.

Note

We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.

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: type[ParameterBase] | None = 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: 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 a ChannelTuple.

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:
  • KeyError – If this instrument already contains a submodule with this name.

  • TypeError – If the submodule that we are trying to add is not an instance of an Metadatable object.

property ancestors: tuple[InstrumentBase, ...]

Ancestors in the form of a list of InstrumentBase

The list starts with the current module then the parent and the parents parent until the root instrument is reached.

ask_raw(cmd: str) str
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: ClassVar[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 of self.

delegate_attr_objects: ClassVar[list[str]] = []

A list of names (strings) of objects which are (or will be) attributes of self, whose attributes should be passed through to self.

property full_name: str

Full name of the instrument.

For an InstrumentModule this includes all parents separated by _

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_component(full_name: str) MetadatableWithName

Recursively get a component of the instrument by full_name.

Parameters:

full_name – The name of the component to get.

Returns:

The component with the given name.

Raises:

KeyError – If the component does not exist.

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.

property label: str

Nicely formatted label of the instrument.

load_metadata(metadata: Mapping[str, Any]) None

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

property name: str

Full name of the instrument

This is equivalent to full_name() for backwards compatibility.

property name_parts: list[str]

A list of all the parts of the instrument name from root_instrument() to the current InstrumentModule.

omit_delegate_attrs: ClassVar[list[str]] = []

A list of attribute names (strings) to not delegate to any other dictionary or object.

property parent: InstrumentBase

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. If False, 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: InstrumentBase

The topmost parent of this module.

For the root_instrument this is self.

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.

property short_name: str

Short name of the instrument.

For an InstrumentModule this does not include any parent names.

snapshot(update: bool | None = False) dict[str, 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: bool | None = False, params_to_skip_update: Sequence[str] | None = 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. If False, 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:

dict

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_raw(cmd: str) None
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, 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 via add_submodule().

log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
metadata: dict[str, Any] = {}