daplis.functions.cross_talk module
Module for analyzing cross-talk of LinoSPAD2.
A set of functions to calculate and save, collect and plot the cross-talk data for the given data sets.
This file can also be imported as a module and contains the following functions:
collect_dcr_by_file - calculate the DCR for each file in the
given folder and save the result into a .pkl file. Calculate average and median DCR with and without masking the hot pixels.
plot_dcr_histogram_and_stability - plot the DCR vs file to check
setup stability, and plot histogram of DCR averaged over files together with integral over pixels
zero_to_cross_talk_collect - collect timestamp differences from
the ‘.dat’ with the cross-talk data (preferably, noise only). Timestamp differences are collected for the given hot pixels plus 20 pixels to each side of the hot pixel where it is possible. The result is saved into a ‘.feather’ file.
zero_to_cross_talk_plot - collect the timestamp differences from
the ‘.feather’ file and plot the cross-talk peaks applying a Gaussian fit where possible, plot the average cross-talk probability vs distance from the hot pixel for each pair of aggressor-victim pixels, and finally plot the average cross-talk probability for the whole sensor half.
- daplis.functions.cross_talk.collect_dcr_by_file(path: str, daughterboard_number: str, motherboard_number: str, firmware_version: str, timestamps: int = 1000)[source]
Calculate dark count rate in counts per second per pixel.
Calculate dark count rate for the given daughterboard and motherboard in units of counts per second per pixel for each file in the given folder and save the resulting list as a .pkl file.
- Parameters:
path (str) – Path to the folder with the ‘.dat’ data files.
daughterboard_number (str) – LinoSPAD2 daughterboard number.
motherboard_number (str) – LinoSPAD2 motherboard (FPGA) number, including the ‘#’.
firmware_version (str) – LinoSPAD2 firmware version.
timestamps (int, optional) – Number of timestamps per acquisition cycle per TDC. The default is 1000.
- Raises:
TypeError – Raised if the firmware version given is not recognized.
TypeError – Raised if the daughterboard number given is not recognized.
TypeError – Raised if the motherboard number given is not recognized.
- daplis.functions.cross_talk.plot_dcr_histogram_and_stability(path: str, hist_number_of_bins: int = 200)[source]
Plot median DCR vs file and histogram of DCR with integral.
Plot median DCR vs file for checking the setup stability. Also, plot a histogram of DCR together with intergral over pixels in units of %.
- Parameters:
path (str) – Path to the folder with ‘.dat’ data files.
hist_number_of_bins (int, optional) – Number of bins for the DCR histogram. The default is 200.
- Raises:
FileNotFoundError – Raised if the folder with the DCR data was not found.
FileNotFoundError – Raised if the .pkl file with the DCR data was not found.
- daplis.functions.cross_talk.unpickle_cross_talk(pkl_file: str)[source]
Unpickle a saved cross-talk plot and return data.
Load the pickled ‘.pkl’ file with the figure, return the figure, extract the data points and errorbars for y and return them.
- Parameters:
pkl_file (str) – Absolute path to the ‘.pkl’ file with the cross-talk plot.
- Returns:
A tuple containing three numpy arrays: - x : ndarray
The x-coordinates of the data points.
- yndarray
The y-coordinates of the data points.
- yerrndarray
The y-error values associated with each data point.
- Return type:
tuple of numpy.ndarray
- daplis.functions.cross_talk.zero_to_cross_talk_collect(path: str, pixels: List[int], rewrite: bool, daughterboard_number: str, motherboard_number: str, firmware_version: str, timestamps: int, include_offset: bool = False, delta_window: float = 50000.0, apply_calibration: bool = True, absolute_timestamps: bool = False, correct_pix_address: bool = False)[source]
Collect timestamp differences from cross-talk data.
For the given list of hot pixels, collect all timestamp differences for pairs of pixels as aggressor-victim, where the victim pixel is taken from each side of the aggressor (where applicable) and up to the distance of 20 pixels (e.g., 100,120).
- Parameters:
path (str) – Path to the folder with the ‘.dat’ data files.
pixels (list) – List of pixels to use as aggressors. These can be hot pixels or pixels where the signal is focused.
rewrite (bool) – Switch for rewriting the feather file with timestamp differences. Used for conscious start of an hours-long data processing and avoiding rewriting/deleting already existing files.
daughterboard_number (str) – LinoSPAD2 daughterboard number.
motherboard_number (str) – LinoSPAD2 motherboard (FPGA) number, including the ‘#’.
firmware_version (str) – LinoSPAD2 firmware version.
timestamps (int) – Number of timestamps per TDC per cycle used during data collection.
include_offset (bool) – Switch for including the offset calibration. The default is False.
delta_window (float, optional) – Window size for collecting timestamp differences. The default is 50e3.
apply_calibration (bool, optional) – Switch for applying callibration. The default is True.
absolute_timestamps (bool, optional) – Indicator of data collected with absolute timestamps. The default is False.
correct_pix_address (bool, optional) – Correct pixel address for the FPGA board on side 23. Here used to reverse the correction. The default is False.
- daplis.functions.cross_talk.zero_to_cross_talk_plot(path: str, pixels: List[int], delta_window: float = 50000.0, multiplier: int = 10, show_plots: bool = False, feather_file_name: str = '')[source]
Plot cross-talk peaks and as average vs distance from aggressor.
For the given pixels, look for the timestamp differences in feather files, plot histograms and fits with Gaussian of cross-talk peaks for each pair of pixels (aggressor-victim), collects cross-talk peak population in a 2*sigma window, plots as average vs distance from the aggressor for each aggressor pixel and to each side (to the left and to the right). Finally, averages all numbers and produces a single plot of average cross-talk vs distance from the aggressor across all hot pixels.
- Parameters:
path (str) – Path to the folder with the ‘.dat’ data files.
pixels (List[int]) – List of pixels to use as aggressors. These can be hot pixels or pixels where the signal is focused.
delta_window (float, optional) – Window size for histograms of timestamp differences. The default is 50e3.
multiplier (int, optional) – Multiplier of average LinoSPAD2 time bin, which is 17.857 ps, for histograms. The default is 10.
show_plots (bool, optional) – Switch for showing the plots at the end. The default is False.
feather_file_name (str, optional) – Naming pattern of the feather files that can be used when actual data files are not available. The pattern should include the number of the first and the last data files, e.g., “0000010000-0000012000”. The default is “”.
- Raises:
FileNotFoundError – Raised when no txt file with the sensor population data is found.