Keithley Drivers
Classes:
|
Driver for the Keithley 2000 multimeter. |
|
QCoDeS driver for the Keithley 2400 voltage source. |
|
The QCoDeS driver for the Keithley 2450 SMU |
|
Treat the reading buffer as a submodule, similar to Sense and Source |
|
The sense module of the Keithley 2450 SMU. |
|
The source module of the Keithley 2450 SMU. |
Keeps track of measurement status. |
|
|
QCoDeS driver for the Keithley 2601B Source-Meter |
|
QCoDeS driver for the Keithley 2602A Source-Meter |
|
QCoDeS driver for the Keithley 2602B Source-Meter |
|
QCoDeS driver for the Keithley 2604B Source-Meter |
|
QCoDeS driver for the Keithley 2611B Source-Meter |
|
QCoDeS driver for the Keithley 2612B Source-Meter |
|
QCoDeS driver for the Keithley 2614B Source-Meter |
|
QCoDeS driver for the Keithley 2634B Source-Meter |
|
QCoDeS driver for the Keithley 2635B Source-Meter |
|
QCoDeS driver for the Keithley 2636B Source-Meter |
|
This is the QCoDeS instrument driver for the Keithley 3706A-SNFP System Switch. |
|
Driver for the Keithley 6500 multimeter. Based on the Keithley 2000 driver, |
|
The QCoDeS driver for the Keithley 7510 DMM |
|
Treat the reading buffer as a submodule, similar to Sense. |
|
The Digitize sense module of the Keithley 7510 DMM. |
|
The sense module of the Keithley 7510 DMM, based on the sense module of Keithley 2450 SMU. |
|
|
|
The S46 either has six pole or a four pole relays. |
Data:
All Keithley 26xx SMUs supported by QCoDeS. |
Exceptions:
- class qcodes.instrument_drivers.Keithley.Keithley2000(name: str, address: str, reset: bool = False, **kwargs: Any)[source]
Bases:
VisaInstrument
Driver for the Keithley 2000 multimeter.
Methods:
trigger
()__del__
()Close the instrument and remove its instance record.
__getitem__
(key)Delegate instrument['name'] to parameter or function 'name'.
Prevent pickling instruments, and give a nice error message.
__repr__
()Simplified repr giving just the class and name.
add_function
(name, **kwargs)Bind one
Function
to this instrument.add_parameter
(name[, parameter_class])Bind one Parameter to this instrument.
add_submodule
(name, submodule)Bind one submodule to this instrument.
ask
(cmd)Write a command string to the hardware and return a response.
ask_raw
(cmd)Low-level interface to
visa_handle.ask
.call
(func_name, *args)Shortcut for calling a function from its name.
close
()Disconnect and irreversibly tear down the instrument.
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.
Clear the buffers of the device
exist
(name[, instrument_class])Check if an instrument with a given names exists (i.e.
find_instrument
(name[, instrument_class])Find an existing instrument by name.
get
(param_name)Shortcut for getting a parameter from its name.
get_component
(full_name)Recursively get a component of the instrument by full_name.
get_idn
()Parse a standard VISA
*IDN?
response into an ID dict.Get all currently defined instances of this instrument class.
Invalidate the cache of all parameters on the instrument.
is_valid
(instr_instance)Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a "valid" instrument.
load_metadata
(metadata)Load metadata into this classes metadata dictionary.
print_readable_snapshot
([update, max_chars])Prints a readable version of the snapshot.
record_instance
(instance)Record (a weak ref to) an instance in a class's instance list.
remove_instance
(instance)Remove a particular instance from the record.
set
(param_name, value)Shortcut for setting a parameter from its name and new value.
set_address
(address)Set the address for this instrument.
set_terminator
(terminator)Change the read terminator to use.
snapshot
([update])Decorate a snapshot dictionary with metadata.
snapshot_base
([update, params_to_skip_update])State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncoder
supports).validate_status
([verbose])Validate the values of all gettable parameters
write
(cmd)Write a command string with NO response to the hardware.
write_raw
(cmd)Low-level interface to
visa_handle.write
.Attributes:
Ancestors in the form of a list of
InstrumentBase
A list of names (strings) of dictionaries which are (or will be) attributes of
self
, whose keys should be treated as attributes ofself
.A list of names (strings) of objects which are (or will be) attributes of
self
, whose attributes should be passed through toself
.Full name of the instrument.
Nicely formatted label of the instrument.
Full name of the instrument
A list of all the parts of the instrument name from
root_instrument()
to the currentInstrumentModule
.A list of attribute names (strings) to not delegate to any other dictionary or object.
The parent instrument.
The topmost parent of this module.
Short name of the instrument.
The VISA resource used by this instrument.
All the parameters supported by this instrument.
All the functions supported by this instrument.
All the submodules of this instrument such as channel lists or logical groupings of parameters.
All the
InstrumentModule
of this instrument Usually populated viaadd_submodule()
.- __getitem__(key: str) Callable[[...], Any] | Parameter
Delegate instrument[‘name’] to parameter or function ‘name’.
- add_function(name: str, **kwargs: Any) None
Bind one
Function
to this instrument.Instrument subclasses can call this repeatedly in their
__init__
for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST
(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.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[qcodes.parameters.parameter_base.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 aChannelTuple
.- Parameters:
name – How the submodule will be stored within
instrument.submodules
and also how it can be addressed.submodule – The submodule to be stored.
- Raises:
- property ancestors: tuple[qcodes.instrument.instrument_base.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 callsuper().ask(new_cmd)
. Subclasses that define a new hardware communication should instead overrideask_raw
.- Parameters:
cmd – The string to send to the instrument.
- Returns:
response
- Raises:
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- ask_raw(cmd: str) str
Low-level interface to
visa_handle.ask
.- Parameters:
cmd – The command to send to the instrument.
- Returns:
The instrument’s response.
- Return type:
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters:
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns:
The return value of the function.
- 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_time –
time.time()
when init started. Default isself._t0
, set at start ofInstrument.__init__
.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self
, whose keys should be treated as attributes ofself
.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self
, whose attributes should be passed through toself
.
- static exist(name: str, instrument_class: type | 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
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:
- 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:
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.
- 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 currentInstrumentModule
.
- omit_delegate_attrs: 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. IfFalse
, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- classmethod record_instance(instance: Instrument) None
Record (a weak ref to) an instance in a class’s instance list.
Also records the instance in list of all instruments, and verifies that there are no other instruments with the same name.
This method is called after initialization of the instrument is completed.
- Parameters:
instance – Instance to record.
- Raises:
KeyError – If another instance with the same name is already present.
- classmethod remove_instance(instance: Instrument) None
Remove a particular instance from the record.
- Parameters:
instance – The instance to remove
- property root_instrument: InstrumentBase
The topmost parent of this module.
For the
root_instrument
this isself
.
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters:
param_name – The name of a parameter of this instrument.
value – The new value to set.
- set_address(address: str) None
Set the address for this instrument.
- Parameters:
address – The visa resource name to use to connect. The address should be the actual address and just that. If you wish to change the backend for VISA, use the self.visalib attribute (and then call this function).
- set_terminator(terminator: str | None) None
Change the read terminator to use.
- Parameters:
terminator – Character(s) to look for at the end of a read and to end each write command with. eg.
\r\n
. If None the terminator will not be set.
- property short_name: str
Short name of the instrument.
For an
InstrumentModule
this does not include any parent names.
- snapshot(update: bool | None = False) Dict[str, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base()
.- Parameters:
update – Passed to snapshot_base.
- Returns:
Base snapshot.
- snapshot_base(update: bool | None = True, params_to_skip_update: Sequence[str] | None = None) dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncoder
supports).- Parameters:
update – If True, update the state by querying the instrument. If None only update if the state is known to be invalid. If False, just use the latest values in memory and never update.
params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_get
attribute of those parameters instead.
- Returns:
base snapshot
- Return type:
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters:
verbose – If
True
, then information about the parameters that are being check is printed.
- write(cmd: str) None
Write a command string with NO response to the hardware.
Subclasses that transform
cmd
should override this method, and in it callsuper().write(new_cmd)
. Subclasses that define a new hardware communication should instead overridewrite_raw
.- Parameters:
cmd – The string to send to the instrument.
- Raises:
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- write_raw(cmd: str) None
Low-level interface to
visa_handle.write
.- Parameters:
cmd – The command to send to the instrument.
- visa_handle: pyvisa.resources.MessageBasedResource = visa_handle
The VISA resource used by this 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 viaadd_submodule()
.
- log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
- class qcodes.instrument_drivers.Keithley.Keithley2400(name: str, address: str, **kwargs: Any)[source]
Bases:
VisaInstrument
QCoDeS driver for the Keithley 2400 voltage source.
Methods:
reset
()Reset the instrument.
__del__
()Close the instrument and remove its instance record.
__getitem__
(key)Delegate instrument['name'] to parameter or function 'name'.
Prevent pickling instruments, and give a nice error message.
__repr__
()Simplified repr giving just the class and name.
add_function
(name, **kwargs)Bind one
Function
to this instrument.add_parameter
(name[, parameter_class])Bind one Parameter to this instrument.
add_submodule
(name, submodule)Bind one submodule to this instrument.
ask
(cmd)Write a command string to the hardware and return a response.
ask_raw
(cmd)Low-level interface to
visa_handle.ask
.call
(func_name, *args)Shortcut for calling a function from its name.
close
()Disconnect and irreversibly tear down the instrument.
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.
Clear the buffers of the device
exist
(name[, instrument_class])Check if an instrument with a given names exists (i.e.
find_instrument
(name[, instrument_class])Find an existing instrument by name.
get
(param_name)Shortcut for getting a parameter from its name.
get_component
(full_name)Recursively get a component of the instrument by full_name.
get_idn
()Parse a standard VISA
*IDN?
response into an ID dict.Get all currently defined instances of this instrument class.
Invalidate the cache of all parameters on the instrument.
is_valid
(instr_instance)Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a "valid" instrument.
load_metadata
(metadata)Load metadata into this classes metadata dictionary.
print_readable_snapshot
([update, max_chars])Prints a readable version of the snapshot.
record_instance
(instance)Record (a weak ref to) an instance in a class's instance list.
remove_instance
(instance)Remove a particular instance from the record.
set
(param_name, value)Shortcut for setting a parameter from its name and new value.
set_address
(address)Set the address for this instrument.
set_terminator
(terminator)Change the read terminator to use.
snapshot
([update])Decorate a snapshot dictionary with metadata.
snapshot_base
([update, params_to_skip_update])State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncoder
supports).validate_status
([verbose])Validate the values of all gettable parameters
write
(cmd)Write a command string with NO response to the hardware.
write_raw
(cmd)Low-level interface to
visa_handle.write
.Attributes:
Ancestors in the form of a list of
InstrumentBase
A list of names (strings) of dictionaries which are (or will be) attributes of
self
, whose keys should be treated as attributes ofself
.A list of names (strings) of objects which are (or will be) attributes of
self
, whose attributes should be passed through toself
.Full name of the instrument.
Nicely formatted label of the instrument.
Full name of the instrument
A list of all the parts of the instrument name from
root_instrument()
to the currentInstrumentModule
.A list of attribute names (strings) to not delegate to any other dictionary or object.
The parent instrument.
The topmost parent of this module.
Short name of the instrument.
The VISA resource used by this instrument.
All the parameters supported by this instrument.
All the functions supported by this instrument.
All the submodules of this instrument such as channel lists or logical groupings of parameters.
All the
InstrumentModule
of this instrument Usually populated viaadd_submodule()
.- reset() None [source]
Reset the instrument. When the instrument is reset, it performs the following actions.
Returns the SourceMeter to the GPIB default conditions.
Cancels all pending commands.
Cancels all previously send *OPC and *OPC?
- __getitem__(key: str) Callable[[...], Any] | Parameter
Delegate instrument[‘name’] to parameter or function ‘name’.
- add_function(name: str, **kwargs: Any) None
Bind one
Function
to this instrument.Instrument subclasses can call this repeatedly in their
__init__
for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST
(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.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[qcodes.parameters.parameter_base.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 aChannelTuple
.- Parameters:
name – How the submodule will be stored within
instrument.submodules
and also how it can be addressed.submodule – The submodule to be stored.
- Raises:
- property ancestors: tuple[qcodes.instrument.instrument_base.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 callsuper().ask(new_cmd)
. Subclasses that define a new hardware communication should instead overrideask_raw
.- Parameters:
cmd – The string to send to the instrument.
- Returns:
response
- Raises:
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- ask_raw(cmd: str) str
Low-level interface to
visa_handle.ask
.- Parameters:
cmd – The command to send to the instrument.
- Returns:
The instrument’s response.
- Return type:
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters:
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns:
The return value of the function.
- 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_time –
time.time()
when init started. Default isself._t0
, set at start ofInstrument.__init__
.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self
, whose keys should be treated as attributes ofself
.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self
, whose attributes should be passed through toself
.
- static exist(name: str, instrument_class: type | 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
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:
- 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:
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.
- 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 currentInstrumentModule
.
- omit_delegate_attrs: 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. IfFalse
, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- classmethod record_instance(instance: Instrument) None
Record (a weak ref to) an instance in a class’s instance list.
Also records the instance in list of all instruments, and verifies that there are no other instruments with the same name.
This method is called after initialization of the instrument is completed.
- Parameters:
instance – Instance to record.
- Raises:
KeyError – If another instance with the same name is already present.
- classmethod remove_instance(instance: Instrument) None
Remove a particular instance from the record.
- Parameters:
instance – The instance to remove
- property root_instrument: InstrumentBase
The topmost parent of this module.
For the
root_instrument
this isself
.
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters:
param_name – The name of a parameter of this instrument.
value – The new value to set.
- set_address(address: str) None
Set the address for this instrument.
- Parameters:
address – The visa resource name to use to connect. The address should be the actual address and just that. If you wish to change the backend for VISA, use the self.visalib attribute (and then call this function).
- set_terminator(terminator: str | None) None
Change the read terminator to use.
- Parameters:
terminator – Character(s) to look for at the end of a read and to end each write command with. eg.
\r\n
. If None the terminator will not be set.
- property short_name: str
Short name of the instrument.
For an
InstrumentModule
this does not include any parent names.
- snapshot(update: bool | None = False) Dict[str, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base()
.- Parameters:
update – Passed to snapshot_base.
- Returns:
Base snapshot.
- snapshot_base(update: bool | None = True, params_to_skip_update: Sequence[str] | None = None) dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncoder
supports).- Parameters:
update – If True, update the state by querying the instrument. If None only update if the state is known to be invalid. If False, just use the latest values in memory and never update.
params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_get
attribute of those parameters instead.
- Returns:
base snapshot
- Return type:
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters:
verbose – If
True
, then information about the parameters that are being check is printed.
- write(cmd: str) None
Write a command string with NO response to the hardware.
Subclasses that transform
cmd
should override this method, and in it callsuper().write(new_cmd)
. Subclasses that define a new hardware communication should instead overridewrite_raw
.- Parameters:
cmd – The string to send to the instrument.
- Raises:
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- write_raw(cmd: str) None
Low-level interface to
visa_handle.write
.- Parameters:
cmd – The command to send to the instrument.
- visa_handle: pyvisa.resources.MessageBasedResource = visa_handle
The VISA resource used by this 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 viaadd_submodule()
.
- log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
- class qcodes.instrument_drivers.Keithley.Keithley2450(name: str, address: str, **kwargs: Any)[source]
Bases:
VisaInstrument
The QCoDeS driver for the Keithley 2450 SMU
Attributes:
We have different source modules depending on the source function, which can be 'current' or 'voltage'
We have different sense modules depending on the sense function, which can be 'current', 'voltage' or 'resistance'
Ancestors in the form of a list of
InstrumentBase
A list of names (strings) of dictionaries which are (or will be) attributes of
self
, whose keys should be treated as attributes ofself
.A list of names (strings) of objects which are (or will be) attributes of
self
, whose attributes should be passed through toself
.Full name of the instrument.
Nicely formatted label of the instrument.
Full name of the instrument
A list of all the parts of the instrument name from
root_instrument()
to the currentInstrumentModule
.A list of attribute names (strings) to not delegate to any other dictionary or object.
The parent instrument.
The topmost parent of this module.
Short name of the instrument.
The VISA resource used by this instrument.
All the parameters supported by this instrument.
All the functions supported by this instrument.
All the submodules of this instrument such as channel lists or logical groupings of parameters.
All the
InstrumentModule
of this instrument Usually populated viaadd_submodule()
.Methods:
buffer
(name[, size, style])npts
()Get the number of points in the sweep axis
The correct communication protocol is SCPI, make sure this is set
abort
()This command stops all trigger model commands on the instrument.
initiate
()This command starts the trigger model.
wait
()This command postpones the execution of subsequent commands until all previous overlapped commands are finished.
This function clears event registers.
This command clears the event log.
reset
()Returns instrument to default settings, cancels all pending commands.
__del__
()Close the instrument and remove its instance record.
__getitem__
(key)Delegate instrument['name'] to parameter or function 'name'.
Prevent pickling instruments, and give a nice error message.
__repr__
()Simplified repr giving just the class and name.
add_function
(name, **kwargs)Bind one
Function
to this instrument.add_parameter
(name[, parameter_class])Bind one Parameter to this instrument.
add_submodule
(name, submodule)Bind one submodule to this instrument.
ask
(cmd)Write a command string to the hardware and return a response.
ask_raw
(cmd)Low-level interface to
visa_handle.ask
.call
(func_name, *args)Shortcut for calling a function from its name.
close
()Disconnect and irreversibly tear down the instrument.
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.
Clear the buffers of the device
exist
(name[, instrument_class])Check if an instrument with a given names exists (i.e.
find_instrument
(name[, instrument_class])Find an existing instrument by name.
get
(param_name)Shortcut for getting a parameter from its name.
get_component
(full_name)Recursively get a component of the instrument by full_name.
get_idn
()Parse a standard VISA
*IDN?
response into an ID dict.Get all currently defined instances of this instrument class.
Invalidate the cache of all parameters on the instrument.
is_valid
(instr_instance)Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a "valid" instrument.
load_metadata
(metadata)Load metadata into this classes metadata dictionary.
print_readable_snapshot
([update, max_chars])Prints a readable version of the snapshot.
record_instance
(instance)Record (a weak ref to) an instance in a class's instance list.
remove_instance
(instance)Remove a particular instance from the record.
set
(param_name, value)Shortcut for setting a parameter from its name and new value.
set_address
(address)Set the address for this instrument.
set_terminator
(terminator)Change the read terminator to use.
snapshot
([update])Decorate a snapshot dictionary with metadata.
snapshot_base
([update, params_to_skip_update])State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncoder
supports).validate_status
([verbose])Validate the values of all gettable parameters
write
(cmd)Write a command string with NO response to the hardware.
write_raw
(cmd)Low-level interface to
visa_handle.write
.- property source: Keithley2450Source
We have different source modules depending on the source function, which can be ‘current’ or ‘voltage’
Return the correct source module based on the source function
- property sense: Keithley2450Sense
We have different sense modules depending on the sense function, which can be ‘current’, ‘voltage’ or ‘resistance’
Return the correct source module based on the sense function
- set_correct_language() None [source]
The correct communication protocol is SCPI, make sure this is set
- wait() None [source]
This command postpones the execution of subsequent commands until all previous overlapped commands are finished.
- __getitem__(key: str) Callable[[...], Any] | Parameter
Delegate instrument[‘name’] to parameter or function ‘name’.
- add_function(name: str, **kwargs: Any) None
Bind one
Function
to this instrument.Instrument subclasses can call this repeatedly in their
__init__
for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST
(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.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[qcodes.parameters.parameter_base.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 aChannelTuple
.- Parameters:
name – How the submodule will be stored within
instrument.submodules
and also how it can be addressed.submodule – The submodule to be stored.
- Raises:
- property ancestors: tuple[qcodes.instrument.instrument_base.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 callsuper().ask(new_cmd)
. Subclasses that define a new hardware communication should instead overrideask_raw
.- Parameters:
cmd – The string to send to the instrument.
- Returns:
response
- Raises:
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- ask_raw(cmd: str) str
Low-level interface to
visa_handle.ask
.- Parameters:
cmd – The command to send to the instrument.
- Returns:
The instrument’s response.
- Return type:
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters:
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns:
The return value of the function.
- 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_time –
time.time()
when init started. Default isself._t0
, set at start ofInstrument.__init__
.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self
, whose keys should be treated as attributes ofself
.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self
, whose attributes should be passed through toself
.
- static exist(name: str, instrument_class: type | 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
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:
- 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:
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.
- 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 currentInstrumentModule
.
- omit_delegate_attrs: 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. IfFalse
, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- classmethod record_instance(instance: Instrument) None
Record (a weak ref to) an instance in a class’s instance list.
Also records the instance in list of all instruments, and verifies that there are no other instruments with the same name.
This method is called after initialization of the instrument is completed.
- Parameters:
instance – Instance to record.
- Raises:
KeyError – If another instance with the same name is already present.
- classmethod remove_instance(instance: Instrument) None
Remove a particular instance from the record.
- Parameters:
instance – The instance to remove
- property root_instrument: InstrumentBase
The topmost parent of this module.
For the
root_instrument
this isself
.
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters:
param_name – The name of a parameter of this instrument.
value – The new value to set.
- set_address(address: str) None
Set the address for this instrument.
- Parameters:
address – The visa resource name to use to connect. The address should be the actual address and just that. If you wish to change the backend for VISA, use the self.visalib attribute (and then call this function).
- set_terminator(terminator: str | None) None
Change the read terminator to use.
- Parameters:
terminator – Character(s) to look for at the end of a read and to end each write command with. eg.
\r\n
. If None the terminator will not be set.
- property short_name: str
Short name of the instrument.
For an
InstrumentModule
this does not include any parent names.
- snapshot(update: bool | None = False) Dict[str, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base()
.- Parameters:
update – Passed to snapshot_base.
- Returns:
Base snapshot.
- snapshot_base(update: bool | None = True, params_to_skip_update: Sequence[str] | None = None) dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncoder
supports).- Parameters:
update – If True, update the state by querying the instrument. If None only update if the state is known to be invalid. If False, just use the latest values in memory and never update.
params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_get
attribute of those parameters instead.
- Returns:
base snapshot
- Return type:
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters:
verbose – If
True
, then information about the parameters that are being check is printed.
- write(cmd: str) None
Write a command string with NO response to the hardware.
Subclasses that transform
cmd
should override this method, and in it callsuper().write(new_cmd)
. Subclasses that define a new hardware communication should instead overridewrite_raw
.- Parameters:
cmd – The string to send to the instrument.
- Raises:
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- write_raw(cmd: str) None
Low-level interface to
visa_handle.write
.- Parameters:
cmd – The command to send to the instrument.
- visa_handle: pyvisa.resources.MessageBasedResource = visa_handle
The VISA resource used by this 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 viaadd_submodule()
.
- log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
- class qcodes.instrument_drivers.Keithley.Keithley2450Buffer(parent: Keithley2450, name: str, size: int | None = None, style: str = '')[source]
Bases:
InstrumentChannel
Treat the reading buffer as a submodule, similar to Sense and Source
Attributes:
Ancestors in the form of a list of
InstrumentBase
A list of names (strings) of dictionaries which are (or will be) attributes of
self
, whose keys should be treated as attributes ofself
.A list of names (strings) of objects which are (or will be) attributes of
self
, whose attributes should be passed through toself
.Full name of the instrument.
Nicely formatted label of the instrument.
Full name of the instrument
A list of all the parts of the instrument name from
root_instrument()
to the currentInstrumentModule
.A list of attribute names (strings) to not delegate to any other dictionary or object.
The parent instrument.
The topmost parent of this module.
Short name of the instrument.
All the parameters supported by this instrument.
All the functions supported by this instrument.
All the submodules of this instrument such as channel lists or logical groupings of parameters.
All the
InstrumentModule
of this instrument Usually populated viaadd_submodule()
.Methods:
from_name_to_scpi
(element_names)from_scpi_to_name
(element_scpis)This method requests the latest reading from a reading buffer.
get_data
(start_idx, end_idx[, readings_only])This command returns specified data elements from reading buffer.
Clear the data in the buffer
This method makes readings using the active measure function and stores them in a reading buffer.
delete
()__getitem__
(key)Delegate instrument['name'] to parameter or function 'name'.
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 the cache of all parameters on the instrument.
load_metadata
(metadata)Load metadata into this classes metadata dictionary.
print_readable_snapshot
([update, max_chars])Prints a readable version of the snapshot.
set
(param_name, value)Shortcut for setting a parameter from its name and new value.
snapshot
([update])Decorate a snapshot dictionary with metadata.
snapshot_base
([update, params_to_skip_update])State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncoder
supports).validate_status
([verbose])Validate the values of all gettable parameters
write
(cmd)write_raw
(cmd)- default_buffer = {'defbuffer1', 'defbuffer2'}
- buffer_elements = {'date': 'DATE', 'fractional_seconds': 'FRACtional', 'measurement': 'READing', 'measurement_formatted': 'FORMatted', 'measurement_status': 'STATus', 'measurement_unit': 'UNIT', 'relative_time': 'RELative', 'seconds': 'SEConds', 'source_value': 'SOURce', 'source_value_formatted': 'SOURFORMatted', 'source_value_status': 'SOURSTATus', 'source_value_unit': 'SOURUNIT', 'time': 'TIME', 'timestamp': 'TSTamp'}
- inverted_buffer_elements = {'DATE': 'date', 'FORMatted': 'measurement_formatted', 'FRACtional': 'fractional_seconds', 'READing': 'measurement', 'RELative': 'relative_time', 'SEConds': 'seconds', 'SOURFORMatted': 'source_value_formatted', 'SOURSTATus': 'source_value_status', 'SOURUNIT': 'source_value_unit', 'SOURce': 'source_value', 'STATus': 'measurement_status', 'TIME': 'time', 'TSTamp': 'timestamp', 'UNIT': 'measurement_unit'}
- get_data(start_idx: int, end_idx: int, readings_only: bool = False) List[Any] [source]
This command returns specified data elements from reading buffer.
- Parameters:
start_idx – beginning index of the buffer to return
end_idx – ending index of the buffer to return
readings_only – a flag to temporarily disable the elements and output only the numerical readings
- Returns:
data elements from the reading buffer
- trigger_start() None [source]
This method makes readings using the active measure function and stores them in a reading buffer.
- __getitem__(key: str) Callable[[...], Any] | Parameter
Delegate instrument[‘name’] to parameter or function ‘name’.
- add_function(name: str, **kwargs: Any) None
Bind one
Function
to this instrument.Instrument subclasses can call this repeatedly in their
__init__
for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST
(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.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[qcodes.parameters.parameter_base.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 aChannelTuple
.- Parameters:
name – How the submodule will be stored within
instrument.submodules
and also how it can be addressed.submodule – The submodule to be stored.
- Raises:
- property ancestors: tuple[qcodes.instrument.instrument_base.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.
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters:
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns:
The return value of the function.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self
, whose keys should be treated as attributes ofself
.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self
, whose attributes should be passed through toself
.
- 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:
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.
- 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 currentInstrumentModule
.
- omit_delegate_attrs: 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. IfFalse
, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- property root_instrument: InstrumentBase
The topmost parent of this module.
For the
root_instrument
this isself
.
- 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. IfFalse
, just use the latest values in memory and never update state.params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_get
attribute of those parameters instead.
- Returns:
base snapshot
- Return type:
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters:
verbose – If
True
, then information about the parameters that are being check is printed.
- parameters: dict[str, ParameterBase] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter()
.
- functions: dict[str, Function] = {}
All the functions supported by this instrument. Usually populated via
add_function()
.
- submodules: dict[str, InstrumentModule | ChannelTuple] = {}
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule()
.
- instrument_modules: dict[str, InstrumentModule] = {}
All the
InstrumentModule
of this instrument Usually populated viaadd_submodule()
.
- log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
- class qcodes.instrument_drivers.Keithley.Keithley2450Sense(parent: Keithley2450, name: str, proper_function: str)[source]
Bases:
InstrumentChannel
The sense module of the Keithley 2450 SMU.
- Parameters:
parent –
name –
proper_function – This can be one of either “current”, “voltage” or “resistance”. All parameters and methods in this submodule should only be accessible to the user if self.parent.sense_function.get() == self._proper_function. We ensure this through the ‘sense’ property on the main driver class which returns the proper submodule for any given function mode
Attributes:
Ancestors in the form of a list of
InstrumentBase
A list of names (strings) of dictionaries which are (or will be) attributes of
self
, whose keys should be treated as attributes ofself
.A list of names (strings) of objects which are (or will be) attributes of
self
, whose attributes should be passed through toself
.Full name of the instrument.
Nicely formatted label of the instrument.
Full name of the instrument
A list of all the parts of the instrument name from
root_instrument()
to the currentInstrumentModule
.A list of attribute names (strings) to not delegate to any other dictionary or object.
The parent instrument.
The topmost parent of this module.
Short name of the instrument.
All the parameters supported by this instrument.
All the functions supported by this instrument.
All the submodules of this instrument such as channel lists or logical groupings of parameters.
All the
InstrumentModule
of this instrument Usually populated viaadd_submodule()
.Methods:
This command causes the instrument to refresh the reference and zero measurements once.
clear_trace
([buffer_name])Clear the data buffer
__getitem__
(key)Delegate instrument['name'] to parameter or function 'name'.
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 the cache of all parameters on the instrument.
load_metadata
(metadata)Load metadata into this classes metadata dictionary.
print_readable_snapshot
([update, max_chars])Prints a readable version of the snapshot.
set
(param_name, value)Shortcut for setting a parameter from its name and new value.
snapshot
([update])Decorate a snapshot dictionary with metadata.
snapshot_base
([update, params_to_skip_update])State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncoder
supports).validate_status
([verbose])Validate the values of all gettable parameters
write
(cmd)write_raw
(cmd)- function_modes = {'current': {'name': '"CURR:DC"', 'range_vals': <Numbers 1e-08<=v<=1>, 'unit': 'A'}, 'resistance': {'name': '"RES"', 'range_vals': <Numbers 20<=v<=200000000.0>, 'unit': 'Ohm'}, 'voltage': {'name': '"VOLT:DC"', 'range_vals': <Numbers 0.02<=v<=200>, 'unit': 'V'}}
- auto_zero_once() None [source]
This command causes the instrument to refresh the reference and zero measurements once.
- __getitem__(key: str) Callable[[...], Any] | Parameter
Delegate instrument[‘name’] to parameter or function ‘name’.
- add_function(name: str, **kwargs: Any) None
Bind one
Function
to this instrument.Instrument subclasses can call this repeatedly in their
__init__
for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST
(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.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[qcodes.parameters.parameter_base.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 aChannelTuple
.- Parameters:
name – How the submodule will be stored within
instrument.submodules
and also how it can be addressed.submodule – The submodule to be stored.
- Raises:
- property ancestors: tuple[qcodes.instrument.instrument_base.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.
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters:
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns:
The return value of the function.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self
, whose keys should be treated as attributes ofself
.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self
, whose attributes should be passed through toself
.
- 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:
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.
- 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 currentInstrumentModule
.
- omit_delegate_attrs: 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. IfFalse
, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- property root_instrument: InstrumentBase
The topmost parent of this module.
For the
root_instrument
this isself
.
- 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. IfFalse
, just use the latest values in memory and never update state.params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_get
attribute of those parameters instead.
- Returns:
base snapshot
- Return type:
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters:
verbose – If
True
, then information about the parameters that are being check is printed.
- parameters: dict[str, ParameterBase] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter()
.
- functions: dict[str, Function] = {}
All the functions supported by this instrument. Usually populated via
add_function()
.
- submodules: dict[str, InstrumentModule | ChannelTuple] = {}
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule()
.
- instrument_modules: dict[str, InstrumentModule] = {}
All the
InstrumentModule
of this instrument Usually populated viaadd_submodule()
.
- log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
- class qcodes.instrument_drivers.Keithley.Keithley2450Source(parent: Keithley2450, name: str, proper_function: str)[source]
Bases:
InstrumentChannel
The source module of the Keithley 2450 SMU.
- Parameters:
parent –
name –
proper_function – This can be one of either “current” or “voltage” All parameters and methods in this submodule should only be accessible to the user if self.parent.source_function.get() == self._proper_function. We ensure this through the ‘source’ property on the main driver class which returns the proper submodule for any given function mode
Attributes:
Ancestors in the form of a list of
InstrumentBase
A list of names (strings) of dictionaries which are (or will be) attributes of
self
, whose keys should be treated as attributes ofself
.A list of names (strings) of objects which are (or will be) attributes of
self
, whose attributes should be passed through toself
.Full name of the instrument.
Nicely formatted label of the instrument.
Full name of the instrument
A list of all the parts of the instrument name from
root_instrument()
to the currentInstrumentModule
.A list of attribute names (strings) to not delegate to any other dictionary or object.
The parent instrument.
The topmost parent of this module.
Short name of the instrument.
All the parameters supported by this instrument.
All the functions supported by this instrument.
All the submodules of this instrument such as channel lists or logical groupings of parameters.
All the
InstrumentModule
of this instrument Usually populated viaadd_submodule()
.Methods:
sweep_setup
(start, stop, step_count[, ...])Start a sweep and return when the sweep has finished.
__getitem__
(key)Delegate instrument['name'] to parameter or function 'name'.
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 the cache of all parameters on the instrument.
load_metadata
(metadata)Load metadata into this classes metadata dictionary.
print_readable_snapshot
([update, max_chars])Prints a readable version of the snapshot.
set
(param_name, value)Shortcut for setting a parameter from its name and new value.
snapshot
([update])Decorate a snapshot dictionary with metadata.
snapshot_base
([update, params_to_skip_update])State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncoder
supports).validate_status
([verbose])Validate the values of all gettable parameters
write
(cmd)write_raw
(cmd)- function_modes = {'current': {'name': 'CURR', 'range_vals': <Numbers -1<=v<=1>, 'unit': 'A'}, 'voltage': {'name': 'VOLT', 'range_vals': <Numbers -200<=v<=200>, 'unit': 'V'}}
- sweep_setup(start: float, stop: float, step_count: int, delay: float = 0, sweep_count: int = 1, range_mode: str = 'AUTO', fail_abort: str = 'ON', dual: str = 'OFF', buffer_name: str = 'defbuffer1') None [source]
- sweep_start() None [source]
Start a sweep and return when the sweep has finished. Note: This call is blocking
- __getitem__(key: str) Callable[[...], Any] | Parameter
Delegate instrument[‘name’] to parameter or function ‘name’.
- add_function(name: str, **kwargs: Any) None
Bind one
Function
to this instrument.Instrument subclasses can call this repeatedly in their
__init__
for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST
(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.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[qcodes.parameters.parameter_base.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 aChannelTuple
.- Parameters:
name – How the submodule will be stored within
instrument.submodules
and also how it can be addressed.submodule – The submodule to be stored.
- Raises:
- property ancestors: tuple[qcodes.instrument.instrument_base.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.
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters:
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns:
The return value of the function.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self
, whose keys should be treated as attributes ofself
.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self
, whose attributes should be passed through toself
.
- 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:
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.
- 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 currentInstrumentModule
.
- omit_delegate_attrs: 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. IfFalse
, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- property root_instrument: InstrumentBase
The topmost parent of this module.
For the
root_instrument
this isself
.
- 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. IfFalse
, just use the latest values in memory and never update state.params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_get
attribute of those parameters instead.
- Returns:
base snapshot
- Return type:
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters:
verbose – If
True
, then information about the parameters that are being check is printed.
- parameters: dict[str, ParameterBase] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter()
.
- functions: dict[str, Function] = {}
All the functions supported by this instrument. Usually populated via
add_function()
.
- submodules: dict[str, InstrumentModule | ChannelTuple] = {}
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule()
.
- instrument_modules: dict[str, InstrumentModule] = {}
All the
InstrumentModule
of this instrument Usually populated viaadd_submodule()
.
- log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
- class qcodes.instrument_drivers.Keithley.Keithley2600MeasurementStatus(value)[source]
Bases:
StrEnum
Keeps track of measurement status.
Attributes:
- CURRENT_COMPLIANCE_ERROR = 'Reached current compliance limit.'
- VOLTAGE_COMPLIANCE_ERROR = 'Reached voltage compliance limit.'
- VOLTAGE_AND_CURRENT_COMPLIANCE_ERROR = 'Reached both voltage and current compliance limits.'
- NORMAL = 'No error occured.'
- COMPLIANCE_ERROR = 'Reached compliance limit.'
- qcodes.instrument_drivers.Keithley.Keithley26xx(*args, **kwargs)
All Keithley 26xx SMUs supported by QCoDeS.
alias of
Union
[Keithley2601B
,Keithley2602A
,Keithley2602B
,Keithley2604B
,Keithley2611B
,Keithley2612B
,Keithley2614B
,Keithley2634B
,Keithley2635B
,Keithley2636B
]
- class qcodes.instrument_drivers.Keithley.Keithley2601B(name: str, address: str, **kwargs: Any)[source]
Bases:
Keithley2600
QCoDeS driver for the Keithley 2601B Source-Meter
- Parameters:
name – Name to use internally in QCoDeS
address – VISA resource address
Methods:
__del__
()Close the instrument and remove its instance record.
__getitem__
(key)Delegate instrument['name'] to parameter or function 'name'.
Prevent pickling instruments, and give a nice error message.
__repr__
()Simplified repr giving just the class and name.
add_function
(name, **kwargs)Bind one
Function
to this instrument.add_parameter
(name[, parameter_class])Bind one Parameter to this instrument.
add_submodule
(name, submodule)Bind one submodule to this instrument.
ask
(cmd)Override of normal ask.
ask_raw
(cmd)Low-level interface to
visa_handle.ask
.call
(func_name, *args)Shortcut for calling a function from its name.
close
()Disconnect and irreversibly tear down the instrument.
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.
Clear the buffers of the device
This function clears the display, but also leaves it in user mode
Set the display to the default mode
exist
(name[, instrument_class])Check if an instrument with a given names exists (i.e.
exit_key
()Get back the normal screen after an error: send an EXIT key press event
find_instrument
(name[, instrument_class])Find an existing instrument by name.
get
(param_name)Shortcut for getting a parameter from its name.
get_component
(full_name)Recursively get a component of the instrument by full_name.
get_idn
()Parse a standard VISA
*IDN?
response into an ID dict.Get all currently defined instances of this instrument class.
Invalidate the cache of all parameters on the instrument.
is_valid
(instr_instance)Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a "valid" instrument.
load_metadata
(metadata)Load metadata into this classes metadata dictionary.
print_readable_snapshot
([update, max_chars])Prints a readable version of the snapshot.
record_instance
(instance)Record (a weak ref to) an instance in a class's instance list.
remove_instance
(instance)Remove a particular instance from the record.
reset
()Reset instrument to factory defaults.
set
(param_name, value)Shortcut for setting a parameter from its name and new value.
set_address
(address)Set the address for this instrument.
set_terminator
(terminator)Change the read terminator to use.
snapshot
([update])Decorate a snapshot dictionary with metadata.
snapshot_base
([update, params_to_skip_update])State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncoder
supports).validate_status
([verbose])Validate the values of all gettable parameters
write
(cmd)Write a command string with NO response to the hardware.
write_raw
(cmd)Low-level interface to
visa_handle.write
.Attributes:
Ancestors in the form of a list of
InstrumentBase
A list of names (strings) of dictionaries which are (or will be) attributes of
self
, whose keys should be treated as attributes ofself
.A list of names (strings) of objects which are (or will be) attributes of
self
, whose attributes should be passed through toself
.Full name of the instrument.
Nicely formatted label of the instrument.
Full name of the instrument
A list of all the parts of the instrument name from
root_instrument()
to the currentInstrumentModule
.A list of attribute names (strings) to not delegate to any other dictionary or object.
The parent instrument.
The topmost parent of this module.
Short name of the instrument.
The VISA resource used by this instrument.
All the parameters supported by this instrument.
All the functions supported by this instrument.
All the submodules of this instrument such as channel lists or logical groupings of parameters.
All the
InstrumentModule
of this instrument Usually populated viaadd_submodule()
.- __getitem__(key: str) Callable[[...], Any] | Parameter
Delegate instrument[‘name’] to parameter or function ‘name’.
- add_function(name: str, **kwargs: Any) None
Bind one
Function
to this instrument.Instrument subclasses can call this repeatedly in their
__init__
for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST
(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.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[qcodes.parameters.parameter_base.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 aChannelTuple
.- Parameters:
name – How the submodule will be stored within
instrument.submodules
and also how it can be addressed.submodule – The submodule to be stored.
- Raises:
- property ancestors: tuple[qcodes.instrument.instrument_base.InstrumentBase, ...]
Ancestors in the form of a list of
InstrumentBase
The list starts with the current module then the parent and the parents parent until the root instrument is reached.
- ask(cmd: str) str
Override of normal ask. This is important, since queries to the instrument must be wrapped in ‘print()’
- ask_raw(cmd: str) str
Low-level interface to
visa_handle.ask
.- Parameters:
cmd – The command to send to the instrument.
- Returns:
The instrument’s response.
- Return type:
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters:
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns:
The return value of the function.
- classmethod close_all() None
Try to close all instruments registered in
_all_instruments
This is handy for use with atexit to ensure that all instruments are closed when a python session is closed.Examples
>>> atexit.register(qc.Instrument.close_all())
- connect_message(idn_param: str = 'IDN', begin_time: float | None = None) None
Print a standard message on initial connection to an instrument.
- Parameters:
idn_param – Name of parameter that returns ID dict. Default
IDN
.begin_time –
time.time()
when init started. Default isself._t0
, set at start ofInstrument.__init__
.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self
, whose keys should be treated as attributes ofself
.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self
, whose attributes should be passed through toself
.
- static exist(name: str, instrument_class: type | 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
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:
- 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:
name – The name of the component to get.
- Returns:
The component with the given name.
- Raises: