daplis.functions.unpack module

Module with scripts for unpacking data from LinoSPAD2.

This file can also be imported as a module and contains the following functions:

  • unpack_binary_data - function for unpacking data from LinoSPAD2,

firmware version 2212. Utilizes the numpy library to speed up the process.

  • unpack_binary_data_with_absolute_timestamps - function for

unpacking data from LinoSPAD2, including the absolute timestamps, works with firmware version 2212.

daplis.functions.unpack.unpack_binary_data(file: str, daughterboard_number: str, motherboard_number: str, firmware_version: str, timestamps: int = 512) tuple[ndarray, ndarray][source]

Unpacks binary-encoded data from LinoSPAD2 firmware version 2212.

Parameters:
  • file (str) – Path to the binary data file.

  • daughterboard_number (str) – LinoSPAD2 daughterboard number.

  • motherboard_number (str) – LinoSPAD2 motherboard (FPGA) number, including the “#”.

  • firmware_version (str) – LinoSPAD2 firmware version. Either ‘2212s’ (skip) or ‘2212b’ (block).

  • timestamps (int, optional) – Number of timestamps per cycle per TDC per acquisition cycle. The default is 512.

Returns:

  • data_pixels (array-like) – 2D array of pixel coordinates in the TDC.

  • data_timestamps (array-like) – 2D array of photon timestamps.

Raises:

TypeError – If ‘daughterboard_number’, ‘motherboard_number’, or ‘firmware_version’ parameters are not of string type.

Notes

The returned data are two 2D arrays where rows represent TDC numbers, columns represent the data, and each cell contains a pixel number in the TDC (from 0 to 3) or the timestamp recorded by that pixel.

daplis.functions.unpack.unpack_binary_data_with_absolute_timestamps(file_path: str, daughterboard_number: str, motherboard_number: str, firmware_version: str, timestamps: int = 512, include_offset: bool = False, apply_calibration: bool = True) ndarray[source]

Unpacks binary-encoded data from LinoSPAD2 firmware version 2212 with absolute timestamps.

Parameters:
  • file_path (str) – Path to the binary data file.

  • daughterboard_number (str) – LinoSPAD2 daughterboard number.

  • motherboard_number (str) – LinoSPAD2 motherboard (FPGA) number, including the “#”.

  • firmware_version (str) – LinoSPAD2 firmware version. Either ‘2212s’ (skip) or ‘2212b’ (block) are accepted.

  • timestamps (int, optional) – Number of timestamps per TDC per acquisition cycle. The default is 512.

  • include_offset (bool, optional) – Switch for applying offset calibration. The default is True.

  • apply_calibration (bool, optional) – Switch for applying TDC and offset calibration. If set to ‘True’ while include_offset is set to ‘False’, only the TDC calibration is applied. The default is True.

Returns:

  • data_all (array-like) – 3D array of pixel coordinates in the TDC and the timestamps.

  • absolute_timestamps (array-like) – Array of absolute timestamps in ps, with length equal to the number of acquisition cycles, as the absolute timestamps are recorded at the start of each cycle.

Raises:
  • TypeError – If ‘daughterboard_number’, ‘motherboard_number’, or ‘firmware_version’ parameters are not of string type.

  • FileNotFoundError – If no calibration data file is found.

Notes

The returned data is a 3D array where rows represent TDC numbers, columns represent the data, and each cell contains a pixel number in the TDC (from 0 to 3) and the timestamp recorded by that pixel. Additionally, an array of absolute timestamps is returned, representing the absolute time at the start of each acquisition cycle.

Absolute timestamps are inserted at the start of each cycle. The value of these timestamps is given by the 400 MHz clock.