MiniCircuits Drivers

Classes:

MiniCircuitsRCSP4T(*args, **kwargs)

Driver for MiniCircuits RC-SP4T RF switch connected via ethernet.

MiniCircuitsRCSP4TChannel(parent, name, ...)

param parent:

The instrument the channel is a part of

MiniCircuitsRCSPDT(*args, **kwargs)

Mini-Circuits RC-SPDT RF switch connected via ethernet.

MiniCircuitsRCSPDTChannel(parent, name, ...)

param parent:

The instrument the channel is a part of

MiniCircuitsRudat13G90Usb(*args, **kwargs)

Driver for the Minicircuits RUDAT-13G-90 90 dB Programmable Attenuator

MiniCircuitsUsbSPDT(name[, driver_path, ...])

Mini-Circuits SPDT RF switch

MiniCircuitsUsbSPDTSwitchChannel(parent, ...)

param parent:

The instrument the channel is a part of

class qcodes.instrument_drivers.Minicircuits.MiniCircuitsRCSP4T(*args: Any, **kwargs: Any)[source]

Bases: IPInstrument

Driver for MiniCircuits RC-SP4T RF switch connected via ethernet.

Parameters:
  • name – the name of the instrument

  • address – ip address ie “10.0.0.1”

  • port – port to connect to default Telnet:23

Methods:

ask(cmd)

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

get_idn()

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

__del__()

Close the instrument and remove its instance record.

__getitem__(key)

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

__getstate__()

Prevent pickling instruments, and give a nice error message.

__repr__()

Simplified repr giving just the class and name.

add_function(name, **kwargs)

Bind one Function to this instrument.

add_parameter(name[, parameter_class])

Bind one Parameter to this instrument.

add_submodule(name, submodule)

Bind one submodule to this instrument.

ask_raw(cmd)

Low-level interface to send a command an read a response.

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.

exist(name[, instrument_class])

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

find_instrument(name[, instrument_class])

Find an existing instrument by name.

flush_connection()

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, port])

Change the IP address and/or port of this instrument.

set_persistent(persistent)

Change whether this instrument keeps its socket open between calls.

set_terminator(terminator)

Change the write terminator to use.

set_timeout(timeout)

Change the read timeout for the socket.

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 send a command that gets no response.

Attributes:

ancestors

Ancestors in the form of a list of InstrumentBase

delegate_attr_dicts

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

delegate_attr_objects

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

full_name

Full name of the instrument.

label

Nicely formatted label of the instrument.

name

Full name of the instrument

name_parts

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

omit_delegate_attrs

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

parent

The parent instrument.

root_instrument

The topmost parent of this module.

short_name

Short name of the instrument.

parameters

All the parameters supported by this instrument.

functions

All the functions supported by this instrument.

submodules

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

instrument_modules

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

ask(cmd: str) str[source]

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

Subclasses that transform cmd should override this method, and in it call super().ask(new_cmd). Subclasses that define a new hardware communication should instead override ask_raw.

Parameters:

cmd – The string to send to the instrument.

Returns:

response

Raises:

Exception – Wraps any underlying exception with extra context, including the command and the instrument.

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

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

Even though this is the VISA standard, it applies to various other types as well, such as IPInstruments, so it is included here in the Instrument base class.

Override this if your instrument does not support *IDN? or returns a nonstandard IDN string. This string is supposed to be a comma-separated list of vendor, model, serial, and firmware, but semicolon and colon are also common separators so we accept them here as well.

Returns:

A dict containing vendor, model, serial, and firmware.

__del__() None

Close the instrument and remove its instance record.

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

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

__getstate__() None

Prevent pickling instruments, and give a nice error message.

__repr__() str

Simplified repr giving just the class and name.

add_function(name: str, **kwargs: Any) None

Bind one Function to this instrument.

Instrument subclasses can call this repeatedly in their __init__ for every real function of the instrument.

This functionality is meant for simple cases, principally things that map to simple commands like *RST (reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.

Note

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

Parameters:
  • name – How the Function will be stored within instrument.Functions and also how you address it using the shortcut methods: instrument.call(func_name, *args) etc.

  • **kwargs – constructor kwargs for Function

Raises:

KeyError – If this instrument already has a function with this name.

add_parameter(name: str, parameter_class: type[ParameterBase] | None = None, **kwargs: Any) None

Bind one Parameter to this instrument.

Instrument subclasses can call this repeatedly in their __init__ for every real parameter of the instrument.

In this sense, parameters are the state variables of the instrument, anything the user can set and/or get.

Parameters:
  • name – How the parameter will be stored within parameters and also how you address it using the shortcut methods: instrument.set(param_name, value) etc.

  • parameter_class – You can construct the parameter out of any class. Default parameters.Parameter.

  • **kwargs – Constructor arguments for parameter_class.

Raises:
  • KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.

  • ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.

add_submodule(name: str, submodule: InstrumentModule | ChannelTuple) None

Bind one submodule to this instrument.

Instrument subclasses can call this repeatedly in their __init__ method for every submodule of the instrument.

Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an InstrumentModule or a ChannelTuple.

Parameters:
  • name – How the submodule will be stored within instrument.submodules and also how it can be addressed.

  • submodule – The submodule to be stored.

Raises:
  • KeyError – If this instrument already contains a submodule with this name.

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

property ancestors: tuple[InstrumentBase, ...]

Ancestors in the form of a list of InstrumentBase

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

ask_raw(cmd: str) str

Low-level interface to send a command an read a response.

Parameters:

cmd – The command to send to the instrument.

Returns:

The instrument’s string response.

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.

static exist(name: str, instrument_class: type[Instrument] | None = None) bool

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

Parameters:
  • name – Name of the instrument.

  • instrument_class – The type of instrument you are looking for.

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

Find an existing instrument by name.

Parameters:
  • name – Name of the instrument.

  • instrument_class – The type of instrument you are looking for.

Returns:

The instrument found.

Raises:
  • KeyError – If no instrument of that name was found, or if its reference is invalid (dead).

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

flush_connection() None
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 = None, port: int | None = None) None

