semi_cr.core.lab.station package

Subpackages

Submodules

semi_cr.core.lab.station.base module

class semi_cr.core.lab.station.base.GraphRelation(*values)[source]

Bases: StrEnum

CONTAINS = 'contains'
DEPENDENCY = 'dependency'
CONNECTION = 'connection'
REPRESENTS = 'represents'
INTERNAL_CONNECTION = 'internal_connection'
PHYSICAL = 'physical'
DEVICE = 'device'
__new_member__(*values)

values must already be of type str

encode(encoding='utf-8', errors='strict')

Encode the string using the codec registered for encoding.

encoding

The encoding in which to encode the string.

errors

The error handling scheme to use for encoding errors. The default is ‘strict’ meaning that encoding errors raise a UnicodeEncodeError. Other possible values are ‘ignore’, ‘replace’ and ‘xmlcharrefreplace’ as well as any other name registered with codecs.register_error that can handle UnicodeEncodeErrors.

replace(old, new, count=-1, /)

Return a copy with all occurrences of substring old replaced by new.

count

Maximum number of occurrences to replace. -1 (the default value) means replace all occurrences.

If the optional argument count is given, only the first count occurrences are replaced.

split(sep=None, maxsplit=-1)

Return a list of the substrings in the string, using sep as the separator string.

sep

The separator used to split the string.

When set to None (the default value), will split on any whitespace character (including n r t f and spaces) and will discard empty strings from the result.

maxsplit

Maximum number of splits. -1 (the default value) means no limit.

Splitting starts at the front of the string and works to the end.

Note, str.split() is mainly useful for data that has been intentionally delimited. With natural text that includes punctuation, consider using the regular expression module.

rsplit(sep=None, maxsplit=-1)

Return a list of the substrings in the string, using sep as the separator string.

sep

The separator used to split the string.

When set to None (the default value), will split on any whitespace character (including n r t f and spaces) and will discard empty strings from the result.

maxsplit

Maximum number of splits. -1 (the default value) means no limit.

Splitting starts at the end of the string and works to the front.

join(iterable, /)

Concatenate any number of strings.

The string whose method is called is inserted in between each given string. The result is returned as a new string.

Example: ‘.’.join([‘ab’, ‘pq’, ‘rs’]) -> ‘ab.pq.rs’

capitalize()

Return a capitalized version of the string.

More specifically, make the first character have upper case and the rest lower case.

casefold()

Return a version of the string suitable for caseless comparisons.

title()

Return a version of the string where each word is titlecased.

More specifically, words start with uppercased characters and all remaining cased characters have lower case.

center(width, fillchar=' ', /)

Return a centered string of length width.

Padding is done using the specified fill character (default is a space).

count(sub[, start[, end]]) int

Return the number of non-overlapping occurrences of substring sub in string S[start:end]. Optional arguments start and end are interpreted as in slice notation.

expandtabs(tabsize=8)

Return a copy where all tab characters are expanded using spaces.

If tabsize is not given, a tab size of 8 characters is assumed.

find(sub[, start[, end]]) int

Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Return -1 on failure.

partition(sep, /)

Partition the string into three parts using the given separator.

This will search for the separator in the string. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

If the separator is not found, returns a 3-tuple containing the original string and two empty strings.

index(sub[, start[, end]]) int

Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Raises ValueError when the substring is not found.

ljust(width, fillchar=' ', /)

Return a left-justified string of length width.

Padding is done using the specified fill character (default is a space).

lower()

Return a copy of the string converted to lowercase.

lstrip(chars=None, /)

Return a copy of the string with leading whitespace removed.

If chars is given and not None, remove characters in chars instead.

rfind(sub[, start[, end]]) int

Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Return -1 on failure.

rindex(sub[, start[, end]]) int

Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Raises ValueError when the substring is not found.

rjust(width, fillchar=' ', /)

Return a right-justified string of length width.

Padding is done using the specified fill character (default is a space).

rstrip(chars=None, /)

Return a copy of the string with trailing whitespace removed.

If chars is given and not None, remove characters in chars instead.

rpartition(sep, /)

Partition the string into three parts using the given separator.

This will search for the separator in the string, starting at the end. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

If the separator is not found, returns a 3-tuple containing two empty strings and the original string.

splitlines(keepends=False)

Return a list of the lines in the string, breaking at line boundaries.

Line breaks are not included in the resulting list unless keepends is given and true.

strip(chars=None, /)

Return a copy of the string with leading and trailing whitespace removed.

If chars is given and not None, remove characters in chars instead.

swapcase()

Convert uppercase characters to lowercase and lowercase characters to uppercase.

translate(table, /)

Replace each character in the string using the given translation table.

table

Translation table, which must be a mapping of Unicode ordinals to Unicode ordinals, strings, or None.

The table must implement lookup/indexing via __getitem__, for instance a dictionary or list. If this operation raises LookupError, the character is left untouched. Characters mapped to None are deleted.

upper()

Return a copy of the string converted to uppercase.

startswith(prefix[, start[, end]]) bool

Return True if S starts with the specified prefix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. prefix can also be a tuple of strings to try.

endswith(suffix[, start[, end]]) bool

Return True if S ends with the specified suffix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. suffix can also be a tuple of strings to try.

removeprefix(prefix, /)

Return a str with the given prefix string removed if present.

If the string starts with the prefix string, return string[len(prefix):]. Otherwise, return a copy of the original string.

removesuffix(suffix, /)

Return a str with the given suffix string removed if present.

If the string ends with the suffix string and that suffix is not empty, return string[:-len(suffix)]. Otherwise, return a copy of the original string.

isascii()

Return True if all characters in the string are ASCII, False otherwise.

ASCII characters have code points in the range U+0000-U+007F. Empty string is ASCII too.

islower()

Return True if the string is a lowercase string, False otherwise.

A string is lowercase if all cased characters in the string are lowercase and there is at least one cased character in the string.

isupper()

Return True if the string is an uppercase string, False otherwise.

A string is uppercase if all cased characters in the string are uppercase and there is at least one cased character in the string.

istitle()

Return True if the string is a title-cased string, False otherwise.

In a title-cased string, upper- and title-case characters may only follow uncased characters and lowercase characters only cased ones.

isspace()

Return True if the string is a whitespace string, False otherwise.

A string is whitespace if all characters in the string are whitespace and there is at least one character in the string.

isdecimal()

Return True if the string is a decimal string, False otherwise.

A string is a decimal string if all characters in the string are decimal and there is at least one character in the string.

isdigit()

Return True if the string is a digit string, False otherwise.

A string is a digit string if all characters in the string are digits and there is at least one character in the string.

isnumeric()

Return True if the string is a numeric string, False otherwise.

A string is numeric if all characters in the string are numeric and there is at least one character in the string.

isalpha()

Return True if the string is an alphabetic string, False otherwise.

A string is alphabetic if all characters in the string are alphabetic and there is at least one character in the string.

isalnum()

Return True if the string is an alpha-numeric string, False otherwise.

A string is alpha-numeric if all characters in the string are alpha-numeric and there is at least one character in the string.

isidentifier()

Return True if the string is a valid Python identifier, False otherwise.

Call keyword.iskeyword(s) to test whether string s is a reserved identifier, such as “def” or “class”.

