Keithley Drivers

Classes:

Keithley2000(name, address[, reset])

Driver for the Keithley 2000 multimeter.

Keithley2400(name, address, **kwargs)

QCoDeS driver for the Keithley 2400 voltage source.

Keithley2450(name, address, **kwargs)

The QCoDeS driver for the Keithley 2450 SMU

Keithley2450Buffer(parent, name[, size, style])

Treat the reading buffer as a submodule, similar to Sense and Source

Keithley2450Sense(parent, name, proper_function)

The sense module of the Keithley 2450 SMU.

Keithley2450Source(parent, name, proper_function)

The source module of the Keithley 2450 SMU.

Keithley2600MeasurementStatus(value[, ...])

Keeps track of measurement status.

Keithley2601B(name, address, **kwargs)

QCoDeS driver for the Keithley 2601B Source-Meter

Keithley2602A(name, address, **kwargs)

QCoDeS driver for the Keithley 2602A Source-Meter

Keithley2602B(name, address, **kwargs)

QCoDeS driver for the Keithley 2602B Source-Meter

Keithley2604B(name, address, **kwargs)

QCoDeS driver for the Keithley 2604B Source-Meter

Keithley2611B(name, address, **kwargs)

QCoDeS driver for the Keithley 2611B Source-Meter

Keithley2612B(name, address, **kwargs)

QCoDeS driver for the Keithley 2612B Source-Meter

Keithley2614B(name, address, **kwargs)

QCoDeS driver for the Keithley 2614B Source-Meter

Keithley2634B(name, address, **kwargs)

QCoDeS driver for the Keithley 2634B Source-Meter

Keithley2635B(name, address, **kwargs)

QCoDeS driver for the Keithley 2635B Source-Meter

Keithley2636B(name, address, **kwargs)

QCoDeS driver for the Keithley 2636B Source-Meter

Keithley3706A(name, address[, terminator])

This is the QCoDeS instrument driver for the Keithley 3706A-SNFP System Switch.

Keithley6500(name, address[, reset_device])

Driver for the Keithley 6500 multimeter. Based on the Keithley 2000 driver,

Keithley7510(name, address[, terminator])

The QCoDeS driver for the Keithley 7510 DMM

Keithley7510Buffer(parent, name[, size, style])

Treat the reading buffer as a submodule, similar to Sense.

Keithley7510DigitizeSense(parent, name, ...)

The Digitize sense module of the Keithley 7510 DMM.

Keithley7510Sense(parent, name, proper_function)

The sense module of the Keithley 7510 DMM, based on the sense module of Keithley 2450 SMU.

KeithleyS46(name, address, **kwargs)

KeithleyS46RelayLock(relay_name)

The S46 either has six pole or a four pole relays.

Data:

Keithley26xx

All Keithley 26xx SMUs supported by QCoDeS.

Exceptions:

Keithley3706AInvalidValue

Keithley3706AUnknownOrEmptySlot

Keithley6500CommandSetError

KeithleyS46LockAcquisitionError

class qcodes.instrument_drivers.Keithley.Keithley2000(name: str, address: str, reset: bool = False, **kwargs: Any)[source]

Bases: VisaInstrument

Driver for the Keithley 2000 multimeter.

Methods:

trigger()

__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().

trigger() None[source]
__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.Keithley.Keithley2400(name: str, address: str, **kwargs: Any)[source]

Bases: VisaInstrument

QCoDeS driver for the Keithley 2400 voltage source.

Methods:

reset()

Reset the instrument.

__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().

reset() None[source]

Reset the instrument. When the instrument is reset, it performs the following actions.

Returns the SourceMeter to the GPIB default conditions.

Cancels all pending commands.

Cancels all previously send *OPC and *OPC?

__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.Keithley.Keithley2450(name: str, address: str, **kwargs: Any)[source]

Bases: VisaInstrument

The QCoDeS driver for the Keithley 2450 SMU

Attributes:

source

We have different source modules depending on the source function, which can be 'current' or 'voltage'

sense

We have different sense modules depending on the sense function, which can be 'current', 'voltage' or 'resistance'

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:

buffer(name[, size, style])

npts()

Get the number of points in the sweep axis

set_correct_language()

The correct communication protocol is SCPI, make sure this is set

abort()

This command stops all trigger model commands on the instrument.

initiate()

This command starts the trigger model.

wait()

This command postpones the execution of subsequent commands until all previous overlapped commands are finished.

clear_event_register()

This function clears event registers.

clear_event_log()

This command clears the event log.

reset()

Returns instrument to default settings, cancels all pending commands.

__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.

property source: Keithley2450Source

We have different source modules depending on the source function, which can be ‘current’ or ‘voltage’

Return the correct source module based on the source function

property sense: Keithley2450Sense

We have different sense modules depending on the sense function, which can be ‘current’, ‘voltage’ or ‘resistance’

Return the correct source module based on the sense function

buffer(name: str, size: int | None = None, style: str = '') Keithley2450Buffer[source]
npts() int[source]

Get the number of points in the sweep axis

set_correct_language() None[source]

The correct communication protocol is SCPI, make sure this is set

abort() None[source]

This command stops all trigger model commands on the instrument.

initiate() None[source]

This command starts the trigger model.

wait() None[source]

This command postpones the execution of subsequent commands until all previous overlapped commands are finished.

clear_event_register() None[source]

This function clears event registers.

clear_event_log() None[source]

This command clears the event log.

reset() None[source]

Returns instrument to default settings, cancels all pending commands.

__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.Keithley.Keithley2450Buffer(parent: Keithley2450, name: str, size: int | None = None, style: str = '')[source]

Bases: InstrumentChannel

Treat the reading buffer as a submodule, similar to Sense and Source

Attributes:

default_buffer

buffer_elements

inverted_buffer_elements

available_elements

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:

from_name_to_scpi(element_names)

from_scpi_to_name(element_scpis)

get_last_reading()

This method requests the latest reading from a reading buffer.

get_data(start_idx, end_idx[, readings_only])

This command returns specified data elements from reading buffer.

clear_buffer()

Clear the data in the buffer

trigger_start()

This method makes readings using the active measure function and stores them in a reading buffer.

delete()

__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)

default_buffer: ClassVar[set[str]] = {'defbuffer1', 'defbuffer2'}
buffer_elements: ClassVar[dict[str, str]] = {'date': 'DATE', 'fractional_seconds': 'FRACtional', 'measurement': 'READing', 'measurement_formatted': 'FORMatted', 'measurement_status': 'STATus', 'measurement_unit': 'UNIT', 'relative_time': 'RELative', 'seconds': 'SEConds', 'source_value': 'SOURce', 'source_value_formatted': 'SOURFORMatted', 'source_value_status': 'SOURSTATus', 'source_value_unit': 'SOURUNIT', 'time': 'TIME', 'timestamp': 'TSTamp'}
inverted_buffer_elements = {'DATE': 'date', 'FORMatted': 'measurement_formatted', 'FRACtional': 'fractional_seconds', 'READing': 'measurement', 'RELative': 'relative_time', 'SEConds': 'seconds', 'SOURFORMatted': 'source_value_formatted', 'SOURSTATus': 'source_value_status', 'SOURUNIT': 'source_value_unit', 'SOURce': 'source_value', 'STATus': 'measurement_status', 'TIME': 'time', 'TSTamp': 'timestamp', 'UNIT': 'measurement_unit'}
from_name_to_scpi(element_names: list[str]) list[str][source]
from_scpi_to_name(element_scpis: list[str]) list[str][source]
property available_elements: set[str]
get_last_reading() str[source]

This method requests the latest reading from a reading buffer.

get_data(start_idx: int, end_idx: int, readings_only: bool = False) list[Any][source]

This command returns specified data elements from reading buffer.

Parameters:
  • start_idx – beginning index of the buffer to return

  • end_idx – ending index of the buffer to return

  • readings_only – a flag to temporarily disable the elements and output only the numerical readings

Returns:

data elements from the reading buffer

clear_buffer() None[source]

Clear the data in the buffer

trigger_start() None[source]

This method makes readings using the active measure function and stores them in a reading buffer.

delete() 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.Keithley.Keithley2450Sense(parent: Keithley2450, name: str, proper_function: str)[source]

Bases: InstrumentChannel

The sense module of the Keithley 2450 SMU.

Parameters:
  • parent

  • name

  • proper_function – This can be one of either “current”, “voltage” or “resistance”. All parameters and methods in this submodule should only be accessible to the user if self.parent.sense_function.get() == self._proper_function. We ensure this through the ‘sense’ property on the main driver class which returns the proper submodule for any given function mode

Attributes:

function_modes

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:

auto_zero_once()

This command causes the instrument to refresh the reference and zero measurements once.

clear_trace([buffer_name])

Clear the data buffer

__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_modes: ClassVar[dict[str, _FunctionMode]] = {'current': {'name': '"CURR:DC"', 'range_vals': <Numbers 1e-08<=v<=1>, 'unit': 'A'}, 'resistance': {'name': '"RES"', 'range_vals': <Numbers 20<=v<=200000000.0>, 'unit': 'Ohm'}, 'voltage': {'name': '"VOLT:DC"', 'range_vals': <Numbers 0.02<=v<=200>, 'unit': 'V'}}
auto_zero_once() None[source]

This command causes the instrument to refresh the reference and zero measurements once.

clear_trace(buffer_name: str = 'defbuffer1') None[source]

Clear the data buffer

__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.Keithley.Keithley2450Source(parent: Keithley2450, name: str, proper_function: str)[source]

Bases: InstrumentChannel

The source module of the Keithley 2450 SMU.

Parameters:
  • parent

  • name

  • proper_function – This can be one of either “current” or “voltage” All parameters and methods in this submodule should only be accessible to the user if self.parent.source_function.get() == self._proper_function. We ensure this through the ‘source’ property on the main driver class which returns the proper submodule for any given function mode

Attributes:

function_modes

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:

get_sweep_axis()

sweep_setup(start, stop, step_count[, ...])

sweep_start()

Start a sweep and return when the sweep has finished.

sweep_reset()

__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_modes: ClassVar[dict[str, _FunctionMode]] = {'current': {'name': 'CURR', 'range_vals': <Numbers -1<=v<=1>, 'unit': 'A'}, 'voltage': {'name': 'VOLT', 'range_vals': <Numbers -200<=v<=200>, 'unit': 'V'}}
get_sweep_axis() ndarray[source]
sweep_setup(start: float, stop: float, step_count: int, delay: float = 0, sweep_count: int = 1, range_mode: str = 'AUTO', fail_abort: str = 'ON', dual: str = 'OFF', buffer_name: str = 'defbuffer1') None[source]
sweep_start() None[source]

Start a sweep and return when the sweep has finished. Note: This call is blocking

sweep_reset() 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.Keithley.Keithley2600MeasurementStatus(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: StrEnum

Keeps track of measurement status.

Attributes:

CURRENT_COMPLIANCE_ERROR

VOLTAGE_COMPLIANCE_ERROR

VOLTAGE_AND_CURRENT_COMPLIANCE_ERROR

NORMAL

COMPLIANCE_ERROR

Methods:

__new_member__(*values)

values must already be of type str

encode([encoding, errors])

Encode the string using the codec registered for encoding.

replace(old, new[, count])

Return a copy with all occurrences of substring old replaced by new.

split([sep, maxsplit])

Return a list of the substrings in the string, using sep as the separator string.

rsplit([sep, maxsplit])

Return a list of the substrings in the string, using sep as the separator string.

join(iterable, /)

Concatenate any number of strings.

capitalize()

Return a capitalized version of the string.

casefold()

Return a version of the string suitable for caseless comparisons.

title()

Return a version of the string where each word is titlecased.

center(width[, fillchar])

Return a centered string of length width.

count(sub[, start[, end]])

Return the number of non-overlapping occurrences of substring sub in string S[start:end].

expandtabs([tabsize])

Return a copy where all tab characters are expanded using spaces.

find(sub[, start[, end]])

Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end].

partition(sep, /)

Partition the string into three parts using the given separator.

index(sub[, start[, end]])

Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end].

ljust(width[, fillchar])

Return a left-justified string of length width.

lower()

Return a copy of the string converted to lowercase.

lstrip([chars])

Return a copy of the string with leading whitespace removed.

rfind(sub[, start[, end]])

Return the highest index in S where substring sub is found, such that sub is contained within S[start:end].

rindex(sub[, start[, end]])

Return the highest index in S where substring sub is found, such that sub is contained within S[start:end].

rjust(width[, fillchar])

Return a right-justified string of length width.

rstrip([chars])

Return a copy of the string with trailing whitespace removed.

rpartition(sep, /)

Partition the string into three parts using the given separator.

splitlines([keepends])

Return a list of the lines in the string, breaking at line boundaries.

strip([chars])

Return a copy of the string with leading and trailing whitespace removed.

swapcase()

Convert uppercase characters to lowercase and lowercase characters to uppercase.

translate(table, /)

Replace each character in the string using the given translation table.

upper()

Return a copy of the string converted to uppercase.

startswith(prefix[, start[, end]])

Return True if S starts with the specified prefix, False otherwise.

endswith(suffix[, start[, end]])

Return True if S ends with the specified suffix, False otherwise.

removeprefix(prefix, /)

Return a str with the given prefix string removed if present.

removesuffix(suffix, /)

Return a str with the given suffix string removed if present.

isascii()

Return True if all characters in the string are ASCII, False otherwise.

islower()

Return True if the string is a lowercase string, False otherwise.

isupper()

Return True if the string is an uppercase string, False otherwise.

istitle()

Return True if the string is a title-cased string, False otherwise.

isspace()

Return True if the string is a whitespace string, False otherwise.

isdecimal()

Return True if the string is a decimal string, False otherwise.

isdigit()

Return True if the string is a digit string, False otherwise.

isnumeric()

Return True if the string is a numeric string, False otherwise.

isalpha()

Return True if the string is an alphabetic string, False otherwise.

isalnum()

Return True if the string is an alpha-numeric string, False otherwise.

isidentifier()

Return True if the string is a valid Python identifier, False otherwise.

isprintable()

Return True if the string is printable, False otherwise.

zfill(width, /)

Pad a numeric string with zeros on the left, to fill a field of the given width.

format(*args, **kwargs)

Return a formatted version of S, using substitutions from args and kwargs.

format_map(mapping)

Return a formatted version of S, using substitutions from mapping.

maketrans

Return a translation table usable for str.translate().

__dir__()

Returns public methods and other interesting attributes.

CURRENT_COMPLIANCE_ERROR = 'Reached current compliance limit.'
VOLTAGE_COMPLIANCE_ERROR = 'Reached voltage compliance limit.'
VOLTAGE_AND_CURRENT_COMPLIANCE_ERROR = 'Reached both voltage and current compliance limits.'
NORMAL = 'No error occured.'
COMPLIANCE_ERROR = 'Reached compliance limit.'
__new_member__(*values)

values must already be of type str

encode(encoding='utf-8', errors='strict')

Encode the string using the codec registered for encoding.

encoding

The encoding in which to encode the string.

errors

The error handling scheme to use for encoding errors. The default is ‘strict’ meaning that encoding errors raise a UnicodeEncodeError. Other possible values are ‘ignore’, ‘replace’ and ‘xmlcharrefreplace’ as well as any other name registered with codecs.register_error that can handle UnicodeEncodeErrors.

replace(old, new, count=-1, /)

Return a copy with all occurrences of substring old replaced by new.

count

Maximum number of occurrences to replace. -1 (the default value) means replace all occurrences.

If the optional argument count is given, only the first count occurrences are replaced.

split(sep=None, maxsplit=-1)

Return a list of the substrings in the string, using sep as the separator string.

sep

The separator used to split the string.

When set to None (the default value), will split on any whitespace character (including n r t f and spaces) and will discard empty strings from the result.

maxsplit

Maximum number of splits. -1 (the default value) means no limit.

Splitting starts at the front of the string and works to the end.

Note, str.split() is mainly useful for data that has been intentionally delimited. With natural text that includes punctuation, consider using the regular expression module.

rsplit(sep=None, maxsplit=-1)

Return a list of the substrings in the string, using sep as the separator string.

sep

The separator used to split the string.

When set to None (the default value), will split on any whitespace character (including n r t f and spaces) and will discard empty strings from the result.

maxsplit

Maximum number of splits. -1 (the default value) means no limit.

Splitting starts at the end of the string and works to the front.

join(iterable, /)

Concatenate any number of strings.

The string whose method is called is inserted in between each given string. The result is returned as a new string.

Example: ‘.’.join([‘ab’, ‘pq’, ‘rs’]) -> ‘ab.pq.rs’

capitalize()

Return a capitalized version of the string.

More specifically, make the first character have upper case and the rest lower case.

casefold()

Return a version of the string suitable for caseless comparisons.

title()

Return a version of the string where each word is titlecased.

More specifically, words start with uppercased characters and all remaining cased characters have lower case.

center(width, fillchar=' ', /)

Return a centered string of length width.

Padding is done using the specified fill character (default is a space).

count(sub[, start[, end]]) int

Return the number of non-overlapping occurrences of substring sub in string S[start:end]. Optional arguments start and end are interpreted as in slice notation.

expandtabs(tabsize=8)

Return a copy where all tab characters are expanded using spaces.

If tabsize is not given, a tab size of 8 characters is assumed.

find(sub[, start[, end]]) int

Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Return -1 on failure.

partition(sep, /)

Partition the string into three parts using the given separator.

This will search for the separator in the string. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

If the separator is not found, returns a 3-tuple containing the original string and two empty strings.

index(sub[, start[, end]]) int

Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Raises ValueError when the substring is not found.

ljust(width, fillchar=' ', /)

Return a left-justified string of length width.

Padding is done using the specified fill character (default is a space).

lower()

Return a copy of the string converted to lowercase.

lstrip(chars=None, /)

Return a copy of the string with leading whitespace removed.

If chars is given and not None, remove characters in chars instead.

rfind(sub[, start[, end]]) int

Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Return -1 on failure.

rindex(sub[, start[, end]]) int

Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Raises ValueError when the substring is not found.

rjust(width, fillchar=' ', /)

Return a right-justified string of length width.

Padding is done using the specified fill character (default is a space).

rstrip(chars=None, /)

Return a copy of the string with trailing whitespace removed.

If chars is given and not None, remove characters in chars instead.

rpartition(sep, /)

Partition the string into three parts using the given separator.

This will search for the separator in the string, starting at the end. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

If the separator is not found, returns a 3-tuple containing two empty strings and the original string.

splitlines(keepends=False)

Return a list of the lines in the string, breaking at line boundaries.

Line breaks are not included in the resulting list unless keepends is given and true.

strip(chars=None, /)

Return a copy of the string with leading and trailing whitespace removed.

If chars is given and not None, remove characters in chars instead.

swapcase()

Convert uppercase characters to lowercase and lowercase characters to uppercase.

translate(table, /)

Replace each character in the string using the given translation table.

table

Translation table, which must be a mapping of Unicode ordinals to Unicode ordinals, strings, or None.

The table must implement lookup/indexing via __getitem__, for instance a dictionary or list. If this operation raises LookupError, the character is left untouched. Characters mapped to None are deleted.

upper()