Change the IP address and/or port of this instrument.

Parameters:
  • address – The IP address or name.

  • port – The IP port.

set_persistent(persistent: bool) None

Change whether this instrument keeps its socket open between calls.

Parameters:

persistent – Set True to keep the socket open all the time.

set_terminator(terminator: str) None

Change the write terminator to use.

Parameters:

terminator – Character(s) to terminate each send. Default ‘n’.

set_timeout(timeout: float) None

Change the read timeout for the socket.

Parameters:

timeout – Seconds to allow for responses.

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 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 send a command that gets no response.

Parameters:

cmd – The command to send to the instrument.

parameters: dict[str, ParameterBase] = {}

All the parameters supported by this instrument. Usually populated via add_parameter().

functions: dict[str, Function] = {}

All the functions supported by this instrument. Usually populated via add_function().

submodules: dict[str, 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.Minicircuits.MiniCircuitsRCSP4TChannel(parent: IPInstrument, name: str, channel_letter: str)[source]

Bases: InstrumentChannel

Parameters:
  • parent – The instrument the channel is a part of

  • name – the name of the channel

  • channel_letter – channel letter [‘a’, ‘b’])

Methods:

__getitem__(key)

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

__getstate__()

Prevent pickling instruments, and give a nice error message.

__repr__()

Custom repr to give parent information

add_function(name, **kwargs)

Bind one Function to this instrument.

add_parameter(name[, parameter_class])

Bind one Parameter to this instrument.

add_submodule(name, submodule)

Bind one submodule to this instrument.

ask(cmd)

ask_raw(cmd)

call(func_name, *args)

Shortcut for calling a function from its name.

get(param_name)

Shortcut for getting a parameter from its name.

get_component(full_name)

Recursively get a component of the instrument by full_name.

invalidate_cache()

Invalidate the cache of all parameters on the instrument.

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

print_readable_snapshot([update, max_chars])

Prints a readable version of the snapshot.

set(param_name, value)

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

snapshot([update])

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

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

validate_status([verbose])

Validate the values of all gettable parameters

write(cmd)

write_raw(cmd)

Attributes:

ancestors

Ancestors in the form of a list of InstrumentBase

delegate_attr_dicts

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

delegate_attr_objects

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

full_name

Full name of the instrument.

label

Nicely formatted label of the instrument.

name

Full name of the instrument

name_parts

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

omit_delegate_attrs

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

parent

The parent instrument.

root_instrument

The topmost parent of this module.

short_name

Short name of the instrument.

parameters

All the parameters supported by this instrument.

functions

All the functions supported by this instrument.

submodules

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

instrument_modules

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

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

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

__getstate__() None

Prevent pickling instruments, and give a nice error message.

__repr__() str

Custom repr to give parent information

add_function(name: str, **kwargs: Any) None

Bind one Function to this instrument.

Instrument subclasses can call this repeatedly in their __init__ for every real function of the instrument.

