4.1.1.1.1.2. lib.data_handling.data_converter
#
Module that provides functionality in order to post-process data, here construct experiment object from input data.
@author: Thomas Arne Hensel, 2023
4.1.1.1.1.2.1. Module Contents#
4.1.1.1.1.2.1.1. Classes#
Class that provides a constructor object in order to create experiments from loaded data. Can be full experiments (from simulations) or extracted data from real experiments. |
4.1.1.1.1.2.1.2. API#
- class lib.data_handling.data_converter.Constructor(obj, collect_artefacts=True)#
Class that provides a constructor object in order to create experiments from loaded data. Can be full experiments (from simulations) or extracted data from real experiments.
Initialization
Initialize the Constructor object.
- Parameters:
obj (Experiment or str) – Experiment object or path to data (tif, tiff, yaml).
collect_artefacts (bool) – Whether to collect artefacts during extraction (default is True).
- get_experiments(batchsize=1, agnostic=True, fast_return=False)#
Construct experiments from a file or experiment object, segmented at bleaching steps. Currently functional for phase scans!!!
- Parameters:
batchsize (int, optional) – Number of lines to be averaged with moving average.
agnostic (bool, optional) – Boolean, default=True. Forget about all information from the experiment.
fast_return (bool, optional) – Optional direct return of the experiment object. The routine effectively only reshapes the record.
- Returns:
List of experiments.
- Return type:
list
- _get_bgr_estimate(avg_scan_seg)#
Retrieve the average number of background photons from 0M experiment.
- Parameters:
avg_scan_seg (list) – List containing x and y segments.
- Returns:
Average number of background photons in each axis.
- Return type:
numpy.ndarray
- _get_beta_estimate(N_bgr, brightness)#
Calculate the beta estimate.
- Parameters:
N_bgr (numpy.ndarray) – Average number of background photons in each axis.
brightness (list) – Estimated brightness.
- Returns:
Beta estimate.
- Return type:
numpy.float64
- _get_brightness_estimate(avg_scan_seg, N_bgr)#
Calculate the brightness estimate.
- Parameters:
avg_scan_seg (list) – List containing x and y segments.
N_bgr (numpy.ndarray) – Average number of background photons in each axis.
- Returns:
Estimated brightness.
- Return type:
list
- _construct_record(seg, exp, brightness, restore_line_order=False, agnostic=True)#
Construct a measurement record from experimental or simulated data, e.g., after averaging.
Takes a scan segment (e.g., 2M or 1M or 0M) and divides it into x and y blocks. Each segment is a list of [x_avg_scan, y_avg_scan]. Those pairs form 1 record by combining all their measurement sites and counts (considering the block_size!). This procedure is repeated, and a dictionary of measurement records is returned. If a MeasurementRecord object is provided, the counts are substituted by seg, and the record is truncated. If agnostic mode is chosen, c0 is estimated from record; otherwise, the default from the provided experiment is chosen.
- Parameters:
seg (list) – List of x/y segments.
exp (Experiment) – Experiment object with information on how to construct the record.
brightness (list) – Estimated brightness.
restore_line_order (bool) – Option to assemble blocks as in the original scan or keep plain x-y scans.
agnostic (bool) – If True, be agnostic about c0 and estimate from counts.
- Returns:
Record object.
- Return type:
MeasurementRecord
- _assemble_blocks(x_scans, y_scans, seg_idcs)#
Re-assemble the x- and y-segments to an array with alternating x- and y-blocks according to the segment indices.
- Parameters:
x_scans (list) – List of x-scans.
y_scans (list) – List of y-scans.
seg_idcs (numpy.ndarray) – Segment indices.
- Returns:
Assembled array with alternating x- and y-blocks.
- Return type:
numpy.ndarray