Return a copy of the string converted to uppercase.

startswith(prefix[, start[, end]]) bool

Return True if S starts with the specified prefix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. prefix can also be a tuple of strings to try.

endswith(suffix[, start[, end]]) bool

Return True if S ends with the specified suffix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. suffix can also be a tuple of strings to try.

removeprefix(prefix, /)

Return a str with the given prefix string removed if present.

If the string starts with the prefix string, return string[len(prefix):]. Otherwise, return a copy of the original string.

removesuffix(suffix, /)

Return a str with the given suffix string removed if present.

If the string ends with the suffix string and that suffix is not empty, return string[:-len(suffix)]. Otherwise, return a copy of the original string.

isascii()

Return True if all characters in the string are ASCII, False otherwise.

ASCII characters have code points in the range U+0000-U+007F. Empty string is ASCII too.

islower()

Return True if the string is a lowercase string, False otherwise.

A string is lowercase if all cased characters in the string are lowercase and there is at least one cased character in the string.

isupper()

Return True if the string is an uppercase string, False otherwise.

A string is uppercase if all cased characters in the string are uppercase and there is at least one cased character in the string.

istitle()

Return True if the string is a title-cased string, False otherwise.

In a title-cased string, upper- and title-case characters may only follow uncased characters and lowercase characters only cased ones.

isspace()

Return True if the string is a whitespace string, False otherwise.

A string is whitespace if all characters in the string are whitespace and there is at least one character in the string.

isdecimal()

Return True if the string is a decimal string, False otherwise.

A string is a decimal string if all characters in the string are decimal and there is at least one character in the string.

isdigit()

Return True if the string is a digit string, False otherwise.

A string is a digit string if all characters in the string are digits and there is at least one character in the string.

isnumeric()

Return True if the string is a numeric string, False otherwise.

A string is numeric if all characters in the string are numeric and there is at least one character in the string.

isalpha()

Return True if the string is an alphabetic string, False otherwise.

A string is alphabetic if all characters in the string are alphabetic and there is at least one character in the string.

isalnum()

Return True if the string is an alpha-numeric string, False otherwise.

A string is alpha-numeric if all characters in the string are alpha-numeric and there is at least one character in the string.

isidentifier()

Return True if the string is a valid Python identifier, False otherwise.

Call keyword.iskeyword(s) to test whether string s is a reserved identifier, such as “def” or “class”.

isprintable()

Return True if the string is printable, False otherwise.

A string is printable if all of its characters are considered printable in repr() or if it is empty.

zfill(width, /)

Pad a numeric string with zeros on the left, to fill a field of the given width.

The string is never truncated.

format(*args, **kwargs) str

Return a formatted version of S, using substitutions from args and kwargs. The substitutions are identified by braces (‘{’ and ‘}’).

format_map(mapping) str

Return a formatted version of S, using substitutions from mapping. The substitutions are identified by braces (‘{’ and ‘}’).

static maketrans()

Return a translation table usable for str.translate().

If there is only one argument, it must be a dictionary mapping Unicode ordinals (integers) or characters to Unicode ordinals, strings or None. Character keys will be then converted to ordinals. If there are two arguments, they must be strings of equal length, and in the resulting dictionary, each character in x will be mapped to the character at the same position in y. If there is a third argument, it must be a string, whose characters will be mapped to None in the result.

__dir__()

Returns public methods and other interesting attributes.

qcodes.instrument_drivers.Keithley.Keithley26xx(*args, **kwargs)

All Keithley 26xx SMUs supported by QCoDeS.

alias of Keithley2601B | Keithley2602A | Keithley2602B | Keithley2604B | Keithley2611B | Keithley2612B | Keithley2614B | Keithley2634B | Keithley2635B | Keithley2636B

class qcodes.instrument_drivers.Keithley.Keithley2601B(name: str, address: str, **kwargs: Any)[source]

Bases: Keithley2600

QCoDeS driver for the Keithley 2601B Source-Meter

Parameters:
  • name – Name to use internally in QCoDeS

  • address – VISA resource address

  • **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)

Override of normal ask.

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

display_clear()

This function clears the display, but also leaves it in user mode

display_normal()

Set the display to the default mode

exist(name[, instrument_class])

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

exit_key()

Get back the normal screen after an error: send an EXIT key press event

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.

reset()

Reset 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.

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

Override of normal ask. This is important, since queries to the instrument must be wrapped in ‘print()’

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

display_clear() None

This function clears the display, but also leaves it in user mode

display_normal() None

Set the display to the default mode

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.

exit_key() None

Get back the normal screen after an error: send an EXIT key press event

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

reset() None

Reset instrument to factory defaults. This resets both channels.

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.

channels: list[Keithley2600Channel] = []
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.Keithley.Keithley2602A(name: str, address: str, **kwargs: Any)[source]

Bases: Keithley2600

QCoDeS driver for the Keithley 2602A Source-Meter

Parameters:
  • name – Name to use internally in QCoDeS

  • address – VISA resource address

  • **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)

Override of normal ask.

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

display_clear()

This function clears the display, but also leaves it in user mode

display_normal()

Set the display to the default mode

exist(name[, instrument_class])

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

exit_key()

Get back the normal screen after an error: send an EXIT key press event

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.

reset()

Reset 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.

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

Override of normal ask. This is important, since queries to the instrument must be wrapped in ‘print()’

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

display_clear() None

This function clears the display, but also leaves it in user mode

display_normal() None

Set the display to the default mode

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.

exit_key() None

Get back the normal screen after an error: send an EXIT key press event

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

reset() None

Reset instrument to factory defaults. This resets both channels.

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.

channels: list[Keithley2600Channel] = []
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.Keithley.Keithley2602B(name: str, address: str, **kwargs: Any)[source]

Bases: Keithley2600

QCoDeS driver for the Keithley 2602B Source-Meter

Parameters:
  • name – Name to use internally in QCoDeS

  • address – VISA resource address

  • **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)

Override of normal ask.

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

display_clear()

This function clears the display, but also leaves it in user mode

display_normal()

Set the display to the default mode

exist(name[, instrument_class])

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

exit_key()

Get back the normal screen after an error: send an EXIT key press event

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.

reset()

Reset 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.

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

Override of normal ask. This is important, since queries to the instrument must be wrapped in ‘print()’

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

display_clear() None

This function clears the display, but also leaves it in user mode

display_normal() None

Set the display to the default mode

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.

exit_key() None

Get back the normal screen after an error: send an EXIT key press event

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

reset() None

Reset instrument to factory defaults. This resets both channels.

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.

