qcodes.instrument_drivers.rohde_schwarz package
Subpackages
Submodules
qcodes.instrument_drivers.rohde_schwarz.RTE1000 module
qcodes.instrument_drivers.rohde_schwarz.RTO1000 module
- class qcodes.instrument_drivers.rohde_schwarz.RTO1000.RTO1000(*args: Any, **kwargs: Any)[source]
Bases:
qcodes.instrument.visa.VisaInstrument
QCoDeS Instrument driver for the Rohde-Schwarz RTO1000 series oscilloscopes.
- Parameters
name – name of the instrument
address – VISA resource address
model – The instrument model. For newer firmware versions, this can be auto-detected
timeout – The VISA query timeout
HD – Does the unit have the High Definition Option (allowing 16 bit vertical resolution)
terminator – Command termination character to strip from VISA commands.
- __getitem__(key: str) Union[Callable[[...], Any], qcodes.instrument.parameter.Parameter]
Delegate instrument[‘name’] to parameter or function ‘name’.
- add_function(name: str, **kwargs: Any) None
Bind one
Function
to this instrument.Instrument subclasses can call this repeatedly in their
__init__
for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST
(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only. If your case is more complicated, you’re probably better off simply making a new method in yourInstrument
subclass definition.- Parameters
name – How the Function will be stored within
instrument.Functions
and also how you address it using the shortcut methods:instrument.call(func_name, *args)
etc.**kwargs – constructor kwargs for
Function
- Raises
KeyError – If this instrument already has a function with this name.
- add_parameter(name: str, parameter_class: type = <class 'qcodes.instrument.parameter.Parameter'>, **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
instrument.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
parameter.Parameter
.**kwargs – Constructor arguments for
parameter_class
.
- Raises
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- add_submodule(name: str, submodule: Union[InstrumentModule, ChannelTuple]) None
Bind one submodule to this instrument.
Instrument subclasses can call this repeatedly in their
__init__
method for every submodule of the instrument.Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an
InstrumentModule
or aChannelTuple
.- Parameters
name – How the submodule will be stored within
instrument.submodules
and also how it can be addressed.submodule – The submodule to be stored.
- Raises
- property ancestors: List[qcodes.instrument.base.InstrumentBase]
Returns a list of instruments, starting from the current instrument and following to the parent instrument and the parents parent instrument until the root instrument is reached.
- ask(cmd: str) str
Write a command string to the hardware and return a response.
Subclasses that transform
cmd
should override this method, and in it callsuper().ask(new_cmd)
. Subclasses that define a new hardware communication should instead overrideask_raw
.- Parameters
cmd – The string to send to the instrument.
- Returns
response
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- ask_raw(cmd: str) str
Low-level interface to
visa_handle.ask
.- Parameters
cmd – The command to send to the instrument.
- Returns
The instrument’s response.
- Return type
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns
The return value of the function.
- check_error(ret_code: int) None
Default error checking, raises an error if return code
!=0
. Does not differentiate between warnings or specific error messages. Override this function in your driver if you want to add specific error messages.- Parameters
ret_code – A Visa error code. See eg: https://github.com/hgrecco/pyvisa/blob/master/pyvisa/errors.py
- Raises
visa.VisaIOError – if
ret_code
indicates a communication problem.
- classmethod close_all() None
Try to close all instruments registered in
_all_instruments
This is handy for use with atexit to ensure that all instruments are closed when a python session is closed.Examples
>>> atexit.register(qc.Instrument.close_all())
- connect_message(idn_param: str = 'IDN', begin_time: Optional[float] = None) None
Print a standard message on initial connection to an instrument.
- Parameters
idn_param – Name of parameter that returns ID dict. Default
IDN
.begin_time –
time.time()
when init started. Default isself._t0
, set at start ofInstrument.__init__
.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self
, whose keys should be treated as attributes ofself
.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self
, whose attributes should be passed through toself
.
- static exist(name: str, instrument_class: Optional[type] = None) bool
Check if an instrument with a given names exists (i.e. is already instantiated).
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- classmethod find_instrument(name: str, instrument_class: Optional[Type[qcodes.instrument.base.T]] = None) qcodes.instrument.base.T
Find an existing instrument by name.
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- Returns
The instrument found.
- Raises
- get(param_name: str) Any
Shortcut for getting a parameter from its name.
- Parameters
param_name – The name of a parameter of this instrument.
- Returns
The current value of the parameter.
- get_idn() Dict[str, Optional[str]]
Parse a standard VISA
*IDN?
response into an ID dict.Even though this is the VISA standard, it applies to various other types as well, such as IPInstruments, so it is included here in the Instrument base class.
Override this if your instrument does not support
*IDN?
or returns a nonstandard IDN string. This string is supposed to be a comma-separated list of vendor, model, serial, and firmware, but semicolon and colon are also common separators so we accept them here as well.- Returns
A dict containing vendor, model, serial, and firmware.
- classmethod instances() List[qcodes.instrument.base.Instrument]
Get all currently defined instances of this instrument class.
You can use this to get the objects back if you lose track of them, and it’s also used by the test system to find objects to test against.
- Returns
A list of instances.
- invalidate_cache() None
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- static is_valid(instr_instance: qcodes.instrument.base.Instrument) bool
Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a “valid” instrument.
- Parameters
instr_instance – Instance of an Instrument class or its subclass.
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Name of the instrument This is equivalent to full_name for backwards compatibility.
- omit_delegate_attrs: List[str] = []
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: Optional[qcodes.instrument.base.InstrumentBase]
Returns the parent instrument. By default this is
None
. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters
update – If
True
, update the state by querying the instrument. IfFalse
, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- classmethod record_instance(instance: qcodes.instrument.base.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: qcodes.instrument.base.Instrument) None
Remove a particular instance from the record.
- Parameters
instance – The instance to remove
- property root_instrument: qcodes.instrument.base.InstrumentBase
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters
param_name – The name of a parameter of this instrument.
value – The new value to set.
- set_address(address: str) None
Set the address for this instrument.
- Parameters
address – The visa resource name to use to connect. The address should be the actual address and just that. If you wish to change the backend for VISA, use the self.visalib attribute (and then call this function).
- set_terminator(terminator: str) None
Change the read terminator to use.
- Parameters
terminator – Character(s) to look for at the end of a read. eg.
\r\n
.
- snapshot(update: Optional[bool] = False) Dict[Any, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base()
.- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: Optional[bool] = True, params_to_skip_update: Optional[Sequence[str]] = None) Dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
qcodes.utils.helpers.NumpyJSONEncoder
supports).- Parameters
update – If True, update the state by querying the instrument. If None only update if the state is known to be invalid. If False, just use the latest values in memory and never update.
params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_get
attribute of those parameters instead.
- Returns
base snapshot
- Return type
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters
verbose – If
True
, then information about the parameters that are being check is printed.
- write(cmd: str) None
Write a command string with NO response to the hardware.
Subclasses that transform
cmd
should override this method, and in it callsuper().write(new_cmd)
. Subclasses that define a new hardware communication should instead overridewrite_raw
.- Parameters
cmd – The string to send to the instrument.
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- write_raw(cmd: str) None
Low-level interface to
visa_handle.write
.- Parameters
cmd – The command to send to the instrument.
- parameters: Dict[str, _BaseParameter] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter()
.
- functions: Dict[str, Function] = {}
All the functions supported by this instrument. Usually populated via
add_function()
.
- submodules: Dict[str, Union['InstrumentModule', 'ChannelTuple']] = {}
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule()
.
- instrument_modules: Dict[str, 'InstrumentModule'] = {}
All the instrument_modules of this instrument Usually populated via
add_submodule()
.
- class qcodes.instrument_drivers.rohde_schwarz.RTO1000.ScopeChannel(parent: qcodes.instrument.base.Instrument, name: str, channum: int)[source]
Bases:
qcodes.instrument.channel.InstrumentChannel
Class to hold an input channel of the scope.
Exposes: state, coupling, ground, scale, range, position, offset, invert, bandwidth, impedance, overload.
- Parameters
parent – The instrument to which the channel is attached
name – The name of the channel
channum – The number of the channel in question. Must match the actual number as used by the instrument (1..4)
- __getitem__(key: str) Union[Callable[[...], Any], qcodes.instrument.parameter.Parameter]
Delegate instrument[‘name’] to parameter or function ‘name’.
- add_function(name: str, **kwargs: Any) None
Bind one
Function
to this instrument.Instrument subclasses can call this repeatedly in their
__init__
for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST
(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only. If your case is more complicated, you’re probably better off simply making a new method in yourInstrument
subclass definition.- Parameters
name – How the Function will be stored within
instrument.Functions
and also how you address it using the shortcut methods:instrument.call(func_name, *args)
etc.**kwargs – constructor kwargs for
Function
- Raises
KeyError – If this instrument already has a function with this name.
- add_parameter(name: str, parameter_class: type = <class 'qcodes.instrument.parameter.Parameter'>, **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
instrument.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
parameter.Parameter
.**kwargs – Constructor arguments for
parameter_class
.
- Raises
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- add_submodule(name: str, submodule: Union[InstrumentModule, ChannelTuple]) None
Bind one submodule to this instrument.
Instrument subclasses can call this repeatedly in their
__init__
method for every submodule of the instrument.Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an
InstrumentModule
or aChannelTuple
.- Parameters
name – How the submodule will be stored within
instrument.submodules
and also how it can be addressed.submodule – The submodule to be stored.
- Raises
- property ancestors: List[qcodes.instrument.base.InstrumentBase]
Returns a list of instruments, starting from the current instrument and following to the parent instrument and the parents parent instrument until the root instrument is reached.
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns
The return value of the function.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self
, whose keys should be treated as attributes ofself
.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self
, whose attributes should be passed through toself
.
- get(param_name: str) Any
Shortcut for getting a parameter from its name.
- Parameters
param_name – The name of a parameter of this instrument.
- Returns
The current value of the parameter.
- invalidate_cache() None
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Name of the instrument This is equivalent to full_name for backwards compatibility.
- omit_delegate_attrs: List[str] = []
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: qcodes.instrument.base.InstrumentBase
Returns the parent instrument. By default this is
None
. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters
update – If
True
, update the state by querying the instrument. IfFalse
, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- property root_instrument: qcodes.instrument.base.InstrumentBase
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters
param_name – The name of a parameter of this instrument.
value – The new value to set.
- snapshot(update: Optional[bool] = False) Dict[Any, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base()
.- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: Optional[bool] = False, params_to_skip_update: Optional[Sequence[str]] = None) Dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
qcodes.utils.helpers.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, _BaseParameter] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter()
.
- functions: Dict[str, Function] = {}
All the functions supported by this instrument. Usually populated via
add_function()
.
- submodules: Dict[str, Union['InstrumentModule', 'ChannelTuple']] = {}
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule()
.
- instrument_modules: Dict[str, 'InstrumentModule'] = {}
All the instrument_modules of this instrument Usually populated via
add_submodule()
.
- class qcodes.instrument_drivers.rohde_schwarz.RTO1000.ScopeMeasurement(parent: qcodes.instrument.base.Instrument, name: str, meas_nr: int)[source]
Bases:
qcodes.instrument.channel.InstrumentChannel
Class to hold a measurement of the scope.
- Parameters
parent – The instrument to which the channel is attached
name – The name of the measurement
meas_nr – The number of the measurement in question. Must match the actual number as used by the instrument (1..8)
- __getitem__(key: str) Union[Callable[[...], Any], qcodes.instrument.parameter.Parameter]
Delegate instrument[‘name’] to parameter or function ‘name’.
- add_function(name: str, **kwargs: Any) None
Bind one
Function
to this instrument.Instrument subclasses can call this repeatedly in their
__init__
for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST
(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only. If your case is more complicated, you’re probably better off simply making a new method in yourInstrument
subclass definition.- Parameters
name – How the Function will be stored within
instrument.Functions
and also how you address it using the shortcut methods:instrument.call(func_name, *args)
etc.**kwargs – constructor kwargs for
Function
- Raises
KeyError – If this instrument already has a function with this name.
- add_parameter(name: str, parameter_class: type = <class 'qcodes.instrument.parameter.Parameter'>, **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
instrument.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
parameter.Parameter
.**kwargs – Constructor arguments for
parameter_class
.
- Raises
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- add_submodule(name: str, submodule: Union[InstrumentModule, ChannelTuple]) None
Bind one submodule to this instrument.
Instrument subclasses can call this repeatedly in their
__init__
method for every submodule of the instrument.Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an
InstrumentModule
or aChannelTuple
.- Parameters
name – How the submodule will be stored within
instrument.submodules
and also how it can be addressed.submodule – The submodule to be stored.
- Raises
- property ancestors: List[qcodes.instrument.base.InstrumentBase]
Returns a list of instruments, starting from the current instrument and following to the parent instrument and the parents parent instrument until the root instrument is reached.
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns
The return value of the function.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self
, whose keys should be treated as attributes ofself
.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self
, whose attributes should be passed through toself
.
- get(param_name: str) Any
Shortcut for getting a parameter from its name.
- Parameters
param_name – The name of a parameter of this instrument.
- Returns
The current value of the parameter.
- invalidate_cache() None
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Name of the instrument This is equivalent to full_name for backwards compatibility.
- omit_delegate_attrs: List[str] = []
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: qcodes.instrument.base.InstrumentBase
Returns the parent instrument. By default this is
None
. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters
update – If
True
, update the state by querying the instrument. IfFalse
, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- property root_instrument: qcodes.instrument.base.InstrumentBase
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters
param_name – The name of a parameter of this instrument.
value – The new value to set.
- snapshot(update: Optional[bool] = False) Dict[Any, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base()
.- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: Optional[bool] = False, params_to_skip_update: Optional[Sequence[str]] = None) Dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
qcodes.utils.helpers.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, _BaseParameter] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter()
.
- functions: Dict[str, Function] = {}
All the functions supported by this instrument. Usually populated via
add_function()
.
- submodules: Dict[str, Union['InstrumentModule', 'ChannelTuple']] = {}
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule()
.
- instrument_modules: Dict[str, 'InstrumentModule'] = {}
All the instrument_modules of this instrument Usually populated via
add_submodule()
.
- class qcodes.instrument_drivers.rohde_schwarz.RTO1000.ScopeTrace(name: str, instrument: qcodes.instrument.channel.InstrumentChannel, channum: int, **kwargs: Any)[source]
Bases:
qcodes.instrument.parameter.ArrayParameter
The ScopeTrace parameter is attached to a channel of the oscilloscope.
For now, we only support reading out the entire trace.
- get_raw() numpy.ndarray [source]
Returns a trace
- property full_name: str
Name of the parameter including the name of the instrument and submodule that the parameter may be bound to. The names are separated by underscores, like this:
instrument_submodule_parameter
.
- get_ramp_values(value: Union[float, Sized], step: Optional[float] = None) Sequence[Union[float, Sized]]
Return values to sweep from current value to target value. This method can be overridden to have a custom sweep behaviour. It can even be overridden by a generator.
- Parameters
value – target value
step – maximum step size
- Returns
List of stepped values, including target value.
- property instrument: Optional[InstrumentBase]
Return the first instrument that this parameter is bound to. E.g if this is bound to a channel it will return the channel and not the instrument that the channel is bound too. Use
root_instrument()
to get the real instrument.
- property inter_delay: float
Delay time between consecutive set operations. The actual time will not be shorter than this, but may be longer if the underlying set call takes longer.
Typically used in conjunction with step to create an effective ramp rate, but can also be used without a step to enforce a delay between sets.
- Getter
Returns the current inter_delay.
- Setter
Sets the value of the inter_delay.
- Raises
TypeError – If delay is not int nor float
ValueError – If delay is negative
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Name of the parameter. This is identical to
short_name()
.
- property post_delay: float
Delay time after start of set operation, for each set. The actual time will not be shorter than this, but may be longer if the underlying set call takes longer.
Typically used in conjunction with step to create an effective ramp rate, but can also be used without a step to enforce a delay after every set. One might think of post_delay as how long a set operation is supposed to take. For example, there might be an instrument that needs extra time after setting a parameter although the command for setting the parameter returns quickly.
- Getter
Returns the current post_delay.
- Setter
Sets the value of the post_delay.
- Raises
TypeError – If delay is not int nor float
ValueError – If delay is negative
- property raw_value: Any
Note that this property will be deprecated soon. Use
cache.raw_value
instead.Represents the cached raw value of the parameter.
- Getter
Returns the cached raw value of the parameter.
- restore_at_exit(allow_changes: bool = True) qcodes.instrument.parameter._SetParamContext
Use a context manager to restore the value of a parameter after a
with
block.By default, the parameter value may be changed inside the block, but this can be prevented with
allow_changes=False
. This can be useful, for example, for debugging a complex measurement that unintentionally modifies a parameter.Example
>>> p = Parameter("p", set_cmd=None, get_cmd=None) >>> p.set(2) >>> with p.restore_at_exit(): ... p.set(3) ... print(f"value inside with block: {p.get()}") # prints 3 >>> print(f"value after with block: {p.get()}") # prints 2 >>> with p.restore_at_exit(allow_changes=False): ... p.set(5) # raises an exception
- property root_instrument: Optional[InstrumentBase]
Return the fundamental instrument that this parameter belongs too. E.g if the parameter is bound to a channel this will return the fundamental instrument that that channel belongs to. Use
instrument()
to get the channel.
- set_raw(value: Any) None
set_raw
is called to perform the actual setting of a parameter on the instrument. This method should either be overwritten to perform the desired operation or alternatively forParameter
a suitable method is automatically generated ifset_cmd
is supplied to the parameter constructor. The method is automatically wrapped to provide aset
method on the parameter instance.
- set_to(value: Any, allow_changes: bool = False) qcodes.instrument.parameter._SetParamContext
Use a context manager to temporarily set a parameter to a value. By default, the parameter value cannot be changed inside the context. This may be overridden with
allow_changes=True
.Examples
>>> from qcodes import Parameter >>> p = Parameter("p", set_cmd=None, get_cmd=None) >>> p.set(2) >>> with p.set_to(3): ... print(f"p value in with block {p.get()}") # prints 3 ... p.set(5) # raises an exception >>> print(f"p value outside with block {p.get()}") # prints 2 >>> with p.set_to(3, allow_changes=True): ... p.set(5) # now this works >>> print(f"value after second block: {p.get()}") # still prints 2
- property setpoint_full_names: Optional[Sequence[str]]
Full names of setpoints including instrument names if available
- property short_name: str
Short name of the parameter. This is without the name of the instrument or submodule that the parameter may be bound to. For full name refer to
full_name()
.
- snapshot(update: Optional[bool] = False) Dict[Any, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base()
.- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: Optional[bool] = True, params_to_skip_update: Optional[Sequence[str]] = None) Dict[Any, Any]
State of the parameter as a JSON-compatible dict (everything that the custom JSON encoder class
qcodes.utils.helpers.NumpyJSONEncoder
supports).If the parameter has been initiated with
snapshot_value=False
, the snapshot will NOT include thevalue
andraw_value
of the parameter.- Parameters
update – If True, update the state by calling
parameter.get()
unlesssnapshot_get
of the parameter isFalse
. Ifupdate
isNone
, use the current value from thecache
unless the cache is invalid. IfFalse
, never callparameter.get()
.params_to_skip_update – No effect but may be passed from superclass
- Returns
base snapshot
- property step: Optional[float]
Stepsize that this Parameter uses during set operation. Stepsize must be a positive number or None. If step is a positive number, this is the maximum value change allowed in one hardware call, so a single set can result in many calls to the hardware if the starting value is far from the target. All but the final change will attempt to change by +/- step exactly. If step is None stepping will not be used.
- Getter
Returns the current stepsize.
- Setter
Sets the value of the step.
- Raises
TypeError – if step is set to not numeric or None
ValueError – if step is set to negative
TypeError – if step is set to not integer or None for an integer parameter
TypeError – if step is set to not a number on None
- property underlying_instrument: Optional[InstrumentBase]
Returns an instance of the underlying hardware instrument that this parameter communicates with, per this parameter’s implementation.
This is useful in the case where a parameter does not belongs to an instrument instance that represents a real hardware instrument but actually uses a real hardware instrument in its implementation (e.g. via calls to one or more parameters of that real hardware instrument). This is also useful when a parameter does belong to an instrument instance but that instance does not represent the real hardware instrument that the parameter interacts with: hence
root_instrument
of the parameter cannot be thehardware_instrument
, howeverunderlying_instrument
can be implemented to return thehardware_instrument
.By default it returns the
root_instrument
of the parameter.
- validate(value: Any) None
Validate the value supplied.
- Parameters
value – value to validate
- Raises
TypeError – If the value is of the wrong type.
ValueError – If the value is outside the bounds specified by the validator.
qcodes.instrument_drivers.rohde_schwarz.SGS100A module
- class qcodes.instrument_drivers.rohde_schwarz.SGS100A.RohdeSchwarz_SGS100A(*args: Any, **kwargs: Any)[source]
Bases:
qcodes.instrument.visa.VisaInstrument
This is the QCoDeS driver for the Rohde & Schwarz SGS100A signal generator.
Status: beta-version.
Todo
Add all parameters that are in the manual
Add test suite
See if there can be a common driver for RS mw sources from which different models inherit
This driver will most likely work for multiple Rohde & Schwarz sources. it would be a good idea to group all similar RS drivers together in one module.
Tested working with
RS_SGS100A
This driver does not contain all commands available for the RS_SGS100A but only the ones most commonly used.
- __getitem__(key: str) Union[Callable[[...], Any], qcodes.instrument.parameter.Parameter]
Delegate instrument[‘name’] to parameter or function ‘name’.
- add_function(name: str, **kwargs: Any) None
Bind one
Function
to this instrument.Instrument subclasses can call this repeatedly in their
__init__
for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST
(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only. If your case is more complicated, you’re probably better off simply making a new method in yourInstrument
subclass definition.- Parameters
name – How the Function will be stored within
instrument.Functions
and also how you address it using the shortcut methods:instrument.call(func_name, *args)
etc.**kwargs – constructor kwargs for
Function
- Raises
KeyError – If this instrument already has a function with this name.
- add_parameter(name: str, parameter_class: type = <class 'qcodes.instrument.parameter.Parameter'>, **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
instrument.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
parameter.Parameter
.**kwargs – Constructor arguments for
parameter_class
.
- Raises
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- add_submodule(name: str, submodule: Union[InstrumentModule, ChannelTuple]) None
Bind one submodule to this instrument.
Instrument subclasses can call this repeatedly in their
__init__
method for every submodule of the instrument.Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an
InstrumentModule
or aChannelTuple
.- Parameters
name – How the submodule will be stored within
instrument.submodules
and also how it can be addressed.submodule – The submodule to be stored.
- Raises
- property ancestors: List[qcodes.instrument.base.InstrumentBase]
Returns a list of instruments, starting from the current instrument and following to the parent instrument and the parents parent instrument until the root instrument is reached.
- ask(cmd: str) str
Write a command string to the hardware and return a response.
Subclasses that transform
cmd
should override this method, and in it callsuper().ask(new_cmd)
. Subclasses that define a new hardware communication should instead overrideask_raw
.- Parameters
cmd – The string to send to the instrument.
- Returns
response
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- ask_raw(cmd: str) str
Low-level interface to
visa_handle.ask
.- Parameters
cmd – The command to send to the instrument.
- Returns
The instrument’s response.
- Return type
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns
The return value of the function.
- check_error(ret_code: int) None
Default error checking, raises an error if return code
!=0
. Does not differentiate between warnings or specific error messages. Override this function in your driver if you want to add specific error messages.- Parameters
ret_code – A Visa error code. See eg: https://github.com/hgrecco/pyvisa/blob/master/pyvisa/errors.py
- Raises
visa.VisaIOError – if
ret_code
indicates a communication problem.
- classmethod close_all() None
Try to close all instruments registered in
_all_instruments
This is handy for use with atexit to ensure that all instruments are closed when a python session is closed.Examples
>>> atexit.register(qc.Instrument.close_all())
- connect_message(idn_param: str = 'IDN', begin_time: Optional[float] = None) None
Print a standard message on initial connection to an instrument.
- Parameters
idn_param – Name of parameter that returns ID dict. Default
IDN
.begin_time –
time.time()
when init started. Default isself._t0
, set at start ofInstrument.__init__
.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self
, whose keys should be treated as attributes ofself
.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self
, whose attributes should be passed through toself
.
- static exist(name: str, instrument_class: Optional[type] = None) bool
Check if an instrument with a given names exists (i.e. is already instantiated).
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- classmethod find_instrument(name: str, instrument_class: Optional[Type[qcodes.instrument.base.T]] = None) qcodes.instrument.base.T
Find an existing instrument by name.
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- Returns
The instrument found.
- Raises
- get(param_name: str) Any
Shortcut for getting a parameter from its name.
- Parameters
param_name – The name of a parameter of this instrument.
- Returns
The current value of the parameter.
- get_idn() Dict[str, Optional[str]]
Parse a standard VISA
*IDN?
response into an ID dict.Even though this is the VISA standard, it applies to various other types as well, such as IPInstruments, so it is included here in the Instrument base class.
Override this if your instrument does not support
*IDN?
or returns a nonstandard IDN string. This string is supposed to be a comma-separated list of vendor, model, serial, and firmware, but semicolon and colon are also common separators so we accept them here as well.- Returns
A dict containing vendor, model, serial, and firmware.
- classmethod instances() List[qcodes.instrument.base.Instrument]
Get all currently defined instances of this instrument class.
You can use this to get the objects back if you lose track of them, and it’s also used by the test system to find objects to test against.
- Returns
A list of instances.
- invalidate_cache() None
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- static is_valid(instr_instance: qcodes.instrument.base.Instrument) bool
Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a “valid” instrument.
- Parameters
instr_instance – Instance of an Instrument class or its subclass.
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Name of the instrument This is equivalent to full_name for backwards compatibility.
- omit_delegate_attrs: List[str] = []
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: Optional[qcodes.instrument.base.InstrumentBase]
Returns the parent instrument. By default this is
None
. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters
update – If
True
, update the state by querying the instrument. IfFalse
, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- classmethod record_instance(instance: qcodes.instrument.base.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: qcodes.instrument.base.Instrument) None
Remove a particular instance from the record.
- Parameters
instance – The instance to remove
- property root_instrument: qcodes.instrument.base.InstrumentBase
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters
param_name – The name of a parameter of this instrument.
value – The new value to set.
- set_address(address: str) None
Set the address for this instrument.
- Parameters
address – The visa resource name to use to connect. The address should be the actual address and just that. If you wish to change the backend for VISA, use the self.visalib attribute (and then call this function).
- set_terminator(terminator: str) None
Change the read terminator to use.
- Parameters
terminator – Character(s) to look for at the end of a read. eg.
\r\n
.
- snapshot(update: Optional[bool] = False) Dict[Any, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base()
.- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: Optional[bool] = True, params_to_skip_update: Optional[Sequence[str]] = None) Dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
qcodes.utils.helpers.NumpyJSONEncoder
supports).- Parameters
update – If True, update the state by querying the instrument. If None only update if the state is known to be invalid. If False, just use the latest values in memory and never update.
params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_get
attribute of those parameters instead.
- Returns
base snapshot
- Return type
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters
verbose – If
True
, then information about the parameters that are being check is printed.
- write(cmd: str) None
Write a command string with NO response to the hardware.
Subclasses that transform
cmd
should override this method, and in it callsuper().write(new_cmd)
. Subclasses that define a new hardware communication should instead overridewrite_raw
.- Parameters
cmd – The string to send to the instrument.
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- write_raw(cmd: str) None
Low-level interface to
visa_handle.write
.- Parameters
cmd – The command to send to the instrument.
- parameters: Dict[str, _BaseParameter] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter()
.
- functions: Dict[str, Function] = {}
All the functions supported by this instrument. Usually populated via
add_function()
.
- submodules: Dict[str, Union['InstrumentModule', 'ChannelTuple']] = {}
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule()
.
- instrument_modules: Dict[str, 'InstrumentModule'] = {}
All the instrument_modules of this instrument Usually populated via
add_submodule()
.
qcodes.instrument_drivers.rohde_schwarz.ZNB module
- class qcodes.instrument_drivers.rohde_schwarz.ZNB.FixedFrequencyPointIQ(name: str, instrument: qcodes.instrument_drivers.rohde_schwarz.ZNB.ZNBChannel)[source]
Bases:
qcodes.instrument.parameter.MultiParameter
Parameter for sweep that returns the mean of the real (I) and imaginary (Q) parts of the VNA response. Requires the use of the sweep type to be set to continuous wave mode. See (https://www.rohde-schwarz.com/webhelp/ZNB_ZNBT_HTML_UserManual_en /ZNB_ZNBT_HTML_UserManual_en.htm) under GUI reference -> sweep softtool -> sweep type tab -> CW mode Useful for two-tone and other bigger sweeps where you do not want to store all individual I-Q values.
- Parameters
name – parameter name
instrument – instrument the parameter belongs to
- get_raw() Tuple[float, float] [source]
Gets the mean of the raw real and imaginary part of the data. If parameter cw_check_sweep_first is set to True then at the cost of a few ms overhead checks if the vna is setup correctly.
- property full_name: str
Name of the parameter including the name of the instrument and submodule that the parameter may be bound to. The names are separated by underscores, like this:
instrument_submodule_parameter
.
- property full_names: Tuple[str, ...]
Names of the parameter components including the name of the instrument and submodule that the parameter may be bound to. The name parts are separated by underscores, like this:
instrument_submodule_parameter
- get_ramp_values(value: Union[float, Sized], step: Optional[float] = None) Sequence[Union[float, Sized]]
Return values to sweep from current value to target value. This method can be overridden to have a custom sweep behaviour. It can even be overridden by a generator.
- Parameters
value – target value
step – maximum step size
- Returns
List of stepped values, including target value.
- property instrument: Optional[InstrumentBase]
Return the first instrument that this parameter is bound to. E.g if this is bound to a channel it will return the channel and not the instrument that the channel is bound too. Use
root_instrument()
to get the real instrument.
- property inter_delay: float
Delay time between consecutive set operations. The actual time will not be shorter than this, but may be longer if the underlying set call takes longer.
Typically used in conjunction with step to create an effective ramp rate, but can also be used without a step to enforce a delay between sets.
- Getter
Returns the current inter_delay.
- Setter
Sets the value of the inter_delay.
- Raises
TypeError – If delay is not int nor float
ValueError – If delay is negative
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Name of the parameter. This is identical to
short_name()
.
- property post_delay: float
Delay time after start of set operation, for each set. The actual time will not be shorter than this, but may be longer if the underlying set call takes longer.
Typically used in conjunction with step to create an effective ramp rate, but can also be used without a step to enforce a delay after every set. One might think of post_delay as how long a set operation is supposed to take. For example, there might be an instrument that needs extra time after setting a parameter although the command for setting the parameter returns quickly.
- Getter
Returns the current post_delay.
- Setter
Sets the value of the post_delay.
- Raises
TypeError – If delay is not int nor float
ValueError – If delay is negative
- property raw_value: Any
Note that this property will be deprecated soon. Use
cache.raw_value
instead.Represents the cached raw value of the parameter.
- Getter
Returns the cached raw value of the parameter.
- restore_at_exit(allow_changes: bool = True) qcodes.instrument.parameter._SetParamContext
Use a context manager to restore the value of a parameter after a
with
block.By default, the parameter value may be changed inside the block, but this can be prevented with
allow_changes=False
. This can be useful, for example, for debugging a complex measurement that unintentionally modifies a parameter.Example
>>> p = Parameter("p", set_cmd=None, get_cmd=None) >>> p.set(2) >>> with p.restore_at_exit(): ... p.set(3) ... print(f"value inside with block: {p.get()}") # prints 3 >>> print(f"value after with block: {p.get()}") # prints 2 >>> with p.restore_at_exit(allow_changes=False): ... p.set(5) # raises an exception
- property root_instrument: Optional[InstrumentBase]
Return the fundamental instrument that this parameter belongs too. E.g if the parameter is bound to a channel this will return the fundamental instrument that that channel belongs to. Use
instrument()
to get the channel.
- set_raw(value: Any) None
set_raw
is called to perform the actual setting of a parameter on the instrument. This method should either be overwritten to perform the desired operation or alternatively forParameter
a suitable method is automatically generated ifset_cmd
is supplied to the parameter constructor. The method is automatically wrapped to provide aset
method on the parameter instance.
- set_to(value: Any, allow_changes: bool = False) qcodes.instrument.parameter._SetParamContext
Use a context manager to temporarily set a parameter to a value. By default, the parameter value cannot be changed inside the context. This may be overridden with
allow_changes=True
.Examples
>>> from qcodes import Parameter >>> p = Parameter("p", set_cmd=None, get_cmd=None) >>> p.set(2) >>> with p.set_to(3): ... print(f"p value in with block {p.get()}") # prints 3 ... p.set(5) # raises an exception >>> print(f"p value outside with block {p.get()}") # prints 2 >>> with p.set_to(3, allow_changes=True): ... p.set(5) # now this works >>> print(f"value after second block: {p.get()}") # still prints 2
- property setpoint_full_names: Optional[Sequence[Sequence[str]]]
Full names of setpoints including instrument names, if available
- property short_name: str
Short name of the parameter. This is without the name of the instrument or submodule that the parameter may be bound to. For full name refer to
full_name()
.
- property short_names: Tuple[str, ...]
short_names is identical to names i.e. the names of the parameter parts but does not add the instrument name.
It exists for consistency with instruments and other parameters.
- snapshot(update: Optional[bool] = False) Dict[Any, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base()
.- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: Optional[bool] = True, params_to_skip_update: Optional[Sequence[str]] = None) Dict[Any, Any]
State of the parameter as a JSON-compatible dict (everything that the custom JSON encoder class
qcodes.utils.helpers.NumpyJSONEncoder
supports).If the parameter has been initiated with
snapshot_value=False
, the snapshot will NOT include thevalue
andraw_value
of the parameter.- Parameters
update – If True, update the state by calling
parameter.get()
unlesssnapshot_get
of the parameter isFalse
. Ifupdate
isNone
, use the current value from thecache
unless the cache is invalid. IfFalse
, never callparameter.get()
.params_to_skip_update – No effect but may be passed from superclass
- Returns
base snapshot
- property step: Optional[float]
Stepsize that this Parameter uses during set operation. Stepsize must be a positive number or None. If step is a positive number, this is the maximum value change allowed in one hardware call, so a single set can result in many calls to the hardware if the starting value is far from the target. All but the final change will attempt to change by +/- step exactly. If step is None stepping will not be used.
- Getter
Returns the current stepsize.
- Setter
Sets the value of the step.
- Raises
TypeError – if step is set to not numeric or None
ValueError – if step is set to negative
TypeError – if step is set to not integer or None for an integer parameter
TypeError – if step is set to not a number on None
- property underlying_instrument: Optional[InstrumentBase]
Returns an instance of the underlying hardware instrument that this parameter communicates with, per this parameter’s implementation.
This is useful in the case where a parameter does not belongs to an instrument instance that represents a real hardware instrument but actually uses a real hardware instrument in its implementation (e.g. via calls to one or more parameters of that real hardware instrument). This is also useful when a parameter does belong to an instrument instance but that instance does not represent the real hardware instrument that the parameter interacts with: hence
root_instrument
of the parameter cannot be thehardware_instrument
, howeverunderlying_instrument
can be implemented to return thehardware_instrument
.By default it returns the
root_instrument
of the parameter.
- validate(value: Any) None
Validate the value supplied.
- Parameters
value – value to validate
- Raises
TypeError – If the value is of the wrong type.
ValueError – If the value is outside the bounds specified by the validator.
- class qcodes.instrument_drivers.rohde_schwarz.ZNB.FixedFrequencyPointMagPhase(name: str, instrument: qcodes.instrument_drivers.rohde_schwarz.ZNB.ZNBChannel)[source]
Bases:
qcodes.instrument.parameter.MultiParameter
Parameter for sweep that returns the magnitude of mean of the real (I) and imaginary (Q) parts of the VNA response and it’s phase. Requires the use of the sweep type to be set to continuous wave mode. See (https://www.rohde-schwarz.com/webhelp/ZNB_ZNBT_HTML_UserManual_en /ZNB_ZNBT_HTML_UserManual_en.htm) under GUI reference -> sweep softtool -> sweep type tab -> CW mode
- Parameters
name – parameter name
instrument – instrument the parameter belongs to
- get_raw() Tuple[float, ...] [source]
Gets the magnitude and phase of the mean of the raw real and imaginary part of the data. If the parameter cw_check_sweep_first is set to True for the instrument then at the cost of a few ms overhead checks if the vna is setup correctly.
- property full_name: str
Name of the parameter including the name of the instrument and submodule that the parameter may be bound to. The names are separated by underscores, like this:
instrument_submodule_parameter
.
- property full_names: Tuple[str, ...]
Names of the parameter components including the name of the instrument and submodule that the parameter may be bound to. The name parts are separated by underscores, like this:
instrument_submodule_parameter
- get_ramp_values(value: Union[float, Sized], step: Optional[float] = None) Sequence[Union[float, Sized]]
Return values to sweep from current value to target value. This method can be overridden to have a custom sweep behaviour. It can even be overridden by a generator.
- Parameters
value – target value
step – maximum step size
- Returns
List of stepped values, including target value.
- property instrument: Optional[InstrumentBase]
Return the first instrument that this parameter is bound to. E.g if this is bound to a channel it will return the channel and not the instrument that the channel is bound too. Use
root_instrument()
to get the real instrument.
- property inter_delay: float
Delay time between consecutive set operations. The actual time will not be shorter than this, but may be longer if the underlying set call takes longer.
Typically used in conjunction with step to create an effective ramp rate, but can also be used without a step to enforce a delay between sets.
- Getter
Returns the current inter_delay.
- Setter
Sets the value of the inter_delay.
- Raises
TypeError – If delay is not int nor float
ValueError – If delay is negative
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Name of the parameter. This is identical to
short_name()
.
- property post_delay: float
Delay time after start of set operation, for each set. The actual time will not be shorter than this, but may be longer if the underlying set call takes longer.
Typically used in conjunction with step to create an effective ramp rate, but can also be used without a step to enforce a delay after every set. One might think of post_delay as how long a set operation is supposed to take. For example, there might be an instrument that needs extra time after setting a parameter although the command for setting the parameter returns quickly.
- Getter
Returns the current post_delay.
- Setter
Sets the value of the post_delay.
- Raises
TypeError – If delay is not int nor float
ValueError – If delay is negative
- property raw_value: Any
Note that this property will be deprecated soon. Use
cache.raw_value
instead.Represents the cached raw value of the parameter.
- Getter
Returns the cached raw value of the parameter.
- restore_at_exit(allow_changes: bool = True) qcodes.instrument.parameter._SetParamContext
Use a context manager to restore the value of a parameter after a
with
block.By default, the parameter value may be changed inside the block, but this can be prevented with
allow_changes=False
. This can be useful, for example, for debugging a complex measurement that unintentionally modifies a parameter.Example
>>> p = Parameter("p", set_cmd=None, get_cmd=None) >>> p.set(2) >>> with p.restore_at_exit(): ... p.set(3) ... print(f"value inside with block: {p.get()}") # prints 3 >>> print(f"value after with block: {p.get()}") # prints 2 >>> with p.restore_at_exit(allow_changes=False): ... p.set(5) # raises an exception
- property root_instrument: Optional[InstrumentBase]
Return the fundamental instrument that this parameter belongs too. E.g if the parameter is bound to a channel this will return the fundamental instrument that that channel belongs to. Use
instrument()
to get the channel.
- set_raw(value: Any) None
set_raw
is called to perform the actual setting of a parameter on the instrument. This method should either be overwritten to perform the desired operation or alternatively forParameter
a suitable method is automatically generated ifset_cmd
is supplied to the parameter constructor. The method is automatically wrapped to provide aset
method on the parameter instance.
- set_to(value: Any, allow_changes: bool = False) qcodes.instrument.parameter._SetParamContext
Use a context manager to temporarily set a parameter to a value. By default, the parameter value cannot be changed inside the context. This may be overridden with
allow_changes=True
.Examples
>>> from qcodes import Parameter >>> p = Parameter("p", set_cmd=None, get_cmd=None) >>> p.set(2) >>> with p.set_to(3): ... print(f"p value in with block {p.get()}") # prints 3 ... p.set(5) # raises an exception >>> print(f"p value outside with block {p.get()}") # prints 2 >>> with p.set_to(3, allow_changes=True): ... p.set(5) # now this works >>> print(f"value after second block: {p.get()}") # still prints 2
- property setpoint_full_names: Optional[Sequence[Sequence[str]]]
Full names of setpoints including instrument names, if available
- property short_name: str
Short name of the parameter. This is without the name of the instrument or submodule that the parameter may be bound to. For full name refer to
full_name()
.
- property short_names: Tuple[str, ...]
short_names is identical to names i.e. the names of the parameter parts but does not add the instrument name.
It exists for consistency with instruments and other parameters.
- snapshot(update: Optional[bool] = False) Dict[Any, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base()
.- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: Optional[bool] = True, params_to_skip_update: Optional[Sequence[str]] = None) Dict[Any, Any]
State of the parameter as a JSON-compatible dict (everything that the custom JSON encoder class
qcodes.utils.helpers.NumpyJSONEncoder
supports).If the parameter has been initiated with
snapshot_value=False
, the snapshot will NOT include thevalue
andraw_value
of the parameter.- Parameters
update – If True, update the state by calling
parameter.get()
unlesssnapshot_get
of the parameter isFalse
. Ifupdate
isNone
, use the current value from thecache
unless the cache is invalid. IfFalse
, never callparameter.get()
.params_to_skip_update – No effect but may be passed from superclass
- Returns
base snapshot
- property step: Optional[float]
Stepsize that this Parameter uses during set operation. Stepsize must be a positive number or None. If step is a positive number, this is the maximum value change allowed in one hardware call, so a single set can result in many calls to the hardware if the starting value is far from the target. All but the final change will attempt to change by +/- step exactly. If step is None stepping will not be used.
- Getter
Returns the current stepsize.
- Setter
Sets the value of the step.
- Raises
TypeError – if step is set to not numeric or None
ValueError – if step is set to negative
TypeError – if step is set to not integer or None for an integer parameter
TypeError – if step is set to not a number on None
- property underlying_instrument: Optional[InstrumentBase]
Returns an instance of the underlying hardware instrument that this parameter communicates with, per this parameter’s implementation.
This is useful in the case where a parameter does not belongs to an instrument instance that represents a real hardware instrument but actually uses a real hardware instrument in its implementation (e.g. via calls to one or more parameters of that real hardware instrument). This is also useful when a parameter does belong to an instrument instance but that instance does not represent the real hardware instrument that the parameter interacts with: hence
root_instrument
of the parameter cannot be thehardware_instrument
, howeverunderlying_instrument
can be implemented to return thehardware_instrument
.By default it returns the
root_instrument
of the parameter.
- validate(value: Any) None
Validate the value supplied.
- Parameters
value – value to validate
- Raises
TypeError – If the value is of the wrong type.
ValueError – If the value is outside the bounds specified by the validator.
- class qcodes.instrument_drivers.rohde_schwarz.ZNB.FixedFrequencyTraceIQ(name: str, instrument: qcodes.instrument_drivers.rohde_schwarz.ZNB.ZNBChannel, npts: int, bandwidth: int)[source]
Bases:
qcodes.instrument.parameter.MultiParameter
Parameter for sweep that returns the real (I) and imaginary (Q) parts of the VNA response. Requires the use of the sweep type to be set to continuous wave mode. See (https://www.rohde-schwarz.com/webhelp/ZNB_ZNBT_HTML_UserManual_en /ZNB_ZNBT_HTML_UserManual_en.htm) under GUI reference -> sweep softtool -> sweep type tab -> CW mode
- set_cw_sweep(npts: int, bandwidth: int) None [source]
Updates config of the software parameter on sweep change. This is needed in order to sync the setpoint shape with the returned data shape after a change of sweep settings.
Sets setpoints to the tuple which are hashable for look up.
Note: This is similar to the set_sweep functions of the frequency sweep parameters. The time setpoints here neglect a small VNA overhead. The total time including overhead can be queried with the sweep_time function of the vna, but since it is not clear where this overhead is spend, we keep the x-axis set to 1/bandwidth. The error is only apparent in really fast measurements at 1us and 10us but depends on the amount of points you take. More points give less overhead.
- get_raw() Tuple[numpy.ndarray, numpy.ndarray] [source]
Gets the raw real and imaginary part of the data. If parameter cw_check_sweep_first is set to True then at the cost of a few ms overhead checks if the vna is setup correctly.
- property full_name: str
Name of the parameter including the name of the instrument and submodule that the parameter may be bound to. The names are separated by underscores, like this:
instrument_submodule_parameter
.
- property full_names: Tuple[str, ...]
Names of the parameter components including the name of the instrument and submodule that the parameter may be bound to. The name parts are separated by underscores, like this:
instrument_submodule_parameter
- get_ramp_values(value: Union[float, Sized], step: Optional[float] = None) Sequence[Union[float, Sized]]
Return values to sweep from current value to target value. This method can be overridden to have a custom sweep behaviour. It can even be overridden by a generator.
- Parameters
value – target value
step – maximum step size
- Returns
List of stepped values, including target value.
- property instrument: Optional[InstrumentBase]
Return the first instrument that this parameter is bound to. E.g if this is bound to a channel it will return the channel and not the instrument that the channel is bound too. Use
root_instrument()
to get the real instrument.
- property inter_delay: float
Delay time between consecutive set operations. The actual time will not be shorter than this, but may be longer if the underlying set call takes longer.
Typically used in conjunction with step to create an effective ramp rate, but can also be used without a step to enforce a delay between sets.
- Getter
Returns the current inter_delay.
- Setter
Sets the value of the inter_delay.
- Raises
TypeError – If delay is not int nor float
ValueError – If delay is negative
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Name of the parameter. This is identical to
short_name()
.
- property post_delay: float
Delay time after start of set operation, for each set. The actual time will not be shorter than this, but may be longer if the underlying set call takes longer.
Typically used in conjunction with step to create an effective ramp rate, but can also be used without a step to enforce a delay after every set. One might think of post_delay as how long a set operation is supposed to take. For example, there might be an instrument that needs extra time after setting a parameter although the command for setting the parameter returns quickly.
- Getter
Returns the current post_delay.
- Setter
Sets the value of the post_delay.
- Raises
TypeError – If delay is not int nor float
ValueError – If delay is negative
- property raw_value: Any
Note that this property will be deprecated soon. Use
cache.raw_value
instead.Represents the cached raw value of the parameter.
- Getter
Returns the cached raw value of the parameter.
- restore_at_exit(allow_changes: bool = True) qcodes.instrument.parameter._SetParamContext
Use a context manager to restore the value of a parameter after a
with
block.By default, the parameter value may be changed inside the block, but this can be prevented with
allow_changes=False
. This can be useful, for example, for debugging a complex measurement that unintentionally modifies a parameter.Example
>>> p = Parameter("p", set_cmd=None, get_cmd=None) >>> p.set(2) >>> with p.restore_at_exit(): ... p.set(3) ... print(f"value inside with block: {p.get()}") # prints 3 >>> print(f"value after with block: {p.get()}") # prints 2 >>> with p.restore_at_exit(allow_changes=False): ... p.set(5) # raises an exception
- property root_instrument: Optional[InstrumentBase]
Return the fundamental instrument that this parameter belongs too. E.g if the parameter is bound to a channel this will return the fundamental instrument that that channel belongs to. Use
instrument()
to get the channel.
- set_raw(value: Any) None
set_raw
is called to perform the actual setting of a parameter on the instrument. This method should either be overwritten to perform the desired operation or alternatively forParameter
a suitable method is automatically generated ifset_cmd
is supplied to the parameter constructor. The method is automatically wrapped to provide aset
method on the parameter instance.
- set_to(value: Any, allow_changes: bool = False) qcodes.instrument.parameter._SetParamContext
Use a context manager to temporarily set a parameter to a value. By default, the parameter value cannot be changed inside the context. This may be overridden with
allow_changes=True
.Examples
>>> from qcodes import Parameter >>> p = Parameter("p", set_cmd=None, get_cmd=None) >>> p.set(2) >>> with p.set_to(3): ... print(f"p value in with block {p.get()}") # prints 3 ... p.set(5) # raises an exception >>> print(f"p value outside with block {p.get()}") # prints 2 >>> with p.set_to(3, allow_changes=True): ... p.set(5) # now this works >>> print(f"value after second block: {p.get()}") # still prints 2
- property setpoint_full_names: Optional[Sequence[Sequence[str]]]
Full names of setpoints including instrument names, if available
- property short_name: str
Short name of the parameter. This is without the name of the instrument or submodule that the parameter may be bound to. For full name refer to
full_name()
.
- property short_names: Tuple[str, ...]
short_names is identical to names i.e. the names of the parameter parts but does not add the instrument name.
It exists for consistency with instruments and other parameters.
- snapshot(update: Optional[bool] = False) Dict[Any, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base()
.- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: Optional[bool] = True, params_to_skip_update: Optional[Sequence[str]] = None) Dict[Any, Any]
State of the parameter as a JSON-compatible dict (everything that the custom JSON encoder class
qcodes.utils.helpers.NumpyJSONEncoder
supports).If the parameter has been initiated with
snapshot_value=False
, the snapshot will NOT include thevalue
andraw_value
of the parameter.- Parameters
update – If True, update the state by calling
parameter.get()
unlesssnapshot_get
of the parameter isFalse
. Ifupdate
isNone
, use the current value from thecache
unless the cache is invalid. IfFalse
, never callparameter.get()
.params_to_skip_update – No effect but may be passed from superclass
- Returns
base snapshot
- property step: Optional[float]
Stepsize that this Parameter uses during set operation. Stepsize must be a positive number or None. If step is a positive number, this is the maximum value change allowed in one hardware call, so a single set can result in many calls to the hardware if the starting value is far from the target. All but the final change will attempt to change by +/- step exactly. If step is None stepping will not be used.
- Getter
Returns the current stepsize.
- Setter
Sets the value of the step.
- Raises
TypeError – if step is set to not numeric or None
ValueError – if step is set to negative
TypeError – if step is set to not integer or None for an integer parameter
TypeError – if step is set to not a number on None
- property underlying_instrument: Optional[InstrumentBase]
Returns an instance of the underlying hardware instrument that this parameter communicates with, per this parameter’s implementation.
This is useful in the case where a parameter does not belongs to an instrument instance that represents a real hardware instrument but actually uses a real hardware instrument in its implementation (e.g. via calls to one or more parameters of that real hardware instrument). This is also useful when a parameter does belong to an instrument instance but that instance does not represent the real hardware instrument that the parameter interacts with: hence
root_instrument
of the parameter cannot be thehardware_instrument
, howeverunderlying_instrument
can be implemented to return thehardware_instrument
.By default it returns the
root_instrument
of the parameter.
- validate(value: Any) None
Validate the value supplied.
- Parameters
value – value to validate
- Raises
TypeError – If the value is of the wrong type.
ValueError – If the value is outside the bounds specified by the validator.
- class qcodes.instrument_drivers.rohde_schwarz.ZNB.FrequencySweep(name: str, instrument: qcodes.instrument.base.Instrument, start: float, stop: float, npts: int, channel: int)[source]
Bases:
qcodes.instrument.parameter.ArrayParameter
Hardware controlled parameter class for Rohde Schwarz ZNB trace.
Instrument returns an array of transmission or reflection data depending on the active measurement.
- Parameters
name – parameter name
instrument – instrument the parameter belongs to
start – starting frequency of sweep
stop – ending frequency of sweep
npts – number of points in frequency sweep
- get()
executes a sweep and returns magnitude and phase arrays
- set_sweep(start: float, stop: float, npts: int) None [source]
sets the shapes and setpoint arrays of the parameter to correspond with the sweep
- Parameters
start – Starting frequency of the sweep
stop – Stopping frequency of the sweep
npts – Number of points in the sweep
- get_raw() Any [source]
get_raw
is called to perform the actual data acquisition from the instrument. This method should either be overwritten to perform the desired operation or alternatively forParameter
a suitable method is automatically generated ifget_cmd
is supplied to the parameter constructor. The method is automatically wrapped to provide aget
method on the parameter instance.
- property full_name: str
Name of the parameter including the name of the instrument and submodule that the parameter may be bound to. The names are separated by underscores, like this:
instrument_submodule_parameter
.
- get_ramp_values(value: Union[float, Sized], step: Optional[float] = None) Sequence[Union[float, Sized]]
Return values to sweep from current value to target value. This method can be overridden to have a custom sweep behaviour. It can even be overridden by a generator.
- Parameters
value – target value
step – maximum step size
- Returns
List of stepped values, including target value.
- property instrument: Optional[InstrumentBase]
Return the first instrument that this parameter is bound to. E.g if this is bound to a channel it will return the channel and not the instrument that the channel is bound too. Use
root_instrument()
to get the real instrument.
- property inter_delay: float
Delay time between consecutive set operations. The actual time will not be shorter than this, but may be longer if the underlying set call takes longer.
Typically used in conjunction with step to create an effective ramp rate, but can also be used without a step to enforce a delay between sets.
- Getter
Returns the current inter_delay.
- Setter
Sets the value of the inter_delay.
- Raises
TypeError – If delay is not int nor float
ValueError – If delay is negative
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Name of the parameter. This is identical to
short_name()
.
- property post_delay: float
Delay time after start of set operation, for each set. The actual time will not be shorter than this, but may be longer if the underlying set call takes longer.
Typically used in conjunction with step to create an effective ramp rate, but can also be used without a step to enforce a delay after every set. One might think of post_delay as how long a set operation is supposed to take. For example, there might be an instrument that needs extra time after setting a parameter although the command for setting the parameter returns quickly.
- Getter
Returns the current post_delay.
- Setter
Sets the value of the post_delay.
- Raises
TypeError – If delay is not int nor float
ValueError – If delay is negative
- property raw_value: Any
Note that this property will be deprecated soon. Use
cache.raw_value
instead.Represents the cached raw value of the parameter.
- Getter
Returns the cached raw value of the parameter.
- restore_at_exit(allow_changes: bool = True) qcodes.instrument.parameter._SetParamContext
Use a context manager to restore the value of a parameter after a
with
block.By default, the parameter value may be changed inside the block, but this can be prevented with
allow_changes=False
. This can be useful, for example, for debugging a complex measurement that unintentionally modifies a parameter.Example
>>> p = Parameter("p", set_cmd=None, get_cmd=None) >>> p.set(2) >>> with p.restore_at_exit(): ... p.set(3) ... print(f"value inside with block: {p.get()}") # prints 3 >>> print(f"value after with block: {p.get()}") # prints 2 >>> with p.restore_at_exit(allow_changes=False): ... p.set(5) # raises an exception
- property root_instrument: Optional[InstrumentBase]
Return the fundamental instrument that this parameter belongs too. E.g if the parameter is bound to a channel this will return the fundamental instrument that that channel belongs to. Use
instrument()
to get the channel.
- set_raw(value: Any) None
set_raw
is called to perform the actual setting of a parameter on the instrument. This method should either be overwritten to perform the desired operation or alternatively forParameter
a suitable method is automatically generated ifset_cmd
is supplied to the parameter constructor. The method is automatically wrapped to provide aset
method on the parameter instance.
- set_to(value: Any, allow_changes: bool = False) qcodes.instrument.parameter._SetParamContext
Use a context manager to temporarily set a parameter to a value. By default, the parameter value cannot be changed inside the context. This may be overridden with
allow_changes=True
.Examples
>>> from qcodes import Parameter >>> p = Parameter("p", set_cmd=None, get_cmd=None) >>> p.set(2) >>> with p.set_to(3): ... print(f"p value in with block {p.get()}") # prints 3 ... p.set(5) # raises an exception >>> print(f"p value outside with block {p.get()}") # prints 2 >>> with p.set_to(3, allow_changes=True): ... p.set(5) # now this works >>> print(f"value after second block: {p.get()}") # still prints 2
- property setpoint_full_names: Optional[Sequence[str]]
Full names of setpoints including instrument names if available
- property short_name: str
Short name of the parameter. This is without the name of the instrument or submodule that the parameter may be bound to. For full name refer to
full_name()
.
- snapshot(update: Optional[bool] = False) Dict[Any, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base()
.- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: Optional[bool] = True, params_to_skip_update: Optional[Sequence[str]] = None) Dict[Any, Any]
State of the parameter as a JSON-compatible dict (everything that the custom JSON encoder class
qcodes.utils.helpers.NumpyJSONEncoder
supports).If the parameter has been initiated with
snapshot_value=False
, the snapshot will NOT include thevalue
andraw_value
of the parameter.- Parameters
update – If True, update the state by calling
parameter.get()
unlesssnapshot_get
of the parameter isFalse
. Ifupdate
isNone
, use the current value from thecache
unless the cache is invalid. IfFalse
, never callparameter.get()
.params_to_skip_update – No effect but may be passed from superclass
- Returns
base snapshot
- property step: Optional[float]
Stepsize that this Parameter uses during set operation. Stepsize must be a positive number or None. If step is a positive number, this is the maximum value change allowed in one hardware call, so a single set can result in many calls to the hardware if the starting value is far from the target. All but the final change will attempt to change by +/- step exactly. If step is None stepping will not be used.
- Getter
Returns the current stepsize.
- Setter
Sets the value of the step.
- Raises
TypeError – if step is set to not numeric or None
ValueError – if step is set to negative
TypeError – if step is set to not integer or None for an integer parameter
TypeError – if step is set to not a number on None
- property underlying_instrument: Optional[InstrumentBase]
Returns an instance of the underlying hardware instrument that this parameter communicates with, per this parameter’s implementation.
This is useful in the case where a parameter does not belongs to an instrument instance that represents a real hardware instrument but actually uses a real hardware instrument in its implementation (e.g. via calls to one or more parameters of that real hardware instrument). This is also useful when a parameter does belong to an instrument instance but that instance does not represent the real hardware instrument that the parameter interacts with: hence
root_instrument
of the parameter cannot be thehardware_instrument
, howeverunderlying_instrument
can be implemented to return thehardware_instrument
.By default it returns the
root_instrument
of the parameter.
- validate(value: Any) None
Validate the value supplied.
- Parameters
value – value to validate
- Raises
TypeError – If the value is of the wrong type.
ValueError – If the value is outside the bounds specified by the validator.
- class qcodes.instrument_drivers.rohde_schwarz.ZNB.FrequencySweepDBPhase(name: str, instrument: qcodes.instrument_drivers.rohde_schwarz.ZNB.ZNBChannel, start: float, stop: float, npts: int, channel: int)[source]
Bases:
qcodes.instrument.parameter.MultiParameter
Sweep that return magnitude in decibel (dB) and phase in radians.
- get_raw() Tuple[Any, ...] [source]
get_raw
is called to perform the actual data acquisition from the instrument. This method should either be overwritten to perform the desired operation or alternatively forParameter
a suitable method is automatically generated ifget_cmd
is supplied to the parameter constructor. The method is automatically wrapped to provide aget
method on the parameter instance.
- property full_name: str
Name of the parameter including the name of the instrument and submodule that the parameter may be bound to. The names are separated by underscores, like this:
instrument_submodule_parameter
.
- property full_names: Tuple[str, ...]
Names of the parameter components including the name of the instrument and submodule that the parameter may be bound to. The name parts are separated by underscores, like this:
instrument_submodule_parameter
- get_ramp_values(value: Union[float, Sized], step: Optional[float] = None) Sequence[Union[float, Sized]]
Return values to sweep from current value to target value. This method can be overridden to have a custom sweep behaviour. It can even be overridden by a generator.
- Parameters
value – target value
step – maximum step size
- Returns
List of stepped values, including target value.
- property instrument: Optional[InstrumentBase]
Return the first instrument that this parameter is bound to. E.g if this is bound to a channel it will return the channel and not the instrument that the channel is bound too. Use
root_instrument()
to get the real instrument.
- property inter_delay: float
Delay time between consecutive set operations. The actual time will not be shorter than this, but may be longer if the underlying set call takes longer.
Typically used in conjunction with step to create an effective ramp rate, but can also be used without a step to enforce a delay between sets.
- Getter
Returns the current inter_delay.
- Setter
Sets the value of the inter_delay.
- Raises
TypeError – If delay is not int nor float
ValueError – If delay is negative
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Name of the parameter. This is identical to
short_name()
.
- property post_delay: float
Delay time after start of set operation, for each set. The actual time will not be shorter than this, but may be longer if the underlying set call takes longer.
Typically used in conjunction with step to create an effective ramp rate, but can also be used without a step to enforce a delay after every set. One might think of post_delay as how long a set operation is supposed to take. For example, there might be an instrument that needs extra time after setting a parameter although the command for setting the parameter returns quickly.
- Getter
Returns the current post_delay.
- Setter
Sets the value of the post_delay.
- Raises
TypeError – If delay is not int nor float
ValueError – If delay is negative
- property raw_value: Any
Note that this property will be deprecated soon. Use
cache.raw_value
instead.Represents the cached raw value of the parameter.
- Getter
Returns the cached raw value of the parameter.
- restore_at_exit(allow_changes: bool = True) qcodes.instrument.parameter._SetParamContext
Use a context manager to restore the value of a parameter after a
with
block.By default, the parameter value may be changed inside the block, but this can be prevented with
allow_changes=False
. This can be useful, for example, for debugging a complex measurement that unintentionally modifies a parameter.Example
>>> p = Parameter("p", set_cmd=None, get_cmd=None) >>> p.set(2) >>> with p.restore_at_exit(): ... p.set(3) ... print(f"value inside with block: {p.get()}") # prints 3 >>> print(f"value after with block: {p.get()}") # prints 2 >>> with p.restore_at_exit(allow_changes=False): ... p.set(5) # raises an exception
- property root_instrument: Optional[InstrumentBase]
Return the fundamental instrument that this parameter belongs too. E.g if the parameter is bound to a channel this will return the fundamental instrument that that channel belongs to. Use
instrument()
to get the channel.
- set_raw(value: Any) None
set_raw
is called to perform the actual setting of a parameter on the instrument. This method should either be overwritten to perform the desired operation or alternatively forParameter
a suitable method is automatically generated ifset_cmd
is supplied to the parameter constructor. The method is automatically wrapped to provide aset
method on the parameter instance.
- set_to(value: Any, allow_changes: bool = False) qcodes.instrument.parameter._SetParamContext
Use a context manager to temporarily set a parameter to a value. By default, the parameter value cannot be changed inside the context. This may be overridden with
allow_changes=True
.Examples
>>> from qcodes import Parameter >>> p = Parameter("p", set_cmd=None, get_cmd=None) >>> p.set(2) >>> with p.set_to(3): ... print(f"p value in with block {p.get()}") # prints 3 ... p.set(5) # raises an exception >>> print(f"p value outside with block {p.get()}") # prints 2 >>> with p.set_to(3, allow_changes=True): ... p.set(5) # now this works >>> print(f"value after second block: {p.get()}") # still prints 2
- property setpoint_full_names: Optional[Sequence[Sequence[str]]]
Full names of setpoints including instrument names, if available
- property short_name: str
Short name of the parameter. This is without the name of the instrument or submodule that the parameter may be bound to. For full name refer to
full_name()
.
- property short_names: Tuple[str, ...]
short_names is identical to names i.e. the names of the parameter parts but does not add the instrument name.
It exists for consistency with instruments and other parameters.
- snapshot(update: Optional[bool] = False) Dict[Any, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base()
.- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: Optional[bool] = True, params_to_skip_update: Optional[Sequence[str]] = None) Dict[Any, Any]
State of the parameter as a JSON-compatible dict (everything that the custom JSON encoder class
qcodes.utils.helpers.NumpyJSONEncoder
supports).If the parameter has been initiated with
snapshot_value=False
, the snapshot will NOT include thevalue
andraw_value
of the parameter.- Parameters
update – If True, update the state by calling
parameter.get()
unlesssnapshot_get
of the parameter isFalse
. Ifupdate
isNone
, use the current value from thecache
unless the cache is invalid. IfFalse
, never callparameter.get()
.params_to_skip_update – No effect but may be passed from superclass
- Returns
base snapshot
- property step: Optional[float]
Stepsize that this Parameter uses during set operation. Stepsize must be a positive number or None. If step is a positive number, this is the maximum value change allowed in one hardware call, so a single set can result in many calls to the hardware if the starting value is far from the target. All but the final change will attempt to change by +/- step exactly. If step is None stepping will not be used.
- Getter
Returns the current stepsize.
- Setter
Sets the value of the step.
- Raises
TypeError – if step is set to not numeric or None
ValueError – if step is set to negative
TypeError – if step is set to not integer or None for an integer parameter
TypeError – if step is set to not a number on None
- property underlying_instrument: Optional[InstrumentBase]
Returns an instance of the underlying hardware instrument that this parameter communicates with, per this parameter’s implementation.
This is useful in the case where a parameter does not belongs to an instrument instance that represents a real hardware instrument but actually uses a real hardware instrument in its implementation (e.g. via calls to one or more parameters of that real hardware instrument). This is also useful when a parameter does belong to an instrument instance but that instance does not represent the real hardware instrument that the parameter interacts with: hence
root_instrument
of the parameter cannot be thehardware_instrument
, howeverunderlying_instrument
can be implemented to return thehardware_instrument
.By default it returns the
root_instrument
of the parameter.
- validate(value: Any) None
Validate the value supplied.
- Parameters
value – value to validate
- Raises
TypeError – If the value is of the wrong type.
ValueError – If the value is outside the bounds specified by the validator.
- class qcodes.instrument_drivers.rohde_schwarz.ZNB.FrequencySweepMagPhase(name: str, instrument: qcodes.instrument_drivers.rohde_schwarz.ZNB.ZNBChannel, start: float, stop: float, npts: int, channel: int)[source]
Bases:
qcodes.instrument.parameter.MultiParameter
Sweep that return magnitude and phase.
- get_raw() Tuple[Any, ...] [source]
get_raw
is called to perform the actual data acquisition from the instrument. This method should either be overwritten to perform the desired operation or alternatively forParameter
a suitable method is automatically generated ifget_cmd
is supplied to the parameter constructor. The method is automatically wrapped to provide aget
method on the parameter instance.
- property full_name: str
Name of the parameter including the name of the instrument and submodule that the parameter may be bound to. The names are separated by underscores, like this:
instrument_submodule_parameter
.
- property full_names: Tuple[str, ...]
Names of the parameter components including the name of the instrument and submodule that the parameter may be bound to. The name parts are separated by underscores, like this:
instrument_submodule_parameter
- get_ramp_values(value: Union[float, Sized], step: Optional[float] = None) Sequence[Union[float, Sized]]
Return values to sweep from current value to target value. This method can be overridden to have a custom sweep behaviour. It can even be overridden by a generator.
- Parameters
value – target value
step – maximum step size
- Returns
List of stepped values, including target value.
- property instrument: Optional[InstrumentBase]
Return the first instrument that this parameter is bound to. E.g if this is bound to a channel it will return the channel and not the instrument that the channel is bound too. Use
root_instrument()
to get the real instrument.
- property inter_delay: float
Delay time between consecutive set operations. The actual time will not be shorter than this, but may be longer if the underlying set call takes longer.
Typically used in conjunction with step to create an effective ramp rate, but can also be used without a step to enforce a delay between sets.
- Getter
Returns the current inter_delay.
- Setter
Sets the value of the inter_delay.
- Raises
TypeError – If delay is not int nor float
ValueError – If delay is negative
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Name of the parameter. This is identical to
short_name()
.
- property post_delay: float
Delay time after start of set operation, for each set. The actual time will not be shorter than this, but may be longer if the underlying set call takes longer.
Typically used in conjunction with step to create an effective ramp rate, but can also be used without a step to enforce a delay after every set. One might think of post_delay as how long a set operation is supposed to take. For example, there might be an instrument that needs extra time after setting a parameter although the command for setting the parameter returns quickly.
- Getter
Returns the current post_delay.
- Setter
Sets the value of the post_delay.
- Raises
TypeError – If delay is not int nor float
ValueError – If delay is negative
- property raw_value: Any
Note that this property will be deprecated soon. Use
cache.raw_value
instead.Represents the cached raw value of the parameter.
- Getter
Returns the cached raw value of the parameter.
- restore_at_exit(allow_changes: bool = True) qcodes.instrument.parameter._SetParamContext
Use a context manager to restore the value of a parameter after a
with
block.By default, the parameter value may be changed inside the block, but this can be prevented with
allow_changes=False
. This can be useful, for example, for debugging a complex measurement that unintentionally modifies a parameter.Example
>>> p = Parameter("p", set_cmd=None, get_cmd=None) >>> p.set(2) >>> with p.restore_at_exit(): ... p.set(3) ... print(f"value inside with block: {p.get()}") # prints 3 >>> print(f"value after with block: {p.get()}") # prints 2 >>> with p.restore_at_exit(allow_changes=False): ... p.set(5) # raises an exception
- property root_instrument: Optional[InstrumentBase]
Return the fundamental instrument that this parameter belongs too. E.g if the parameter is bound to a channel this will return the fundamental instrument that that channel belongs to. Use
instrument()
to get the channel.
- set_raw(value: Any) None
set_raw
is called to perform the actual setting of a parameter on the instrument. This method should either be overwritten to perform the desired operation or alternatively forParameter
a suitable method is automatically generated ifset_cmd
is supplied to the parameter constructor. The method is automatically wrapped to provide aset
method on the parameter instance.
- set_to(value: Any, allow_changes: bool = False) qcodes.instrument.parameter._SetParamContext
Use a context manager to temporarily set a parameter to a value. By default, the parameter value cannot be changed inside the context. This may be overridden with
allow_changes=True
.Examples
>>> from qcodes import Parameter >>> p = Parameter("p", set_cmd=None, get_cmd=None) >>> p.set(2) >>> with p.set_to(3): ... print(f"p value in with block {p.get()}") # prints 3 ... p.set(5) # raises an exception >>> print(f"p value outside with block {p.get()}") # prints 2 >>> with p.set_to(3, allow_changes=True): ... p.set(5) # now this works >>> print(f"value after second block: {p.get()}") # still prints 2
- property setpoint_full_names: Optional[Sequence[Sequence[str]]]
Full names of setpoints including instrument names, if available
- property short_name: str
Short name of the parameter. This is without the name of the instrument or submodule that the parameter may be bound to. For full name refer to
full_name()
.
- property short_names: Tuple[str, ...]
short_names is identical to names i.e. the names of the parameter parts but does not add the instrument name.
It exists for consistency with instruments and other parameters.
- snapshot(update: Optional[bool] = False) Dict[Any, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base()
.- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: Optional[bool] = True, params_to_skip_update: Optional[Sequence[str]] = None) Dict[Any, Any]
State of the parameter as a JSON-compatible dict (everything that the custom JSON encoder class
qcodes.utils.helpers.NumpyJSONEncoder
supports).If the parameter has been initiated with
snapshot_value=False
, the snapshot will NOT include thevalue
andraw_value
of the parameter.- Parameters
update – If True, update the state by calling
parameter.get()
unlesssnapshot_get
of the parameter isFalse
. Ifupdate
isNone
, use the current value from thecache
unless the cache is invalid. IfFalse
, never callparameter.get()
.params_to_skip_update – No effect but may be passed from superclass
- Returns
base snapshot
- property step: Optional[float]
Stepsize that this Parameter uses during set operation. Stepsize must be a positive number or None. If step is a positive number, this is the maximum value change allowed in one hardware call, so a single set can result in many calls to the hardware if the starting value is far from the target. All but the final change will attempt to change by +/- step exactly. If step is None stepping will not be used.
- Getter
Returns the current stepsize.
- Setter
Sets the value of the step.
- Raises
TypeError – if step is set to not numeric or None
ValueError – if step is set to negative
TypeError – if step is set to not integer or None for an integer parameter
TypeError – if step is set to not a number on None
- property underlying_instrument: Optional[InstrumentBase]
Returns an instance of the underlying hardware instrument that this parameter communicates with, per this parameter’s implementation.
This is useful in the case where a parameter does not belongs to an instrument instance that represents a real hardware instrument but actually uses a real hardware instrument in its implementation (e.g. via calls to one or more parameters of that real hardware instrument). This is also useful when a parameter does belong to an instrument instance but that instance does not represent the real hardware instrument that the parameter interacts with: hence
root_instrument
of the parameter cannot be thehardware_instrument
, howeverunderlying_instrument
can be implemented to return thehardware_instrument
.By default it returns the
root_instrument
of the parameter.
- validate(value: Any) None
Validate the value supplied.
- Parameters
value – value to validate
- Raises
TypeError – If the value is of the wrong type.
ValueError – If the value is outside the bounds specified by the validator.
- class qcodes.instrument_drivers.rohde_schwarz.ZNB.ZNB(*args: Any, **kwargs: Any)[source]
Bases:
qcodes.instrument.visa.VisaInstrument
QCoDeS driver for the Rohde & Schwarz ZNB8 and ZNB20 virtual network analyser. It can probably be extended to ZNB4 and 40 without too much work.
Requires FrequencySweep parameter for taking a trace
- Parameters
name – instrument name
address – Address of instrument probably in format ‘TCPIP0::192.168.15.100::inst0::INSTR’
init_s_params – Automatically setup channels for all S parameters on the VNA.
reset_channels – If True any channels defined on the VNA at the time of initialization are reset and removed.
**kwargs – passed to base class
TODO: - check initialisation settings and test functions
- CHANNEL_CLASS
alias of
qcodes.instrument_drivers.rohde_schwarz.ZNB.ZNBChannel
- __getitem__(key: str) Union[Callable[[...], Any], qcodes.instrument.parameter.Parameter]
Delegate instrument[‘name’] to parameter or function ‘name’.
- add_function(name: str, **kwargs: Any) None
Bind one
Function
to this instrument.Instrument subclasses can call this repeatedly in their
__init__
for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST
(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only. If your case is more complicated, you’re probably better off simply making a new method in yourInstrument
subclass definition.- Parameters
name – How the Function will be stored within
instrument.Functions
and also how you address it using the shortcut methods:instrument.call(func_name, *args)
etc.**kwargs – constructor kwargs for
Function
- Raises
KeyError – If this instrument already has a function with this name.
- add_parameter(name: str, parameter_class: type = <class 'qcodes.instrument.parameter.Parameter'>, **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
instrument.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
parameter.Parameter
.**kwargs – Constructor arguments for
parameter_class
.
- Raises
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- add_submodule(name: str, submodule: Union[InstrumentModule, ChannelTuple]) None
Bind one submodule to this instrument.
Instrument subclasses can call this repeatedly in their
__init__
method for every submodule of the instrument.Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an
InstrumentModule
or aChannelTuple
.- Parameters
name – How the submodule will be stored within
instrument.submodules
and also how it can be addressed.submodule – The submodule to be stored.
- Raises
- property ancestors: List[qcodes.instrument.base.InstrumentBase]
Returns a list of instruments, starting from the current instrument and following to the parent instrument and the parents parent instrument until the root instrument is reached.
- ask(cmd: str) str
Write a command string to the hardware and return a response.
Subclasses that transform
cmd
should override this method, and in it callsuper().ask(new_cmd)
. Subclasses that define a new hardware communication should instead overrideask_raw
.- Parameters
cmd – The string to send to the instrument.
- Returns
response
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- ask_raw(cmd: str) str
Low-level interface to
visa_handle.ask
.- Parameters
cmd – The command to send to the instrument.
- Returns
The instrument’s response.
- Return type
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns
The return value of the function.
- check_error(ret_code: int) None
Default error checking, raises an error if return code
!=0
. Does not differentiate between warnings or specific error messages. Override this function in your driver if you want to add specific error messages.- Parameters
ret_code – A Visa error code. See eg: https://github.com/hgrecco/pyvisa/blob/master/pyvisa/errors.py
- Raises
visa.VisaIOError – if
ret_code
indicates a communication problem.
- classmethod close_all() None
Try to close all instruments registered in
_all_instruments
This is handy for use with atexit to ensure that all instruments are closed when a python session is closed.Examples
>>> atexit.register(qc.Instrument.close_all())
- connect_message(idn_param: str = 'IDN', begin_time: Optional[float] = None) None
Print a standard message on initial connection to an instrument.
- Parameters
idn_param – Name of parameter that returns ID dict. Default
IDN
.begin_time –
time.time()
when init started. Default isself._t0
, set at start ofInstrument.__init__
.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self
, whose keys should be treated as attributes ofself
.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self
, whose attributes should be passed through toself
.
- static exist(name: str, instrument_class: Optional[type] = None) bool
Check if an instrument with a given names exists (i.e. is already instantiated).
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- classmethod find_instrument(name: str, instrument_class: Optional[Type[qcodes.instrument.base.T]] = None) qcodes.instrument.base.T
Find an existing instrument by name.
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- Returns
The instrument found.
- Raises
- get(param_name: str) Any
Shortcut for getting a parameter from its name.
- Parameters
param_name – The name of a parameter of this instrument.
- Returns
The current value of the parameter.
- get_idn() Dict[str, Optional[str]]
Parse a standard VISA
*IDN?
response into an ID dict.Even though this is the VISA standard, it applies to various other types as well, such as IPInstruments, so it is included here in the Instrument base class.
Override this if your instrument does not support
*IDN?
or returns a nonstandard IDN string. This string is supposed to be a comma-separated list of vendor, model, serial, and firmware, but semicolon and colon are also common separators so we accept them here as well.- Returns
A dict containing vendor, model, serial, and firmware.
- classmethod instances() List[qcodes.instrument.base.Instrument]
Get all currently defined instances of this instrument class.
You can use this to get the objects back if you lose track of them, and it’s also used by the test system to find objects to test against.
- Returns
A list of instances.
- invalidate_cache() None
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- static is_valid(instr_instance: qcodes.instrument.base.Instrument) bool
Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a “valid” instrument.
- Parameters
instr_instance – Instance of an Instrument class or its subclass.
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Name of the instrument This is equivalent to full_name for backwards compatibility.
- omit_delegate_attrs: List[str] = []
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: Optional[qcodes.instrument.base.InstrumentBase]
Returns the parent instrument. By default this is
None
. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters
update – If
True
, update the state by querying the instrument. IfFalse
, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- classmethod record_instance(instance: qcodes.instrument.base.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: qcodes.instrument.base.Instrument) None
Remove a particular instance from the record.
- Parameters
instance – The instance to remove
- property root_instrument: qcodes.instrument.base.InstrumentBase
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters
param_name – The name of a parameter of this instrument.
value – The new value to set.
- set_address(address: str) None
Set the address for this instrument.
- Parameters
address – The visa resource name to use to connect. The address should be the actual address and just that. If you wish to change the backend for VISA, use the self.visalib attribute (and then call this function).
- set_terminator(terminator: str) None
Change the read terminator to use.
- Parameters
terminator – Character(s) to look for at the end of a read. eg.
\r\n
.
- snapshot(update: Optional[bool] = False) Dict[Any, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base()
.- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: Optional[bool] = True, params_to_skip_update: Optional[Sequence[str]] = None) Dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
qcodes.utils.helpers.NumpyJSONEncoder
supports).- Parameters
update – If True, update the state by querying the instrument. If None only update if the state is known to be invalid. If False, just use the latest values in memory and never update.
params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_get
attribute of those parameters instead.
- Returns
base snapshot
- Return type
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters
verbose – If
True
, then information about the parameters that are being check is printed.
- write(cmd: str) None
Write a command string with NO response to the hardware.
Subclasses that transform
cmd
should override this method, and in it callsuper().write(new_cmd)
. Subclasses that define a new hardware communication should instead overridewrite_raw
.- Parameters
cmd – The string to send to the instrument.
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- write_raw(cmd: str) None
Low-level interface to
visa_handle.write
.- Parameters
cmd – The command to send to the instrument.
- parameters: Dict[str, _BaseParameter] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter()
.
- functions: Dict[str, Function] = {}
All the functions supported by this instrument. Usually populated via
add_function()
.
- submodules: Dict[str, Union['InstrumentModule', 'ChannelTuple']] = {}
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule()
.
- instrument_modules: Dict[str, 'InstrumentModule'] = {}
All the instrument_modules of this instrument Usually populated via
add_submodule()
.
- class qcodes.instrument_drivers.rohde_schwarz.ZNB.ZNBChannel(parent: qcodes.instrument_drivers.rohde_schwarz.ZNB.ZNB, name: str, channel: int, vna_parameter: Optional[str] = None, existing_trace_to_bind_to: Optional[str] = None)[source]
Bases:
qcodes.instrument.channel.InstrumentChannel
- Parameters
parent – Instrument that this channel is bound to.
name – Name to use for this channel.
channel – channel on the VNA to use
vna_parameter – Name of parameter on the vna that this should measure such as S12. If left empty this will fall back to name.
existing_trace_to_bind_to – Name of an existing trace on the VNA. If supplied try to bind to an existing trace with this name rather than creating a new trace.
- update_lin_traces() None [source]
Updates start, stop and npts of all trace parameters so that the x-coordinates are updated for the sweep.
- update_cw_traces() None [source]
Updates the bandwidth and npts of all fixed frequency (CW) traces.
- setup_cw_sweep() None [source]
This method sets the VNA to CW mode. CW Mode sweeps are performed at fixed frequency and allow to perform measurements versus time instead of versus frequency. See (https://www.rohde-schwarz.com/webhelp/ZNB_ZNBT_HTML_UserManual_en /ZNB_ZNBT_HTML_UserManual_en.htm) under GUI reference -> sweep softtool -> sweep type tab -> CW mode
- __getitem__(key: str) Union[Callable[[...], Any], qcodes.instrument.parameter.Parameter]
Delegate instrument[‘name’] to parameter or function ‘name’.
- add_function(name: str, **kwargs: Any) None
Bind one
Function
to this instrument.Instrument subclasses can call this repeatedly in their
__init__
for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST
(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only. If your case is more complicated, you’re probably better off simply making a new method in yourInstrument
subclass definition.- Parameters
name – How the Function will be stored within
instrument.Functions
and also how you address it using the shortcut methods:instrument.call(func_name, *args)
etc.**kwargs – constructor kwargs for
Function
- Raises
KeyError – If this instrument already has a function with this name.
- add_parameter(name: str, parameter_class: type = <class 'qcodes.instrument.parameter.Parameter'>, **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
instrument.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
parameter.Parameter
.**kwargs – Constructor arguments for
parameter_class
.
- Raises
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- add_submodule(name: str, submodule: Union[InstrumentModule, ChannelTuple]) None
Bind one submodule to this instrument.
Instrument subclasses can call this repeatedly in their
__init__
method for every submodule of the instrument.Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an
InstrumentModule
or aChannelTuple
.- Parameters
name – How the submodule will be stored within
instrument.submodules
and also how it can be addressed.submodule – The submodule to be stored.
- Raises
- property ancestors: List[qcodes.instrument.base.InstrumentBase]
Returns a list of instruments, starting from the current instrument and following to the parent instrument and the parents parent instrument until the root instrument is reached.
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns
The return value of the function.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self
, whose keys should be treated as attributes ofself
.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self
, whose attributes should be passed through toself
.
- get(param_name: str) Any
Shortcut for getting a parameter from its name.
- Parameters
param_name – The name of a parameter of this instrument.
- Returns
The current value of the parameter.
- invalidate_cache() None
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Name of the instrument This is equivalent to full_name for backwards compatibility.
- omit_delegate_attrs: List[str] = []
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: qcodes.instrument.base.InstrumentBase
Returns the parent instrument. By default this is
None
. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters
update – If
True
, update the state by querying the instrument. IfFalse
, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- property root_instrument: qcodes.instrument.base.InstrumentBase
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters
param_name – The name of a parameter of this instrument.
value – The new value to set.
- snapshot(update: Optional[bool] = False) Dict[Any, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base()
.- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: Optional[bool] = False, params_to_skip_update: Optional[Sequence[str]] = None) Dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
qcodes.utils.helpers.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, _BaseParameter] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter()
.
- functions: Dict[str, Function] = {}
All the functions supported by this instrument. Usually populated via
add_function()
.
- submodules: Dict[str, Union['InstrumentModule', 'ChannelTuple']] = {}
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule()
.
- instrument_modules: Dict[str, 'InstrumentModule'] = {}
All the instrument_modules of this instrument Usually populated via
add_submodule()
.