isprintable()

Return True if the string is printable, False otherwise.

A string is printable if all of its characters are considered printable in repr() or if it is empty.

zfill(width, /)

Pad a numeric string with zeros on the left, to fill a field of the given width.

The string is never truncated.

format(*args, **kwargs) str

Return a formatted version of S, using substitutions from args and kwargs. The substitutions are identified by braces (‘{’ and ‘}’).

format_map(mapping) str

Return a formatted version of S, using substitutions from mapping. The substitutions are identified by braces (‘{’ and ‘}’).

static maketrans()

Return a translation table usable for str.translate().

If there is only one argument, it must be a dictionary mapping Unicode ordinals (integers) or characters to Unicode ordinals, strings or None. Character keys will be then converted to ordinals. If there are two arguments, they must be strings of equal length, and in the resulting dictionary, each character in x will be mapped to the character at the same position in y. If there is a third argument, it must be a string, whose characters will be mapped to None in the result.

__dir__()

Returns public methods and other interesting attributes.

class semi_cr.core.lab.station.base.InstrumentSpec(name: str, type: str, init: dict[str, ~typing.Any]=<factory>)[source]

Bases: object

Static description of an instrument.

Does not represent an active connection and does not contain a QCoDeS Instrument instance.

name: str
type: str
init: dict[str, Any]
property runtime_name: str
semi_cr.core.lab.station.base.static_instrument_node_id(spec: InstrumentSpec) str[source]
class semi_cr.core.lab.station.base.ConfigBundle(files: str | Path | tuple[str | Path, ...] | None = None)[source]

Bases: object

A container class for QCoDes configuration that has been loaded from one or more yaml files. Instantiate a ConfigBundle with or without files, and add more using import_yaml.

Jens has a suspicion that we can avoid some complexity by encapsulating the configuration merging logic properly in here and having it here only. I believe now the ConfifBundle does that properly.

files: tuple[str | Path, ...]
load() dict[str, Any][source]

Loads a dict of paths to configuration files into a merged dict. A

Maintaining parity by initializing self.config to the empty dict. Would be nice if the ConfigBundle would maintain state.

DEPRECATED: Get rid of this method and self.config in order to maintain atomicity. :return:

import_yaml(yamlfile: str | Path | tuple[str | Path, ...]) None[source]

Takes a reference to a file or a tuple of such references and augments the current set of configurations with it.

merge(other: ConfigBundle) ConfigBundle[source]
dump_yaml(stream) None[source]

Dumps a YaML structure from the current ConfigBundle contents into a provided stream.

get_yaml() str[source]
Returns:

a string containing a YaML document containing the current state of the ConfigBundle.

property config: dict[str, Any]
classmethod combine(*bundles: ConfigBundle) ConfigBundle[source]

semi_cr.core.lab.station.context_old module

class semi_cr.core.lab.station.context_old.StaticTerminalRef(instrument: str, module: str | None, terminal: str)[source]

Bases: object

instrument: str
module: str | None
terminal: str
class semi_cr.core.lab.station.context_old.InfrastructureContext(wiring_config: semi_cr.core.lab.station.base.ConfigBundle, electronics_config: semi_cr.core.lab.station.base.ConfigBundle)[source]

Bases: object

wiring_config: ConfigBundle
electronics_config: ConfigBundle
config: ConfigBundle
graph: MultiDiGraph
build_graph() MultiDiGraph[source]
view_graph(what: Literal['nodes', 'edges', 'both'] = 'both', include_attrs: bool = True)[source]
semi_cr.core.lab.station.context_old.build_instrument_specs(config: dict[str, Any]) dict[str, InstrumentSpec][source]
class semi_cr.core.lab.station.context_old.StaticStationContext(device: ConfigContext, infrastructure: InfrastructureContext)[source]

Bases: object

Description of the complete station without talking to hardware.

device: ConfigContext
infrastructure: InfrastructureContext
config: ConfigBundle
instruments: dict[str, InstrumentSpec]
graph: MultiDiGraph
class semi_cr.core.lab.station.context_old.RuntimeBinding(static_id: str, runtime_id: str, runtime_object: Any)[source]

Bases: object

static_id: str
runtime_id: str
runtime_object: Any
class semi_cr.core.lab.station.context_old.RuntimeBindingRegistry[source]

Bases: object

bind(static_id: str, runtime_id: str, runtime_object: Any) None[source]
resolve(static_id: str) Any[source]
get_binding(static_id: str) RuntimeBinding[source]
is_bound(static_id: str) bool[source]
items()[source]
values()[source]
semi_cr.core.lab.station.context_old.normalize_qcodes_config(config: dict[str, Any]) dict[str, Any][source]
class semi_cr.core.lab.station.context_old.ContextState(*values)[source]

Bases: Enum

CREATED = 1
LOADED = 2
PARTIALLY_CONNECTED = 3
CONNECTED = 4
classmethod __contains__(value)

Return True if value is in cls.

value is in cls if: 1) value is a member of cls, or 2) value is the value of one of the cls’s members.

classmethod __getitem__(name)

Return the member matching name.

classmethod __iter__()

Return members in definition order.

classmethod __len__()

Return the number of members (no aliases)

class semi_cr.core.lab.station.context_old.StationContext(station: LabStation, static: StaticStationContext)[source]

Bases: object

Runtime realization of a StaticStationContext.

Construction is intentionally side-effect free.

Lifecycle:

context = StationContext(station, static)

context.load() context.connect()

context.disconnect()

station: LabStation
static: StaticStationContext
property bindings: RuntimeBindingRegistry
resolve_runtime(static_id: str) Any[source]

Resolve a static object ID to its runtime realization.

Runtime resolution is available once bindings have been created, including while the context is being connected.

property instruments: dict[str, Instrument]
property devices: tuple[BaseDevice, ...]
property chips: tuple[Chip, ...]
property pcbs: tuple[PCB, ...]
property connectors: tuple[Connector, ...]
property graph: MultiDiGraph
property modules: dict[str, Any]
property has_runtime: bool
property state: ContextState
property loaded: bool
property connected: bool

True when all configured instruments are connected.

property partially_connected: bool
property connected_instrument_names: tuple[str, ...]
property has_connections: bool

True when at least one instrument owned by this context is currently connected.

load() None[source]

Load the static configuration into the QCoDeS station.

This does not connect to physical instruments.

connect(instruments: str | Iterable[str] | None = None) None[source]

Connect one, several, or all configured instruments.

Parameters:

instruments – QCoDeS instrument config name, iterable of config names, or None to connect all configured instruments.

Examples

context.connect() context.connect(“qdac_1”) context.connect([“qdac_1”, “smu”])

disconnect(instruments: str | Iterable[str] | None = None) None[source]

Disconnect one, several, or all runtime instruments instantiated by this context.

QCoDeS configuration remains loaded.

Parameters:

instruments – Config name, iterable of config names, or None to disconnect all instruments owned by this context.

Examples

context.disconnect() context.disconnect(“qdac_1”) context.disconnect([“qdac_1”, “smu”])

semi_cr.core.lab.station.metadata module

class semi_cr.core.lab.station.metadata.LabStation(cfg_file: str | pathlib.Path)[source]