channels: list[Keithley2600Channel] = []
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.Keithley.Keithley2604B(name: str, address: str, **kwargs: Any)[source]

Bases: Keithley2600

QCoDeS driver for the Keithley 2604B Source-Meter

Parameters:
  • name – Name to use internally in QCoDeS

  • address – VISA resource address

  • **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)

Override of normal ask.

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

display_clear()

This function clears the display, but also leaves it in user mode

display_normal()

Set the display to the default mode

exist(name[, instrument_class])

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

exit_key()

Get back the normal screen after an error: send an EXIT key press event

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.

reset()

Reset 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.

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

Override of normal ask. This is important, since queries to the instrument must be wrapped in ‘print()’

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

display_clear() None

This function clears the display, but also leaves it in user mode

display_normal() None

Set the display to the default mode

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.

exit_key() None

Get back the normal screen after an error: send an EXIT key press event

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

reset() None

Reset instrument to factory defaults. This resets both channels.

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.

channels: list[Keithley2600Channel] = []
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.Keithley.Keithley2611B(name: str, address: str, **kwargs: Any)[source]

Bases: Keithley2600

QCoDeS driver for the Keithley 2611B Source-Meter

Parameters:
  • name – Name to use internally in QCoDeS

  • address – VISA resource address

  • **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)

Override of normal ask.

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

display_clear()

This function clears the display, but also leaves it in user mode

display_normal()

Set the display to the default mode

exist(name[, instrument_class])

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

exit_key()

Get back the normal screen after an error: send an EXIT key press event

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.

reset()

Reset 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.

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

Override of normal ask. This is important, since queries to the instrument must be wrapped in ‘print()’

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

display_clear() None

This function clears the display, but also leaves it in user mode

display_normal() None

Set the display to the default mode

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.

exit_key() None

Get back the normal screen after an error: send an EXIT key press event

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

reset() None

Reset instrument to factory defaults. This resets both channels.

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.

channels: list[Keithley2600Channel] = []
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.Keithley.Keithley2612B(name: str, address: str, **kwargs: Any)[source]

Bases: Keithley2600

QCoDeS driver for the Keithley 2612B Source-Meter

Parameters:
  • name – Name to use internally in QCoDeS

  • address – VISA resource address

  • **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)

Override of normal ask.

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

display_clear()

This function clears the display, but also leaves it in user mode

display_normal()

Set the display to the default mode

exist(name[, instrument_class])

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

exit_key()

Get back the normal screen after an error: send an EXIT key press event

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.

reset()

Reset 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.

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

Override of normal ask. This is important, since queries to the instrument must be wrapped in ‘print()’

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

display_clear() None

This function clears the display, but also leaves it in user mode

display_normal() None

Set the display to the default mode

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.

exit_key() None

Get back the normal screen after an error: send an EXIT key press event

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

reset() None

Reset instrument to factory defaults. This resets both channels.

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.

channels: list[Keithley2600Channel] = []
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.Keithley.Keithley2614B(name: str, address: str, **kwargs: Any)[source]

Bases: Keithley2600

QCoDeS driver for the Keithley 2614B Source-Meter

Parameters:
  • name – Name to use internally in QCoDeS

  • address – VISA resource address

  • **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)

Override of normal ask.

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

display_clear()

This function clears the display, but also leaves it in user mode

display_normal()

Set the display to the default mode

exist(name[, instrument_class])

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

exit_key()

Get back the normal screen after an error: send an EXIT key press event

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.

reset()

Reset 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.

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

Override of normal ask. This is important, since queries to the instrument must be wrapped in ‘print()’

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

display_clear() None

This function clears the display, but also leaves it in user mode

display_normal() None

Set the display to the default mode

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.

exit_key() None

Get back the normal screen after an error: send an EXIT key press event

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

reset() None

Reset instrument to factory defaults. This resets both channels.

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.

channels: list[Keithley2600Channel] = []
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.Keithley.Keithley2634B(name: str, address: str, **kwargs: Any)[source]

Bases: Keithley2600

QCoDeS driver for the Keithley 2634B Source-Meter

Parameters:
  • name – Name to use internally in QCoDeS

  • address – VISA resource address

  • **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)

Override of normal ask.

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

display_clear()

This function clears the display, but also leaves it in user mode

display_normal()

Set the display to the default mode

exist(name[, instrument_class])

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

exit_key()

Get back the normal screen after an error: send an EXIT key press event

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.

reset()

Reset 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.

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

Override of normal ask. This is important, since queries to the instrument must be wrapped in ‘print()’

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

display_clear() None

This function clears the display, but also leaves it in user mode

display_normal() None

Set the display to the default mode

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.

exit_key() None

Get back the normal screen after an error: send an EXIT key press event

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

reset() None

Reset instrument to factory defaults. This resets both channels.

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.

channels: list[Keithley2600Channel] = []
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.Keithley.Keithley2635B(name: str, address: str, **kwargs: Any)[source]

Bases: Keithley2600

QCoDeS driver for the Keithley 2635B Source-Meter

Parameters:
  • name – Name to use internally in QCoDeS

  • address – VISA resource address

  • **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)

Override of normal ask.

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

display_clear()

This function clears the display, but also leaves it in user mode

display_normal()

Set the display to the default mode

exist(name[, instrument_class])

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

exit_key()

Get back the normal screen after an error: send an EXIT key press event

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.

reset()

Reset 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.

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

Override of normal ask. This is important, since queries to the instrument must be wrapped in ‘print()’

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

display_clear() None

This function clears the display, but also leaves it in user mode

display_normal() None

Set the display to the default mode

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.

exit_key() None

Get back the normal screen after an error: send an EXIT key press event

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

reset() None

Reset instrument to factory defaults. This resets both channels.

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.

channels: list[Keithley2600Channel] = []
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.Keithley.Keithley2636B(name: str, address: str, **kwargs: Any)[source]

Bases: Keithley2600

QCoDeS driver for the Keithley 2636B Source-Meter

Parameters:
  • name – Name to use internally in QCoDeS

  • address – VISA resource address

  • **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)

Override of normal ask.

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

display_clear()

This function clears the display, but also leaves it in user mode

display_normal()

Set the display to the default mode

exist(name[, instrument_class])

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

exit_key()

Get back the normal screen after an error: send an EXIT key press event

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.

reset()

Reset 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.

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

Override of normal ask. This is important, since queries to the instrument must be wrapped in ‘print()’

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

display_clear() None

This function clears the display, but also leaves it in user mode

display_normal() None

