semi_cr.core.lab.virtualization package¶
Submodules¶
semi_cr.core.lab.virtualization.gate_virtualization module¶
- class semi_cr.core.lab.virtualization.gate_virtualization.M1Editor(gds: GDSFile | None = None, gate_names: list[str] | None = None, layer: VirtualGateLayer | None = None)[source]¶
Bases:
MatrixEditorEditor for MAViS M_1 sensor compensation matrix.
The M_1 matrix defines sensor compensation - how virtual gates map to physical gates. Rows are physical gates (from GDS file), columns are virtual gates (v-prefixed).
Voltage transformation: physical_voltages = M1 @ virtual_voltages
- Example: For gates [P1, P2, P3], creates a 3x3 identity matrix with:
Row headers: P1, P2, P3
Column headers: vP1, vP2, vP3
When a VirtualGateLayer is provided via the
layerargument, the editor drives the layer directly: voltage inputs set virtual gate Parameters on the layer, and matrix cell edits calllayer.set_matrix(). Physical voltage display is then read back from the layer’s downstream parameters. Whenlayeris None the editor works as a standalone calculator.- get_title() str[source]¶
Return a human-readable title for this component.
Used as the window label when the component is shown in standalone mode, and may appear in tab labels or headers when embedded.
- draw(parent_id: int | None = None)[source]¶
Draw the matrix editor with virtual/physical voltage controls.
- get_hovered_cell() tuple[int, int] | None¶
Return (row, col) of the hovered cell, or None if no cell is hovered.
- on_mouse_wheel(delta: float, mouse: MouseContext) bool¶
Handle mouse wheel event. Returns True if handled.
- value_to_color(val)¶
Map value to RGBA color (blue to red gradient).
semi_cr.core.lab.virtualization.virtual_gate_layer module¶
- class semi_cr.core.lab.virtualization.virtual_gate_layer.VirtualGateChannel(parent: VirtualGateLayer, name: str, index: int, **kwargs)[source]¶
Bases:
InstrumentModuleOne virtual gate channel of a VirtualGateLayer.
Setting the voltage triggers propagation through the transformation matrix to all downstream (physical) parameters.
- __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.virtualization.virtual_gate_layer.VirtualGateLayer(*args: Any, **kwargs: Any)[source]¶
Bases:
InstrumentLinear virtualization layer: physical = M @ virtual.
Maps N virtual gate voltages to M physical gate voltages (or the next virtualization layer’s inputs) via a transformation matrix. Layers can be chained or arranged in a tree structure.
When multiple virtual layers share the same physical downstream (tree structure), they are automatically registered as siblings. Propagating one sibling recomputes the others’ virtual values to stay consistent with the new physical state.
- Parameters:
name – QCoDeS instrument name.
virtual_gate_names – Names for the virtual gates (must be valid Python identifiers, e.g. [“vP1”, “vP2”]).
downstream – List of QCoDeS Parameters to set when voltages propagate. Length determines the number of physical outputs (rows in matrix).
matrix – Transformation matrix of shape (len(downstream), len(virtual_gate_names)). Defaults to identity when the layer is square (n_virtual == n_physical). Must be provided explicitly for non-square layers.
Example (single layer):
d5a = DummyD5a("d5a_1") m1 = VirtualGateLayer( "m1", ["vP1", "vP2"], downstream=[d5a.ch0.voltage, d5a.ch1.voltage], matrix=[ [1.0, 0.1,], [0.1, 1.0,], ], ) m1.vP1.voltage(0.5) # propagates: G = M1 @ [0.5, 0.0]
Example (chained layers):
# G ◄──M1── vG ◄──M2── vvG d5a = DummyD5a("d5a_1") m1 = VirtualGateLayer( "m1", ["vP1", "vP2"], downstream=[d5a.ch0.voltage, d5a.ch1.voltage], matrix=[ [1.0, 0.1,], [0.1, 1.0,], ], ) m2 = VirtualGateLayer( "m2", ["vvP1", "vvP2"], downstream=[m1.vP1.voltage, m1.vP2.voltage], matrix=[ [1.0, 0.05,], [0.05, 1.0,], ], ) m2.vvP1.voltage(0.5) # triggers: m2._propagate → m1.vPx.voltage.set → m1._propagate → d5a.chX.voltage.set
Example (tree: two virtual layers over one physical):
# G ◄──M1── vG ◄──M2── vvG # ◄──M3── O d5a = DummyD5a("d5a_1") m1 = VirtualGateLayer( "m1", ["vP1", "vP2"], downstream=[d5a.ch0.voltage, d5a.ch1.voltage], ) m2 = VirtualGateLayer( "m2", ["vvP1", "vvP2"], downstream=[m1.vP1.voltage, m1.vP2.voltage], matrix=[ [1.0, 0.1,], [0.1, 1.0,], ], ) m3 = VirtualGateLayer( "m3", ["oP1", "oP2"], downstream=[m1.vP1.voltage, m1.vP2.voltage], matrix=[ [1.0, 0.2,], [0.2, 1.0,], ], ) # m2 and m3 are automatically registered as siblings. m2.vvP1.voltage(0.5) # triggers: m2._propagate → vG updated → m1._propagate → G updated # → m3._recompute_virtual: O recomputed from new vG
- set_matrix(M: ndarray)[source]¶
Update the transformation matrix, pinning physical and recomputing virtual.
Per propagation rule 3: changing the matrix pins the left (physical) vector and recomputes the right (virtual) vector. Any layers using this layer’s virtual channels as their downstream will also have their virtual values recomputed (rightward propagation).
- Parameters:
M – New matrix with the same shape as the current matrix.
- compute_virtual_bounds(physical_bounds: list[tuple[float, float]]) list[tuple[float, float]][source]¶
Derive per-axis bounds for virtual gates from physical gate bounds.
Given that
physical = M @ virtual, the feasible virtual voltages form a parallelepiped (the pre-image of the physical bounding box under M). The tight per-axis bounds — the range each virtual gate can reach independently — are computed analytically from the rows of M⁻¹:v_j^{min} = Σᵢ min(M⁻¹ⱼᵢ · lb_i, M⁻¹ⱼᵢ · ub_i) v_j^{max} = Σᵢ max(M⁻¹ⱼᵢ · lb_i, M⁻¹ⱼᵢ · ub_i)
Only valid for square, invertible matrices. For non-square layers this would require a linear program; raise ValueError instead.
- Parameters:
physical_bounds – Sequence of (min, max) voltage tuples, one per physical gate (i.e. one per row of M).
- Returns:
List of (min, max) tuples, one per virtual gate.
Example — 10 % nearest-neighbour crosstalk, physical limits ±2 V:
M = [[1.0, 0.1], [0.1, 1.0]] bounds = layer.compute_virtual_bounds([(-2, 2), (-2, 2)]) # bounds ≈ [(-2.222, 2.222), (-2.222, 2.222)] # Virtual gates can exceed the physical limits because the coupling # allows one gate to compensate while the other is pushed further.
- set_voltages(voltages: dict[str, float] | list[float]) None[source]¶
Set multiple virtual gate voltages simultaneously.
Unlike setting each gate individually — which propagates after every assignment and can create an out-of-range intermediate physical state due to cross-coupling — this method updates all stored voltages first and propagates exactly once.
- Parameters:
voltages – Gate name → voltage mapping, or a sequence in gate order.
Example:
layer.set_voltages({"vvP1": 0.0, "vvP2": 0.0}) layer.set_voltages([0.0, 0.0])
- joint_sweep_range() list[tuple[float, float]][source]¶
Safe per-axis ranges for sweeping all gates simultaneously from the current position.
Per-axis bounds from
settable_range()are too generous for a joint sweep: at the corner(hi_1, hi_2, …)cross-coupling can push a physical output out of range.This method finds the largest scale factor
t ∈ [0, 1]such that the corner of the n-dimensional sweep grid — each axis moved byt x (marginal_bound - current)from the current position — still maps to a valid physical state. The result is proportional to the marginal per-axis bounds, so relative sweep widths are preserved.- Returns:
List of
(lo, hi)tuples in absolute voltage, one per virtual gate.
Example:
bounds = layer.joint_sweep_range() lo1, hi1 = bounds[0] # for the first virtual gate lo2, hi2 = bounds[1] # for the second virtual gate
- settable_range(gate: str | int) tuple[float, float][source]¶
Return the safe voltage range for one virtual gate given the current values of all others.
Unlike
compute_virtual_bounds(), which returns marginal bounds (the per-axis maximum range assuming all other virtual gates are at their optimal position), this method returns the conditional range: how far the specified gate can move while the others stay exactly where they are right now.- Parameters:
gate – Virtual gate name (e.g.
"vvP1") or 0-based index.- Returns:
(min, max)voltage tuple for the requested gate. Returns(-inf, inf)if no downstream validators are available.
Example:
lo, hi = layer.settable_range("vvP1") layer.vvP1.voltage(lo) # guaranteed in-range given current vvP2
- get_idn()[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.
- 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¶