Bases: Station

cfg_file: str | Path
property name: str
property lab: str
__getitem__(key: str) Metadatable

Shortcut to components dictionary.

add_component(component: MetadatableWithName, name: str | None = None, update_snapshot: bool = True) str

Record one component as part of this Station.

Parameters:
  • component – Components to add to the Station.

  • name – Name of the component.

  • update_snapshot – Immediately update the snapshot of each component as it is added to the Station.

Returns:

The name assigned this component, which may have been changed

to make it unique among previously added components.

Return type:

str

close_all_registered_instruments() None

Closes all instruments that are registered to this Station object by calling the base.Instrument.close()-method on each one. The instruments will be removed from the station and from the QCoDeS monitor.

close_and_remove_instrument(instrument: Instrument | str) None

Safely close instrument and remove from station and monitor list.

config: StationConfig | None = None

A user dict representing the YAML file that the station was loaded from

default: Station | None = None

Class attribute to store the default station.

delegate_attr_dicts: ClassVar[list[str]] = ['components']

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

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

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

get_component(full_name: str) MetadatableWithName

Get a (sub)component with a given name from this Station. The name may be of a component that is a sub-component of another component, e.g. a parameter on an instrument, an instrument module or an top-level instrument.

Parameters:

full_name – Name of the component.

Returns:

The component with the given name.

Raises:

KeyError – If a component with the given name is not part of this station.

load_all_instruments(only_names: Iterable[str] | None = None, only_types: Iterable[str] | None = None) tuple[str, ...]

Load all instruments specified in the loaded YAML station configuration.

Optionally, the instruments to be loaded can be filtered by their names or types, use only_names and only_types arguments for that. It is an error to supply both only_names and only_types.

Parameters:
  • only_names – List of instrument names to load from the config. If left as None, then all instruments are loaded.

  • only_types – List of instrument types e.g. the class names of the instruments to load. If left as None, then all instruments are loaded.

Returns:

The names of the loaded instruments

load_config(config: str | IO) None

Loads a configuration from a supplied string or file/stream handle. The string or file/stream is expected to be YAML formatted

Loading of a configuration will update the snapshot of the station and make the instruments described in the config file available for instantiation with the load_instrument() method.

Additionally the shortcut methods load_<instrument_name> will be updated.

load_config_file(filename: str | None = None) None

Loads a configuration from a YAML file. If filename is not specified the default file name from the qcodes configuration will be used.

Loading of a configuration will update the snapshot of the station and make the instruments described in the config file available for instantiation with the load_instrument() method.

Additionally the shortcut methods load_<instrument_name> will be updated.

load_config_files(*filenames: str) None

Loads configuration from multiple YAML files after merging them into one. If filenames are not specified the default file name from the qcodes configuration will be used.

Loading of configuration will update the snapshot of the station and make the instruments described in the config files available for instantiation with the load_instrument() method.

Additionally the shortcut methods load_<instrument_name> will be updated.

load_instrument(identifier: str, revive_instance: bool = False, update_snapshot: bool = True, **kwargs: Any) Instrument

Creates an Instrument instance as described by the loaded configuration file.

Parameters:
  • identifier – The identifying string that is looked up in the yaml configuration file, which identifies the instrument to be added.

  • revive_instance – If True, try to return an instrument with the specified name instead of closing it and creating a new one.

  • update_snapshot – Immediately update the snapshot of the instrument as it is added to the Station.

  • **kwargs – Additional keyword arguments that get passed on to the __init__-method of the instrument to be added.

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

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

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

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

remove_component(name: str) MetadatableWithName | None

Remove a component with a given name from this Station.

Parameters:

name – Name of the component.

Returns:

The component that has been removed (this behavior is the same as for Python dictionaries).

Raises:

KeyError – If a component with the given name is not part of this station.

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 station as a JSON-compatible dictionary (everything that the custom JSON encoder class NumpyJSONEncoder supports).

Note: If the station contains an instrument that has already been closed, not only will it not be snapshotted, it will also be removed from the station during the execution of this function.

Parameters:
  • update – If True, update the state by querying the all the children: f.ex. instruments, parameters, components, etc. If None only update if the state is known to be invalid. If False, just use the latest values in memory and never update the state.

  • params_to_skip_update – Not used.

Returns:

Base snapshot.

Return type:

dict

metadata: dict[str, Any]

semi_cr.core.lab.station.nodes module

class semi_cr.core.lab.station.nodes.BetterDelegateParameter(name: str, *, source: Parameter | None, **kwargs: Unpack[ParameterKWArgs[ParameterDataTypeVar, InstrumentTypeVar_co]])[source]

Bases: DelegateParameter

validate(value: Any | None) None[source]

Validate the supplied value. If it has a source parameter, validate the value as well with the source validator.

Parameters:

value – value to validate

Raises:
  • TypeError – If the value is of the wrong type.

  • ValueError – If the value is outside the bounds specified by the validator.

__getitem__(keys: Any) SweepFixedValues

Slice a Parameter to get a SweepValues object to iterate over during a sweep

__str__() str

Include the instrument name with the Parameter name if possible.

property abstract: bool | None
add_validator(vals: Validator) None

Add a validator for the parameter. The parameter is validated against all validators in reverse order of how they are added.

Parameters:

vals – Validator to add to the parameter.

property depends_on: ParameterSet
extra_validator(vals: Validator) Generator[None, None, None]

Contextmanager to to temporarily add a validator to the parameter within the given context. The validator is removed from the parameter when the context ends.

property full_name: str

Name of the parameter including the name of the instrument and submodule that the parameter may be bound to. The names are separated by underscores, like this: instrument_submodule_parameter.

get_ramp_values(value: NumberType | Sized, step: NumberType | None = None) Sequence[NumberType | Sized]

Return values to sweep from current value to target value. This method can be overridden to have a custom sweep behaviour. It can even be overridden by a generator.

Parameters:
  • value – target value

  • step – maximum step size

Returns:

List of stepped values, including target value.

get_raw() Any

get_raw is called to perform the actual data acquisition from the instrument. This method should either be overwritten to perform the desired operation or alternatively for Parameter a suitable method is automatically generated if get_cmd is supplied to the parameter constructor. The method is automatically wrapped to provide a get method on the parameter instance.

property gettable: bool

Is it allowed to call get on this parameter?

global_on_set_callback = None
property has_control_of: ParameterSet
increment(value: ParameterDataTypeVar) None

Increment the parameter with a value

Parameters:

value – Value to be added to the parameter.

property instrument: InstrumentTypeVar_co

Return the first instrument that this parameter is bound to. E.g if this is bound to a channel it will return the channel and not the instrument that the channel is bound too. Use root_instrument() to get the real instrument.

property inter_delay: float

Delay time between consecutive set operations. The actual time will not be shorter than this, but may be longer if the underlying set call takes longer.

Typically used in conjunction with step to create an effective ramp rate, but can also be used without a step to enforce a delay between sets.

Getter:

Returns the current inter_delay.

Setter:

Sets the value of the inter_delay.

Raises:
property is_controlled_by: ParameterSet
property label: str

Label of the data used for plots etc. Read from source if not explicitly overwritten. Set to None to disable overwrite.

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

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

property name: str