This functionality is meant for simple cases, principally things that map to simple commands like *RST (reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.

Note

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

Parameters:
  • name – How the Function will be stored within instrument.Functions and also how you address it using the shortcut methods: instrument.call(func_name, *args) etc.

  • **kwargs – constructor kwargs for Function

Raises:

KeyError – If this instrument already has a function with this name.

add_parameter(name: str, parameter_class: type[ParameterBase] | None = None, **kwargs: Any) None

Bind one Parameter to this instrument.

Instrument subclasses can call this repeatedly in their __init__ for every real parameter of the instrument.

In this sense, parameters are the state variables of the instrument, anything the user can set and/or get.

Parameters:
  • name – How the parameter will be stored within parameters and also how you address it using the shortcut methods: instrument.set(param_name, value) etc.

  • parameter_class – You can construct the parameter out of any class. Default parameters.Parameter.

  • **kwargs – Constructor arguments for parameter_class.

Raises:
  • KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.

  • ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.

add_submodule(name: str, submodule: InstrumentModule | ChannelTuple) None

Bind one submodule to this instrument.

Instrument subclasses can call this repeatedly in their __init__ method for every submodule of the instrument.

Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an InstrumentModule or a ChannelTuple.

Parameters:
  • name – How the submodule will be stored within instrument.submodules and also how it can be addressed.

  • submodule – The submodule to be stored.

Raises:
  • KeyError – If this instrument already contains a submodule with this name.

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

property ancestors: tuple[InstrumentBase, ...]

Ancestors in the form of a list of InstrumentBase

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

ask(cmd: str) str
ask_raw(cmd: str) str
call(func_name: str, *args: Any) Any

Shortcut for calling a function from its name.

Parameters:
  • func_name – The name of a function of this instrument.

  • *args – any arguments to the function.

Returns:

The return value of the function.

delegate_attr_dicts: ClassVar[list[str]] = ['parameters', 'functions', 'submodules']

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

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

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

property full_name: str

Full name of the instrument.

For an InstrumentModule this includes all parents separated by _

get(param_name: str) Any

Shortcut for getting a parameter from its name.

Parameters:

param_name – The name of a parameter of this instrument.

Returns:

The current value of the parameter.

get_component(full_name: str) MetadatableWithName

Recursively get a component of the instrument by full_name.

Parameters:

full_name – The name of the component to get.

Returns:

The component with the given name.

Raises:

KeyError – If the component does not exist.

invalidate_cache() None

Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.

This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.

This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.

property label: str

Nicely formatted label of the instrument.

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

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

property name: str

Full name of the instrument

This is equivalent to full_name() for backwards compatibility.

property name_parts: list[str]

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

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

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

property parent: InstrumentBase

The parent instrument. By default, this is None. Any SubInstrument should subclass this to return the parent instrument.

print_readable_snapshot(update: bool = False, max_chars: int = 80) None

Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.

Parameters:
  • update – If True, update the state by querying the instrument. If False, just use the latest values in memory. This argument gets passed to the snapshot function.

  • max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.

property root_instrument: InstrumentBase

The topmost parent of this module.

For the root_instrument this is self.

set(param_name: str, value: Any) None

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

Parameters:
  • param_name – The name of a parameter of this instrument.

  • value – The new value to set.

property short_name: str

Short name of the instrument.

For an InstrumentModule this does not include any parent names.

snapshot(update: bool | None = False) dict[str, Any]

Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override snapshot_base().

Parameters:

update – Passed to snapshot_base.

Returns:

Base snapshot.

snapshot_base(update: bool | None = False, params_to_skip_update: Sequence[str] | None = None) dict[Any, Any]

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

Parameters:
  • update – If True, update the state by querying the instrument. If None update the state if known to be invalid. If False, just use the latest values in memory and never update state.

  • params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the snapshot_get attribute of those parameters instead.

Returns:

base snapshot

Return type:

dict

validate_status(verbose: bool = False) None

Validate the values of all gettable parameters

The validation is done for all parameters that have both a get and set method.

Parameters:

verbose – If True, then information about the parameters that are being check is printed.

write(cmd: str) None
write_raw(cmd: str) None
parameters: dict[str, ParameterBase] = {}

All the parameters supported by this instrument. Usually populated via add_parameter().

functions: dict[str, Function] = {}

All the functions supported by this instrument. Usually populated via add_function().

submodules: dict[str, InstrumentModule | ChannelTuple] = {}

All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via add_submodule().

instrument_modules: dict[str, InstrumentModule] = {}

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

log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
metadata: dict[str, Any] = {}
class qcodes.instrument_drivers.Minicircuits.MiniCircuitsRCSPDT(*args: Any, **kwargs: Any)[source]

Bases: IPInstrument

Mini-Circuits RC-SPDT RF switch connected via ethernet.

Parameters:
  • name – the name of the instrument

  • address – ip address ie “10.0.0.1”

  • port – port to connect to default Telnet:23

Methods:

ask(cmd)

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

get_idn()

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

__del__()

Close the instrument and remove its instance record.

__getitem__(key)

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

__getstate__()

Prevent pickling instruments, and give a nice error message.

__repr__()

Simplified repr giving just the class and name.

add_function(name, **kwargs)

Bind one Function to this instrument.

add_parameter(name[, parameter_class])

Bind one Parameter to this instrument.

add_submodule(name, submodule)

Bind one submodule to this instrument.

ask_raw(cmd)

Low-level interface to send a command an read a response.

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.

exist(name[, instrument_class])

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

find_instrument(name[, instrument_class])

Find an existing instrument by name.

flush_connection()

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, port])

Change the IP address and/or port of this instrument.

set_persistent(persistent)

Change whether this instrument keeps its socket open between calls.

set_terminator(terminator)

Change the write terminator to use.

set_timeout(timeout)

Change the read timeout for the socket.

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 send a command that gets no response.

Attributes:

ancestors

Ancestors in the form of a list of InstrumentBase

delegate_attr_dicts

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

delegate_attr_objects

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

full_name

Full name of the instrument.

label

Nicely formatted label of the instrument.

name

Full name of the instrument

name_parts

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

omit_delegate_attrs

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

parent

The parent instrument.

root_instrument

The topmost parent of this module.

short_name

Short name of the instrument.

parameters

All the parameters supported by this instrument.

functions

All the functions supported by this instrument.

submodules

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

instrument_modules

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

