Data Acquisition Module

class zhinst.toolkit.control.drivers.base.DAQModule(parent: zhinst.toolkit.control.drivers.base.base.BaseInstrument, clk_rate: float = 60000000.0)

Implements a Data Acquisition Module for Lock-In instruments.

The data acquisition module is a powerful tool that builds on top of LabOne. It allows for triggered acquisition of multiple data streams on an equidistant temporal grid. For more information on how to use the DAQ Module, have a look at the LabOne Programming Manual.

This base class is overwritten by device specific DAQ classes with additional signal sources and types. After setup, the nodetree of the module is retrieved from the API and added to the DAQModule object attributes as zhinst-toolkit Parameters.

In a typical measurement using the DAQ Module one would first configure its trigger and grid settings.

>>> # configure a measurement
>>> mfli.daq.fft_window("rectangular")
>>> mfli.daq.type("continuous")
>>> mfli.daq.grid_cols(512)
>>> mfli.daq.grid_rows(10)

The signal streams that are available for acquisition can be listed using signals_list(…).

>>> # list available signal sources ...
>>> mf.daq.signals_list()
['auxin0', 'demod0', 'demod1', 'imp0']
>>> # ... and according singal types
>>> mf.daq.signals_list("demod1")
['x', 'y', 'r', 'xiy', 'theta', 'frequency', 'auxin0', 'auxin1', 'dio']

To specify which signals should be acquired during the measurement, they need to be added to the measurement. This is done with the signals_add(…) method. Note that the return value is a string with the exact node path that will be subscribed to during the measurement. The string can be used later as a key in the results dictionary.

>>> # add signals to the measurement
>>> mf.daq.signals_clear()
>>> signal1 = mf.daq.signals_add("demod1", "r")     # specify signal_source and signal_type
>>> signal2 = mf.daq.signals_add("demod1", "theta")
>>> signal3 = mf.daq.signals_add("demod1", "xiy", fft=True)

The measurement is started …

>>> # start the measurement
>>> mf.daq.measure()
subscribed to: /dev3337/demods/0/sample.r.avg
subscribed to: /dev3337/demods/0/sample.theta.avg
subscribed to: /dev3337/demods/0/sample.xiy.fft.abs.avg
Progress: 0.0%
Progress: 40.0%
...

… and afterwards the results can be found in the results attribute of the DAQModule. The values in the dictionary are of type DAQResults.

>>> # retrieve the measurement results
>>> result1 = mf.daq.results[signal1]
>>> result2 = mf.daq.results[signal2]
>>> result3 = mf.daq.results[signal3]
>>> ...
>>> result1
<zhinst.toolkit.control.drivers.base.daq.DAQResult object at 0x0000023B8467D588>
    path:        /dev3337/demods/0/sample.xiy.fft.abs.avg
    value:       (10, 511)
    frequency:   (511,)

See below for details on zhinst.toolkit.control.drivers.base.daq.DAQResult.

signals

A list of node strings of signals that are added to the measurement and will be subscribed to before data acquisition.

Type

list

results

A dictionary with signal strings as keys and zhinst.toolkit.control.drivers.base.daq.DAQResult objects as values that hold all the data of the measurement result.

Type

dict

measure(verbose: bool = True, timeout: float = 20) → None

Performs the measurement.

Starts a measurement and stores the result in daq.results. This method subscribes to all the paths previously added to daq.signals, then starts the measurement, waits until the measurement in finished and eventually reads the result.

Keyword Arguments
  • verbose (bool) – A flag to enable or disable console output during the measurement. (default: True)

  • timeout (int) – The measurement will be stopped after the timeout. The valiue is given in seconds. (default: 20)

signals_add(signal_source: str, signal_type: str = '', operation: str = 'avg', fft: bool = False, complex_selector: str = 'abs') → str

Add a signal to the signals list to be subscribed to during measurement.

The specified signal is added to the property signals list. On measure(), the DAQ Module subscribes to all the signal nodes in the list.

Parameters

signal_source (str) – The source of the signal, e.g. ‘demod0’. See signals_list() for available signals.