Name of the parameter. This is identical to short_name().

property name_parts: list[str]

List of the parts that make up the full name of this parameter

property param_spec: ParamSpecBase
property paramtype: str
property post_delay: float

Delay time after start of set operation, for each set. The actual time will not be shorter than this, but may be longer if the underlying set call takes longer.

Typically used in conjunction with step to create an effective ramp rate, but can also be used without a step to enforce a delay after every set. One might think of post_delay as how long a set operation is supposed to take. For example, there might be an instrument that needs extra time after setting a parameter although the command for setting the parameter returns quickly.

Getter:

Returns the current post_delay.

Setter:

Sets the value of the post_delay.

Raises:
property raw_value: Any

Note that this property will be deprecated soon. Use cache.raw_value instead.

Represents the cached raw value of the parameter.

Getter:

Returns the cached raw value of the parameter.

property register_name: str

Name that will be used to register this parameter in a dataset By default, this returns full_name or the value of the register_name argument if it was passed at initialization.

remove_validator() Validator | None

Remove the last validator added to the parameter and return it. Returns None if there are no validators associated with the parameter.

Returns:

The last validator added to the parameter or None if there are no validators associated with the parameter.

restore_at_exit(allow_changes: bool = True) _SetParamContext

Use a context manager to restore the value of a parameter after a with block.

By default, the parameter value may be changed inside the block, but this can be prevented with allow_changes=False. This can be useful, for example, for debugging a complex measurement that unintentionally modifies a parameter.

Example

>>> p = Parameter("p", set_cmd=None, get_cmd=None)
>>> p.set(2)
>>> with p.restore_at_exit():
...     p.set(3)
...     print(f"value inside with block: {p.get()}")  # prints 3
>>> print(f"value after with block: {p.get()}")  # prints 2
>>> with p.restore_at_exit(allow_changes=False):
...     p.set(5)  # raises an exception
property root_instrument: InstrumentBase | None

Return the fundamental instrument that this parameter belongs too. E.g if the parameter is bound to a channel this will return the fundamental instrument that that channel belongs to. Use instrument() to get the channel.

set_raw(value: Any) None

set_raw is called to perform the actual setting of a parameter on the instrument. This method should either be overwritten to perform the desired operation or alternatively for Parameter a suitable method is automatically generated if set_cmd is supplied to the parameter constructor. The method is automatically wrapped to provide a set method on the parameter instance.

set_to(value: ParameterDataTypeVar, allow_changes: bool = False) _SetParamContext

Use a context manager to temporarily set a parameter to a value. By default, the parameter value cannot be changed inside the context. This may be overridden with allow_changes=True.

Examples

>>> from qcodes.parameters import Parameter
>>> p = Parameter("p", set_cmd=None, get_cmd=None)
>>> p.set(2)
>>> with p.set_to(3):
...     print(f"p value in with block {p.get()}")  # prints 3
...     p.set(5)  # raises an exception
>>> print(f"p value outside with block {p.get()}")  # prints 2
>>> with p.set_to(3, allow_changes=True):
...     p.set(5)  # now this works
>>> print(f"value after second block: {p.get()}")  # still prints 2
property settable: bool

Is it allowed to call set on this parameter?

property short_name: str

Short name of the parameter. This is without the name of the instrument or submodule that the parameter may be bound to. For full name refer to full_name().