ask(cmd: str) str[source]

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

Subclasses that transform cmd should override this method, and in it call super().ask(new_cmd). Subclasses that define a new hardware communication should instead override ask_raw.

Parameters:

cmd – The string to send to the instrument.

Returns:

response

Raises:

Exception – Wraps any underlying exception with extra context, including the command and the instrument.

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

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

Even though this is the VISA standard, it applies to various other types as well, such as IPInstruments, so it is included here in the Instrument base class.

Override this if your instrument does not support *IDN? or returns a nonstandard IDN string. This string is supposed to be a comma-separated list of vendor, model, serial, and firmware, but semicolon and colon are also common separators so we accept them here as well.

Returns:

A dict containing vendor, model, serial, and firmware.

__del__() None

Close the instrument and remove its instance record.

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

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

__getstate__() None

Prevent pickling instruments, and give a nice error message.

__repr__() str

Simplified repr giving just the class and name.

add_function(name: str, **kwargs: Any) None

Bind one Function to this instrument.

Instrument subclasses can call this repeatedly in their __init__ for every real function of the instrument.

This functionality is meant for simple cases, principally things that map to simple commands like *RST (reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.

Note

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

Parameters:
  • name – How the Function will be stored within instrument.Functions and also how you address it using the shortcut methods: instrument.call(func_name, *args) etc.

  • **kwargs – constructor kwargs for Function

Raises:

KeyError – If this instrument already has a function with this name.

add_parameter(name: str, parameter_class: type[ParameterBase] | None = None, **kwargs: Any) None

Bind one Parameter to this instrument.

Instrument subclasses can call this repeatedly in their __init__ for every real parameter of the instrument.

In this sense, parameters are the state variables of the instrument, anything the user can set and/or get.

Parameters:
  • name – How the parameter will be stored within parameters and also how you address it using the shortcut methods: instrument.set(param_name, value) etc.

  • parameter_class – You can construct the parameter out of any class. Default parameters.Parameter.

  • **kwargs – Constructor arguments for parameter_class.

Raises:
  • KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.

  • ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.

add_submodule(name: str, submodule: InstrumentModule | ChannelTuple) None

Bind one submodule to this instrument.

Instrument subclasses can call this repeatedly in their __init__ method for every submodule of the instrument.

Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an InstrumentModule or a ChannelTuple.

Parameters:
  • name – How the submodule will be stored within instrument.submodules and also how it can be addressed.

  • submodule – The submodule to be stored.

Raises:
  • KeyError – If this instrument already contains a submodule with this name.

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

property ancestors: tuple[InstrumentBase, ...]

Ancestors in the form of a list of InstrumentBase

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

ask_raw(cmd: str) str

Low-level interface to send a command an read a response.

Parameters:

cmd – The command to send to the instrument.

Returns:

The instrument’s string response.

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.

static exist(name: str, instrument_class: type[Instrument] | None = None) bool

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

Parameters:
  • name – Name of the instrument.

  • instrument_class – The type of instrument you are looking for.

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

Find an existing instrument by name.

Parameters:
  • name – Name of the instrument.

  • instrument_class – The type of instrument you are looking for.

Returns:

The instrument found.

Raises:
  • KeyError – If no instrument of that name was found, or if its reference is invalid (dead).

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

flush_connection() None
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 = None, port: int | None = None) None

Change the IP address and/or port of this instrument.

Parameters:
  • address – The IP address or name.

  • port – The IP port.

set_persistent(persistent: bool) None

Change whether this instrument keeps its socket open between calls.

Parameters:

persistent – Set True to keep the socket open all the time.

set_terminator(terminator: str) None

Change the write terminator to use.

Parameters:

terminator – Character(s) to terminate each send. Default ‘n’.

set_timeout(timeout: float) None

Change the read timeout for the socket.

Parameters:

timeout – Seconds to allow for responses.

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 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 send a command that gets no response.

Parameters:

cmd – The command to send to the instrument.

parameters: dict[str, ParameterBase] = {}

All the parameters supported by this instrument. Usually populated via add_parameter().

functions: dict[str, Function] = {}

All the functions supported by this instrument. Usually populated via add_function().

submodules: dict[str, 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.Minicircuits.MiniCircuitsRCSPDTChannel(parent: MiniCircuitsRCSPDT, name: str, channel_letter: str)[source]

Bases: InstrumentChannel

Parameters:
  • parent – The instrument the channel is a part of

  • name – the name of the channel

  • channel_letter – channel letter [‘a’, ‘b’, ‘c’ or ‘d’])

Methods:

__getitem__(key)

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

__getstate__()

Prevent pickling instruments, and give a nice error message.

__repr__()

Custom repr to give parent information

add_function(name, **kwargs)

Bind one Function to this instrument.

add_parameter(name[, parameter_class])

Bind one Parameter to this instrument.

add_submodule(name, submodule)

Bind one submodule to this instrument.

ask(cmd)

ask_raw(cmd)

call(func_name, *args)

Shortcut for calling a function from its name.

get(param_name)

Shortcut for getting a parameter from its name.

get_component(full_name)

Recursively get a component of the instrument by full_name.

invalidate_cache()