Set the display to the default mode

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.

exit_key() None

Get back the normal screen after an error: send an EXIT key press event

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

reset() None

Reset instrument to factory defaults. This resets both channels.

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.

channels: list[Keithley2600Channel] = []
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.Keithley.Keithley3706A(name: str, address: str, terminator: str = '\n', **kwargs: Any)[source]

Bases: VisaInstrument

This is the QCoDeS instrument driver for the Keithley 3706A-SNFP System Switch.

Parameters:
  • name – Name to use internally in QCoDeS

  • address – VISA resource address

  • terminator – Character to terminate messages with.

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

Methods:

reset_channel(val)

Resets the specified channels to factory default settings.

open_channel(val)

Opens the specified channels and backplane relays.

close_channel(val)

Closes the channels and backplane relays.

exclusive_close(val)

Closes the specified channels such that any presently closed channels opens if they are not in the specified by the parameter.

exclusive_slot_close(val)

Closes the specified channels on the associated slots abd opens any other channels if they are not specified by the parameter.

get_closed_channels(val)

Queries for the closed channels.

set_forbidden_channels(val)

Prevents the closing of specified channels and backplane relays.

get_forbidden_channels(val)

Returns a string that lists the channels and backplane relays that are forbidden to close.

clear_forbidden_channels(val)

Clears the list of channels that are forbidden to close.

set_delay(val, delay_time)

Sets an additional delay time for the specified channels.

get_delay(val)

Queries for the delay times.

set_backplane(val, backplane)

Sets the analog backplane relays to use with given channels when they are used in switching applications.

get_backplane(val)

Lists the backplane relays that are controlled in switching applications for specified channels.

get_channels()

This function returns the name of the matrix channels.

get_channels_by_slot(slot_no)

Returns the channel names of a given slot.

get_analog_backplane_specifiers()

Returns a list of comma separated strings representing available analog backplane relays.

connect_row_to_columns(slot_id, row_id, columns)

A convenient function that connects given columns to a row of a slot and opens the formed channels.

disconnect_row_from_columns(slot_id, row_id, ...)

A convenient function that disconnects given columns to a row of a slot and closes the formed channels.

connect_column_to_rows(slot_id, column_id, rows)

A convenient function that connects given rows to a column of a slot and opens the formed channels.

disconnect_column_from_rows(slot_id, ...)

A convenient function that disconnects given rows to a column of a slot and closes the formed channels.

get_idn()

Overwrites the generic QCoDeS get IDN method.

get_switch_cards()

Returns a list of dictionaries listing the properties of the installed switch cards including the slot number tha it is installed, model, firmware version and serial number.

get_available_memory()

Returns the amount of memory that is currently available for storing scripts, configurations and channel patterns.

get_interlock_state()

A function that collects the interlock status of the installed cards.

get_interlock_state_by_slot(slot)

get_ip_address()

Returns the current IP address of the instrument.

reset_local_network()

Resets the local network (LAN).

save_setup([val])

Saves the present setup.

load_setup(val)

Loads the settings from a saved setup.

connect_message([idn_param, begin_time])

Overwrites the generic QCoDeS instrument connect message.

ask(cmd)

Override of normal ask.

__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.

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().

reset_channel(val: str) None[source]

Resets the specified channels to factory default settings.

Parameters:

val – A string representing the channels, channel ranges, backplane relays, slots or channel patterns to be queried.

open_channel(val: str) None[source]

Opens the specified channels and backplane relays.

Parameters:

val – A string representing the channels, channel ranges, backplane relays, slots or channel patterns to be queried.

close_channel(val: str) None[source]

Closes the channels and backplane relays.

Parameters:

val – A string representing the channels, channel ranges, backplane relays to be queried.

exclusive_close(val: str) None[source]

Closes the specified channels such that any presently closed channels opens if they are not in the specified by the parameter.

Parameters:

val – A string representing the channels, channel ranges, backplane relays to be queried.

exclusive_slot_close(val: str) None[source]

Closes the specified channels on the associated slots abd opens any other channels if they are not specified by the parameter.

Parameters:

val – A string representing the channels, channel ranges, backplane relays to be queried.

get_closed_channels(val: str) list[str] | None[source]

Queries for the closed channels.

Parameters:

val – A string representing the channels, backplane relays or channel patterns to be queried.

set_forbidden_channels(val: str) None[source]

Prevents the closing of specified channels and backplane relays.

Parameters:

val – A string representing channels and backplane relays to make forbidden to close.

get_forbidden_channels(val: str) str[source]

Returns a string that lists the channels and backplane relays that are forbidden to close.

Parameters:

val – A string representing the channels, backplane relays or channel patterns to be queried to see if they are forbidden to close.

clear_forbidden_channels(val: str) None[source]

Clears the list of channels that are forbidden to close.

Parameters:

val – A string representing the channels that will no longer be listed as forbidden to close.

set_delay(val: str, delay_time: float) None[source]

Sets an additional delay time for the specified channels.

Parameters:
  • val – A string representing the channels for which there will be an additional delay time.

  • delay_time – Delay time for the specified channels in seconds.

get_delay(val: str) list[float][source]

Queries for the delay times.

Parameters:

val – A string representing the channels to query for additional delay times.

set_backplane(val: str, backplane: str) None[source]

Sets the analog backplane relays to use with given channels when they are used in switching applications.

Parameters:
  • val – A string representing the list of channels to change.

  • backplane – A string representing the list of analog backplane relays to set for the channels specified.

get_backplane(val: str) str[source]

Lists the backplane relays that are controlled in switching applications for specified channels.

Parameters:

val – A string representing the channels being queried.

get_channels() list[str][source]

This function returns the name of the matrix channels. User can call this function to see the names of the available channels, in case he/she is not familiar with the naming convention. However, note that, this is a standalone helper function and the usage of channel attributes of the instrument driver does not depend on the functionality of this method.

get_channels_by_slot(slot_no: int) list[str][source]

Returns the channel names of a given slot.

Parameters:

slot_no – An integer value specifying the slot number.

get_analog_backplane_specifiers() list[str][source]

Returns a list of comma separated strings representing available analog backplane relays. This function should not be mixed with the get_backplane method. The latter returns backplane relays which are associated with a channel by using set_backplane method.

connect_row_to_columns(slot_id: int, row_id: int, columns: list[int]) list[str][source]

A convenient function that connects given columns to a row of a slot and opens the formed channels.

Parameters:
  • slot_id – The specifier for the slot from which the row and columns will be selected.

  • row_id – The specifier for the row to which the provided columns will be connected.

  • columns – The specifiers of the columns will be connected to the provided row.