snapshot(update: 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 parameter as a JSON-compatible dict (everything that the custom JSON encoder class NumpyJSONEncoder supports).

If the parameter has been initiated with snapshot_value=False, the snapshot will NOT include the value and raw_value of the parameter.

Parameters:
  • update – If True, update the state by calling parameter.get() unless snapshot_get of the parameter is False. If update is None, use the current value from the cache unless the cache is invalid. If False, never call parameter.get().

  • params_to_skip_update – No effect but may be passed from superclass

Returns:

base snapshot

property snapshot_value: bool

If True the value of the parameter will be included in the snapshot.

property source: Parameter | None

The source parameter that this DelegateParameter is bound to or None if this DelegateParameter is unbound.

Getter:

Returns the current source.

Setter:

Sets the source.

property step: int | float | integer | floating | None

Stepsize that this Parameter uses during set operation. Stepsize must be a positive number or None. If step is a positive number, this is the maximum value change allowed in one hardware call, so a single set can result in many calls to the hardware if the starting value is far from the target. All but the final change will attempt to change by +/- step exactly. If step is None stepping will not be used.

Getter:

Returns the current stepsize.

Setter:

Sets the value of the step.

Raises:
  • TypeError – if step is set to not numeric or None

  • ValueError – if step is set to negative

  • TypeError – if step is set to not integer or None for an integer parameter

  • TypeError – if step is set to not a number on None

sweep(start: float, stop: float, step: float | None = None, num: int | None = None) SweepFixedValues

Create a collection of parameter values to be iterated over. Requires start and stop and (step or num) The sign of step is not relevant.

Parameters:
  • start – The starting value of the sequence.

  • stop – The end value of the sequence.

  • step – Spacing between values.

  • num – Number of values to generate.

Returns:

Collection of parameter values to be iterated over.

Return type:

SweepFixedValues

Examples

>>> sweep(0, 10, num=5)
 [0.0, 2.5, 5.0, 7.5, 10.0]
>>> sweep(5, 10, step=1)
[5.0, 6.0, 7.0, 8.0, 9.0, 10.0]
>>> sweep(15, 10.5, step=1.5)
>[15.0, 13.5, 12.0, 10.5]
property underlying_instrument: InstrumentBase | None

Returns an instance of the underlying hardware instrument that this parameter communicates with, per this parameter’s implementation.

This is useful in the case where a parameter does not belongs to an instrument instance that represents a real hardware instrument but actually uses a real hardware instrument in its implementation (e.g. via calls to one or more parameters of that real hardware instrument). This is also useful when a parameter does belong to an instrument instance but that instance does not represent the real hardware instrument that the parameter interacts with: hence root_instrument of the parameter cannot be the hardware_instrument, however underlying_instrument can be implemented to return the hardware_instrument.

By default it returns the root_instrument of the parameter.

property unit: str

The unit of measure. Read from source if not explicitly overwritten. Set to None to disable overwrite.

unpack_self(value: ValuesType) list[tuple[ParameterBase, ValuesType]]
property validators: tuple[Validator, ...]

Tuple of all validators associated with the parameter. Note that this includes validators of the source parameter if source parameter is set and has any validators.

Getter:

All validators associated with the parameter.

property vals: Validator | None

The first validator of the parameter. None if no validators are set for this parameter.

Getter:

Returns the first validator or None if no validators.

Setter:

Sets the first validator. Set to None to remove the first validator.

Raises:

RuntimeError – If removing the first validator when more than one validator is set.

get_parser
set_parser
cache
get_latest
get
set
metadata
class semi_cr.core.lab.station.nodes.NoneParameter(**kwargs: Any)[source]

Bases: Parameter

__getitem__(keys: Any) SweepFixedValues

Slice a Parameter to get a SweepValues object to iterate over during a sweep

__str__() str

Include the instrument name with the Parameter name if possible.

property abstract: bool | None
add_validator(vals: Validator) None

Add a validator for the parameter. The parameter is validated against all validators in reverse order of how they are added.

Parameters:

vals – Validator to add to the parameter.

property depends_on: ParameterSet
extra_validator(vals: Validator) Generator[None, None, None]

Contextmanager to to temporarily add a validator to the parameter within the given context. The validator is removed from the parameter when the context ends.

property full_name: str

Name of the parameter including the name of the instrument and submodule that the parameter may be bound to. The names are separated by underscores, like this: instrument_submodule_parameter.

get_ramp_values(value: NumberType | Sized, step: NumberType | None = None) Sequence[NumberType | Sized]

Return values to sweep from current value to target value. This method can be overridden to have a custom sweep behaviour. It can even be overridden by a generator.

Parameters:
  • value – target value

  • step – maximum step size

Returns:

List of stepped values, including target value.

get_raw() Any

get_raw is called to perform the actual data acquisition from the instrument. This method should either be overwritten to perform the desired operation or alternatively for Parameter a suitable method is automatically generated if get_cmd is supplied to the parameter constructor. The method is automatically wrapped to provide a get method on the parameter instance.

property gettable: bool

Is it allowed to call get on this parameter?

global_on_set_callback = None
property has_control_of: ParameterSet
increment(value: ParameterDataTypeVar) None

Increment the parameter with a value

Parameters:

value – Value to be added to the parameter.

property instrument: InstrumentTypeVar_co

Return the first instrument that this parameter is bound to. E.g if this is bound to a channel it will return the channel and not the instrument that the channel is bound too. Use root_instrument() to get the real instrument.

property inter_delay: float

Delay time between consecutive set operations. The actual time will not be shorter than this, but may be longer if the underlying set call takes longer.

Typically used in conjunction with step to create an effective ramp rate, but can also be used without a step to enforce a delay between sets.

Getter:

Returns the current inter_delay.

Setter:

Sets the value of the inter_delay.

Raises:
property is_controlled_by: ParameterSet
property label: str

Label of the data used for plots etc.

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

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

property name: str

Name of the parameter. This is identical to short_name().

property name_parts: list[str]

List of the parts that make up the full name of this parameter

property param_spec: ParamSpecBase
property paramtype: str
property post_delay: float

Delay time after start of set operation, for each set. The actual time will not be shorter than this, but may be longer if the underlying set call takes longer.

Typically used in conjunction with step to create an effective ramp rate, but can also be used without a step to enforce a delay after every set. One might think of post_delay as how long a set operation is supposed to take. For example, there might be an instrument that needs extra time after setting a parameter although the command for setting the parameter returns quickly.

Getter:

Returns the current post_delay.

Setter:

Sets the value of the post_delay.

Raises:
property raw_value: Any

Note that this property will be deprecated soon. Use cache.raw_value instead.

Represents the cached raw value of the parameter.

Getter:

Returns the cached raw value of the parameter.

property register_name: str

Name that will be used to register this parameter in a dataset By default, this returns full_name or the value of the register_name argument if it was passed at initialization.

remove_validator() Validator | None

Remove the last validator added to the parameter and return it. Returns None if there are no validators associated with the parameter.

Returns:

The last validator added to the parameter or None if there are no validators associated with the parameter.

restore_at_exit(allow_changes: bool = True) _SetParamContext

Use a context manager to restore the value of a parameter after a with block.

By default, the parameter value may be changed inside the block, but this can be prevented with allow_changes=False. This can be useful, for example, for debugging a complex measurement that unintentionally modifies a parameter.

Example

>>> p = Parameter("p", set_cmd=None, get_cmd=None)
>>> p.set(2)
>>> with p.restore_at_exit():
...     p.set(3)
...     print(f"value inside with block: {p.get()}")  # prints 3
>>> print(f"value after with block: {p.get()}")  # prints 2
>>> with p.restore_at_exit(allow_changes=False):
...     p.set(5)  # raises an exception
property root_instrument: InstrumentBase | None

Return the fundamental instrument that this parameter belongs too. E.g if the parameter is bound to a channel this will return the fundamental instrument that that channel belongs to. Use instrument() to get the channel.

set_raw(value: Any) None

set_raw is called to perform the actual setting of a parameter on the instrument. This method should either be overwritten to perform the desired operation or alternatively for Parameter a suitable method is automatically generated if set_cmd is supplied to the parameter constructor. The method is automatically wrapped to provide a set method on the parameter instance.

set_to(value: ParameterDataTypeVar, allow_changes: bool = False) _SetParamContext

Use a context manager to temporarily set a parameter to a value. By default, the parameter value cannot be changed inside the context. This may be overridden with allow_changes=True.

Examples

>>> from qcodes.parameters import Parameter
>>> p = Parameter("p", set_cmd=None, get_cmd=None)
>>> p.set(2)
>>> with p.set_to(3):
...     print(f"p value in with block {p.get()}")  # prints 3
...     p.set(5)  # raises an exception
>>> print(f"p value outside with block {p.get()}")  # prints 2
>>> with p.set_to(3, allow_changes=True):
...     p.set(5)  # now this works
>>> print(f"value after second block: {p.get()}")  # still prints 2
property settable: bool

Is it allowed to call set on this parameter?

property short_name: str

Short name of the parameter. This is without the name of the instrument or submodule that the parameter may be bound to. For full name refer to full_name().

snapshot(update: 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 parameter as a JSON-compatible dict (everything that the custom JSON encoder class NumpyJSONEncoder supports).

If the parameter has been initiated with snapshot_value=False, the snapshot will NOT include the value and raw_value of the parameter.

Parameters:
  • update – If True, update the state by calling parameter.get() unless snapshot_get of the parameter is False. If update is None, use the current value from the cache unless the cache is invalid. If False, never call parameter.get().

  • params_to_skip_update – No effect but may be passed from superclass

Returns:

base snapshot

property snapshot_value: bool

If True the value of the parameter will be included in the snapshot.

property step: int | float | integer | floating | None

Stepsize that this Parameter uses during set operation. Stepsize must be a positive number or None. If step is a positive number, this is the maximum value change allowed in one hardware call, so a single set can result in many calls to the hardware if the starting value is far from the target. All but the final change will attempt to change by +/- step exactly. If step is None stepping will not be used.

Getter:

Returns the current stepsize.

Setter:

Sets the value of the step.

Raises:
  • TypeError – if step is set to not numeric or None

  • ValueError – if step is set to negative

  • TypeError – if step is set to not integer or None for an integer parameter

  • TypeError – if step is set to not a number on None

sweep(start: float, stop: float, step: float | None = None, num: int | None = None) SweepFixedValues

Create a collection of parameter values to be iterated over. Requires start and stop and (step or num) The sign of step is not relevant.

Parameters:
  • start – The starting value of the sequence.

  • stop – The end value of the sequence.

  • step – Spacing between values.

  • num – Number of values to generate.

Returns:

Collection of parameter values to be iterated over.

Return type:

SweepFixedValues

Examples

>>> sweep(0, 10, num=5)
 [0.0, 2.5, 5.0, 7.5, 10.0]
>>> sweep(5, 10, step=1)
[5.0, 6.0, 7.0, 8.0, 9.0, 10.0]
>>> sweep(15, 10.5, step=1.5)
>[15.0, 13.5, 12.0, 10.5]
property underlying_instrument: InstrumentBase | None

Returns an instance of the underlying hardware instrument that this parameter communicates with, per this parameter’s implementation.

This is useful in the case where a parameter does not belongs to an instrument instance that represents a real hardware instrument but actually uses a real hardware instrument in its implementation (e.g. via calls to one or more parameters of that real hardware instrument). This is also useful when a parameter does belong to an instrument instance but that instance does not represent the real hardware instrument that the parameter interacts with: hence root_instrument of the parameter cannot be the hardware_instrument, however underlying_instrument can be implemented to return the hardware_instrument.

By default it returns the root_instrument of the parameter.

property unit: str

The unit of measure. Use '' (the empty string) for unitless.

unpack_self(value: ValuesType) list[tuple[ParameterBase, ValuesType]]
validate(value: ParameterDataTypeVar) None

Validate the value supplied.

Parameters:

value – value to validate

Raises:
  • TypeError – If the value is of the wrong type.

  • ValueError – If the value is outside the bounds specified by the validator.

property validators: tuple[Validator, ...]

Tuple of all validators associated with the parameter.

Getter:

All validators associated with the parameter.

property vals: Validator | None

The first validator of the parameter. None if no validators are set for this parameter.

Getter:

Returns the first validator or None if no validators.

Setter:

Sets the first validator. Set to None to remove the first validator.

Raises:

RuntimeError – If removing the first validator when more than one validator is set.

get_parser
set_parser
cache
get_latest
get
set
metadata
class semi_cr.core.lab.station.nodes.Node(name: str = 'Node', parameters: Iterable[Parameter] = ())[source]

Bases: ABC

property name: str
property parameters: Iterable[Parameter]
class semi_cr.core.lab.station.nodes.Edge(*values)[source]

Bases: Enum

Active = 1
Inactive = 2
Disabled = 3
classmethod __contains__(value)

Return True if value is in cls.

value is in cls if: 1) value is a member of cls, or 2) value is the value of one of the cls’s members.