Invalidate the cache of all parameters on the instrument.

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

print_readable_snapshot([update, max_chars])

Prints a readable version of the snapshot.

set(param_name, value)

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

snapshot([update])

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

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

validate_status([verbose])

Validate the values of all gettable parameters

write(cmd)

write_raw(cmd)

Attributes:

ancestors

Ancestors in the form of a list of InstrumentBase

delegate_attr_dicts

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

delegate_attr_objects

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

full_name

Full name of the instrument.

label

Nicely formatted label of the instrument.

name

Full name of the instrument

name_parts

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

omit_delegate_attrs

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

parent

The parent instrument.

root_instrument

The topmost parent of this module.

short_name

Short name of the instrument.

parameters

All the parameters supported by this instrument.

functions

All the functions supported by this instrument.

submodules

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

instrument_modules

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

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

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

__getstate__() None

Prevent pickling instruments, and give a nice error message.

__repr__() str

Custom repr to give parent information

add_function(name: str, **kwargs: Any) None

Bind one Function to this instrument.

Instrument subclasses can call this repeatedly in their __init__ for every real function of the instrument.

This functionality is meant for simple cases, principally things that map to simple commands like *RST (reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.

Note

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

Parameters:
  • name – How the Function will be stored within instrument.Functions and also how you address it using the shortcut methods: instrument.call(func_name, *args) etc.

  • **kwargs – constructor kwargs for Function

Raises:

KeyError – If this instrument already has a function with this name.

add_parameter(name: str, parameter_class: type[ParameterBase] | None = None, **kwargs: Any) None

Bind one Parameter to this instrument.

Instrument subclasses can call this repeatedly in their __init__ for every real parameter of the instrument.

In this sense, parameters are the state variables of the instrument, anything the user can set and/or get.

Parameters:
  • name – How the parameter will be stored within parameters and also how you address it using the shortcut methods: instrument.set(param_name, value) etc.

  • parameter_class – You can construct the parameter out of any class. Default parameters.Parameter.

  • **kwargs – Constructor arguments for parameter_class.

Raises:
  • KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.

  • ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.

add_submodule(name: str, submodule: InstrumentModule | ChannelTuple) None

Bind one submodule to this instrument.

Instrument subclasses can call this repeatedly in their __init__ method for every submodule of the instrument.

Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an InstrumentModule or a ChannelTuple.

Parameters:
  • name – How the submodule will be stored within instrument.submodules and also how it can be addressed.

  • submodule – The submodule to be stored.

Raises:
  • KeyError – If this instrument already contains a submodule with this name.

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

property ancestors: tuple[InstrumentBase, ...]

Ancestors in the form of a list of InstrumentBase

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

ask(cmd: str) str
ask_raw(cmd: str) str
call(func_name: str, *args: Any) Any

Shortcut for calling a function from its name.

Parameters:
  • func_name – The name of a function of this instrument.

  • *args – any arguments to the function.

Returns:

The return value of the function.

delegate_attr_dicts: ClassVar[list[str]] = ['parameters', 'functions', 'submodules']

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

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

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

property full_name: str

Full name of the instrument.

For an InstrumentModule this includes all parents separated by _

get(param_name: str) Any

Shortcut for getting a parameter from its name.

Parameters:

param_name – The name of a parameter of this instrument.

Returns:

The current value of the parameter.

get_component(full_name: str) MetadatableWithName

Recursively get a component of the instrument by full_name.

Parameters:

full_name – The name of the component to get.

Returns:

The component with the given name.

Raises:

KeyError – If the component does not exist.

invalidate_cache() None

Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.

This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.

This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.

property label: str

Nicely formatted label of the instrument.

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

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

property name: str

Full name of the instrument

This is equivalent to full_name() for backwards compatibility.

property name_parts: list[str]

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

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

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

property parent: InstrumentBase

The parent instrument. By default, this is None. Any SubInstrument should subclass this to return the parent instrument.

print_readable_snapshot(update: bool = False, max_chars: int = 80) None

Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.

Parameters:
  • update – If True, update the state by querying the instrument. If False, just use the latest values in memory. This argument gets passed to the snapshot function.

  • max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.

property root_instrument: InstrumentBase

The topmost parent of this module.

For the root_instrument this is self.

set(param_name: str, value: Any) None

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

Parameters:
  • param_name – The name of a parameter of this instrument.

  • value – The new value to set.

property short_name: str

Short name of the instrument.

For an InstrumentModule this does not include any parent names.

snapshot(update: bool | None = False) dict[str, Any]

Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override snapshot_base().

Parameters:

update – Passed to snapshot_base.

Returns:

Base snapshot.

snapshot_base(update: bool | None = False, params_to_skip_update: Sequence[str] | None = None) dict[Any, Any]

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

Parameters:
  • update – If True, update the state by querying the instrument. If None update the state if known to be invalid. If False, just use the latest values in memory and never update state.

  • params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the snapshot_get attribute of those parameters instead.

Returns:

base snapshot

Return type:

dict

validate_status(verbose: bool = False) None

Validate the values of all gettable parameters

The validation is done for all parameters that have both a get and set method.

Parameters:

verbose – If True, then information about the parameters that are being check is printed.

write(cmd: str) None
write_raw(cmd: str) None
parameters: dict[str, ParameterBase] = {}

All the parameters supported by this instrument. Usually populated via add_parameter().

functions: dict[str, Function] = {}

All the functions supported by this instrument. Usually populated via add_function().

submodules: dict[str, InstrumentModule | ChannelTuple] = {}

All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via add_submodule().

instrument_modules: dict[str, InstrumentModule] = {}

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

log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
metadata: dict[str, Any] = {}
class qcodes.instrument_drivers.Minicircuits.MiniCircuitsRudat13G90Usb(*args: Any, **kwargs: Any)[source]

Bases: MiniCircuitsHIDMixin, MiniCircuitsRudat13G90Base

Driver for the Minicircuits RUDAT-13G-90 90 dB Programmable Attenuator

Attributes:

vendor_id

product_id

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:

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

Send a string command to the human interface device and wait for a reply

call(func_name, *args)

Shortcut for calling a function from its name.

close()

Irreversibly stop this instrument and free its resources.

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.

enumerate_devices()

This method returns the 'instance_id's of all connected devices for with the given product and vendor IDs.

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.

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)

Send a string command to the human interface device

vendor_id = 8398
product_id = 35
__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

Send a string command to the human interface device and wait for a reply

The given command is processed by _pack_string method to return a byte sequence that is going to be actually sent to the device. Subclasses must implement _pack_string method.

The byte sequence of the reply is processed by _unpack_string method, and the resulting string is returned. Subclasses must implement _unpack_string method.

Parameters:

cmd – a command to send in a form of a string

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

Irreversibly stop this instrument and free its resources.

Subclasses should override this if they have other specific resources to close.

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.

classmethod enumerate_devices() list[str]

This method returns the ‘instance_id’s of all connected devices for with the given product and vendor IDs.

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.

property short_name: str

Short name of the instrument.

For an InstrumentModule this does not include any parent names.

snapshot(update: bool | None = False) dict[str, Any]

Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override snapshot_base().

Parameters:

update – Passed to snapshot_base.

Returns:

Base snapshot.

snapshot_base(update: bool | None = False, params_to_skip_update: Sequence[str] | None = None) dict[Any, Any]

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

Parameters:
  • update – If True, update the state by querying the instrument. If None update the state if known to be invalid. If False, just use the latest values in memory and never update state.

  • params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the snapshot_get attribute of those parameters instead.

Returns:

base snapshot

Return type:

dict

validate_status(verbose: bool = False) None

Validate the values of all gettable parameters

The validation is done for all parameters that have both a get and set method.

Parameters:

verbose – If True, then information about the parameters that are being check is printed.

write(cmd: str) None

Write a command string with NO response to the hardware.

Subclasses that transform cmd should override this method, and in it call super().write(new_cmd). Subclasses that define a new hardware communication should instead override write_raw.

Parameters:

cmd – The string to send to the instrument.

Raises:

Exception – Wraps any underlying exception with extra context, including the command and the instrument.

write_raw(cmd: str) None

Send a string command to the human interface device

The given command is processed by _pack_string method to return a byte sequence that is going to be actually sent to the device. Subclasses must implement _pack_string method.

Parameters:

cmd – a command to send in a form of a string

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.Minicircuits.MiniCircuitsUsbSPDT(name: str, driver_path: str | None = None, serial_number: str | None = None, **kwargs: Any)[source]

Bases: SPDT_Base

Mini-Circuits SPDT RF switch

Parameters:
  • name – the name of the instrument

  • driver_path – path to the dll

  • serial_number – the serial number of the device (printed on the sticker on the back side, without s/n)

  • kwargs – kwargs to be passed to Instrument class.

Classes:

CHANNEL_CLASS

alias of MiniCircuitsUsbSPDTSwitchChannel

Attributes:

PATH_TO_DRIVER

PATH_TO_DRIVER_45

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

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

__del__()

Close the instrument and remove its instance record.

__getitem__(key)

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

__getstate__()

Prevent pickling instruments, and give a nice error message.

__repr__()

Simplified repr giving just the class and name.

add_channels()

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.

all(switch_to)

ask(cmd)

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

ask_raw(cmd)

Low level method to write to the hardware and return a response.

call(func_name, *args)

Shortcut for calling a function from its name.

close()

Irreversibly stop this instrument and free its resources.

close_all()

Try to close all instruments registered in _all_instruments This is handy for use with atexit to ensure that all instruments are closed when a python session is closed.

connect_message([idn_param, begin_time])

Print a standard message on initial connection to an instrument.

exist(name[, instrument_class])

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

find_instrument(name[, instrument_class])

Find an existing instrument by name.

get(param_name)

Shortcut for getting a parameter from its name.

get_component(full_name)

Recursively get a component of the instrument by full_name.

get_number_of_channels()

instances()

Get all currently defined instances of this instrument class.

invalidate_cache()

Invalidate the cache of all parameters on the instrument.

is_valid(instr_instance)

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

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

print_readable_snapshot([update, max_chars])

Prints a readable version of the snapshot.

