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) tuple[ndarray, ndarray, ndarray][source]
Unpack LinoSPAD2 firmware 2212 data 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.
- Returns:
data_pixels (ndarray) – 2D array of pixel coordinates in the TDC, shape (64, cycles*timestamps).
data_timestamps (ndarray) – 2D array of photon timestamps, shape (64, cycles*timestamps).
absolute_timestamps (ndarray) – Array of absolute timestamps in clock counts, one per acquisition cycle.
- Raises:
TypeError – If ‘daughterboard_number’, ‘motherboard_number’, or ‘firmware_version’ parameters are not of string type.
Notes
Each acquisition cycle is preceded by two full 32-bit words that together encode a 64-bit absolute timestamp: first word = counter bits 31:0, second word = counter bits 63:32 (verified against the firmware, tdc_array.vhd). The counter runs at 133.333 MHz, so one tick is 7.5 ns. It is free-running from FPGA configuration and is latched at the start of each acquisition window.