semi_cr.core.lab.drivers package¶
Submodules¶
semi_cr.core.lab.drivers.cqcc module¶
- class semi_cr.core.lab.drivers.cqcc.QcodesCQCC(*args: Any, **kwargs: Any)[source]¶
Bases:
Instrument- close()[source]¶
Irreversibly stop this instrument and free its resources.
Subclasses should override this if they have other specific resources to close.
- get_idn() dict[str, str | None][source]¶
Parse a standard VISA
*IDN?response into an ID dict.Even though this is the VISA standard, it applies to various other types as well, such as IPInstruments, so it is included here in the Instrument base class.
Override this if your instrument does not support
*IDN?or returns a nonstandard IDN string. This string is supposed to be a comma-separated list of vendor, model, serial, and firmware, but semicolon and colon are also common separators so we accept them here as well.- Returns:
A dict containing vendor, model, serial, and firmware.
- __getitem__(key: str) Callable[[...], Any] | Parameter¶
Delegate instrument[‘name’] to parameter or function ‘name’.
Note
This is deprecated. Use attributes directly or if dynamic attribute required look up via .parameters or .functions dictionaries
- add_function(name: str, **kwargs: Any) None¶
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters:
name – How the Function will be stored within
instrument.Functionsand 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[TParameter] | None = None, **kwargs: Any) TParameter¶
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
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises:
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- Returns:
The created Parameter.
- add_submodule(name: str, submodule: TSubmodule) TSubmodule¶
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
InstrumentModuleor aChannelTuple.- Parameters:
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises:
- Returns:
The submodule.
- property ancestors: tuple[InstrumentBase, ...]¶
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- ask(cmd: str) str¶
Write a command string to the hardware and return a response.
Subclasses that transform
cmdshould 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 method to write to the hardware and return a response.
Subclasses that define a new hardware communication should override this method. Subclasses that transform
cmdshould instead overrideask.- Parameters:
cmd – The string to send to the instrument.
- call(func_name: str, *args: Any) Any¶
Shortcut for calling a function from its name.
- Parameters:
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns:
The return value of the function.
Note
This is deprecated. Call the function directly.
- classmethod close_all() None¶
Try to close all instruments registered in
_all_instrumentsThis is handy for use with atexit to ensure that all instruments are closed when a python session is closed.Examples
>>> atexit.register(qc.Instrument.close_all())
- connect_message(idn_param: str = 'IDN', begin_time: float | None = None) None¶
Print a standard message on initial connection to an instrument.
- Parameters:
idn_param – Name of parameter that returns ID dict. Default
IDN.begin_time –
time.time()when init started. Default isself._t0, set at start ofInstrument.__init__.
- delegate_attr_dicts = ['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 = []¶
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- static exist(name: str, instrument_class: type[Instrument] | None = None) bool¶
Check if an instrument with a given names exists (i.e. is already instantiated).
- Parameters:
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- classmethod find_instrument(name: str, instrument_class: type[T] | None = None) T | Instrument¶
Find an existing instrument by name.
- Parameters:
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- Returns:
The instrument found.
- Raises:
- property full_name: str¶
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any¶
Shortcut for getting a parameter from its name.
- Parameters:
param_name – The name of a parameter of this instrument.
- Returns:
The current value of the parameter.
Note
This is deprecated. Call get directly on the parameter.
- get_component(full_name: str) MetadatableWithName¶
Recursively get a component of the instrument by full_name.
- Parameters:
full_name – The name of the component to get.
- Returns:
The component with the given name.
- Raises:
KeyError – If the component does not exist.
- classmethod instances() list[Self]¶
Get all currently defined instances of this instrument class.
You can use this to get the objects back if you lose track of them, and it’s also used by the test system to find objects to test against.
- Returns:
A list of instances.
- invalidate_cache() None¶
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- static is_valid(instr_instance: Instrument) bool¶
Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a “valid” instrument.
- Parameters:
instr_instance – Instance of an Instrument class or its subclass.
- load_metadata(metadata: Mapping[str, Any]) None¶
Load metadata into this classes metadata dictionary.
- Parameters:
metadata – Metadata to load.
- property name: str¶
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]¶
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs = []¶
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: InstrumentBase | None¶
The parent instrument. By default, this is
None. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None¶
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters:
update – If
True, update the state by querying the instrument. IfFalse, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- classmethod record_instance(instance: Instrument) None¶
Record (a weak ref to) an instance in a class’s instance list.
Also records the instance in list of all instruments, and verifies that there are no other instruments with the same name.
This method is called after initialization of the instrument is completed.
- Parameters:
instance – Instance to record.
- Raises:
KeyError – If another instance with the same name is already present.
- classmethod remove_instance(instance: Instrument) None¶
Remove a particular instance from the record.
- Parameters:
instance – The instance to remove
- remove_parameter(name: str) None¶
Remove a Parameter from this instrument.
Unlike modifying the parameters dict directly, this method will make sure that the parameter is properly unbound from the instrument if the parameter is added as a real attribute to the instrument. If a property of the same name exists it will not be modified. If name is an attribute but not a parameter, it will not be modified.
- Parameters:
name – The name of the parameter to remove.
- Raises:
KeyError – If the parameter does not exist on the instrument.
- property root_instrument: InstrumentBase¶
The topmost parent of this module.
For the
root_instrumentthis isself.
- set(param_name: str, value: Any) None¶
Shortcut for setting a parameter from its name and new value.
- Parameters:
param_name – The name of a parameter of this instrument.
value – The new value to set.
Note
This is deprecated. Call set directly on the parameter.
- property short_name: str¶
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: bool | None = False) dict[str, Any]¶
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters:
update – Passed to snapshot_base.
- Returns:
Base snapshot.
- snapshot_base(update: bool | None = False, params_to_skip_update: Sequence[str] | None = None) dict[Any, Any]¶
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- 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_getattribute 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
cmdshould 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 method to write a command string to the hardware.
Subclasses that define a new hardware communication should override this method. Subclasses that transform
cmdshould instead overridewrite.- Parameters:
cmd – The string to send to the instrument.
- IDN¶
Standard IDN parameter, which queries the instrument for its ID
- parameters¶
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions¶
All the functions supported by this instrument. Usually populated via
add_function().
- submodules¶
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules¶
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
- exception semi_cr.core.lab.drivers.cqcc.ConnectionError[source]¶
Bases:
Exception- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class semi_cr.core.lab.drivers.cqcc.SwitchSingleControlStruct[source]¶
Bases:
objectClass for constructing data between PC and MCU This class is used for open single channel control
- class semi_cr.core.lab.drivers.cqcc.SwitchPairControlStruct[source]¶
Bases:
objectClass for constructing data between PC and MCU This class is used for open pair channel control
- class semi_cr.core.lab.drivers.cqcc.CQCC(settings_path='src\\semi_cr\\setup\\juno\\cqcc\\conf\\cqcc_conf\\CQCC_V1.yaml')[source]¶
Bases:
objectInitialize cqcc driver
Parameters: Settings_path: stores the hardware mapping
- send_switchSingleControlStruct_to_arduino(data: SwitchSingleControlStruct)[source]¶
- send_switchPairControlStruct_to_arduino(data: SwitchPairControlStruct, header=True)[source]¶
semi_cr.core.lab.drivers.cqccV2 module¶
Need to sort out the storage of variables in general here
- exception semi_cr.core.lab.drivers.cqccV2.ConnectionError[source]¶
Bases:
Exception- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception semi_cr.core.lab.drivers.cqccV2.DisconnectionError[source]¶
Bases:
Exception- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class semi_cr.core.lab.drivers.cqccV2.SwitchSingleControlStruct[source]¶
Bases:
objectClass for constructing data between PC and MCU This class is used for open single channel control
- class semi_cr.core.lab.drivers.cqccV2.SwitchPairControlStruct[source]¶
Bases:
objectClass for constructing data between PC and MCU This class is used for open pair channel control
- class semi_cr.core.lab.drivers.cqccV2.CQCC[source]¶
Bases:
object- send_switchSingleControlStruct_to_arduino(data: SwitchSingleControlStruct)[source]¶
- send_switchPairControlStruct_to_arduino(data: SwitchPairControlStruct, header=True)[source]¶
semi_cr.core.lab.drivers.experiment module¶
This is a single driver for experiments.
Code is good but still areas for improving and making more pythonic - A.I. is good at brain storming ideas to do this
Noticed that the measurement give spurious outputs sometimes I am not sure if this is a program error or not but it is always resolved by turning the Keithley on and off again There may be a need for a reset sequence before executing large measurements
semi_cr.core.lab.drivers.instrument module¶
A single driver to make resistance readings on an individual and full-matrix scale
Need to debug the full matrix as it sometimes gets stuck on the last run
Need to understand error checking better
Improve the way settings are updated …
- class semi_cr.core.lab.drivers.instrument.CheckChannel(positive: int = 12, gnd: int = 6, repeats: int = 5, tolerance: float = 0.01, theoretical_resistance: float = 100000, err_message: str = 'High deviation from the theoretical resistance detected: power system on and off and try again.')[source]¶
Bases:
object
- exception semi_cr.core.lab.drivers.instrument.SetupError[source]¶
Bases:
Exception- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class semi_cr.core.lab.drivers.instrument.Paths(cqcc_v1: str = 'src\\\\semi_cr\\\\setup\\\\juno\\\\cqcc\\\\conf\\\\cqcc_conf\\\\CQCC_V1.yaml', lua_script: str = 'src\\\\semi_cr\\\\setup\\\\juno\\\\cqcc\\\\conf\\\\keitheley_scripts\\\\keithley_script.lua', data: str = 'src\\semi_cr\\\\setup\\\\juno\\\\cqcc\\\\tests')[source]¶
Bases:
object
- class semi_cr.core.lab.drivers.instrument.FullMatrixParams(n: int = 10, chunk_size: int = 20, path: semi_cr.core.lab.drivers.instrument.Paths = <factory>)[source]¶
Bases:
object
semi_cr.core.lab.drivers.keithley_2636 module¶
- exception semi_cr.core.lab.drivers.keithley_2636.ConnectionError[source]¶
Bases:
Exception- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class semi_cr.core.lab.drivers.keithley_2636.Keithley_2636b_driver(address='TCPIP::169.254.25.152::INSTR')[source]¶
Bases:
object- upload_keithley_script(inst, path_to_script, total_measurements: int, **kwargs)[source]¶
- descrption:
used when multiple measurements are needed
- Parameters:
kwargs – other parameters to be replaced in the lua script, such as nplc, levelv, delay, filter type and filter count
nplc – number of power line cycles for each measurement, default to be 10
levelv – the voltage level to be applied, default to be 0.01v
delay – the delay between each measurement, default to be 0.1s
filter – the type of filter to be applied, default to be turn off
filter_count – the count of the filter, default to be 3
semi_cr.core.lab.drivers.keithley_2636V2 module¶
Code is good but still areas for improving and making more pythonic - A.I. is good at brain storming ideas to do this.
Noticed that the measurement give spurious outputs sometimes. I am not sure if this is a program error or not but it is always resolved by turning the Keithley on and off again. There may be a need for a reset sequence before executing large measurements.
There is somethimes a lack of clarity in naming. If Keithley or Arduino is not specified then the Keithley can be assumed to be the device of interest as this is a keithley driver.
Need to trouble shoot and ensure parameters are actually being updated - e.g. nplc.
An idea in the future would be one class that incorporates both drivers.
- class semi_cr.core.lab.drivers.keithley_2636V2.Keithley(address: str, status: Any = None)[source]¶
Bases:
object
- class semi_cr.core.lab.drivers.keithley_2636V2.Arduino(connected: bool = False, communication_port: str = 'COM4', status: Any = None)[source]¶
Bases:
object
- class semi_cr.core.lab.drivers.keithley_2636V2.Device(keithley: semi_cr.core.lab.drivers.keithley_2636V2.Keithley, arduino: semi_cr.core.lab.drivers.keithley_2636V2.Arduino)[source]¶
Bases:
object
- class semi_cr.core.lab.drivers.keithley_2636V2.FilePaths(cqcc_v1: str = 'src\\semi_cr\\setup\\juno\\cqcc\\conf\\cqcc_conf\\CQCC_V1.yaml', keithley_script: str = 'src\\semi_cr\\setup\\juno\\cqcc\\conf\\keitheley_scripts\\keithley_script.lua', data: str = 'src\\semi_cr\\setup\\juno\\cqcc\\tests')[source]¶
Bases:
object
- class semi_cr.core.lab.drivers.keithley_2636V2.Check(ch1: int = 12, ch2: int = 6, repeats: int = 5, tolerance: float = 0.01, theoretical_resistance: float = 100000, err_message: str = 'High deviation from the theoretical resistance detected: power Keithley on and off and try again.')[source]¶
Bases:
object
- class semi_cr.core.lab.drivers.keithley_2636V2.FullMatrixParams(path: semi_cr.core.lab.drivers.keithley_2636V2.FilePaths = <factory>, check: semi_cr.core.lab.drivers.keithley_2636V2.Check = <factory>, full_scan: bool = False, chunk_size: int = 20)[source]¶
Bases:
object
- class semi_cr.core.lab.drivers.keithley_2636V2.Source(channel: str = 'a', delay: float = 0.1, iv: str = 'v', current_level: float = 0.01, voltage_level: float = 0.01)[source]¶
Bases:
object
- class semi_cr.core.lab.drivers.keithley_2636V2.Measurement(filter: str = 'FILTER_REPEAT_AVG', filter_count: int = 3, filter_status: bool = True, nplc: int = 10)[source]¶
Bases:
object
- class semi_cr.core.lab.drivers.keithley_2636V2.Settings(source: semi_cr.core.lab.drivers.keithley_2636V2.Source, measurement: semi_cr.core.lab.drivers.keithley_2636V2.Measurement)[source]¶
Bases:
object- measurement: Measurement¶
- exception semi_cr.core.lab.drivers.keithley_2636V2.ConnectionError[source]¶
Bases:
Exception- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception semi_cr.core.lab.drivers.keithley_2636V2.KeithleySetupError[source]¶
Bases:
Exception- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
semi_cr.core.lab.drivers.keithley_2636V3 module¶
Code is good but still areas for improving and making more pythonic - A.I. is good at brain storming ideas to do this.
Need to trouble shoot and ensure parameters are actually being updated - e.g. nplc.
- class semi_cr.core.lab.drivers.keithley_2636V3.Source(channel: str = 'a', delay: float = 0.1, iv: str = 'v', current_level: float = 0.01, voltage_level: float = 0.01)[source]¶
Bases:
object
- class semi_cr.core.lab.drivers.keithley_2636V3.Measurement(filter: str = 'FILTER_REPEAT_AVG', filter_count: int = 3, filter_status: bool = True, nplc: int = 10)[source]¶
Bases:
object
- class semi_cr.core.lab.drivers.keithley_2636V3.Settings(source: semi_cr.core.lab.drivers.keithley_2636V3.Source = <factory>, measurement: semi_cr.core.lab.drivers.keithley_2636V3.Measurement = <factory>)[source]¶
Bases:
object- measurement: Measurement¶
- exception semi_cr.core.lab.drivers.keithley_2636V3.ConnectionError[source]¶
Bases:
Exception- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception semi_cr.core.lab.drivers.keithley_2636V3.DisconnectionError[source]¶
Bases:
Exception- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception semi_cr.core.lab.drivers.keithley_2636V3.MeasurementError[source]¶
Bases:
Exception- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
semi_cr.core.lab.drivers.opx module¶
- class semi_cr.core.lab.drivers.opx.OPXChannel(parent: InstrumentModule, name: str, channel_number: int, direction: str, **kwargs: Any)[source]¶
Bases:
InstrumentChannel- __getitem__(key: str) Callable[[...], Any] | Parameter¶
Delegate instrument[‘name’] to parameter or function ‘name’.
Note
This is deprecated. Use attributes directly or if dynamic attribute required look up via .parameters or .functions dictionaries
- add_function(name: str, **kwargs: Any) None¶
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters:
name – How the Function will be stored within
instrument.Functionsand 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[TParameter] | None = None, **kwargs: Any) TParameter¶
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
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises:
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- Returns:
The created Parameter.
- add_submodule(name: str, submodule: TSubmodule) TSubmodule¶
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
InstrumentModuleor aChannelTuple.- Parameters:
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises:
- Returns:
The submodule.
- property ancestors: tuple[InstrumentBase, ...]¶
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- call(func_name: str, *args: Any) Any¶
Shortcut for calling a function from its name.
- Parameters:
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns:
The return value of the function.
Note
This is deprecated. Call the function directly.
- delegate_attr_dicts = ['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 = []¶
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- property full_name: str¶
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any¶
Shortcut for getting a parameter from its name.
- Parameters:
param_name – The name of a parameter of this instrument.
- Returns:
The current value of the parameter.
Note
This is deprecated. Call get directly on the parameter.
- get_component(full_name: str) MetadatableWithName¶
Recursively get a component of the instrument by full_name.
- Parameters:
full_name – The name of the component to get.
- Returns:
The component with the given name.
- Raises:
KeyError – If the component does not exist.
- invalidate_cache() None¶
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- load_metadata(metadata: Mapping[str, Any]) None¶
Load metadata into this classes metadata dictionary.
- Parameters:
metadata – Metadata to load.
- property name: str¶
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]¶
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs = []¶
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: _TIB_co¶
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.
- remove_parameter(name: str) None¶
Remove a Parameter from this instrument.
Unlike modifying the parameters dict directly, this method will make sure that the parameter is properly unbound from the instrument if the parameter is added as a real attribute to the instrument. If a property of the same name exists it will not be modified. If name is an attribute but not a parameter, it will not be modified.
- Parameters:
name – The name of the parameter to remove.
- Raises:
KeyError – If the parameter does not exist on the instrument.
- property root_instrument: InstrumentBase¶
The topmost parent of this module.
For the
root_instrumentthis isself.
- set(param_name: str, value: Any) None¶
Shortcut for setting a parameter from its name and new value.
- Parameters:
param_name – The name of a parameter of this instrument.
value – The new value to set.
Note
This is deprecated. Call set directly on the parameter.
- property short_name: str¶
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: bool | None = False) dict[str, Any]¶
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters:
update – Passed to snapshot_base.
- Returns:
Base snapshot.
- snapshot_base(update: bool | None = False, params_to_skip_update: Sequence[str] | None = None) dict[Any, Any]¶
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- 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_getattribute 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¶
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions¶
All the functions supported by this instrument. Usually populated via
add_function().
- submodules¶
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules¶
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
- log¶
- metadata¶
- class semi_cr.core.lab.drivers.opx.OPXOutputChannel(parent, name: str, channel_number: int, **kwargs)[source]¶
Bases:
OPXChannel- __getitem__(key: str) Callable[[...], Any] | Parameter¶
Delegate instrument[‘name’] to parameter or function ‘name’.
Note
This is deprecated. Use attributes directly or if dynamic attribute required look up via .parameters or .functions dictionaries
- add_function(name: str, **kwargs: Any) None¶
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters:
name – How the Function will be stored within
instrument.Functionsand 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[TParameter] | None = None, **kwargs: Any) TParameter¶
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
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises:
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- Returns:
The created Parameter.
- add_submodule(name: str, submodule: TSubmodule) TSubmodule¶
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
InstrumentModuleor aChannelTuple.- Parameters:
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises:
- Returns:
The submodule.
- property ancestors: tuple[InstrumentBase, ...]¶
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- call(func_name: str, *args: Any) Any¶
Shortcut for calling a function from its name.
- Parameters:
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns:
The return value of the function.
Note
This is deprecated. Call the function directly.
- delegate_attr_dicts = ['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 = []¶
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- property full_name: str¶
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any¶
Shortcut for getting a parameter from its name.
- Parameters:
param_name – The name of a parameter of this instrument.
- Returns:
The current value of the parameter.
Note
This is deprecated. Call get directly on the parameter.
- get_component(full_name: str) MetadatableWithName¶
Recursively get a component of the instrument by full_name.
- Parameters:
full_name – The name of the component to get.
- Returns:
The component with the given name.
- Raises:
KeyError – If the component does not exist.
- invalidate_cache() None¶
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- load_metadata(metadata: Mapping[str, Any]) None¶
Load metadata into this classes metadata dictionary.
- Parameters:
metadata – Metadata to load.
- property name: str¶
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]¶
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs = []¶
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: _TIB_co¶
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.
- remove_parameter(name: str) None¶
Remove a Parameter from this instrument.
Unlike modifying the parameters dict directly, this method will make sure that the parameter is properly unbound from the instrument if the parameter is added as a real attribute to the instrument. If a property of the same name exists it will not be modified. If name is an attribute but not a parameter, it will not be modified.
- Parameters:
name – The name of the parameter to remove.
- Raises:
KeyError – If the parameter does not exist on the instrument.
- property root_instrument: InstrumentBase¶
The topmost parent of this module.
For the
root_instrumentthis isself.
- set(param_name: str, value: Any) None¶
Shortcut for setting a parameter from its name and new value.
- Parameters:
param_name – The name of a parameter of this instrument.
value – The new value to set.
Note
This is deprecated. Call set directly on the parameter.
- property short_name: str¶
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: bool | None = False) dict[str, Any]¶
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters:
update – Passed to snapshot_base.
- Returns:
Base snapshot.
- snapshot_base(update: bool | None = False, params_to_skip_update: Sequence[str] | None = None) dict[Any, Any]¶
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- 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_getattribute 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¶
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions¶
All the functions supported by this instrument. Usually populated via
add_function().
- submodules¶
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules¶
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
- log¶
- metadata¶
- class semi_cr.core.lab.drivers.opx.OPXInputChannel(parent, name: str, channel_number: int, **kwargs)[source]¶
Bases:
OPXChannel- __getitem__(key: str) Callable[[...], Any] | Parameter¶
Delegate instrument[‘name’] to parameter or function ‘name’.
Note
This is deprecated. Use attributes directly or if dynamic attribute required look up via .parameters or .functions dictionaries
- add_function(name: str, **kwargs: Any) None¶
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters:
name – How the Function will be stored within
instrument.Functionsand 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[TParameter] | None = None, **kwargs: Any) TParameter¶
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
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises:
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- Returns:
The created Parameter.
- add_submodule(name: str, submodule: TSubmodule) TSubmodule¶
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
InstrumentModuleor aChannelTuple.- Parameters:
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises:
- Returns:
The submodule.
- property ancestors: tuple[InstrumentBase, ...]¶
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- call(func_name: str, *args: Any) Any¶
Shortcut for calling a function from its name.
- Parameters:
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns:
The return value of the function.
Note
This is deprecated. Call the function directly.
- delegate_attr_dicts = ['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 = []¶
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- property full_name: str¶
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any¶
Shortcut for getting a parameter from its name.
- Parameters:
param_name – The name of a parameter of this instrument.
- Returns:
The current value of the parameter.
Note
This is deprecated. Call get directly on the parameter.
- get_component(full_name: str) MetadatableWithName¶
Recursively get a component of the instrument by full_name.
- Parameters:
full_name – The name of the component to get.
- Returns:
The component with the given name.
- Raises:
KeyError – If the component does not exist.
- invalidate_cache() None¶
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- load_metadata(metadata: Mapping[str, Any]) None¶
Load metadata into this classes metadata dictionary.
- Parameters:
metadata – Metadata to load.
- property name: str¶
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]¶
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs = []¶
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: _TIB_co¶
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.
- remove_parameter(name: str) None¶
Remove a Parameter from this instrument.
Unlike modifying the parameters dict directly, this method will make sure that the parameter is properly unbound from the instrument if the parameter is added as a real attribute to the instrument. If a property of the same name exists it will not be modified. If name is an attribute but not a parameter, it will not be modified.
- Parameters:
name – The name of the parameter to remove.
- Raises:
KeyError – If the parameter does not exist on the instrument.
- property root_instrument: InstrumentBase¶
The topmost parent of this module.
For the
root_instrumentthis isself.
- set(param_name: str, value: Any) None¶
Shortcut for setting a parameter from its name and new value.
- Parameters:
param_name – The name of a parameter of this instrument.
value – The new value to set.
Note
This is deprecated. Call set directly on the parameter.
- property short_name: str¶
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: bool | None = False) dict[str, Any]¶
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters:
update – Passed to snapshot_base.
- Returns:
Base snapshot.
- snapshot_base(update: bool | None = False, params_to_skip_update: Sequence[str] | None = None) dict[Any, Any]¶
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- 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_getattribute 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¶
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions¶
All the functions supported by this instrument. Usually populated via
add_function().
- submodules¶
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules¶
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
- log¶
- metadata¶
- class semi_cr.core.lab.drivers.opx.FEMModule(parent: Instrument, name: str, slot: int, module_type: str, n_outputs: int, n_inputs: int, **kwargs: Any)[source]¶
Bases:
InstrumentModule- __getitem__(key: str) Callable[[...], Any] | Parameter¶
Delegate instrument[‘name’] to parameter or function ‘name’.
Note
This is deprecated. Use attributes directly or if dynamic attribute required look up via .parameters or .functions dictionaries
- add_function(name: str, **kwargs: Any) None¶
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters:
name – How the Function will be stored within
instrument.Functionsand 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[TParameter] | None = None, **kwargs: Any) TParameter¶
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
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises:
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- Returns:
The created Parameter.
- add_submodule(name: str, submodule: TSubmodule) TSubmodule¶
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
InstrumentModuleor aChannelTuple.- Parameters:
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises:
- Returns:
The submodule.
- property ancestors: tuple[InstrumentBase, ...]¶
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- call(func_name: str, *args: Any) Any¶
Shortcut for calling a function from its name.
- Parameters:
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns:
The return value of the function.
Note
This is deprecated. Call the function directly.
- delegate_attr_dicts = ['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 = []¶
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- property full_name: str¶
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any¶
Shortcut for getting a parameter from its name.
- Parameters:
param_name – The name of a parameter of this instrument.
- Returns:
The current value of the parameter.
Note
This is deprecated. Call get directly on the parameter.
- get_component(full_name: str) MetadatableWithName¶
Recursively get a component of the instrument by full_name.
- Parameters:
full_name – The name of the component to get.
- Returns:
The component with the given name.
- Raises:
KeyError – If the component does not exist.
- invalidate_cache() None¶
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- load_metadata(metadata: Mapping[str, Any]) None¶
Load metadata into this classes metadata dictionary.
- Parameters:
metadata – Metadata to load.
- property name: str¶
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]¶
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs = []¶
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: _TIB_co¶
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.
- remove_parameter(name: str) None¶
Remove a Parameter from this instrument.
Unlike modifying the parameters dict directly, this method will make sure that the parameter is properly unbound from the instrument if the parameter is added as a real attribute to the instrument. If a property of the same name exists it will not be modified. If name is an attribute but not a parameter, it will not be modified.
- Parameters:
name – The name of the parameter to remove.
- Raises:
KeyError – If the parameter does not exist on the instrument.
- property root_instrument: InstrumentBase¶
The topmost parent of this module.
For the
root_instrumentthis isself.
- set(param_name: str, value: Any) None¶
Shortcut for setting a parameter from its name and new value.
- Parameters:
param_name – The name of a parameter of this instrument.
value – The new value to set.
Note
This is deprecated. Call set directly on the parameter.
- property short_name: str¶
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: bool | None = False) dict[str, Any]¶
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters:
update – Passed to snapshot_base.
- Returns:
Base snapshot.
- snapshot_base(update: bool | None = False, params_to_skip_update: Sequence[str] | None = None) dict[Any, Any]¶
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- 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_getattribute 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¶
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions¶
All the functions supported by this instrument. Usually populated via
add_function().
- submodules¶
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules¶
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
- log¶
- metadata¶
- class semi_cr.core.lab.drivers.opx.OPX1000(*args: Any, **kwargs: Any)[source]¶
Bases:
Instrument- get_idn() dict[str, str | None][source]¶
Override Instrument.get_idn so QCoDeS never calls self.ask(’*IDN?’).
- __getitem__(key: str) Callable[[...], Any] | Parameter¶
Delegate instrument[‘name’] to parameter or function ‘name’.
Note
This is deprecated. Use attributes directly or if dynamic attribute required look up via .parameters or .functions dictionaries
- add_function(name: str, **kwargs: Any) None¶
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters:
name – How the Function will be stored within
instrument.Functionsand 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[TParameter] | None = None, **kwargs: Any) TParameter¶
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
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises:
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- Returns:
The created Parameter.
- add_submodule(name: str, submodule: TSubmodule) TSubmodule¶
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
InstrumentModuleor aChannelTuple.- Parameters:
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises:
- Returns:
The submodule.
- property ancestors: tuple[InstrumentBase, ...]¶
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- ask(cmd: str) str¶
Write a command string to the hardware and return a response.
Subclasses that transform
cmdshould 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 method to write to the hardware and return a response.
Subclasses that define a new hardware communication should override this method. Subclasses that transform
cmdshould instead overrideask.- Parameters:
cmd – The string to send to the instrument.
- call(func_name: str, *args: Any) Any¶
Shortcut for calling a function from its name.
- Parameters:
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns:
The return value of the function.
Note
This is deprecated. Call the function directly.
- close() None¶
Irreversibly stop this instrument and free its resources.
Subclasses should override this if they have other specific resources to close.
- classmethod close_all() None¶
Try to close all instruments registered in
_all_instrumentsThis is handy for use with atexit to ensure that all instruments are closed when a python session is closed.Examples
>>> atexit.register(qc.Instrument.close_all())
- connect_message(idn_param: str = 'IDN', begin_time: float | None = None) None¶
Print a standard message on initial connection to an instrument.
- Parameters:
idn_param – Name of parameter that returns ID dict. Default
IDN.begin_time –
time.time()when init started. Default isself._t0, set at start ofInstrument.__init__.
- delegate_attr_dicts = ['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 = []¶
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- static exist(name: str, instrument_class: type[Instrument] | None = None) bool¶
Check if an instrument with a given names exists (i.e. is already instantiated).
- Parameters:
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- classmethod find_instrument(name: str, instrument_class: type[T] | None = None) T | Instrument¶
Find an existing instrument by name.
- Parameters:
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- Returns:
The instrument found.
- Raises:
- property full_name: str¶
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any¶
Shortcut for getting a parameter from its name.
- Parameters:
param_name – The name of a parameter of this instrument.
- Returns:
The current value of the parameter.
Note
This is deprecated. Call get directly on the parameter.
- get_component(full_name: str) MetadatableWithName¶
Recursively get a component of the instrument by full_name.
- Parameters:
full_name – The name of the component to get.
- Returns:
The component with the given name.
- Raises:
KeyError – If the component does not exist.
- classmethod instances() list[Self]¶
Get all currently defined instances of this instrument class.
You can use this to get the objects back if you lose track of them, and it’s also used by the test system to find objects to test against.
- Returns:
A list of instances.
- invalidate_cache() None¶
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- static is_valid(instr_instance: Instrument) bool¶
Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a “valid” instrument.
- Parameters:
instr_instance – Instance of an Instrument class or its subclass.
- load_metadata(metadata: Mapping[str, Any]) None¶
Load metadata into this classes metadata dictionary.
- Parameters:
metadata – Metadata to load.
- property name: str¶
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]¶
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs = []¶
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: InstrumentBase | None¶
The parent instrument. By default, this is
None. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None¶
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters:
update – If
True, update the state by querying the instrument. IfFalse, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- classmethod record_instance(instance: Instrument) None¶
Record (a weak ref to) an instance in a class’s instance list.
Also records the instance in list of all instruments, and verifies that there are no other instruments with the same name.
This method is called after initialization of the instrument is completed.
- Parameters:
instance – Instance to record.
- Raises:
KeyError – If another instance with the same name is already present.
- classmethod remove_instance(instance: Instrument) None¶
Remove a particular instance from the record.
- Parameters:
instance – The instance to remove
- remove_parameter(name: str) None¶
Remove a Parameter from this instrument.
Unlike modifying the parameters dict directly, this method will make sure that the parameter is properly unbound from the instrument if the parameter is added as a real attribute to the instrument. If a property of the same name exists it will not be modified. If name is an attribute but not a parameter, it will not be modified.
- Parameters:
name – The name of the parameter to remove.
- Raises:
KeyError – If the parameter does not exist on the instrument.
- property root_instrument: InstrumentBase¶
The topmost parent of this module.
For the
root_instrumentthis isself.
- set(param_name: str, value: Any) None¶
Shortcut for setting a parameter from its name and new value.
- Parameters:
param_name – The name of a parameter of this instrument.
value – The new value to set.
Note
This is deprecated. Call set directly on the parameter.
- property short_name: str¶
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: bool | None = False) dict[str, Any]¶
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters:
update – Passed to snapshot_base.
- Returns:
Base snapshot.
- snapshot_base(update: bool | None = False, params_to_skip_update: Sequence[str] | None = None) dict[Any, Any]¶
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- 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_getattribute 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
cmdshould 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 method to write a command string to the hardware.
Subclasses that define a new hardware communication should override this method. Subclasses that transform
cmdshould instead overridewrite.- Parameters:
cmd – The string to send to the instrument.
- IDN¶
Standard IDN parameter, which queries the instrument for its ID
- parameters¶
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions¶
All the functions supported by this instrument. Usually populated via
add_function().
- submodules¶
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules¶
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
- log¶
- metadata¶
semi_cr.core.lab.drivers.opx_config module¶
- class semi_cr.core.lab.drivers.opx_config.OPXChannel(parent: InstrumentModule, name: str, channel_number: int, direction: str, **kwargs: Any)[source]¶
Bases:
InstrumentChannel- __getitem__(key: str) Callable[[...], Any] | Parameter¶
Delegate instrument[‘name’] to parameter or function ‘name’.
Note
This is deprecated. Use attributes directly or if dynamic attribute required look up via .parameters or .functions dictionaries
- add_function(name: str, **kwargs: Any) None¶
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters:
name – How the Function will be stored within
instrument.Functionsand 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[TParameter] | None = None, **kwargs: Any) TParameter¶
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
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises:
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- Returns:
The created Parameter.
- add_submodule(name: str, submodule: TSubmodule) TSubmodule¶
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
InstrumentModuleor aChannelTuple.- Parameters:
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises:
- Returns:
The submodule.
- property ancestors: tuple[InstrumentBase, ...]¶
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- call(func_name: str, *args: Any) Any¶
Shortcut for calling a function from its name.
- Parameters:
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns:
The return value of the function.
Note
This is deprecated. Call the function directly.
- delegate_attr_dicts = ['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 = []¶
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- property full_name: str¶
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any¶
Shortcut for getting a parameter from its name.
- Parameters:
param_name – The name of a parameter of this instrument.
- Returns:
The current value of the parameter.
Note
This is deprecated. Call get directly on the parameter.
- get_component(full_name: str) MetadatableWithName¶
Recursively get a component of the instrument by full_name.
- Parameters:
full_name – The name of the component to get.
- Returns:
The component with the given name.
- Raises:
KeyError – If the component does not exist.
- invalidate_cache() None¶
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- load_metadata(metadata: Mapping[str, Any]) None¶
Load metadata into this classes metadata dictionary.
- Parameters:
metadata – Metadata to load.
- property name: str¶
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]¶
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs = []¶
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: _TIB_co¶
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.
- remove_parameter(name: str) None¶
Remove a Parameter from this instrument.
Unlike modifying the parameters dict directly, this method will make sure that the parameter is properly unbound from the instrument if the parameter is added as a real attribute to the instrument. If a property of the same name exists it will not be modified. If name is an attribute but not a parameter, it will not be modified.
- Parameters:
name – The name of the parameter to remove.
- Raises:
KeyError – If the parameter does not exist on the instrument.
- property root_instrument: InstrumentBase¶
The topmost parent of this module.
For the
root_instrumentthis isself.
- set(param_name: str, value: Any) None¶
Shortcut for setting a parameter from its name and new value.
- Parameters:
param_name – The name of a parameter of this instrument.
value – The new value to set.
Note
This is deprecated. Call set directly on the parameter.
- property short_name: str¶
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: bool | None = False) dict[str, Any]¶
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters:
update – Passed to snapshot_base.
- Returns:
Base snapshot.
- snapshot_base(update: bool | None = False, params_to_skip_update: Sequence[str] | None = None) dict[Any, Any]¶
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- 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_getattribute 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¶
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions¶
All the functions supported by this instrument. Usually populated via
add_function().
- submodules¶
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules¶
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
- log¶
- metadata¶
- class semi_cr.core.lab.drivers.opx_config.OPXOutputChannel(parent: InstrumentModule, name: str, channel_number: int, intermediate_frequency: float = 10000000.0, sampling_rate: float = 2000000000.0, **kwargs: Any)[source]¶
Bases:
OPXChannel- __getitem__(key: str) Callable[[...], Any] | Parameter¶
Delegate instrument[‘name’] to parameter or function ‘name’.
Note
This is deprecated. Use attributes directly or if dynamic attribute required look up via .parameters or .functions dictionaries
- add_function(name: str, **kwargs: Any) None¶
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters:
name – How the Function will be stored within
instrument.Functionsand 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[TParameter] | None = None, **kwargs: Any) TParameter¶
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
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises:
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- Returns:
The created Parameter.
- add_submodule(name: str, submodule: TSubmodule) TSubmodule¶
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
InstrumentModuleor aChannelTuple.- Parameters:
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises:
- Returns:
The submodule.
- property ancestors: tuple[InstrumentBase, ...]¶
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- call(func_name: str, *args: Any) Any¶
Shortcut for calling a function from its name.
- Parameters:
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns:
The return value of the function.
Note
This is deprecated. Call the function directly.
- delegate_attr_dicts = ['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 = []¶
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- property full_name: str¶
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any¶
Shortcut for getting a parameter from its name.
- Parameters:
param_name – The name of a parameter of this instrument.
- Returns:
The current value of the parameter.
Note
This is deprecated. Call get directly on the parameter.
- get_component(full_name: str) MetadatableWithName¶
Recursively get a component of the instrument by full_name.
- Parameters:
full_name – The name of the component to get.
- Returns:
The component with the given name.
- Raises:
KeyError – If the component does not exist.
- invalidate_cache() None¶
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- load_metadata(metadata: Mapping[str, Any]) None¶
Load metadata into this classes metadata dictionary.
- Parameters:
metadata – Metadata to load.
- property name: str¶
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]¶
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs = []¶
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: _TIB_co¶
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.
- remove_parameter(name: str) None¶
Remove a Parameter from this instrument.
Unlike modifying the parameters dict directly, this method will make sure that the parameter is properly unbound from the instrument if the parameter is added as a real attribute to the instrument. If a property of the same name exists it will not be modified. If name is an attribute but not a parameter, it will not be modified.
- Parameters:
name – The name of the parameter to remove.
- Raises:
KeyError – If the parameter does not exist on the instrument.
- property root_instrument: InstrumentBase¶
The topmost parent of this module.
For the
root_instrumentthis isself.
- set(param_name: str, value: Any) None¶
Shortcut for setting a parameter from its name and new value.
- Parameters:
param_name – The name of a parameter of this instrument.
value – The new value to set.
Note
This is deprecated. Call set directly on the parameter.
- property short_name: str¶
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: bool | None = False) dict[str, Any]¶
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters:
update – Passed to snapshot_base.
- Returns:
Base snapshot.
- snapshot_base(update: bool | None = False, params_to_skip_update: Sequence[str] | None = None) dict[Any, Any]¶
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- 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_getattribute 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¶
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions¶
All the functions supported by this instrument. Usually populated via
add_function().
- submodules¶
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules¶
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
- log¶
- metadata¶
- class semi_cr.core.lab.drivers.opx_config.OPXInputChannel(parent: InstrumentModule, name: str, channel_number: int, intermediate_frequency: float = 10000000.0, time_of_flight: int = 28, sampling_rate: float = 2000000000.0, smearing: int = 0, **kwargs: Any)[source]¶
Bases:
OPXChannel- __getitem__(key: str) Callable[[...], Any] | Parameter¶
Delegate instrument[‘name’] to parameter or function ‘name’.
Note
This is deprecated. Use attributes directly or if dynamic attribute required look up via .parameters or .functions dictionaries
- add_function(name: str, **kwargs: Any) None¶
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters:
name – How the Function will be stored within
instrument.Functionsand 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[TParameter] | None = None, **kwargs: Any) TParameter¶
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
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises:
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- Returns:
The created Parameter.
- add_submodule(name: str, submodule: TSubmodule) TSubmodule¶
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
InstrumentModuleor aChannelTuple.- Parameters:
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises:
- Returns:
The submodule.
- property ancestors: tuple[InstrumentBase, ...]¶
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- call(func_name: str, *args: Any) Any¶
Shortcut for calling a function from its name.
- Parameters:
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns:
The return value of the function.
Note
This is deprecated. Call the function directly.
- delegate_attr_dicts = ['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 = []¶
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- property full_name: str¶
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any¶
Shortcut for getting a parameter from its name.
- Parameters:
param_name – The name of a parameter of this instrument.
- Returns:
The current value of the parameter.
Note
This is deprecated. Call get directly on the parameter.
- get_component(full_name: str) MetadatableWithName¶
Recursively get a component of the instrument by full_name.
- Parameters:
full_name – The name of the component to get.
- Returns:
The component with the given name.
- Raises:
KeyError – If the component does not exist.
- invalidate_cache() None¶
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- load_metadata(metadata: Mapping[str, Any]) None¶
Load metadata into this classes metadata dictionary.
- Parameters:
metadata – Metadata to load.
- property name: str¶
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]¶
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs = []¶
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: _TIB_co¶
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.
- remove_parameter(name: str) None¶
Remove a Parameter from this instrument.
Unlike modifying the parameters dict directly, this method will make sure that the parameter is properly unbound from the instrument if the parameter is added as a real attribute to the instrument. If a property of the same name exists it will not be modified. If name is an attribute but not a parameter, it will not be modified.
- Parameters:
name – The name of the parameter to remove.
- Raises:
KeyError – If the parameter does not exist on the instrument.
- property root_instrument: InstrumentBase¶
The topmost parent of this module.
For the
root_instrumentthis isself.
- set(param_name: str, value: Any) None¶
Shortcut for setting a parameter from its name and new value.
- Parameters:
param_name – The name of a parameter of this instrument.
value – The new value to set.
Note
This is deprecated. Call set directly on the parameter.
- property short_name: str¶
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: bool | None = False) dict[str, Any]¶
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters:
update – Passed to snapshot_base.
- Returns:
Base snapshot.
- snapshot_base(update: bool | None = False, params_to_skip_update: Sequence[str] | None = None) dict[Any, Any]¶
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- 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_getattribute 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¶
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions¶
All the functions supported by this instrument. Usually populated via
add_function().
- submodules¶
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules¶
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
- log¶
- metadata¶
- class semi_cr.core.lab.drivers.opx_config.OPXDigitalOutputChannel(parent: InstrumentModule, name: str, channel_number: int, trigger_id: str | None = None, port: int | None = None, intermediate_frequency: float | None = None, delay: int = 0, buffer: int = 0, **kwargs: Any)[source]¶
Bases:
OPXChannel- __getitem__(key: str) Callable[[...], Any] | Parameter¶
Delegate instrument[‘name’] to parameter or function ‘name’.
Note
This is deprecated. Use attributes directly or if dynamic attribute required look up via .parameters or .functions dictionaries
- add_function(name: str, **kwargs: Any) None¶
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters:
name – How the Function will be stored within
instrument.Functionsand 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[TParameter] | None = None, **kwargs: Any) TParameter¶
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
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises:
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- Returns:
The created Parameter.
- add_submodule(name: str, submodule: TSubmodule) TSubmodule¶
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
InstrumentModuleor aChannelTuple.- Parameters:
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises:
- Returns:
The submodule.
- property ancestors: tuple[InstrumentBase, ...]¶
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- call(func_name: str, *args: Any) Any¶
Shortcut for calling a function from its name.
- Parameters:
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns:
The return value of the function.
Note
This is deprecated. Call the function directly.
- delegate_attr_dicts = ['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 = []¶
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- property full_name: str¶
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any¶
Shortcut for getting a parameter from its name.
- Parameters:
param_name – The name of a parameter of this instrument.
- Returns:
The current value of the parameter.
Note
This is deprecated. Call get directly on the parameter.
- get_component(full_name: str) MetadatableWithName¶
Recursively get a component of the instrument by full_name.
- Parameters:
full_name – The name of the component to get.
- Returns:
The component with the given name.
- Raises:
KeyError – If the component does not exist.
- invalidate_cache() None¶
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- load_metadata(metadata: Mapping[str, Any]) None¶
Load metadata into this classes metadata dictionary.
- Parameters:
metadata – Metadata to load.
- property name: str¶
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]¶
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs = []¶
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: _TIB_co¶
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.
- remove_parameter(name: str) None¶
Remove a Parameter from this instrument.
Unlike modifying the parameters dict directly, this method will make sure that the parameter is properly unbound from the instrument if the parameter is added as a real attribute to the instrument. If a property of the same name exists it will not be modified. If name is an attribute but not a parameter, it will not be modified.
- Parameters:
name – The name of the parameter to remove.
- Raises:
KeyError – If the parameter does not exist on the instrument.
- property root_instrument: InstrumentBase¶
The topmost parent of this module.
For the
root_instrumentthis isself.
- set(param_name: str, value: Any) None¶
Shortcut for setting a parameter from its name and new value.
- Parameters:
param_name – The name of a parameter of this instrument.
value – The new value to set.
Note
This is deprecated. Call set directly on the parameter.
- property short_name: str¶
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: bool | None = False) dict[str, Any]¶
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters:
update – Passed to snapshot_base.
- Returns:
Base snapshot.
- snapshot_base(update: bool | None = False, params_to_skip_update: Sequence[str] | None = None) dict[Any, Any]¶
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- 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_getattribute 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¶
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions¶
All the functions supported by this instrument. Usually populated via
add_function().
- submodules¶
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules¶
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
- log¶
- metadata¶
- class semi_cr.core.lab.drivers.opx_config.FEMModule(parent: Instrument, name: str, controller: str, slot: int, module_type: str, connections: list[dict[str, Any]] | None = None, inputs: list[int] | dict[int, dict[str, Any]] | None = None, outputs: list[int] | dict[int, dict[str, Any]] | None = None, digital_outputs: list[int] | dict[int, dict[str, Any]] | None = None, **kwargs: Any)[source]¶
Bases:
InstrumentModule,ConnectionRoutable- get_terminal(terminal_name: str) OPXChannel[source]¶
- property graph: MultiDiGraph¶
- __getitem__(key: str) Callable[[...], Any] | Parameter¶
Delegate instrument[‘name’] to parameter or function ‘name’.
Note
This is deprecated. Use attributes directly or if dynamic attribute required look up via .parameters or .functions dictionaries
- add_function(name: str, **kwargs: Any) None¶
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters:
name – How the Function will be stored within
instrument.Functionsand 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[TParameter] | None = None, **kwargs: Any) TParameter¶
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
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises:
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- Returns:
The created Parameter.
- add_submodule(name: str, submodule: TSubmodule) TSubmodule¶
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
InstrumentModuleor aChannelTuple.- Parameters:
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises:
- Returns:
The submodule.
- property ancestors: tuple[InstrumentBase, ...]¶
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- call(func_name: str, *args: Any) Any¶
Shortcut for calling a function from its name.
- Parameters:
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns:
The return value of the function.
Note
This is deprecated. Call the function directly.
- delegate_attr_dicts = ['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 = []¶
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- property full_name: str¶
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any¶
Shortcut for getting a parameter from its name.
- Parameters:
param_name – The name of a parameter of this instrument.
- Returns:
The current value of the parameter.
Note
This is deprecated. Call get directly on the parameter.
- get_component(full_name: str) MetadatableWithName¶
Recursively get a component of the instrument by full_name.
- Parameters:
full_name – The name of the component to get.
- Returns:
The component with the given name.
- Raises:
KeyError – If the component does not exist.
- invalidate_cache() None¶
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- load_metadata(metadata: Mapping[str, Any]) None¶
Load metadata into this classes metadata dictionary.
- Parameters:
metadata – Metadata to load.
- property name: str¶
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]¶
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs = []¶
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: _TIB_co¶
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.
- remove_parameter(name: str) None¶
Remove a Parameter from this instrument.
Unlike modifying the parameters dict directly, this method will make sure that the parameter is properly unbound from the instrument if the parameter is added as a real attribute to the instrument. If a property of the same name exists it will not be modified. If name is an attribute but not a parameter, it will not be modified.
- Parameters:
name – The name of the parameter to remove.
- Raises:
KeyError – If the parameter does not exist on the instrument.
- property root_instrument: InstrumentBase¶
The topmost parent of this module.
For the
root_instrumentthis isself.
- set(param_name: str, value: Any) None¶
Shortcut for setting a parameter from its name and new value.
- Parameters:
param_name – The name of a parameter of this instrument.
value – The new value to set.
Note
This is deprecated. Call set directly on the parameter.
- property short_name: str¶
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: bool | None = False) dict[str, Any]¶
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters:
update – Passed to snapshot_base.
- Returns:
Base snapshot.
- snapshot_base(update: bool | None = False, params_to_skip_update: Sequence[str] | None = None) dict[Any, Any]¶
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- 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_getattribute 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¶
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions¶
All the functions supported by this instrument. Usually populated via
add_function().
- submodules¶
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules¶
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
- log¶
- metadata¶
- class semi_cr.core.lab.drivers.opx_config.TriggerConfig(id: 'str | None' = None, port: 'int | None' = None, intermediate_frequency: 'float | None' = None, delay: 'float' = 0, buffer: 'int' = 0)[source]¶
Bases:
object
- class semi_cr.core.lab.drivers.opx_config.OPX1000(*args: Any, **kwargs: Any)[source]¶
Bases:
Instrument,ConnectionRoutable- get_idn() dict[str, str | None][source]¶
Parse a standard VISA
*IDN?response into an ID dict.Even though this is the VISA standard, it applies to various other types as well, such as IPInstruments, so it is included here in the Instrument base class.
Override this if your instrument does not support
*IDN?or returns a nonstandard IDN string. This string is supposed to be a comma-separated list of vendor, model, serial, and firmware, but semicolon and colon are also common separators so we accept them here as well.- Returns:
A dict containing vendor, model, serial, and firmware.
- property graph: MultiDiGraph¶
- __getitem__(key: str) Callable[[...], Any] | Parameter¶
Delegate instrument[‘name’] to parameter or function ‘name’.
Note
This is deprecated. Use attributes directly or if dynamic attribute required look up via .parameters or .functions dictionaries
- add_function(name: str, **kwargs: Any) None¶
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters:
name – How the Function will be stored within
instrument.Functionsand 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[TParameter] | None = None, **kwargs: Any) TParameter¶
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
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises:
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- Returns:
The created Parameter.
- add_submodule(name: str, submodule: TSubmodule) TSubmodule¶
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
InstrumentModuleor aChannelTuple.- Parameters:
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises:
- Returns:
The submodule.
- property ancestors: tuple[InstrumentBase, ...]¶
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- ask(cmd: str) str¶
Write a command string to the hardware and return a response.
Subclasses that transform
cmdshould 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 method to write to the hardware and return a response.
Subclasses that define a new hardware communication should override this method. Subclasses that transform
cmdshould instead overrideask.- Parameters:
cmd – The string to send to the instrument.
- call(func_name: str, *args: Any) Any¶
Shortcut for calling a function from its name.
- Parameters:
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns:
The return value of the function.
Note
This is deprecated. Call the function directly.
- close() None¶
Irreversibly stop this instrument and free its resources.
Subclasses should override this if they have other specific resources to close.
- classmethod close_all() None¶
Try to close all instruments registered in
_all_instrumentsThis is handy for use with atexit to ensure that all instruments are closed when a python session is closed.Examples
>>> atexit.register(qc.Instrument.close_all())
- connect_message(idn_param: str = 'IDN', begin_time: float | None = None) None¶
Print a standard message on initial connection to an instrument.
- Parameters:
idn_param – Name of parameter that returns ID dict. Default
IDN.begin_time –
time.time()when init started. Default isself._t0, set at start ofInstrument.__init__.
- delegate_attr_dicts = ['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 = []¶
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- static exist(name: str, instrument_class: type[Instrument] | None = None) bool¶
Check if an instrument with a given names exists (i.e. is already instantiated).
- Parameters:
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- classmethod find_instrument(name: str, instrument_class: type[T] | None = None) T | Instrument¶
Find an existing instrument by name.
- Parameters:
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- Returns:
The instrument found.
- Raises:
- property full_name: str¶
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any¶
Shortcut for getting a parameter from its name.
- Parameters:
param_name – The name of a parameter of this instrument.
- Returns:
The current value of the parameter.
Note
This is deprecated. Call get directly on the parameter.
- get_component(full_name: str) MetadatableWithName¶
Recursively get a component of the instrument by full_name.
- Parameters:
full_name – The name of the component to get.
- Returns:
The component with the given name.
- Raises:
KeyError – If the component does not exist.
- classmethod instances() list[Self]¶
Get all currently defined instances of this instrument class.
You can use this to get the objects back if you lose track of them, and it’s also used by the test system to find objects to test against.
- Returns:
A list of instances.
- invalidate_cache() None¶
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- static is_valid(instr_instance: Instrument) bool¶
Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a “valid” instrument.
- Parameters:
instr_instance – Instance of an Instrument class or its subclass.
- load_metadata(metadata: Mapping[str, Any]) None¶
Load metadata into this classes metadata dictionary.
- Parameters:
metadata – Metadata to load.
- property name: str¶
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]¶
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs = []¶
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: InstrumentBase | None¶
The parent instrument. By default, this is
None. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None¶
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters:
update – If
True, update the state by querying the instrument. IfFalse, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- classmethod record_instance(instance: Instrument) None¶
Record (a weak ref to) an instance in a class’s instance list.
Also records the instance in list of all instruments, and verifies that there are no other instruments with the same name.
This method is called after initialization of the instrument is completed.
- Parameters:
instance – Instance to record.
- Raises:
KeyError – If another instance with the same name is already present.
- classmethod remove_instance(instance: Instrument) None¶
Remove a particular instance from the record.
- Parameters:
instance – The instance to remove
- remove_parameter(name: str) None¶
Remove a Parameter from this instrument.
Unlike modifying the parameters dict directly, this method will make sure that the parameter is properly unbound from the instrument if the parameter is added as a real attribute to the instrument. If a property of the same name exists it will not be modified. If name is an attribute but not a parameter, it will not be modified.
- Parameters:
name – The name of the parameter to remove.
- Raises:
KeyError – If the parameter does not exist on the instrument.
- property root_instrument: InstrumentBase¶
The topmost parent of this module.
For the
root_instrumentthis isself.
- set(param_name: str, value: Any) None¶
Shortcut for setting a parameter from its name and new value.
- Parameters:
param_name – The name of a parameter of this instrument.
value – The new value to set.
Note
This is deprecated. Call set directly on the parameter.
- property short_name: str¶
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: bool | None = False) dict[str, Any]¶
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters:
update – Passed to snapshot_base.
- Returns:
Base snapshot.
- snapshot_base(update: bool | None = False, params_to_skip_update: Sequence[str] | None = None) dict[Any, Any]¶
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- 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_getattribute 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
cmdshould 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 method to write a command string to the hardware.
Subclasses that define a new hardware communication should override this method. Subclasses that transform
cmdshould instead overridewrite.- Parameters:
cmd – The string to send to the instrument.
- IDN¶
Standard IDN parameter, which queries the instrument for its ID
- parameters¶
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions¶
All the functions supported by this instrument. Usually populated via
add_function().
- submodules¶
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules¶
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
- log¶
- metadata¶
semi_cr.core.lab.drivers.proteox module¶
- class semi_cr.core.lab.drivers.proteox.Proteox(*args: Any, **kwargs: Any)[source]¶
Bases:
Instrument- get_idn() dict[str, str | None][source]¶
Override Instrument.get_idn so QCoDeS never calls self.ask(’*IDN?’).
- __getitem__(key: str) Callable[[...], Any] | Parameter¶
Delegate instrument[‘name’] to parameter or function ‘name’.
Note
This is deprecated. Use attributes directly or if dynamic attribute required look up via .parameters or .functions dictionaries
- add_function(name: str, **kwargs: Any) None¶
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters:
name – How the Function will be stored within
instrument.Functionsand 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[TParameter] | None = None, **kwargs: Any) TParameter¶
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
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises:
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- Returns:
The created Parameter.
- add_submodule(name: str, submodule: TSubmodule) TSubmodule¶
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
InstrumentModuleor aChannelTuple.- Parameters:
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises:
- Returns:
The submodule.
- property ancestors: tuple[InstrumentBase, ...]¶
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- ask(cmd: str) str¶
Write a command string to the hardware and return a response.
Subclasses that transform
cmdshould 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 method to write to the hardware and return a response.
Subclasses that define a new hardware communication should override this method. Subclasses that transform
cmdshould instead overrideask.- Parameters:
cmd – The string to send to the instrument.
- call(func_name: str, *args: Any) Any¶
Shortcut for calling a function from its name.
- Parameters:
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns:
The return value of the function.
Note
This is deprecated. Call the function directly.
- close() None¶
Irreversibly stop this instrument and free its resources.
Subclasses should override this if they have other specific resources to close.
- classmethod close_all() None¶
Try to close all instruments registered in
_all_instrumentsThis is handy for use with atexit to ensure that all instruments are closed when a python session is closed.Examples
>>> atexit.register(qc.Instrument.close_all())
- connect_message(idn_param: str = 'IDN', begin_time: float | None = None) None¶
Print a standard message on initial connection to an instrument.
- Parameters:
idn_param – Name of parameter that returns ID dict. Default
IDN.begin_time –
time.time()when init started. Default isself._t0, set at start ofInstrument.__init__.
- delegate_attr_dicts = ['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 = []¶
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- static exist(name: str, instrument_class: type[Instrument] | None = None) bool¶
Check if an instrument with a given names exists (i.e. is already instantiated).
- Parameters:
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- classmethod find_instrument(name: str, instrument_class: type[T] | None = None) T | Instrument¶
Find an existing instrument by name.
- Parameters:
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- Returns:
The instrument found.
- Raises:
- property full_name: str¶
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any¶
Shortcut for getting a parameter from its name.
- Parameters:
param_name – The name of a parameter of this instrument.
- Returns:
The current value of the parameter.
Note
This is deprecated. Call get directly on the parameter.
- get_component(full_name: str) MetadatableWithName¶
Recursively get a component of the instrument by full_name.
- Parameters:
full_name – The name of the component to get.
- Returns:
The component with the given name.
- Raises:
KeyError – If the component does not exist.
- classmethod instances() list[Self]¶
Get all currently defined instances of this instrument class.
You can use this to get the objects back if you lose track of them, and it’s also used by the test system to find objects to test against.
- Returns:
A list of instances.
- invalidate_cache() None¶
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- static is_valid(instr_instance: Instrument) bool¶
Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a “valid” instrument.
- Parameters:
instr_instance – Instance of an Instrument class or its subclass.
- load_metadata(metadata: Mapping[str, Any]) None¶
Load metadata into this classes metadata dictionary.
- Parameters:
metadata – Metadata to load.
- property name: str¶
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]¶
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs = []¶
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: InstrumentBase | None¶
The parent instrument. By default, this is
None. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None¶
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters:
update – If
True, update the state by querying the instrument. IfFalse, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- classmethod record_instance(instance: Instrument) None¶
Record (a weak ref to) an instance in a class’s instance list.
Also records the instance in list of all instruments, and verifies that there are no other instruments with the same name.
This method is called after initialization of the instrument is completed.
- Parameters:
instance – Instance to record.
- Raises:
KeyError – If another instance with the same name is already present.
- classmethod remove_instance(instance: Instrument) None¶
Remove a particular instance from the record.
- Parameters:
instance – The instance to remove
- remove_parameter(name: str) None¶
Remove a Parameter from this instrument.
Unlike modifying the parameters dict directly, this method will make sure that the parameter is properly unbound from the instrument if the parameter is added as a real attribute to the instrument. If a property of the same name exists it will not be modified. If name is an attribute but not a parameter, it will not be modified.
- Parameters:
name – The name of the parameter to remove.
- Raises:
KeyError – If the parameter does not exist on the instrument.
- property root_instrument: InstrumentBase¶
The topmost parent of this module.
For the
root_instrumentthis isself.
- set(param_name: str, value: Any) None¶
Shortcut for setting a parameter from its name and new value.
- Parameters:
param_name – The name of a parameter of this instrument.
value – The new value to set.
Note
This is deprecated. Call set directly on the parameter.
- property short_name: str¶
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: bool | None = False) dict[str, Any]¶
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters:
update – Passed to snapshot_base.
- Returns:
Base snapshot.
- snapshot_base(update: bool | None = False, params_to_skip_update: Sequence[str] | None = None) dict[Any, Any]¶
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- 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_getattribute 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
cmdshould 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 method to write a command string to the hardware.
Subclasses that define a new hardware communication should override this method. Subclasses that transform
cmdshould instead overridewrite.- Parameters:
cmd – The string to send to the instrument.
- IDN¶
Standard IDN parameter, which queries the instrument for its ID
- parameters¶
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions¶
All the functions supported by this instrument. Usually populated via
add_function().
- submodules¶
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules¶
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
- log¶
- metadata¶
semi_cr.core.lab.drivers.qdacii module¶
- class semi_cr.core.lab.drivers.qdacii.QdaciiChannel(parent: Qdacii, name: str, channel: int, role: str | None = None, enabled: bool = True)[source]¶
Bases:
QDac2Channel,Routable- property role¶
- property is_enabled¶
- property channel_number¶
- property graph: MultiDiGraph¶
- __getitem__(key: str) Callable[[...], Any] | Parameter¶
Delegate instrument[‘name’] to parameter or function ‘name’.
Note
This is deprecated. Use attributes directly or if dynamic attribute required look up via .parameters or .functions dictionaries
- add_function(name: str, **kwargs: Any) None¶
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters:
name – How the Function will be stored within
instrument.Functionsand 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[TParameter] | None = None, **kwargs: Any) TParameter¶
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
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises:
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- Returns:
The created Parameter.
- add_submodule(name: str, submodule: TSubmodule) TSubmodule¶
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
InstrumentModuleor aChannelTuple.- Parameters:
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises:
- Returns:
The submodule.
- property ancestors: tuple[InstrumentBase, ...]¶
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- arbitrary_wave(trace_name: str, repetitions: int = 1, scale: float = 1.0, offset_V: float = 0.0, slew_V_s: float | None = None) Awg_Context¶
Set up an arbitrary-wave generator
- Parameters:
- Returns:
context manager
- Return type:
Awg_Context
- 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.
Note
This is deprecated. Call the function directly.
- clear_measurements() Sequence[float]¶
Retrieve current measurements
The available measurements will be removed from measurement queue.
- Returns:
list of available current measurements
- Return type:
Sequence[float]
- dc_list(voltages: Sequence[float], repetitions: int = 1, dwell_s: float = 0.001, delay_s: float = 0, backwards: bool = False, stepped: bool = False) List_Context¶
Set up a DC-list generator
- Parameters:
voltages (Sequence[float]) – Voltages in list
repetitions (int, optional) – Number of repetitions of the list (default 1)
dwell_s (float, optional) – Seconds between each voltage (default 1ms)
delay_s (float, optional) – Seconds of delay after receiving a trigger (default 0)
backwards (bool, optional) – Use list in reverse (default is forward)
stepped (bool, optional) – True means that each step needs to be triggered (default False)
- Returns:
context manager
- Return type:
List_Context
- dc_sweep(start_V: float, stop_V: float, points: int, repetitions: int = 1, dwell_s: float = 0.001, delay_s: float = 0, backwards=False, stepped=True) Sweep_Context¶
Set up a DC sweep
- Parameters:
start_V (float) – Start voltage
stop_V (float) – Send voltage
points (int) – Number of steps
repetitions (int, optional) – Number of repetition (default 1)
dwell_s (float, optional) – Seconds between each voltage (default 1ms)
delay_s (float, optional) – Seconds of delay after receiving a trigger (default 0)
backwards (bool, optional) – Sweep in reverse (default is forward)
stepped (bool, optional) – True means discrete steps (default True)
- Returns:
context manager
- Return type:
Sweep_Context
- delegate_attr_dicts = ['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 = []¶
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- property full_name: str¶
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any¶
Shortcut for getting a parameter from its name.
- Parameters:
param_name – The name of a parameter of this instrument.
- Returns:
The current value of the parameter.
Note
This is deprecated. Call get directly on the parameter.
- get_component(full_name: str) MetadatableWithName¶
Recursively get a component of the instrument by full_name.
- Parameters:
full_name – The name of the component to get.
- Returns:
The component with the given name.
- Raises:
KeyError – If the component does not exist.
- invalidate_cache() None¶
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- load_metadata(metadata: Mapping[str, Any]) None¶
Load metadata into this classes metadata dictionary.
- Parameters:
metadata – Metadata to load.
- measurement(delay_s: float = 0.0, repetitions: int = 1, current_range: str = 'high', aperture_s: float | None = None, nplc: int | None = None) Measurement_Context¶
Set up a sequence of current measurements
- Parameters:
delay_s (float, optional) – Seconds to delay the actual measurement after trigger (default 0)
repetitions (int, optional) – Number of consecutive measurements (default 1)
current_range (str, optional) – high (10mA, default) or low (200nA)
nplc (None, optional) – Integration time in power-line cycles (default 1)
aperture_s (None, optional) – Seconds of integration time instead of NPLC
- Returns:
context manager
- Return type:
Measurement_Context
- Raises:
ValueError – configuration error
- property name: str¶
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]¶
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs = []¶
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: _TIB_co¶
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.
- remove_parameter(name: str) None¶
Remove a Parameter from this instrument.
Unlike modifying the parameters dict directly, this method will make sure that the parameter is properly unbound from the instrument if the parameter is added as a real attribute to the instrument. If a property of the same name exists it will not be modified. If name is an attribute but not a parameter, it will not be modified.
- Parameters:
name – The name of the parameter to remove.
- Raises:
KeyError – If the parameter does not exist on the instrument.
- property root_instrument: InstrumentBase¶
The topmost parent of this module.
For the
root_instrumentthis isself.
- set(param_name: str, value: Any) None¶
Shortcut for setting a parameter from its name and new value.
- Parameters:
param_name – The name of a parameter of this instrument.
value – The new value to set.
Note
This is deprecated. Call set directly on the parameter.
- property short_name: str¶
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- sine_wave(frequency_Hz: float | None = None, period_s: float | None = None, repetitions: int = -1, inverted: bool = False, span_V: float = 0.2, offset_V: float = 0.0, delay_s: float = 0, slew_V_s: float | None = None) Sine_Context¶
Set up a sine-wave generator
- Parameters:
frequency_Hz (float, optional) – Frequency
period_s (float, optional) – Period length (instead of frequency)
repetitions (int, optional) – Number of repetition (default infinite)
inverted (bool, optional) – True means flipped (default False)
span_V (float, optional) – Voltage span (default 200mV)
offset_V (float, optional) – Offset (default 0V)
delay_s (float, optional) – Seconds of delay after receiving a trigger (default 0)
slew_V_s (None, optional) – Max slew rate in V/s (default None)
- Returns:
context manager
- Return type:
Sine_Context
- Raises:
ValueError – configuration error
- snapshot(update: bool | None = False) dict[str, Any]¶
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters:
update – Passed to snapshot_base.
- Returns:
Base snapshot.
- snapshot_base(update: bool | None = False, params_to_skip_update: Sequence[str] | None = None) dict[Any, Any]¶
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- 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_getattribute of those parameters instead.
- Returns:
base snapshot
- Return type:
- square_wave(frequency_Hz: float | None = None, period_s: float | None = None, repetitions: int = -1, duty_cycle_percent: float = 50.0, kind: str = 'symmetric', inverted: bool = False, span_V: float = 0.2, offset_V: float = 0.0, delay_s: float = 0, slew_V_s: float | None = None) Square_Context¶
Set up a square-wave generator
- Parameters:
frequency_Hz (float, optional) – Frequency
period_s (float, optional) – Period length (instead of frequency)
repetitions (int, optional) – Number of repetition (default infinite)
duty_cycle_percent (float, optional) – Percentage on-time (default 50%)
kind (str, optional) – Positive, negative or symmetric (default) around the offset
inverted (bool, optional) – True means flipped (default False)
span_V (float, optional) – Voltage span (default 200mV)
offset_V (float, optional) – Offset (default 0V)
delay_s (float, optional) – Seconds of delay after receiving a trigger (default 0)
slew_V_s (float, optional) – Max slew rate in V/s (default None)
- Returns:
context manager
- Return type:
Square_Context
- Raises:
ValueError – configuration error
- triangle_wave(frequency_Hz: float | None = None, period_s: float | None = None, repetitions: int = -1, duty_cycle_percent: float = 50.0, inverted: bool = False, span_V: float = 0.2, offset_V: float = 0.0, delay_s: float = 0, slew_V_s: float | None = None) Triangle_Context¶
Set up a triangle-wave generator
- Parameters:
frequency_Hz (float, optional) – Frequency
period_s (float, optional) – Period length (instead of frequency)
repetitions (int, optional) – Number of repetition (default infinite)
duty_cycle_percent (float, optional) – Percentage on-time (default 50%)
inverted (bool, optional) – True means flipped (default False)
span_V (float, optional) – Voltage span (default 200mV)
offset_V (float, optional) – Offset (default 0V)
delay_s (float, optional) – Seconds of delay after receiving a trigger (default 0)
slew_V_s (float, optional) – Max slew rate in V/s (default None)
- Returns:
context manager
- Return type:
Triangle_Context
- Raises:
ValueError – configuration error
- 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_channel(cmd: str) None¶
Inject channel number into SCPI command
- Parameters:
cmd (str) – Must contain a ‘{0}’ placeholder for the channel number
- write_channel_floats(cmd: str, values: Sequence[float]) None¶
Inject channel number and a list of values into SCPI command
The values are appended to the end of the command.
- parameters¶
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions¶
All the functions supported by this instrument. Usually populated via
add_function().
- submodules¶
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules¶
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
- log¶
- metadata¶
- class semi_cr.core.lab.drivers.qdacii.Qdacii(*args: Any, **kwargs: Any)[source]¶
Bases:
QDac2,ConnectionRoutableConnect to a QDAC-II
- Parameters:
- channel_list(channels: list[int]) ChannelList[source]¶
Return a locked QCoDeS ChannelList containing selected QDAC channels.
- configure_channels(channels: list[int], output_range: str | None = None, output_filter: str | None = None, slew_rate: float | None = None) ChannelList[source]¶
Configure selected QDAC channels and return them as a ChannelList.
- property graph: MultiDiGraph¶
- __getitem__(key: str) Callable[[...], Any] | Parameter¶
Delegate instrument[‘name’] to parameter or function ‘name’.
Note
This is deprecated. Use attributes directly or if dynamic attribute required look up via .parameters or .functions dictionaries
- add_function(name: str, **kwargs: Any) None¶
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters:
name – How the Function will be stored within
instrument.Functionsand 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[TParameter] | None = None, **kwargs: Any) TParameter¶
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
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises:
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- Returns:
The created Parameter.
- add_submodule(name: str, submodule: TSubmodule) TSubmodule¶
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
InstrumentModuleor aChannelTuple.- Parameters:
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises:
- Returns:
The submodule.
- property address: str | None¶
The VISA resource name used to connect to this instrument. Note that pyvisa normalizes the resource name when connecting, so this may not be exactly the same as the address that was passed in when creating the instrument.
- allocate_trigger() QDac2Trigger_Context¶
Allocate an internal trigger
Does not have any effect on the instrument, only the driver.
- Returns:
Context manager
- Return type:
QDac2Trigger_Context
- Raises:
ValueError – no free triggers
- property ancestors: tuple[InstrumentBase, ...]¶
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- arrange(contacts: Dict[str, int], output_triggers: Dict[str, int] | None = None, internal_triggers: Sequence[str] | None = None, outer_trigger_channel: int | None = None) Arrangement_Context¶
An arrangement of contacts and triggers for virtual gates
Each contact corresponds to a particular output channel. Each output_trigger corresponds to a particular external output trigger. Each internal_trigger will be allocated from the pool of internal triggers, and can later be used for synchronisation. After initialisation of the arrangement, contacts and triggers can only be referred to by name.
The voltages that will appear on each contact depends not only on the specified virtual voltage, but also on a correction matrix. Initially, the contacts are assumed to not influence each other, which means that the correction matrix is the identity matrix, ie. the row for each contact has a value of [0, …, 0, 1, 0, …, 0].
- Parameters:
- Returns:
context manager
- Return type:
Arrangement_Context
- 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.
Note
This is deprecated. Call the function directly.
- channel(ch: int) QDac2Channel¶
- Parameters:
ch (int) – Channel number
- Returns:
Visa representation of the channel
- Return type:
QDac2Channel
- clear_read_queue() Sequence[str]¶
Flush the VISA message queue of the instrument
Takes at least _message_flush_timeout_ms to carry out.
- Returns:
Messages lingering in queue
- Return type:
Sequence[str]
- classmethod close_all() None¶
Try to close all instruments registered in
_all_instrumentsThis 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_external_trigger(port: int, trigger: QDac2Trigger_Context, width_s: float = 1e-06) None¶
Route internal trigger to external trigger
- connect_message(idn_param: str = 'IDN', begin_time: float | None = None) None¶
Print a standard message on initial connection to an instrument.
- Parameters:
idn_param – Name of parameter that returns ID dict. Default
IDN.begin_time –
time.time()when init started. Default isself._t0, set at start ofInstrument.__init__.
- default_terminator = None¶
The default terminator to use if the terminator is not specified when creating the instrument. None means use the default terminator from PyVisa.
- default_timeout = 5¶
The default timeout in seconds if the timeout is not specified when creating the instrument. None means no timeout e.g. wait forever.
- delegate_attr_dicts = ['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 = []¶
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- errors() str¶
Retrieve and clear all previous errors
- Returns:
Comma separated list of errors or ‘0, “No error”’
- Return type:
- static exist(name: str, instrument_class: type[Instrument] | None = None) bool¶
Check if an instrument with a given names exists (i.e. is already instantiated).
- Parameters:
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- classmethod find_instrument(name: str, instrument_class: type[T] | None = None) T | Instrument¶
Find an existing instrument by name.
- Parameters:
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- Returns:
The instrument found.
- Raises:
- free_all_triggers() None¶
Free all an internal triggers
Does not have any effect on the instrument, only the driver.
- free_trigger(trigger: QDac2Trigger_Context) None¶
Free an internal trigger
Does not have any effect on the instrument, only the driver.
- Parameters:
trigger (QDac2Trigger_Context) – trigger to free
- property full_name: str¶
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any¶
Shortcut for getting a parameter from its name.
- Parameters:
param_name – The name of a parameter of this instrument.
- Returns:
The current value of the parameter.
Note
This is deprecated. Call get directly on the parameter.
- get_component(full_name: str) MetadatableWithName¶
Recursively get a component of the instrument by full_name.
- Parameters:
full_name – The name of the component to get.
- Returns:
The component with the given name.
- Raises:
KeyError – If the component does not exist.
- get_idn() dict[str, str | None]¶
Parse a standard VISA
*IDN?response into an ID dict.Even though this is the VISA standard, it applies to various other types as well, such as IPInstruments, so it is included here in the Instrument base class.
Override this if your instrument does not support
*IDN?or returns a nonstandard IDN string. This string is supposed to be a comma-separated list of vendor, model, serial, and firmware, but semicolon and colon are also common separators so we accept them here as well.- Returns:
A dict containing vendor, model, serial, and firmware.
- get_recorded_scpi_commands() List[str]¶
- Returns:
SCPI commands sent to the instrument
- Return type:
Sequence[str]
- classmethod instances() list[Self]¶
Get all currently defined instances of this instrument class.
You can use this to get the objects back if you lose track of them, and it’s also used by the test system to find objects to test against.
- Returns:
A list of instances.
- invalidate_cache() None¶
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- static is_valid(instr_instance: Instrument) bool¶
Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a “valid” instrument.
- Parameters:
instr_instance – Instance of an Instrument class or its subclass.
- load_metadata(metadata: Mapping[str, Any]) None¶
Load metadata into this classes metadata dictionary.
- Parameters:
metadata – Metadata to load.
- property name: str¶
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]¶
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs = []¶
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: InstrumentBase | None¶
The parent instrument. By default, this is
None. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None¶
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters:
update – If
True, update the state by querying the instrument. IfFalse, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- classmethod record_instance(instance: Instrument) None¶
Record (a weak ref to) an instance in a class’s instance list.
Also records the instance in list of all instruments, and verifies that there are no other instruments with the same name.
This method is called after initialization of the instrument is completed.
- Parameters:
instance – Instance to record.
- Raises:
KeyError – If another instance with the same name is already present.
- classmethod remove_instance(instance: Instrument) None¶
Remove a particular instance from the record.
- Parameters:
instance – The instance to remove
- remove_parameter(name: str) None¶
Remove a Parameter from this instrument.
Unlike modifying the parameters dict directly, this method will make sure that the parameter is properly unbound from the instrument if the parameter is added as a real attribute to the instrument. If a property of the same name exists it will not be modified. If name is an attribute but not a parameter, it will not be modified.
- Parameters:
name – The name of the parameter to remove.
- Raises:
KeyError – If the parameter does not exist on the instrument.
- remove_traces() None¶
Delete all trace definitions from the instrument
This means that all AWGs loose their data.
- property resource_manager: ResourceManager | None¶
The VISA resource manager used by this instrument.
- property root_instrument: InstrumentBase¶
The topmost parent of this module.
For the
root_instrumentthis isself.
- set(param_name: str, value: Any) None¶
Shortcut for setting a parameter from its name and new value.
- Parameters:
param_name – The name of a parameter of this instrument.
value – The new value to set.
Note
This is deprecated. Call set directly on the parameter.
- set_address(address: str, visalib: str | None) None¶
Set the address for this instrument. Note in most cases this method is not recommended and it is better to close the instrument and create a new instance of the instrument with the new address.
- 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 visalib argument
visalib – Visa backend to use when connecting to this instrument. If not supplied use the default backend.
- set_terminator(terminator: str | None) None¶
Change the read terminator to use.
- Parameters:
terminator – Character(s) to look for at the end of a read and to end each write command with. eg.
\r\n. If None the terminator will not be set.
- property short_name: str¶
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: bool | None = False) dict[str, Any]¶
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters:
update – Passed to snapshot_base.
- Returns:
Base snapshot.
- snapshot_base(update: bool | None = True, params_to_skip_update: Sequence[str] | None = None) dict[Any, Any]¶
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- 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_getattribute of those parameters instead.
- Returns:
base snapshot
- Return type:
- start_all() None¶
Trigger the global SCPI bus (
*TRG)All generators, that have not been explicitly set to trigger on an internal or external trigger, will be started.
- start_recording_scpi() None¶
Record all SCPI commands sent to the instrument
Any previous recordings are removed. To inspect the SCPI commands sent to the instrument, call get_recorded_scpi_commands().
- 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.
- property visa_handle: MessageBasedResource¶
The VISA resource used by this instrument.
- write_floats(cmd: str, values: Sequence[float]) None¶
Append a list of values to a SCPI command
By default, the values are IEEE binary encoded.
Remember to include separating space in command if needed.
- write_raw(cmd: str) None¶
Low-level interface to
visa_handle.write.- Parameters:
cmd – The command to send to the instrument.
- IDN¶
Standard IDN parameter, which queries the instrument for its ID
- parameters¶
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions¶
All the functions supported by this instrument. Usually populated via
add_function().
- submodules¶
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules¶
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
- log¶
- metadata¶
semi_cr.core.lab.drivers.spirack module¶
- class semi_cr.core.lab.drivers.spirack.D5aChannel(parent, name: str, d5a: D5a_module, channel: int, role: str | None = None, enabled: bool = True)[source]¶
Bases:
InstrumentChannel,Routable- property graph: MultiDiGraph¶
- __getitem__(key: str) Callable[[...], Any] | Parameter¶
Delegate instrument[‘name’] to parameter or function ‘name’.
Note
This is deprecated. Use attributes directly or if dynamic attribute required look up via .parameters or .functions dictionaries
- add_function(name: str, **kwargs: Any) None¶
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters:
name – How the Function will be stored within
instrument.Functionsand 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[TParameter] | None = None, **kwargs: Any) TParameter¶
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
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises:
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- Returns:
The created Parameter.
- add_submodule(name: str, submodule: TSubmodule) TSubmodule¶
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
InstrumentModuleor aChannelTuple.- Parameters:
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises:
- Returns:
The submodule.
- property ancestors: tuple[InstrumentBase, ...]¶
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- call(func_name: str, *args: Any) Any¶
Shortcut for calling a function from its name.
- Parameters:
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns:
The return value of the function.
Note
This is deprecated. Call the function directly.
- delegate_attr_dicts = ['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 = []¶
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- property full_name: str¶
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any¶
Shortcut for getting a parameter from its name.
- Parameters:
param_name – The name of a parameter of this instrument.
- Returns:
The current value of the parameter.
Note
This is deprecated. Call get directly on the parameter.
- get_component(full_name: str) MetadatableWithName¶
Recursively get a component of the instrument by full_name.
- Parameters:
full_name – The name of the component to get.
- Returns:
The component with the given name.
- Raises:
KeyError – If the component does not exist.
- invalidate_cache() None¶
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- load_metadata(metadata: Mapping[str, Any]) None¶
Load metadata into this classes metadata dictionary.
- Parameters:
metadata – Metadata to load.
- property name: str¶
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]¶
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs = []¶
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: _TIB_co¶
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.
- remove_parameter(name: str) None¶
Remove a Parameter from this instrument.
Unlike modifying the parameters dict directly, this method will make sure that the parameter is properly unbound from the instrument if the parameter is added as a real attribute to the instrument. If a property of the same name exists it will not be modified. If name is an attribute but not a parameter, it will not be modified.
- Parameters:
name – The name of the parameter to remove.
- Raises:
KeyError – If the parameter does not exist on the instrument.
- property root_instrument: InstrumentBase¶
The topmost parent of this module.
For the
root_instrumentthis isself.
- set(param_name: str, value: Any) None¶
Shortcut for setting a parameter from its name and new value.
- Parameters:
param_name – The name of a parameter of this instrument.
value – The new value to set.
Note
This is deprecated. Call set directly on the parameter.
- property short_name: str¶
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: bool | None = False) dict[str, Any]¶
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters:
update – Passed to snapshot_base.
- Returns:
Base snapshot.
- snapshot_base(update: bool | None = False, params_to_skip_update: Sequence[str] | None = None) dict[Any, Any]¶
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- 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_getattribute 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¶
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions¶
All the functions supported by this instrument. Usually populated via
add_function().
- submodules¶
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules¶
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
- log¶
- metadata¶
- class semi_cr.core.lab.drivers.spirack.QcodesD5aModule(parent, name: str, spirack, slot: int, num_dacs: int = 16, reset_voltages: bool = False, connections: Sequence[dict[str, Any]] | None = None, channels: dict[str, Any] | None = None)[source]¶
Bases:
InstrumentModule,ConnectionRoutable- property channels: list[D5aChannel]¶
- property graph: MultiDiGraph¶
- __getitem__(key: str) Callable[[...], Any] | Parameter¶
Delegate instrument[‘name’] to parameter or function ‘name’.
Note
This is deprecated. Use attributes directly or if dynamic attribute required look up via .parameters or .functions dictionaries
- add_function(name: str, **kwargs: Any) None¶
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters:
name – How the Function will be stored within
instrument.Functionsand 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[TParameter] | None = None, **kwargs: Any) TParameter¶
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
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises:
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- Returns:
The created Parameter.
- add_submodule(name: str, submodule: TSubmodule) TSubmodule¶
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
InstrumentModuleor aChannelTuple.- Parameters:
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises:
- Returns:
The submodule.
- property ancestors: tuple[InstrumentBase, ...]¶
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- call(func_name: str, *args: Any) Any¶
Shortcut for calling a function from its name.
- Parameters:
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns:
The return value of the function.
Note
This is deprecated. Call the function directly.
- delegate_attr_dicts = ['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 = []¶
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- property full_name: str¶
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any¶
Shortcut for getting a parameter from its name.
- Parameters:
param_name – The name of a parameter of this instrument.
- Returns:
The current value of the parameter.
Note
This is deprecated. Call get directly on the parameter.
- get_component(full_name: str) MetadatableWithName¶
Recursively get a component of the instrument by full_name.
- Parameters:
full_name – The name of the component to get.
- Returns:
The component with the given name.
- Raises:
KeyError – If the component does not exist.
- invalidate_cache() None¶
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- load_metadata(metadata: Mapping[str, Any]) None¶
Load metadata into this classes metadata dictionary.
- Parameters:
metadata – Metadata to load.
- property name: str¶
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]¶
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs = []¶
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: _TIB_co¶
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.
- remove_parameter(name: str) None¶
Remove a Parameter from this instrument.
Unlike modifying the parameters dict directly, this method will make sure that the parameter is properly unbound from the instrument if the parameter is added as a real attribute to the instrument. If a property of the same name exists it will not be modified. If name is an attribute but not a parameter, it will not be modified.
- Parameters:
name – The name of the parameter to remove.
- Raises:
KeyError – If the parameter does not exist on the instrument.
- property root_instrument: InstrumentBase¶
The topmost parent of this module.
For the
root_instrumentthis isself.
- set(param_name: str, value: Any) None¶
Shortcut for setting a parameter from its name and new value.
- Parameters:
param_name – The name of a parameter of this instrument.
value – The new value to set.
Note
This is deprecated. Call set directly on the parameter.
- property short_name: str¶
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: bool | None = False) dict[str, Any]¶
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters:
update – Passed to snapshot_base.
- Returns:
Base snapshot.
- snapshot_base(update: bool | None = False, params_to_skip_update: Sequence[str] | None = None) dict[Any, Any]¶
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- 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_getattribute 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¶
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions¶
All the functions supported by this instrument. Usually populated via
add_function().
- submodules¶
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules¶
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
- log¶
- metadata¶
- class semi_cr.core.lab.drivers.spirack.QcodesM1gModule(parent, name: str, slot: int, gain_v_per_a: float, connections: Sequence[dict[str, Any]] | None = None, spirack=None, **kwargs)[source]¶
Bases:
InstrumentModule,ConnectionRoutable- __getitem__(key: str) Callable[[...], Any] | Parameter¶
Delegate instrument[‘name’] to parameter or function ‘name’.
Note
This is deprecated. Use attributes directly or if dynamic attribute required look up via .parameters or .functions dictionaries
- add_function(name: str, **kwargs: Any) None¶
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters:
name – How the Function will be stored within
instrument.Functionsand 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[TParameter] | None = None, **kwargs: Any) TParameter¶
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
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises:
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- Returns:
The created Parameter.
- add_submodule(name: str, submodule: TSubmodule) TSubmodule¶
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
InstrumentModuleor aChannelTuple.- Parameters:
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises:
- Returns:
The submodule.
- property ancestors: tuple[InstrumentBase, ...]¶
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- call(func_name: str, *args: Any) Any¶
Shortcut for calling a function from its name.
- Parameters:
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns:
The return value of the function.
Note
This is deprecated. Call the function directly.
- delegate_attr_dicts = ['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 = []¶
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- property full_name: str¶
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any¶
Shortcut for getting a parameter from its name.
- Parameters:
param_name – The name of a parameter of this instrument.
- Returns:
The current value of the parameter.
Note
This is deprecated. Call get directly on the parameter.
- get_component(full_name: str) MetadatableWithName¶
Recursively get a component of the instrument by full_name.
- Parameters:
full_name – The name of the component to get.
- Returns:
The component with the given name.
- Raises:
KeyError – If the component does not exist.
- property graph: MultiDiGraph¶
- invalidate_cache() None¶
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- load_metadata(metadata: Mapping[str, Any]) None¶
Load metadata into this classes metadata dictionary.
- Parameters:
metadata – Metadata to load.
- property name: str¶
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]¶
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs = []¶
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: _TIB_co¶
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.
- remove_parameter(name: str) None¶
Remove a Parameter from this instrument.
Unlike modifying the parameters dict directly, this method will make sure that the parameter is properly unbound from the instrument if the parameter is added as a real attribute to the instrument. If a property of the same name exists it will not be modified. If name is an attribute but not a parameter, it will not be modified.
- Parameters:
name – The name of the parameter to remove.
- Raises:
KeyError – If the parameter does not exist on the instrument.
- property root_instrument: InstrumentBase¶
The topmost parent of this module.
For the
root_instrumentthis isself.
- set(param_name: str, value: Any) None¶
Shortcut for setting a parameter from its name and new value.
- Parameters:
param_name – The name of a parameter of this instrument.
value – The new value to set.
Note
This is deprecated. Call set directly on the parameter.
- property short_name: str¶
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: bool | None = False) dict[str, Any]¶
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters:
update – Passed to snapshot_base.
- Returns:
Base snapshot.
- snapshot_base(update: bool | None = False, params_to_skip_update: Sequence[str] | None = None) dict[Any, Any]¶
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- 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_getattribute 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¶
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions¶
All the functions supported by this instrument. Usually populated via
add_function().
- submodules¶
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules¶
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
- log¶
- metadata¶
- class semi_cr.core.lab.drivers.spirack.QcodesVIModuleVoltageSource(parent, name: str, conversion_factor: float, connections: Sequence[dict[str, Any]] | None = None)[source]¶
Bases:
InstrumentModule,ConnectionRoutablePassive voltage-source section of a VI module.
It has no hardware commands. It only describes how a voltage from a controllable source, e.g. D5a.ch0, is converted to the voltage delivered at the VI module output.
- __getitem__(key: str) Callable[[...], Any] | Parameter¶
Delegate instrument[‘name’] to parameter or function ‘name’.
Note
This is deprecated. Use attributes directly or if dynamic attribute required look up via .parameters or .functions dictionaries
- add_function(name: str, **kwargs: Any) None¶
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters:
name – How the Function will be stored within
instrument.Functionsand 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[TParameter] | None = None, **kwargs: Any) TParameter¶
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
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises:
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- Returns:
The created Parameter.
- add_submodule(name: str, submodule: TSubmodule) TSubmodule¶
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
InstrumentModuleor aChannelTuple.- Parameters:
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises:
- Returns:
The submodule.
- property ancestors: tuple[InstrumentBase, ...]¶
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- call(func_name: str, *args: Any) Any¶
Shortcut for calling a function from its name.
- Parameters:
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns:
The return value of the function.
Note
This is deprecated. Call the function directly.
- delegate_attr_dicts = ['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 = []¶
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- property full_name: str¶
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any¶
Shortcut for getting a parameter from its name.
- Parameters:
param_name – The name of a parameter of this instrument.
- Returns:
The current value of the parameter.
Note
This is deprecated. Call get directly on the parameter.
- get_component(full_name: str) MetadatableWithName¶
Recursively get a component of the instrument by full_name.
- Parameters:
full_name – The name of the component to get.
- Returns:
The component with the given name.
- Raises:
KeyError – If the component does not exist.
- property graph: MultiDiGraph¶
- invalidate_cache() None¶
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- load_metadata(metadata: Mapping[str, Any]) None¶
Load metadata into this classes metadata dictionary.
- Parameters:
metadata – Metadata to load.
- property name: str¶
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]¶
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs = []¶
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: _TIB_co¶
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.
- remove_parameter(name: str) None¶
Remove a Parameter from this instrument.
Unlike modifying the parameters dict directly, this method will make sure that the parameter is properly unbound from the instrument if the parameter is added as a real attribute to the instrument. If a property of the same name exists it will not be modified. If name is an attribute but not a parameter, it will not be modified.
- Parameters:
name – The name of the parameter to remove.
- Raises:
KeyError – If the parameter does not exist on the instrument.
- property root_instrument: InstrumentBase¶
The topmost parent of this module.
For the
root_instrumentthis isself.
- set(param_name: str, value: Any) None¶
Shortcut for setting a parameter from its name and new value.
- Parameters:
param_name – The name of a parameter of this instrument.
value – The new value to set.
Note
This is deprecated. Call set directly on the parameter.
- property short_name: str¶
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: bool | None = False) dict[str, Any]¶
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters:
update – Passed to snapshot_base.
- Returns:
Base snapshot.
- snapshot_base(update: bool | None = False, params_to_skip_update: Sequence[str] | None = None) dict[Any, Any]¶
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- 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_getattribute 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¶
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions¶
All the functions supported by this instrument. Usually populated via
add_function().
- submodules¶
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules¶
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
- log¶
- metadata¶
- class semi_cr.core.lab.drivers.spirack.QcodesVIModule(parent, name: str, slot: int, voltage_conversion_factor: float, connections: Sequence[dict[str, Any]] | None = None, spirack=None, **kwargs)[source]¶
Bases:
InstrumentModule,ConnectionRoutable- property graph: MultiDiGraph¶
- __getitem__(key: str) Callable[[...], Any] | Parameter¶
Delegate instrument[‘name’] to parameter or function ‘name’.
Note
This is deprecated. Use attributes directly or if dynamic attribute required look up via .parameters or .functions dictionaries
- add_function(name: str, **kwargs: Any) None¶
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters:
name – How the Function will be stored within
instrument.Functionsand 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[TParameter] | None = None, **kwargs: Any) TParameter¶
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
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises:
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- Returns:
The created Parameter.
- add_submodule(name: str, submodule: TSubmodule) TSubmodule¶
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
InstrumentModuleor aChannelTuple.- Parameters:
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises:
- Returns:
The submodule.
- property ancestors: tuple[InstrumentBase, ...]¶
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- call(func_name: str, *args: Any) Any¶
Shortcut for calling a function from its name.
- Parameters:
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns:
The return value of the function.
Note
This is deprecated. Call the function directly.
- delegate_attr_dicts = ['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 = []¶
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- property full_name: str¶
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any¶
Shortcut for getting a parameter from its name.
- Parameters:
param_name – The name of a parameter of this instrument.
- Returns:
The current value of the parameter.
Note
This is deprecated. Call get directly on the parameter.
- get_component(full_name: str) MetadatableWithName¶
Recursively get a component of the instrument by full_name.
- Parameters:
full_name – The name of the component to get.
- Returns:
The component with the given name.
- Raises:
KeyError – If the component does not exist.
- invalidate_cache() None¶
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- load_metadata(metadata: Mapping[str, Any]) None¶
Load metadata into this classes metadata dictionary.
- Parameters:
metadata – Metadata to load.
- property name: str¶
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]¶
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs = []¶
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: _TIB_co¶
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.
- remove_parameter(name: str) None¶
Remove a Parameter from this instrument.
Unlike modifying the parameters dict directly, this method will make sure that the parameter is properly unbound from the instrument if the parameter is added as a real attribute to the instrument. If a property of the same name exists it will not be modified. If name is an attribute but not a parameter, it will not be modified.
- Parameters:
name – The name of the parameter to remove.
- Raises:
KeyError – If the parameter does not exist on the instrument.
- property root_instrument: InstrumentBase¶
The topmost parent of this module.
For the
root_instrumentthis isself.
- set(param_name: str, value: Any) None¶
Shortcut for setting a parameter from its name and new value.
- Parameters:
param_name – The name of a parameter of this instrument.
value – The new value to set.
Note
This is deprecated. Call set directly on the parameter.
- property short_name: str¶
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: bool | None = False) dict[str, Any]¶
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters:
update – Passed to snapshot_base.
- Returns:
Base snapshot.
- snapshot_base(update: bool | None = False, params_to_skip_update: Sequence[str] | None = None) dict[Any, Any]¶
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- 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_getattribute 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¶
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions¶
All the functions supported by this instrument. Usually populated via
add_function().
- submodules¶
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules¶
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
- log¶
- metadata¶
- class semi_cr.core.lab.drivers.spirack.QcodesB1aModule(parent, name: str, slot: int, connections: Sequence[dict[str, Any]] | None = None, spirack=None, **kwargs)[source]¶
Bases:
InstrumentModule,ConnectionRoutablePassive Break IN/OUT module. No SPI commands.
- __getitem__(key: str) Callable[[...], Any] | Parameter¶
Delegate instrument[‘name’] to parameter or function ‘name’.
Note
This is deprecated. Use attributes directly or if dynamic attribute required look up via .parameters or .functions dictionaries
- add_function(name: str, **kwargs: Any) None¶
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters:
name – How the Function will be stored within
instrument.Functionsand 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[TParameter] | None = None, **kwargs: Any) TParameter¶
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
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises:
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- Returns:
The created Parameter.
- add_submodule(name: str, submodule: TSubmodule) TSubmodule¶
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
InstrumentModuleor aChannelTuple.- Parameters:
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises:
- Returns:
The submodule.
- property ancestors: tuple[InstrumentBase, ...]¶
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- call(func_name: str, *args: Any) Any¶
Shortcut for calling a function from its name.
- Parameters:
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns:
The return value of the function.
Note
This is deprecated. Call the function directly.
- delegate_attr_dicts = ['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 = []¶
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- property full_name: str¶
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any¶
Shortcut for getting a parameter from its name.
- Parameters:
param_name – The name of a parameter of this instrument.
- Returns:
The current value of the parameter.
Note
This is deprecated. Call get directly on the parameter.
- get_component(full_name: str) MetadatableWithName¶
Recursively get a component of the instrument by full_name.
- Parameters:
full_name – The name of the component to get.
- Returns:
The component with the given name.
- Raises:
KeyError – If the component does not exist.
- property graph: MultiDiGraph¶
- invalidate_cache() None¶
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- load_metadata(metadata: Mapping[str, Any]) None¶
Load metadata into this classes metadata dictionary.
- Parameters:
metadata – Metadata to load.
- property name: str¶
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]¶
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs = []¶
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: _TIB_co¶
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.
- remove_parameter(name: str) None¶
Remove a Parameter from this instrument.
Unlike modifying the parameters dict directly, this method will make sure that the parameter is properly unbound from the instrument if the parameter is added as a real attribute to the instrument. If a property of the same name exists it will not be modified. If name is an attribute but not a parameter, it will not be modified.
- Parameters:
name – The name of the parameter to remove.
- Raises:
KeyError – If the parameter does not exist on the instrument.
- property root_instrument: InstrumentBase¶
The topmost parent of this module.
For the
root_instrumentthis isself.
- set(param_name: str, value: Any) None¶
Shortcut for setting a parameter from its name and new value.
- Parameters:
param_name – The name of a parameter of this instrument.
value – The new value to set.
Note
This is deprecated. Call set directly on the parameter.
- property short_name: str¶
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: bool | None = False) dict[str, Any]¶
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters:
update – Passed to snapshot_base.
- Returns:
Base snapshot.
- snapshot_base(update: bool | None = False, params_to_skip_update: Sequence[str] | None = None) dict[Any, Any]¶
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- 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_getattribute 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¶
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions¶
All the functions supported by this instrument. Usually populated via
add_function().
- submodules¶
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules¶
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
- log¶
- metadata¶
- class semi_cr.core.lab.drivers.spirack.QcodesR1Module(parent, name: str, slot: int, selected_position: str, connections: Sequence[dict[str, Any]] | None = None, spirack=None, **kwargs)[source]¶
Bases:
InstrumentModule,ConnectionRoutablePassive R1 resistance reference module.
Contains a manual knob selecting one of several resistors. Supports metadata for 2-probe and 4-probe wiring.
- RESISTANCES_OHM = {'0': 0.0, '10': 10, '100': 100, '100M': 100000000.0, '100k': 100000.0, '10M': 10000000.0, '10k': 10000.0, '1G': 1000000000.0, '1M': 1000000.0, '1k': 1000.0}¶
- __getitem__(key: str) Callable[[...], Any] | Parameter¶
Delegate instrument[‘name’] to parameter or function ‘name’.
Note
This is deprecated. Use attributes directly or if dynamic attribute required look up via .parameters or .functions dictionaries
- add_function(name: str, **kwargs: Any) None¶
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters:
name – How the Function will be stored within
instrument.Functionsand 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[TParameter] | None = None, **kwargs: Any) TParameter¶
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
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises:
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- Returns:
The created Parameter.
- add_submodule(name: str, submodule: TSubmodule) TSubmodule¶
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
InstrumentModuleor aChannelTuple.- Parameters:
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises:
- Returns:
The submodule.
- property ancestors: tuple[InstrumentBase, ...]¶
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- call(func_name: str, *args: Any) Any¶
Shortcut for calling a function from its name.
- Parameters:
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns:
The return value of the function.
Note
This is deprecated. Call the function directly.
- delegate_attr_dicts = ['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 = []¶
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- property full_name: str¶
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any¶
Shortcut for getting a parameter from its name.
- Parameters:
param_name – The name of a parameter of this instrument.
- Returns:
The current value of the parameter.
Note
This is deprecated. Call get directly on the parameter.
- get_component(full_name: str) MetadatableWithName¶
Recursively get a component of the instrument by full_name.
- Parameters:
full_name – The name of the component to get.
- Returns:
The component with the given name.
- Raises:
KeyError – If the component does not exist.
- property graph: MultiDiGraph¶
- invalidate_cache() None¶
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- load_metadata(metadata: Mapping[str, Any]) None¶
Load metadata into this classes metadata dictionary.
- Parameters:
metadata – Metadata to load.
- property name: str¶
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]¶
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs = []¶
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: _TIB_co¶
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.
- remove_parameter(name: str) None¶
Remove a Parameter from this instrument.
Unlike modifying the parameters dict directly, this method will make sure that the parameter is properly unbound from the instrument if the parameter is added as a real attribute to the instrument. If a property of the same name exists it will not be modified. If name is an attribute but not a parameter, it will not be modified.
- Parameters:
name – The name of the parameter to remove.
- Raises:
KeyError – If the parameter does not exist on the instrument.
- property root_instrument: InstrumentBase¶
The topmost parent of this module.
For the
root_instrumentthis isself.
- set(param_name: str, value: Any) None¶
Shortcut for setting a parameter from its name and new value.
- Parameters:
param_name – The name of a parameter of this instrument.
value – The new value to set.
Note
This is deprecated. Call set directly on the parameter.
- property short_name: str¶
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: bool | None = False) dict[str, Any]¶
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters:
update – Passed to snapshot_base.
- Returns:
Base snapshot.
- snapshot_base(update: bool | None = False, params_to_skip_update: Sequence[str] | None = None) dict[Any, Any]¶
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- 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_getattribute 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¶
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions¶
All the functions supported by this instrument. Usually populated via
add_function().
- submodules¶
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules¶
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
- log¶
- metadata¶
- class semi_cr.core.lab.drivers.spirack.SPIRackModules[source]¶
Bases:
object- add(name: str, module: InstrumentModule) None[source]¶
- class semi_cr.core.lab.drivers.spirack.QcodesSPIRack(*args: Any, **kwargs: Any)[source]¶
Bases:
Instrument- close()[source]¶
Irreversibly stop this instrument and free its resources.
Subclasses should override this if they have other specific resources to close.
- get_idn() dict[str, str | None][source]¶
Parse a standard VISA
*IDN?response into an ID dict.Even though this is the VISA standard, it applies to various other types as well, such as IPInstruments, so it is included here in the Instrument base class.
Override this if your instrument does not support
*IDN?or returns a nonstandard IDN string. This string is supposed to be a comma-separated list of vendor, model, serial, and firmware, but semicolon and colon are also common separators so we accept them here as well.- Returns:
A dict containing vendor, model, serial, and firmware.
- add_b1a_module(name: str, slot: int) QcodesB1aModule[source]¶
- property graph: MultiDiGraph¶
- __getitem__(key: str) Callable[[...], Any] | Parameter¶
Delegate instrument[‘name’] to parameter or function ‘name’.
Note
This is deprecated. Use attributes directly or if dynamic attribute required look up via .parameters or .functions dictionaries
- add_function(name: str, **kwargs: Any) None¶
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters:
name – How the Function will be stored within
instrument.Functionsand 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[TParameter] | None = None, **kwargs: Any) TParameter¶
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
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises:
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- Returns:
The created Parameter.
- add_submodule(name: str, submodule: TSubmodule) TSubmodule¶
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
InstrumentModuleor aChannelTuple.- Parameters:
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises:
- Returns:
The submodule.
- property ancestors: tuple[InstrumentBase, ...]¶
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- ask(cmd: str) str¶
Write a command string to the hardware and return a response.
Subclasses that transform
cmdshould 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 method to write to the hardware and return a response.
Subclasses that define a new hardware communication should override this method. Subclasses that transform
cmdshould instead overrideask.- Parameters:
cmd – The string to send to the instrument.
- call(func_name: str, *args: Any) Any¶
Shortcut for calling a function from its name.
- Parameters:
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns:
The return value of the function.
Note
This is deprecated. Call the function directly.
- classmethod close_all() None¶
Try to close all instruments registered in
_all_instrumentsThis is handy for use with atexit to ensure that all instruments are closed when a python session is closed.Examples
>>> atexit.register(qc.Instrument.close_all())
- connect_message(idn_param: str = 'IDN', begin_time: float | None = None) None¶
Print a standard message on initial connection to an instrument.
- Parameters:
idn_param – Name of parameter that returns ID dict. Default
IDN.begin_time –
time.time()when init started. Default isself._t0, set at start ofInstrument.__init__.
- delegate_attr_dicts = ['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 = []¶
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- static exist(name: str, instrument_class: type[Instrument] | None = None) bool¶
Check if an instrument with a given names exists (i.e. is already instantiated).
- Parameters:
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- classmethod find_instrument(name: str, instrument_class: type[T] | None = None) T | Instrument¶
Find an existing instrument by name.
- Parameters:
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- Returns:
The instrument found.
- Raises:
- property full_name: str¶
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any¶
Shortcut for getting a parameter from its name.
- Parameters:
param_name – The name of a parameter of this instrument.
- Returns:
The current value of the parameter.
Note
This is deprecated. Call get directly on the parameter.
- get_component(full_name: str) MetadatableWithName¶
Recursively get a component of the instrument by full_name.
- Parameters:
full_name – The name of the component to get.
- Returns:
The component with the given name.
- Raises:
KeyError – If the component does not exist.
- classmethod instances() list[Self]¶
Get all currently defined instances of this instrument class.
You can use this to get the objects back if you lose track of them, and it’s also used by the test system to find objects to test against.
- Returns:
A list of instances.
- invalidate_cache() None¶
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- static is_valid(instr_instance: Instrument) bool¶
Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a “valid” instrument.
- Parameters:
instr_instance – Instance of an Instrument class or its subclass.
- load_metadata(metadata: Mapping[str, Any]) None¶
Load metadata into this classes metadata dictionary.
- Parameters:
metadata – Metadata to load.
- property name: str¶
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]¶
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs = []¶
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: InstrumentBase | None¶
The parent instrument. By default, this is
None. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None¶
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters:
update – If
True, update the state by querying the instrument. IfFalse, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- classmethod record_instance(instance: Instrument) None¶
Record (a weak ref to) an instance in a class’s instance list.
Also records the instance in list of all instruments, and verifies that there are no other instruments with the same name.
This method is called after initialization of the instrument is completed.
- Parameters:
instance – Instance to record.
- Raises:
KeyError – If another instance with the same name is already present.
- classmethod remove_instance(instance: Instrument) None¶
Remove a particular instance from the record.
- Parameters:
instance – The instance to remove
- remove_parameter(name: str) None¶
Remove a Parameter from this instrument.
Unlike modifying the parameters dict directly, this method will make sure that the parameter is properly unbound from the instrument if the parameter is added as a real attribute to the instrument. If a property of the same name exists it will not be modified. If name is an attribute but not a parameter, it will not be modified.
- Parameters:
name – The name of the parameter to remove.
- Raises:
KeyError – If the parameter does not exist on the instrument.
- property root_instrument: InstrumentBase¶
The topmost parent of this module.
For the
root_instrumentthis isself.
- set(param_name: str, value: Any) None¶
Shortcut for setting a parameter from its name and new value.
- Parameters:
param_name – The name of a parameter of this instrument.
value – The new value to set.
Note
This is deprecated. Call set directly on the parameter.
- property short_name: str¶
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: bool | None = False) dict[str, Any]¶
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters:
update – Passed to snapshot_base.
- Returns:
Base snapshot.
- snapshot_base(update: bool | None = False, params_to_skip_update: Sequence[str] | None = None) dict[Any, Any]¶
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- 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_getattribute 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
cmdshould 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 method to write a command string to the hardware.
Subclasses that define a new hardware communication should override this method. Subclasses that transform
cmdshould instead overridewrite.- Parameters:
cmd – The string to send to the instrument.
- IDN¶
Standard IDN parameter, which queries the instrument for its ID
- parameters¶
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions¶
All the functions supported by this instrument. Usually populated via
add_function().
- submodules¶
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules¶
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
- log¶
- metadata¶