Nodetree and Parameters

Nodetree

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.

>>> hdawg.nodetree
<zhinst.toolkit.tools.nodetree.NodeTree object at 0x0000021E467D3BA8>
nodes:
- stats
- oscs
- status
- sines
- awgs
- dio
- system
- sigouts
- triggers
- features
- cnts
parameters:
- clockbase
Parameters

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

device

The associated device.

Type

BaseInstrument

nodetree_dict

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

Type

dict

Node

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 taht holds a list its children. Also the __repr__() method is overwritten such that the output in the console is useful:

>>> hdawg.nodetree.sigouts[0]
<zhinst.toolkit.tools.nodetree.Node object at 0x0000021E49397470>
nodes:
- precompensation
parameters:
- on
- range
- direct
- over
...
nodes

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

Type

list

parameters

A list of Parameters that are children of this Node.

Type

list

Node List

class zhinst.toolkit.control.node_tree.NodeList

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:
    <zhinst.toolkit.tools.nodetree.Node object at 0x0000021E49397470>
    nodes:
    - precompensation
    parameters:
    - on
    - range
    - direct
    - over
...
>>> for sigout in hdawg.nodetree.sigouts:
>>>     sigout.range(1.5)

Parameter

class zhinst.toolkit.control.node_tree.Parameter(parent, params: Dict, device=None, set_parser: Callable = <function Parameter.<lambda>>, get_parser: Callable = <function Parameter.<lambda>>, mapping: Dict = 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()
10000000.00
Parameters
  • 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’.

Keyword Arguments
  • 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) – A parser function that is called with the set value before setting the value and returns the parsed parameter value. (default: ‘lambda v: v’)

  • set_parser – 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’)

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

__call__(value=None)

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.

Parameters

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)

Returns

The value that has been set if a value is specified, otherwise the returned value from the getter.