Nodetree and Parameters


class zhinst.toolkit.control.node_tree.NodeTree(device)

Bases: zhinst.toolkit.control.node_tree.Node

Recreates the device’s nodetree.

Implements a NodeTree data structure used to access the settings (Parameter) of any Zurich Instruments device. A NodeTree is created for every instrument when it is connected to the data server. In this way the available settings always directly correspond to the Nodes that are available on the device.

Inherits from the Node class. On initialization the NodeTree retireves a nested dictionary from the device representing its nodetree heirarchy and then recursively adds Nodes and Parameters as attributes to the Node.

An underscore will be appended to nodes that are identical to reserved keywords in Python (e.g., in -> in_).

>>> hdawg.nodetree
< object at 0x0000021E467D3BA8>
- stats
- oscs
- status
- sines
- awgs
- dio
- system
- sigouts
- triggers
- features
- cnts
- clockbase

device (BaseInstrument) – A reference to the instrument that the NodeTree belongs to. Used for getting and setting of each Parameter.


The associated device.




A nested dictionary created from the dict returned by daq.listNodesJSON(…) of the zhinst.ziPython Python API.




class zhinst.toolkit.control.node_tree.Node(parent)

Implements a node in the NodeTree of a device.

A Node has a parent node and a device it is associated with. It can hold other Nodes as well as Parameters. The data structure of the device NodeTree is recreated by recursively adding either other Nodes or Parameters as attributes to the Node.

To make it easier fo the user to navigate the device NodeTree, each Node has the attributes nodes and parameters that holds a list its children. Also the __repr__() method is overwritten such that the output in the console is useful:

>>> hdawg.nodetree.sigouts[0]
< object at 0x0000021E49397470>
- precompensation
- on
- range
- direct
- over

parent (Node) – The parent Node that the Nodes or Parameters are added to as attributes.


A list of other Node s that are children of this Node.




A list of Parameter s that are children of this Node.



Node List

class zhinst.toolkit.control.node_tree.NodeList(iterable=(), /)

Implements a list of Nodes.

Simply inherits from List and overrides the __repr__() method to make it look nice in the console or in a notebook.

>>> hdawg.nodetree.sigouts
Iterable node with 8 items:
    Node 1:
    < object at 0x0000021E49397470>
    - precompensation
    - on
    - range
    - direct
    - over
>>> for sigout in hdawg.nodetree.sigouts:
>>>     sigout.range(1.5)


class zhinst.toolkit.control.node_tree.Parameter(parent, params: Dict, device=None, set_parser: Union[Callable, list] = <function Parameter.<lambda>>, get_parser: Callable = <function Parameter.<lambda>>, auto_mapping: bool = False, mapping: Dict = None, dynamic_path: Callable = None)

Implements a zhinst-toolkit Parameter.

Implements a callable Parameter as leaves in the NodeTree with a parent Node and a device. It holds the information from the daq.listNodesJSON(…) method of the Zurich Instruments Python API such as the node path, the description, properties, etc. The __repr__() method returns a string with a summary of the Parameter.

>>> uhfqa.nodetree.osc.freq
Node: /DEV2266/OSCS/0/FREQ
Description: Frequency control of the oscillator.
Type: Double
Properties: Read, Write, Setting
Options: none
Unit: Hz
Value: none

Setting and getting a Parameter is easy. Just call the Parameter with or without an argument:

>>> uhfqa.nodetree.osc.freq(10e6)
>>> uhfqa.nodetree.osc.freq()
  • parent (BaseInstrument, NodeTree or Node) – The parent object that the Parameter is associated to.

  • params (dict) – Dictionary with a definition of the Parameter. It must contain the item ‘Node’ corresponding to the node path of the parameter on the device that is used for getting and setting the Parameter value. It may contain the items ‘Description’, ‘Properties’, ‘Options’, ‘Unit’, ‘Type’.

  • device (BaseInstruemnt) – The device driver that the Parameter is associated to. The device is eventually used to set(…) and get(…) the node (default: None).

  • set_parser (Callable or list) – A parser function or a list of parser functions that are called with the set value before setting the value and return the parsed parameter value (default: ‘lambda v: v’).

  • get_parser (Callable) – A parser function that is called with the gotten value from the device before returning it by the getter. It returns the parsed parameter value (default: ‘lambda v: v’).

  • auto_mapping (bool) – A flag that specifies whether a value mapping should be constructed automatically from the options obtained from the device node.

  • mapping (dict) – A value mapping for keyword to integer conversion (default: None).

__call__(value=None, sync=False)

Make the object callable.

Override the __call__(…) method for setting and getting the Parameter value. The Parameter can then be gotten by calling it with no arguments. It is set by calling it with the value as an argument. This works similarly to parameters in qcodes.

Keyword Arguments
  • value – An optional value to call the Parameter with if it is set, leaving the argument out gets the Parameter from the device (default: None).

  • sync (bool) – A flag that specifies if a synchronisation should be performed between the device and the data server after setting the Parameter value (default: False).


The value that the setter returns if a value is specified, otherwise the returned value from the getter.

assert_value(value: Any, blocking: bool = True, timeout: float = 2, sleep_time: float = 0.005) → None

Check if the parameter has the expected value.

Passes the keyword arguments to the _assert_node_value of the BaseInstrument.

  • value (Any) – Value the parameter is expected to change to.

  • blocking (bool) – A flag that specifies if the program should be blocked until the node has the expected value (default: True).

  • timeout (float) – Maximum time in seconds the program waits when blocking is set to True (default: 2).

  • sleep_time (float) – Time in seconds to wait between requesting the node value (default: 0.005)


ToolkitConnectionError – If called and the device in not yet connected to the data server.


Either True or False to indicate whether the node does or does not have the expected value