classmethod __getitem__(name)

Return the member matching name.

classmethod __iter__()

Return members in definition order.

classmethod __len__()

Return the number of members (no aliases)

class semi_cr.core.lab.station.nodes.SingleSourceNode(name: str = 'SingleSourceNode')[source]

Bases: Node

property source: Node | None
property name: str
property parameters: Iterable[Parameter]
class semi_cr.core.lab.station.nodes.ForwardingNode(name: str = 'SingleSourceNode')[source]

Bases: SingleSourceNode

property parameters: Iterable[Parameter]
property name: str
property source: Node | None
class semi_cr.core.lab.station.nodes.MultiSourceForwardingNode(name: str = 'MultiSourceForwardingNode')[source]

Bases: Node

property parameters: Iterable[Parameter]
property name: str
class semi_cr.core.lab.station.nodes.CompositeParameter(name: str, **kwargs: Any)[source]

Bases: Parameter

get_raw() Any[source]

get_raw is called to perform the actual data acquisition from the instrument. This method should either be overwritten to perform the desired operation or alternatively for Parameter a suitable method is automatically generated if get_cmd is supplied to the parameter constructor. The method is automatically wrapped to provide a get method on the parameter instance.

property source: set[Parameter]
__getitem__(keys: Any) SweepFixedValues

Slice a Parameter to get a SweepValues object to iterate over during a sweep

__str__() str

Include the instrument name with the Parameter name if possible.

property abstract: bool | None
add_validator(vals: Validator) None

Add a validator for the parameter. The parameter is validated against all validators in reverse order of how they are added.

Parameters:

vals – Validator to add to the parameter.

property depends_on: ParameterSet
extra_validator(vals: Validator) Generator[None, None, None]

Contextmanager to to temporarily add a validator to the parameter within the given context. The validator is removed from the parameter when the context ends.

property full_name: str

Name of the parameter including the name of the instrument and submodule that the parameter may be bound to. The names are separated by underscores, like this: instrument_submodule_parameter.

get_ramp_values(value: NumberType | Sized, step: NumberType | None = None) Sequence[NumberType | Sized]

Return values to sweep from current value to target value. This method can be overridden to have a custom sweep behaviour. It can even be overridden by a generator.

Parameters:
  • value – target value

  • step – maximum step size

Returns:

List of stepped values, including target value.

property gettable: bool

Is it allowed to call get on this parameter?

global_on_set_callback = None
property has_control_of: ParameterSet
increment(value: ParameterDataTypeVar) None

Increment the parameter with a value

Parameters:

value – Value to be added to the parameter.

property instrument: InstrumentTypeVar_co

Return the first instrument that this parameter is bound to. E.g if this is bound to a channel it will return the channel and not the instrument that the channel is bound too. Use root_instrument() to get the real instrument.

property inter_delay: float

Delay time between consecutive set operations. The actual time will not be shorter than this, but may be longer if the underlying set call takes longer.

Typically used in conjunction with step to create an effective ramp rate, but can also be used without a step to enforce a delay between sets.

Getter:

Returns the current inter_delay.

Setter:

Sets the value of the inter_delay.

Raises:
property is_controlled_by: ParameterSet
property label: str

Label of the data used for plots etc.

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

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

property name: str

Name of the parameter. This is identical to short_name().

property name_parts: list[str]

List of the parts that make up the full name of this parameter

property param_spec: ParamSpecBase
property paramtype: str
property post_delay: float

Delay time after start of set operation, for each set. The actual time will not be shorter than this, but may be longer if the underlying set call takes longer.

Typically used in conjunction with step to create an effective ramp rate, but can also be used without a step to enforce a delay after every set. One might think of post_delay as how long a set operation is supposed to take. For example, there might be an instrument that needs extra time after setting a parameter although the command for setting the parameter returns quickly.

Getter:

Returns the current post_delay.

Setter:

Sets the value of the post_delay.

Raises:
property raw_value: Any

Note that this property will be deprecated soon. Use cache.raw_value instead.

Represents the cached raw value of the parameter.

Getter:

Returns the cached raw value of the parameter.

property register_name: str

Name that will be used to register this parameter in a dataset By default, this returns full_name or the value of the register_name argument if it was passed at initialization.

remove_validator() Validator | None

Remove the last validator added to the parameter and return it. Returns None if there are no validators associated with the parameter.

Returns:

The last validator added to the parameter or None if there are no validators associated with the parameter.

restore_at_exit(allow_changes: bool = True) _SetParamContext

Use a context manager to restore the value of a parameter after a with block.

By default, the parameter value may be changed inside the block, but this can be prevented with allow_changes=False. This can be useful, for example, for debugging a complex measurement that unintentionally modifies a parameter.

Example

>>> p = Parameter("p", set_cmd=None, get_cmd=None)
>>> p.set(2)
>>> with p.restore_at_exit():
...     p.set(3)
...     print(f"value inside with block: {p.get()}")  # prints 3
>>> print(f"value after with block: {p.get()}")  # prints 2
>>> with p.restore_at_exit(allow_changes=False):
...     p.set(5)  # raises an exception
property root_instrument: InstrumentBase | None

Return the fundamental instrument that this parameter belongs too. E.g if the parameter is bound to a channel this will return the fundamental instrument that that channel belongs to. Use instrument() to get the channel.