Keyword Arguments
  • signal_type (str) – The type of the signal. Depends on the given source, e.g. for demod signals the types’X’, ‘Y’, ‘R’, ‘Theta’, … are available. See signals_list({signal source}) for available signal types. (default: “”)

  • operation (str) – The operation that is performed on the acquired signal, e.g. the average of data points (‘avg’), the standard deviation of the signal (‘std’) or single points (‘replace’). (default: “avg”)

  • fft (bool) – A flag to enable the fourier transform (FFT) of the acquired signal. (default: False)

  • complex_selector (str) – If the FFT is enabled, this selects the complex value of the result, e.g. ‘abs’, ‘phase’, ‘real’, ‘imag’. (default: “abs”)

Returns

A string with the exact signal node that will be acquired during the measurement. It can be used as a key in the results dict to retrieve the measurement result corresponding to this signal, e.g.

>>> signal = mfli.daq.signal_add("demod0", "r")
/dev3337/demods/0/sample.r.avg
>>> mfli.daq.measure()
>>> ...
>>> result = mfli.daq.results[signal]

signals_clear() → None

Resets the signals list.

signals_list(source=None) → List

Returns a list of all the available signal sources for data acquisition.

Keyword Arguments

source (str) – specifies the signal source to return signal types (default: None)

Returns

Returns all available signal sources by default. If the keyword is specified with one of the signal sources, all the available signal types for the signal source are returned.

trigger(trigger_source: str, trigger_type: str) → None

Sets the trigger signal of the DAQ Module.

This method can be used to specify the signal used to trigger the data acquisition. Use the method trigger_list() to see the available trigger signal sources and types.The trigger node can also be set directly using the module Parameter triggernode.

Parameters
  • trigger_source (str) – A string that specifies the source of the trigger signal, e.g. “demod0”.

  • trigger_trype (str) – A string that specifies the type of the trigger signal, e.g. “trigin1”.

trigger_list(source=None) → List

Returns a list of all the available signal sources for triggering.

Keyword Arguments

source (str) – specifies the signal source to return signal types (default: None)

Returns

Returns all available trigger sources by default. If the keyword is specified with one of the trigger sources, all the available trigger types for the trigger source are returned.

Result class for the Data Acquisition Module

class zhinst.toolkit.control.drivers.base.daq.DAQResult(path: str, result_dict: Dict, clk_rate: float = 60000000.0)

A wrapper class around the result of a DAQ Module measurement.

The Data Acquisition Result class holds all measurement information returned from the API. The attribute value is a two-dimensional numpy array with the measured data along the measured grid. Depending on whether the time trace or the FFT of a signal was acquired, either the time of frequency attribute holds a 1D numpy array with the correct axis values calculated from the measurement grid.

>>> signal = mf.daq.signals_add("demod1", "r")
>>> mf.daq.measure()
...
>>> result = mf.daq.results[signal]
>>> result
<zhinst.toolkit.control.drivers.base.daq.DAQResult object at 0x0000023B8467D588>
    path:        /dev3337/demods/0/sample.r.avg
    value:       (10, 511)
    time:        (511,)
>>> result.header
   {'systemtime': array([1585136936490779], dtype=uint64),
    'createdtimestamp': array([548560038356], dtype=uint64),
    'changedtimestamp': array([548669852116], dtype=uint64),
    'flags': array([1977], dtype=uint32),
    ...
>>> plt.imshow(result.value, extent=[result.time[0], result.time[-1], 0, result.shape[0]])
value

A 2D numpy array with the measurement result.

Type

array

shape

A tuple with the shape of the acquired data which corresponds to the according grid settings.

Type

tuple

time

A 1D numpy array containing the time axis of the measurement in seconds. Calculated from the returned timestamps using the DAC clock rate. If the result is a Fourier transform this value is None.

Type

array

frequency

A 1D numpy array with the frequency values for FFT measurements in Hertz. If the signal is not a FFT this value is None The frequency grid is calculated from the grid settings. If the “xiy” complex signal of the demodulator data stream is acquired, the frequency spectrum is symmetric around 0 Hz, otherwise it is positive.

Type

array

header

A dictionary containing all information about the measurement settings.

Type

dict