qcodes.station

Station objects - collect all the equipment you use to do an experiment.

class qcodes.station.Station(*components: qcodes.utils.metadata.Metadatable, config_file: Optional[Union[str, Sequence[str]]] = None, use_monitor: Optional[bool] = None, default: bool = True, update_snapshot: bool = True, **kwargs: Any)[source]

Bases: qcodes.utils.metadata.Metadatable, qcodes.utils.helpers.DelegateAttributes

A representation of the entire physical setup.

Lists all the connected Components and the current default measurement (a list of actions).

Parameters
  • *components – components to add immediately to the Station. Can be added later via self.add_component.

  • config_file

    Path to YAML files to load the station config from.

    • If only one yaml file needed to be loaded, it should be passed as a string, e.g., ‘~/station.yaml’

    • If more than one yaml file needed, they should be supplied as a sequence of strings, e.g. [‘~/station1.yaml’, ‘~/station2.yaml’]

  • use_monitor – Should the QCoDeS monitor be activated for this station.

  • default – Is this station the default?

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

default: Optional[qcodes.station.Station] = None

Class attribute to store the default station.

delegate_attr_dicts: 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.

config: Optional[qcodes.station.StationConfig] = None

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

snapshot_base(update: Optional[bool] = True, params_to_skip_update: Optional[Sequence[str]] = None) Dict[Any, Any][source]

State of the station as a JSON-compatible dictionary (everything that the custom JSON encoder class qcodes.utils.helpers.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

add_component(component: qcodes.utils.metadata.Metadatable, name: Optional[str] = None, update_snapshot: bool = True) str[source]

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

remove_component(name: str) Optional[qcodes.utils.metadata.Metadatable][source]

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.

__getitem__(key: str) qcodes.utils.metadata.Metadatable[source]

Shortcut to components dictionary.

close_all_registered_instruments() None[source]

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.

load_config_file(filename: Optional[str] = None) None[source]

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[source]

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_config(config: Union[str, IO]) None[source]

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.

close_and_remove_instrument(instrument: Union[qcodes.instrument.base.Instrument, str]) None[source]

Safely close instrument and remove from station and monitor list.

delegate_attr_objects: List[str] = []

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

load_metadata(metadata: Dict[Any, Any]) None

Load metadata into this classes metadata dictionary.

Parameters

metadata – Metadata to load.

omit_delegate_attrs: List[str] = []

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

snapshot(update: Optional[bool] = False) Dict[Any, Any]

Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override snapshot_base().

Parameters

update – Passed to snapshot_base.

Returns

Base snapshot.

load_instrument(identifier: str, revive_instance: bool = False, **kwargs: Any) qcodes.instrument.base.Instrument[source]

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

Parameters
  • identifier – The identfying 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.

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

load_all_instruments(only_names: Optional[Iterable[str]] = None, only_types: Optional[Iterable[str]] = None) Tuple[str, ...][source]

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

class qcodes.station.StationConfig[source]

Bases: Dict[Any, Any]

snapshot(update: bool = True) qcodes.station.StationConfig[source]
clear() None.  Remove all items from D.
copy() a shallow copy of D
fromkeys(value=None, /)

Create a new dictionary with keys from iterable and values set to value.

get(key, default=None, /)

Return the value for key if key is in the dictionary, else default.

items() a set-like object providing a view on D's items
keys() a set-like object providing a view on D's keys
pop(k[, d]) v, remove specified key and return the corresponding value.

If key is not found, d is returned if given, otherwise KeyError is raised

popitem() (k, v), remove and return some (key, value) pair as a

2-tuple; but raise KeyError if D is empty.

setdefault(key, default=None, /)

Insert key with a value of default if key is not in the dictionary.

Return the value for key if key is in the dictionary, else default.

update([E, ]**F) None.  Update D from dict/iterable E and F.

If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

values() an object providing a view on D's values
exception qcodes.station.ValidationWarning[source]

Bases: Warning

Replacement for jsonschema.error.ValidationError as warning.

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

qcodes.station.get_config_default_file() Optional[str][source]
qcodes.station.get_config_default_folder() Optional[str][source]
qcodes.station.get_config_enable_forced_reconnect() bool[source]
qcodes.station.get_config_use_monitor() Optional[str][source]
qcodes.station.update_config_schema(additional_instrument_modules: Optional[List[module]] = None) None[source]

Update the json schema file ‘station.schema.json’.

Parameters

additional_instrument_modules – python modules that contain qcodes.instrument.base.InstrumentBase definitions (and subclasses thereof) to be included as values for instrument definition in th station definition yaml files.