set_raw(value: Any) None

set_raw is called to perform the actual setting of a parameter on the instrument. This method should either be overwritten to perform the desired operation or alternatively for Parameter a suitable method is automatically generated if set_cmd is supplied to the parameter constructor. The method is automatically wrapped to provide a set method on the parameter instance.

set_to(value: ParameterDataTypeVar, allow_changes: bool = False) _SetParamContext

Use a context manager to temporarily set a parameter to a value. By default, the parameter value cannot be changed inside the context. This may be overridden with allow_changes=True.

Examples

>>> from qcodes.parameters import Parameter
>>> p = Parameter("p", set_cmd=None, get_cmd=None)
>>> p.set(2)
>>> with p.set_to(3):
...     print(f"p value in with block {p.get()}")  # prints 3
...     p.set(5)  # raises an exception
>>> print(f"p value outside with block {p.get()}")  # prints 2
>>> with p.set_to(3, allow_changes=True):
...     p.set(5)  # now this works
>>> print(f"value after second block: {p.get()}")  # still prints 2
property settable: bool

Is it allowed to call set on this parameter?

property short_name: str

Short name of the parameter. This is without the name of the instrument or submodule that the parameter may be bound to. For full name refer to full_name().

snapshot(update: 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 parameter as a JSON-compatible dict (everything that the custom JSON encoder class NumpyJSONEncoder supports).

If the parameter has been initiated with snapshot_value=False, the snapshot will NOT include the value and raw_value of the parameter.

Parameters:
  • update – If True, update the state by calling parameter.get() unless snapshot_get of the parameter is False. If update is None, use the current value from the cache unless the cache is invalid. If False, never call parameter.get().

  • params_to_skip_update – No effect but may be passed from superclass

Returns:

base snapshot

property snapshot_value: bool

If True the value of the parameter will be included in the snapshot.

property step: int | float | integer | floating | None

Stepsize that this Parameter uses during set operation. Stepsize must be a positive number or None. If step is a positive number, this is the maximum value change allowed in one hardware call, so a single set can result in many calls to the hardware if the starting value is far from the target. All but the final change will attempt to change by +/- step exactly. If step is None stepping will not be used.

Getter:

Returns the current stepsize.

Setter:

Sets the value of the step.

Raises:
  • TypeError – if step is set to not numeric or None

  • ValueError – if step is set to negative

  • TypeError – if step is set to not integer or None for an integer parameter

  • TypeError – if step is set to not a number on None

sweep(start: float, stop: float, step: float | None = None, num: int | None = None) SweepFixedValues

Create a collection of parameter values to be iterated over. Requires start and stop and (step or num) The sign of step is not relevant.

Parameters:
  • start – The starting value of the sequence.

  • stop – The end value of the sequence.

  • step – Spacing between values.

  • num – Number of values to generate.

Returns:

Collection of parameter values to be iterated over.

Return type:

SweepFixedValues

Examples

>>> sweep(0, 10, num=5)
 [0.0, 2.5, 5.0, 7.5, 10.0]
>>> sweep(5, 10, step=1)
[5.0, 6.0, 7.0, 8.0, 9.0, 10.0]
>>> sweep(15, 10.5, step=1.5)
>[15.0, 13.5, 12.0, 10.5]
property underlying_instrument: InstrumentBase | None

Returns an instance of the underlying hardware instrument that this parameter communicates with, per this parameter’s implementation.

This is useful in the case where a parameter does not belongs to an instrument instance that represents a real hardware instrument but actually uses a real hardware instrument in its implementation (e.g. via calls to one or more parameters of that real hardware instrument). This is also useful when a parameter does belong to an instrument instance but that instance does not represent the real hardware instrument that the parameter interacts with: hence root_instrument of the parameter cannot be the hardware_instrument, however underlying_instrument can be implemented to return the hardware_instrument.

By default it returns the root_instrument of the parameter.

property unit: str

The unit of measure. Use '' (the empty string) for unitless.

unpack_self(value: ValuesType) list[tuple[ParameterBase, ValuesType]]
validate(value: ParameterDataTypeVar) None

Validate the value supplied.

Parameters:

value – value to validate

Raises:
  • TypeError – If the value is of the wrong type.

  • ValueError – If the value is outside the bounds specified by the validator.

property validators: tuple[Validator, ...]

Tuple of all validators associated with the parameter.

Getter:

All validators associated with the parameter.

property vals: Validator | None

The first validator of the parameter. None if no validators are set for this parameter.

Getter:

Returns the first validator or None if no validators.

Setter:

Sets the first validator. Set to None to remove the first validator.

Raises:

RuntimeError – If removing the first validator when more than one validator is set.

get_parser
set_parser
cache
get_latest
get
set
metadata
class semi_cr.core.lab.station.nodes.SeriesResistanceParameter(name: str, **kwargs: Any)[source]

Bases: CompositeParameter

get_raw() float[source]

get_raw is called to perform the actual data acquisition from the instrument. This method should either be overwritten to perform the desired operation or alternatively for Parameter a suitable method is automatically generated if get_cmd is supplied to the parameter constructor. The method is automatically wrapped to provide a get method on the parameter instance.

__getitem__(keys: Any) SweepFixedValues

Slice a Parameter to get a SweepValues object to iterate over during a sweep

__str__() str

Include the instrument name with the Parameter name if possible.

property abstract: bool | None
add_validator(vals: Validator) None

Add a validator for the parameter. The parameter is validated against all validators in reverse order of how they are added.

Parameters:

vals – Validator to add to the parameter.

property depends_on: ParameterSet
extra_validator(vals: Validator) Generator[None, None, None]

Contextmanager to to temporarily add a validator to the parameter within the given context. The validator is removed from the parameter when the context ends.

property full_name: str

Name of the parameter including the name of the instrument and submodule that the parameter may be bound to. The names are separated by underscores, like this: instrument_submodule_parameter.

get_ramp_values(value: NumberType | Sized, step: NumberType | None = None) Sequence[NumberType | Sized]

Return values to sweep from current value to target value. This method can be overridden to have a custom sweep behaviour. It can even be overridden by a generator.

Parameters:
  • value – target value

  • step – maximum step size

Returns:

List of stepped values, including target value.

property gettable: bool

Is it allowed to call get on this parameter?

global_on_set_callback = None
property has_control_of: ParameterSet
increment(value: ParameterDataTypeVar) None

Increment the parameter with a value

Parameters:

value – Value to be added to the parameter.

property instrument: InstrumentTypeVar_co

Return the first instrument that this parameter is bound to. E.g if this is bound to a channel it will return the channel and not the instrument that the channel is bound too. Use root_instrument() to get the real instrument.

property inter_delay: float

Delay time between consecutive set operations. The actual time will not be shorter than this, but may be longer if the underlying set call takes longer.

Typically used in conjunction with step to create an effective ramp rate, but can also be used without a step to enforce a delay between sets.

Getter:

Returns the current inter_delay.

Setter:

Sets the value of the inter_delay.

Raises:
property is_controlled_by: ParameterSet
property label: str

Label of the data used for plots etc.

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

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

property name: str

Name of the parameter. This is identical to short_name().

property name_parts: list[str]

List of the parts that make up the full name of this parameter

property param_spec: ParamSpecBase
property paramtype: str
property post_delay: float

Delay time after start of set operation, for each set. The actual time will not be shorter than this, but may be longer if the underlying set call takes longer.

Typically used in conjunction with step to create an effective ramp rate, but can also be used without a step to enforce a delay after every set. One might think of post_delay as how long a set operation is supposed to take. For example, there might be an instrument that needs extra time after setting a parameter although the command for setting the parameter returns quickly.

Getter:

Returns the current post_delay.

Setter:

Sets the value of the post_delay.

Raises:
property raw_value: Any

Note that this property will be deprecated soon. Use cache.raw_value instead.

Represents the cached raw value of the parameter.

Getter:

Returns the cached raw value of the parameter.

property register_name: str

Name that will be used to register this parameter in a dataset By default, this returns full_name or the value of the register_name argument if it was passed at initialization.

remove_validator() Validator | None

Remove the last validator added to the parameter and return it. Returns None if there are no validators associated with the parameter.

Returns:

The last validator added to the parameter or None if there are no validators associated with the parameter.

restore_at_exit(allow_changes: bool = True) _SetParamContext

Use a context manager to restore the value of a parameter after a with block.

By default, the parameter value may be changed inside the block, but this can be prevented with allow_changes=False. This can be useful, for example, for debugging a complex measurement that unintentionally modifies a parameter.

Example

>>> p = Parameter("p", set_cmd=None, get_cmd=None)
>>> p.set(2)
>>> with p.restore_at_exit():
...     p.set(3)
...     print(f"value inside with block: {p.get()}")  # prints 3
>>> print(f"value after with block: {p.get()}")  # prints 2
>>> with p.restore_at_exit(allow_changes=False):
...     p.set(5)  # raises an exception
property root_instrument: InstrumentBase | None

Return the fundamental instrument that this parameter belongs too. E.g if the parameter is bound to a channel this will return the fundamental instrument that that channel belongs to. Use instrument() to get the channel.

set_raw(value: Any) None

set_raw is called to perform the actual setting of a parameter on the instrument. This method should either be overwritten to perform the desired operation or alternatively for Parameter a suitable method is automatically generated if set_cmd is supplied to the parameter constructor. The method is automatically wrapped to provide a set method on the parameter instance.

set_to(value: ParameterDataTypeVar, allow_changes: bool = False) _SetParamContext

Use a context manager to temporarily set a parameter to a value. By default, the parameter value cannot be changed inside the context. This may be overridden with allow_changes=True.

Examples

>>> from qcodes.parameters import Parameter
>>> p = Parameter("p", set_cmd=None, get_cmd=None)
>>> p.set(2)
>>> with p.set_to(3):
...     print(f"p value in with block {p.get()}")  # prints 3
...     p.set(5)  # raises an exception
>>> print(f"p value outside with block {p.get()}")  # prints 2
>>> with p.set_to(3, allow_changes=True):
...     p.set(5)  # now this works
>>> print(f"value after second block: {p.get()}")  # still prints 2
property settable: bool

Is it allowed to call set on this parameter?

property short_name: str

Short name of the parameter. This is without the name of the instrument or submodule that the parameter may be bound to. For full name refer to full_name().

snapshot(update: 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 parameter as a JSON-compatible dict (everything that the custom JSON encoder class NumpyJSONEncoder supports).

If the parameter has been initiated with snapshot_value=False, the snapshot will NOT include the value and raw_value of the parameter.

Parameters:
  • update – If True, update the state by calling parameter.get() unless snapshot_get of the parameter is False. If update is None, use the current value from the cache unless the cache is invalid. If False, never call parameter.get().

  • params_to_skip_update – No effect but may be passed from superclass

Returns:

base snapshot

property snapshot_value: bool

If True the value of the parameter will be included in the snapshot.

property source: set[Parameter]
property step: int | float | integer | floating | None

Stepsize that this Parameter uses during set operation. Stepsize must be a positive number or None. If step is a positive number, this is the maximum value change allowed in one hardware call, so a single set can result in many calls to the hardware if the starting value is far from the target. All but the final change will attempt to change by +/- step exactly. If step is None stepping will not be used.

Getter:

Returns the current stepsize.

Setter:

Sets the value of the step.

Raises:
  • TypeError – if step is set to not numeric or None

  • ValueError – if step is set to negative

  • TypeError – if step is set to not integer or None for an integer parameter

  • TypeError – if step is set to not a number on None

sweep(start: float, stop: float, step: float | None = None, num: int | None = None) SweepFixedValues

Create a collection of parameter values to be iterated over. Requires start and stop and (step or num) The sign of step is not relevant.

Parameters:
  • start – The starting value of the sequence.

  • stop – The end value of the sequence.

  • step – Spacing between values.

  • num – Number of values to generate.

Returns:

Collection of parameter values to be iterated over.

Return type:

SweepFixedValues

Examples

>>> sweep(0, 10, num=5)
 [0.0, 2.5, 5.0, 7.5, 10.0]
>>> sweep(5, 10, step=1)
[5.0, 6.0, 7.0, 8.0, 9.0, 10.0]
>>> sweep(15, 10.5, step=1.5)
>[15.0, 13.5, 12.0, 10.5]
property underlying_instrument: InstrumentBase | None

Returns an instance of the underlying hardware instrument that this parameter communicates with, per this parameter’s implementation.

This is useful in the case where a parameter does not belongs to an instrument instance that represents a real hardware instrument but actually uses a real hardware instrument in its implementation (e.g. via calls to one or more parameters of that real hardware instrument). This is also useful when a parameter does belong to an instrument instance but that instance does not represent the real hardware instrument that the parameter interacts with: hence root_instrument of the parameter cannot be the hardware_instrument, however underlying_instrument can be implemented to return the hardware_instrument.

By default it returns the root_instrument of the parameter.

property unit: str

The unit of measure. Use '' (the empty string) for unitless.

unpack_self(value: ValuesType) list[tuple[ParameterBase, ValuesType]]
validate(value: ParameterDataTypeVar) None

Validate the value supplied.

Parameters:

value – value to validate

Raises:
  • TypeError – If the value is of the wrong type.

  • ValueError – If the value is outside the bounds specified by the validator.

property validators: tuple[Validator, ...]

Tuple of all validators associated with the parameter.

Getter:

All validators associated with the parameter.

property vals: Validator | None

The first validator of the parameter. None if no validators are set for this parameter.

Getter:

Returns the first validator or None if no validators.

Setter:

Sets the first validator. Set to None to remove the first validator.

Raises:

RuntimeError – If removing the first validator when more than one validator is set.

get_parser
set_parser
cache
get_latest
get
set
metadata
class semi_cr.core.lab.station.nodes.DelegatingNode(*parameters: DelegateParameter, name: str = 'DelegatingNode')[source]

Bases: SingleSourceNode

property parameters: Iterable[Parameter]
property name: str
property source: Node | None

semi_cr.core.lab.station.runtime module

semi_cr.core.lab.station.runtime.iter_child_modules(obj)[source]
semi_cr.core.lab.station.runtime.iter_routables(obj)[source]

Module contents