disconnect_row_from_columns(slot_id: int, row_id: int, columns: list[int]) list[str][source]

A convenient function that disconnects given columns to a row of a slot and closes the formed channels.

Parameters:
  • slot_id – The specifier for the slot from which the row and columns will be selected.

  • row_id – The specifier for the row to which the provided columns will be disconnected.

  • columns – The specifiers of the columns will be disconnected from the provided row.

connect_column_to_rows(slot_id: int, column_id: int, rows: list[int]) list[str][source]

A convenient function that connects given rows to a column of a slot and opens the formed channels.

Parameters:
  • slot_id – The specifier for the slot from which the row and columns will be selected.

  • column_id – The specifier for the column to which the provided rows will be connected.

  • rows – The specifiers of the rows will be connected to the provided column.

disconnect_column_from_rows(slot_id: int, column_id: int, rows: list[int]) list[str][source]

A convenient function that disconnects given rows to a column of a slot and closes the formed channels.

Parameters:
  • slot_id – The specifier for the slot from which the row and columns will be selected.

  • column_id – The specifier for the column to which the provided rows will be disconnected.

  • rows – The specifiers of the rows will be disconnected from the provided column.

get_idn() dict[str, str | None][source]

Overwrites the generic QCoDeS get IDN method. Returns a dictionary including the vendor, model, serial number and firmware version of the instrument.

get_switch_cards() tuple[dict[str, str], ...][source]

Returns a list of dictionaries listing the properties of the installed switch cards including the slot number tha it is installed, model, firmware version and serial number.

get_available_memory() dict[str, str | None][source]

Returns the amount of memory that is currently available for storing scripts, configurations and channel patterns.

get_interlock_state() tuple[dict[str, str], ...][source]

A function that collects the interlock status of the installed cards. The channel relays can continue to operate even if the interlock in the corresponding slot is disengaged, one cannot perform measurements through the switching card, as the analog backplanes cannot be energized.

get_interlock_state_by_slot(slot: str | int) int | None[source]
get_ip_address() str[source]

Returns the current IP address of the instrument.

reset_local_network() None[source]

Resets the local network (LAN).

save_setup(val: str | None = None) None[source]

Saves the present setup.

Parameters:

val – An optional string representing the path and the file name to which the setup shall be saved on a USB flash drive. If not provided, the setup will be saved to the nonvolatile memory of the instrument, any previous saves will be overwritten.

load_setup(val: int | str) None[source]

Loads the settings from a saved setup.

Parameters:

val – An integer or a string that specifies the location of saved setup. If it is 0, factory defaults load. If it is 1, the saved setup from the nonvolatile memory is recalled. Otherwise, a string specifying the relative path to the saved setup on a USB drive should be passed in.

connect_message(idn_param: str = 'IDN', begin_time: float | None = None) None[source]

Overwrites the generic QCoDeS instrument connect message. Here, additionally, we provide information about which slots of the system switch is occupied with what kind of matrix, as well.

ask(cmd: str) str[source]

Override of normal ask. This is important, since queries to the instrument must be wrapped in ‘print()’

__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())
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.

exception qcodes.instrument_drivers.Keithley.Keithley3706AInvalidValue[source]

Bases: Exception

add_note()

Exception.add_note(note) – add a note to the exception

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception qcodes.instrument_drivers.Keithley.Keithley3706AUnknownOrEmptySlot[source]

Bases: Exception

add_note()

Exception.add_note(note) – add a note to the exception

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

class qcodes.instrument_drivers.Keithley.Keithley6500(name: str, address: str, reset_device: bool = False, **kwargs: Any)[source]

Bases: VisaInstrument

Driver for the Keithley 6500 multimeter. Based on the Keithley 2000 driver,

commands have been adapted for the Keithley 6500. This driver does not contain all commands available, but only the ones most commonly used.

Status: beta-version.

Parameters:
  • name – The name used internally by QCoDeS in the DataSet.

  • address – The VISA device address.

  • reset_device – Reset the device on startup if true.

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

Methods:

reset()

Reset the device

__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().

reset() None[source]

Reset the device

__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.

exception qcodes.instrument_drivers.Keithley.Keithley6500CommandSetError[source]

Bases: Exception

add_note()

Exception.add_note(note) – add a note to the exception

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

class qcodes.instrument_drivers.Keithley.Keithley7510(name: str, address: str, terminator: str = '\n', **kwargs: Any)[source]

Bases: VisaInstrument

The QCoDeS driver for the Keithley 7510 DMM

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:

sense

We have different sense modules depending on the sense function.

digi_sense

We have different sense modules depending on the sense function.

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:

buffer(name[, size, style])

initiate()

This command starts the trigger model.

wait()

This command postpones the execution of subsequent commands until all previous overlapped commands are finished.

clear_status()

This command clears the event registers of the Questionable Event and Operation Event Register set.

reset()

Returns the instrument to default settings, cancels all pending commands.

__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.

property sense: Keithley7510Sense

We have different sense modules depending on the sense function.

Return the correct source module based on the sense function.

property digi_sense: Keithley7510DigitizeSense

We have different sense modules depending on the sense function.

Return the correct source module based on the sense function.

buffer(name: str, size: int | None = None, style: str = '') Keithley7510Buffer[source]
initiate() None[source]

This command starts the trigger model.

wait() None[source]

This command postpones the execution of subsequent commands until all previous overlapped commands are finished.

clear_status() None[source]

This command clears the event registers of the Questionable Event and Operation Event Register set. It does not affect the Questionable Event Enable or Operation Event Enable registers.

reset() None[source]

Returns the instrument to default settings, cancels all pending commands.

__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.Keithley.Keithley7510Buffer(parent: Keithley7510, name: str, size: int | None = None, style: str = '')[source]

Bases: InstrumentChannel

Treat the reading buffer as a submodule, similar to Sense.

Attributes:

default_buffer

buffer_elements

inverted_buffer_elements

available_elements

n_elements

data

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:

set_setpoints(start, stop[, label])

get_last_reading()

This method requests the latest reading from a reading buffer.

clear_buffer()

Clear the data in the buffer

trigger_start()

This method makes readings using the active measure function and stores them in a reading buffer.

delete()

__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)

