daplis.functions.calibrate module

Module for working with the calibration data.

Functions in this module can be used to analyze the LinoSPAD2 data to collect either a calibration matrix for compensating TDC nonlinearities or a calibration matrix for offset calibration. First nonlinearity is introduced by nonequal bins of the 140-bin long TDC line while the second - from the different-length electrical path in the PCB.

The calibration matrices (for TDC calibration) and arrays (for offset calibration) should be put into ~/LinoSPAD2/src/LinoSPAD2/params /calibration_data folder, where it will be pulled from by other functions during analysis.

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

  • calibrate_and_save_TDC_calibration - calculate a calibration

matrix of the TDC calibrations and save it as a ‘.csv’ table.

  • unpack_data_for_offset_calibration - unpack binary data applying

TDC calibration in the process. Used for calculations of the offset calibration.

  • save_offset_timestamp_differences - calculate and save timestamps

differences for pairs of pixels 0, 4 to 255, and 1 to 3 for finding the delta t peaks for calculating the offset calibration.

  • calculate_and_save_offset_calibration - calculate and save the 256

offset compensations for all pixels of the given LinoSPAD2 sensor half. The output is saved as a .npy file for later use.

  • load_calibration_data - load the calibration matrix from a ‘.csv’

table.

daplis.functions.calibrate.calibrate_and_save_TDC_data(path: str, daughterboard_number: str, motherboard_number: str, firmware_version: str, timestamps: int = 1000)[source]

Calculate and save calibration data for TDC nonlinearities.

Function for calculating the calibration matrix and saving it into a ‘.csv’ file. The data files used for the calculation should be taken with the sensor uniformly illuminated by ambient light.

Parameters:
  • path (str) – Path to the folder with the ‘.dat’ data files.

  • daughterboard_number (str) – LinoSPAD2 daughterboard number.

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

  • firmware_version (str) – LinoSPAD2 firmware version. Versions “2208”, “2212s” (skip), and “2212b” (block) are recognized.

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

Return type:

None.

Raises:

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

Notes

The resulting calibration matrix is saved as a ‘.csv’ file, with the filename formatted as “TDC_{db}_{mb}_{fw_ver}.csv”, where {db}, {mb}, and {fw_ver} represent the daughterboard number, motherboard number, and firmware version, respectively.

daplis.functions.calibrate.load_calibration_data(calibration_path: str, daughterboard_number: str, motherboard_number: str, firmware_version: str, include_offset: bool = False)[source]

Load the calibration data.

Parameters:
  • calibration_path (str) – Path to the ‘.csv’ file with the calibration matrix.

  • daughterboard_number (str) – The LinoSPAD2 daughterboard number.

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

  • firmware_version (str) – LinoSPAD2 firmware version.

  • include_offset (bool, optional) – Switch for including the offset calibration. The default is False.

Returns:

  • data_matrix (numpy.ndarray) – 256x140 matrix containing the calibrated data.

  • offset_arr (numpy.ndarray, optional) – Array of 256 offset values, one for each pixel. Returned only if include_offset is True.