record_instance(instance)

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

remove_instance(instance)

Remove a particular instance from the record.

set(param_name, value)

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

snapshot([update])

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

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

validate_status([verbose])

Validate the values of all gettable parameters

write(cmd)

Write a command string with NO response to the hardware.

write_raw(cmd)

Low level method to write a command string to the hardware.

CHANNEL_CLASS

alias of MiniCircuitsUsbSPDTSwitchChannel Methods:

__getitem__(key)

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

__getstate__()

Prevent pickling instruments, and give a nice error message.

__repr__()

Custom repr to give parent information

add_function(name, **kwargs)

Bind one Function to this instrument.

add_parameter(name[, parameter_class])

Bind one Parameter to this instrument.

add_submodule(name, submodule)

Bind one submodule to this instrument.

ask(cmd)

ask_raw(cmd)

call(func_name, *args)

Shortcut for calling a function from its name.

get(param_name)

Shortcut for getting a parameter from its name.

get_component(full_name)

Recursively get a component of the instrument by full_name.

invalidate_cache()

Invalidate the cache of all parameters on the instrument.

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

print_readable_snapshot([update, max_chars])

Prints a readable version of the snapshot.

set(param_name, value)

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

snapshot([update])

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

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

validate_status([verbose])

Validate the values of all gettable parameters

write(cmd)

write_raw(cmd)

Attributes:

ancestors

Ancestors in the form of a list of InstrumentBase

delegate_attr_dicts

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

delegate_attr_objects

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

full_name

Full name of the instrument.

label

Nicely formatted label of the instrument.

name

Full name of the instrument

name_parts

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

omit_delegate_attrs

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

parent

The parent instrument.

root_instrument

The topmost parent of this module.

short_name

Short name of the instrument.

parameters

All the parameters supported by this instrument.

functions

All the functions supported by this instrument.

submodules

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

instrument_modules

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

PATH_TO_DRIVER = 'mcl_RF_Switch_Controller64'
PATH_TO_DRIVER_45 = 'mcl_RF_Switch_Controller_NET45'
get_idn() dict[str, str | None][source]

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

Even though this is the VISA standard, it applies to various other types as well, such as IPInstruments, so it is included here in the Instrument base class.

Override this if your instrument does not support *IDN? or returns a nonstandard IDN string. This string is supposed to be a comma-separated list of vendor, model, serial, and firmware, but semicolon and colon are also common separators so we accept them here as well.

Returns:

A dict containing vendor, model, serial, and firmware.

__del__() None

Close the instrument and remove its instance record.

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

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

__getstate__() None

Prevent pickling instruments, and give a nice error message.

__repr__() str

Simplified repr giving just the class and name.

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

all(switch_to: int) None
property ancestors: tuple[InstrumentBase, ...]

Ancestors in the form of a list of InstrumentBase

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

ask(cmd: str) str

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

Subclasses that transform cmd should override this method, and in it call super().ask(new_cmd). Subclasses that define a new hardware communication should instead override ask_raw.

Parameters:

cmd – The string to send to the instrument.

Returns:

response

Raises:

Exception – Wraps any underlying exception with extra context, including the command and the instrument.

ask_raw(cmd: str) str

Low level method to write to the hardware and return a response.

Subclasses that define a new hardware communication should override this method. Subclasses that transform cmd should instead override ask.

Parameters:

cmd – The string to send to the instrument.

call(func_name: str, *args: Any) Any

Shortcut for calling a function from its name.

Parameters:
  • func_name – The name of a function of this instrument.

  • *args – any arguments to the function.

Returns:

The return value of the function.

close() None

Irreversibly stop this instrument and free its resources.

Subclasses should override this if they have other specific resources to close.

classmethod close_all() None

Try to close all instruments registered in _all_instruments This is handy for use with atexit to ensure that all instruments are closed when a python session is closed.

Examples

>>> atexit.register(qc.Instrument.close_all())
connect_message(idn_param: str = 'IDN', begin_time: float | None = None) None

Print a standard message on initial connection to an instrument.

Parameters:
  • idn_param – Name of parameter that returns ID dict. Default IDN.

  • begin_timetime.time() when init started. Default is self._t0, set at start of Instrument.__init__.

delegate_attr_dicts: ClassVar[list[str]] = ['parameters', 'functions', 'submodules']

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

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

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

static exist(name: str, instrument_class: type[Instrument] | None = None) bool

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

Parameters:
  • name – Name of the instrument.

  • instrument_class – The type of instrument you are looking for.

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

Find an existing instrument by name.

Parameters:
  • name – Name of the instrument.

  • instrument_class – The type of instrument you are looking for.

Returns:

The instrument found.

Raises:
  • KeyError – If no instrument of that name was found, or if its reference is invalid (dead).

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

property full_name: str

Full name of the instrument.

For an InstrumentModule this includes all parents separated by _

get(param_name: str) Any

Shortcut for getting a parameter from its name.

Parameters:

param_name – The name of a parameter of this instrument.

Returns:

The current value of the parameter.

get_component(full_name: str) MetadatableWithName

Recursively get a component of the instrument by full_name.

Parameters:

full_name – The name of the component to get.

Returns:

The component with the given name.

Raises:

KeyError – If the component does not exist.

get_number_of_channels() int
classmethod instances() list[T]

Get all currently defined instances of this instrument class.

You can use this to get the objects back if you lose track of them, and it’s also used by the test system to find objects to test against.

Returns:

A list of instances.

invalidate_cache() None

Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.

This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.

This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.

static is_valid(instr_instance: Instrument) bool

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

Parameters:

instr_instance – Instance of an Instrument class or its subclass.

property label: str

Nicely formatted label of the instrument.

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

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

property name: str

Full name of the instrument

This is equivalent to full_name() for backwards compatibility.

property name_parts: list[str]

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

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

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

property parent: InstrumentBase | None

The parent instrument. By default, this is None. Any SubInstrument should subclass this to return the parent instrument.

print_readable_snapshot(update: bool = False, max_chars: int = 80) None

Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.

Parameters:
  • update – If True, update the state by querying the instrument. If False, just use the latest values in memory. This argument gets passed to the snapshot function.

  • max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.

classmethod record_instance(instance: Instrument) None

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

Also records the instance in list of all instruments, and verifies that there are no other instruments with the same name.

This method is called after initialization of the instrument is completed.

Parameters:

instance – Instance to record.

Raises:

KeyError – If another instance with the same name is already present.

classmethod remove_instance(instance: Instrument) None

Remove a particular instance from the record.

Parameters:

instance – The instance to remove

property root_instrument: InstrumentBase

The topmost parent of this module.

For the root_instrument this is self.

set(param_name: str, value: Any) None

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

Parameters:
  • param_name – The name of a parameter of this instrument.

  • value – The new value to set.

property short_name: str

Short name of the instrument.

For an InstrumentModule this does not include any parent names.

snapshot(update: bool | None = False) dict[str, Any]

Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override snapshot_base().

Parameters:

update – Passed to snapshot_base.

Returns:

Base snapshot.

snapshot_base(update: bool | None = False, params_to_skip_update: Sequence[str] | None = None) dict[Any, Any]

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

Parameters:
  • update – If True, update the state by querying the instrument. If None update the state if known to be invalid. If False, just use the latest values in memory and never update state.

  • params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the snapshot_get attribute of those parameters instead.

Returns:

base snapshot

Return type:

dict

validate_status(verbose: bool = False) None

Validate the values of all gettable parameters

The validation is done for all parameters that have both a get and set method.

Parameters:

verbose – If True, then information about the parameters that are being check is printed.

write(cmd: str) None

Write a command string with NO response to the hardware.

Subclasses that transform cmd should override this method, and in it call super().write(new_cmd). Subclasses that define a new hardware communication should instead override write_raw.

Parameters:

cmd – The string to send to the instrument.

Raises:

Exception – Wraps any underlying exception with extra context, including the command and the instrument.

write_raw(cmd: str) None

Low level method to write a command string to the hardware.

Subclasses that define a new hardware communication should override this method. Subclasses that transform cmd should instead override write.

Parameters:

cmd – The string to send to the instrument.

parameters: dict[str, ParameterBase] = {}

All the parameters supported by this instrument. Usually populated via add_parameter().

functions: dict[str, Function] = {}

All the functions supported by this instrument. Usually populated via add_function().

submodules: dict[str, InstrumentModule | ChannelTuple] = {}

All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via add_submodule().

instrument_modules: dict[str, InstrumentModule] = {}

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

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

Bases: SwitchChannelBase

Parameters:
  • parent – The instrument the channel is a part of

  • name – the name of the channel

  • channel_letter – channel letter [‘a’, ‘b’, ‘c’ or ‘d’])

Methods:

__getitem__(key)

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

__getstate__()

Prevent pickling instruments, and give a nice error message.

__repr__()

Custom repr to give parent information

add_function(name, **kwargs)

Bind one Function to this instrument.

add_parameter(name[, parameter_class])

Bind one Parameter to this instrument.

add_submodule(name, submodule)

Bind one submodule to this instrument.

ask(cmd)

ask_raw(cmd)

call(func_name, *args)

Shortcut for calling a function from its name.

get(param_name)

Shortcut for getting a parameter from its name.

get_component(full_name)

Recursively get a component of the instrument by full_name.

invalidate_cache()

Invalidate the cache of all parameters on the instrument.

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

print_readable_snapshot([update, max_chars])

Prints a readable version of the snapshot.

set(param_name, value)

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

snapshot([update])

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

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

validate_status([verbose])

Validate the values of all gettable parameters

write(cmd)

write_raw(cmd)

Attributes:

ancestors

Ancestors in the form of a list of InstrumentBase

delegate_attr_dicts

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

delegate_attr_objects

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

full_name

Full name of the instrument.

label

Nicely formatted label of the instrument.

name

Full name of the instrument

name_parts

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

omit_delegate_attrs

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

parent

The parent instrument.

root_instrument

The topmost parent of this module.

short_name

Short name of the instrument.

parameters

All the parameters supported by this instrument.

functions

All the functions supported by this instrument.

submodules

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

instrument_modules

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

log

metadata

__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] = {}