default_buffer: ClassVar[set[str]] = {'defbuffer1', 'defbuffer2'}
buffer_elements: ClassVar[dict[str, str]] = {'date': 'DATE', 'fractional_seconds': 'FRACtional', 'measurement': 'READing', 'measurement_formatted': 'FORMatted', 'measurement_status': 'STATus', 'measurement_unit': 'UNIT', 'relative_time': 'RELative', 'seconds': 'SEConds', 'time': 'TIME', 'timestamp': 'TSTamp'}
inverted_buffer_elements = {'DATE': 'date', 'FORMatted': 'measurement_formatted', 'FRACtional': 'fractional_seconds', 'READing': 'measurement', 'RELative': 'relative_time', 'SEConds': 'seconds', 'STATus': 'measurement_status', 'TIME': 'time', 'TSTamp': 'timestamp', 'UNIT': 'measurement_unit'}
set_setpoints(start: Parameter, stop: Parameter, label: str | None = None) None[source]
property available_elements: set[str]
property n_elements: int
property data: DataArray7510
get_last_reading() str[source]

This method requests the latest reading from a reading buffer.

clear_buffer() None[source]

Clear the data in the buffer

trigger_start() None[source]

This method makes readings using the active measure function and stores them in a reading buffer.

delete() 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.Keithley.Keithley7510DigitizeSense(parent: VisaInstrument, name: str, proper_function: str)[source]

Bases: InstrumentChannel

The Digitize sense module of the Keithley 7510 DMM.

Attributes:

function_modes

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_modes: ClassVar[dict[str, _FunctionMode]] = {'None': {'name': '"NONE"', 'range_vals': None, 'unit': ''}, 'current': {'name': '"CURR"', 'range_vals': <Numbers 1e-05<=v<=10>, 'unit': 'V'}, 'voltage': {'name': '"VOLT"', 'range_vals': <Numbers 0.1<=v<=1000>, 'unit': 'V'}}
__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.Keithley.Keithley7510Sense(parent: VisaInstrument, name: str, proper_function: str)[source]

Bases: InstrumentChannel

The sense module of the Keithley 7510 DMM, based on the sense module of Keithley 2450 SMU.

Parameters:
  • parent

  • name

  • proper_function

    This can be one of modes listed in the dictionary “function_modes”, e.g., “current”, “voltage”, or “resistance”. “voltage”/”current” is for DC voltage/current. “Avoltage”/”Acurrent” is for AC voltage/current. “resistance” is for two-wire measurement of resistance. “Fresistance” is for Four-wire measurement of resistance.

    All parameters and methods in this submodule should only be accessible to the user if self.parent.sense_function.get() == self._proper_function. We ensure this through the ‘sense’ property on the main driver class which returns the proper submodule for any given function mode.

Attributes:

function_modes

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:

clear_trace([buffer_name])

Clear the data buffer

__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_modes: ClassVar[dict[str, _FunctionMode]] = {'Acurrent': {'name': '"CURR:AC"', 'range_vals': <Numbers 0.001<=v<=10>, 'unit': 'A'}, 'Avoltage': {'name': '"VOLT:AC"', 'range_vals': <Numbers 0.1<=v<=700>, 'unit': 'V'}, 'Fresistance': {'name': '"FRES"', 'range_vals': <Numbers 1<=v<=1000000000.0>, 'unit': 'Ohm'}, 'current': {'name': '"CURR:DC"', 'range_vals': <Numbers 1e-05<=v<=10>, 'unit': 'V'}, 'resistance': {'name': '"RES"', 'range_vals': <Numbers 10<=v<=1000000000.0>, 'unit': 'Ohm'}, 'voltage': {'name': '"VOLT:DC"', 'range_vals': <Numbers 0.1<=v<=1000>, 'unit': 'V'}}
clear_trace(buffer_name: str = 'defbuffer1') None[source]

Clear the data buffer

__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.Keithley.KeithleyS46(name: str, address: str, **kwargs: Any)[source]

Bases: VisaInstrument

Attributes:

relay_names

channel_numbers

aliases

relay_layout

The relay layout tells us how many channels we have per relay.

available_channels

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:

open_all_channels()

__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.

relay_names: list[str] = ['A', 'B', 'C', 'D', 'R1', 'R2', 'R3', 'R4', 'R5', 'R6', 'R7', 'R8']
channel_numbers: ClassVar[dict[str, int]] = {'A1': 1, 'A2': 2, 'A3': 3, 'A4': 4, 'A5': 5, 'A6': 6, 'B1': 7, 'B2': 8, 'B3': 9, 'B4': 10, 'B5': 11, 'B6': 12, 'C1': 13, 'C2': 14, 'C3': 15, 'C4': 16, 'C5': 17, 'C6': 18, 'D1': 19, 'D2': 20, 'D3': 21, 'D4': 22, 'D5': 23, 'D6': 24, 'R1': 25, 'R2': 26, 'R3': 27, 'R4': 28, 'R5': 29, 'R6': 30, 'R7': 31, 'R8': 32}
aliases: ClassVar[dict[int, str]] = {1: 'A1', 2: 'A2', 3: 'A3', 4: 'A4', 5: 'A5', 6: 'A6', 7: 'B1', 8: 'B2', 9: 'B3', 10: 'B4', 11: 'B5', 12: 'B6', 13: 'C1', 14: 'C2', 15: 'C3', 16: 'C4', 17: 'C5', 18: 'C6', 19: 'D1', 20: 'D2', 21: 'D3', 22: 'D4', 23: 'D5', 24: 'D6', 25: 'R1', 26: 'R2', 27: 'R3', 28: 'R4', 29: 'R5', 30: 'R6', 31: 'R7', 32: 'R8'}
open_all_channels() None[source]
property relay_layout: list[int]

The relay layout tells us how many channels we have per relay. Note that we can have zero channels per relay.

property available_channels: list[str]
__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.

exception qcodes.instrument_drivers.Keithley.KeithleyS46LockAcquisitionError[source]

Bases: Exception

add_note()

Exception.add_note(note) – add a note to the exception

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

class qcodes.instrument_drivers.Keithley.KeithleyS46RelayLock(relay_name: str)[source]

Bases: object

The S46 either has six pole or a four pole relays. For example, channels ‘A1’ to ‘A6’ are all on relay ‘A’. However, channels ‘R1’ to ‘R8’ are all on individual relays.

Only one channel per relay may be closed at any given time to prevent degradation of RF performance and even switch damage. See page 2-11 of the manual. To enforce this, a lock mechanism has been implemented.

Methods:

acquire(channel_number)

Request a lock acquisition

release(channel_number)

Release a lock.

acquire(channel_number: int) None[source]

Request a lock acquisition

release(channel_number: int) None[source]

Release a lock.