generic
Generic algorithms.
This module contains algorithms that perform generic data processing operations, not tied to a specific experimental technique (e.g.: data accumulation, radial averaging, binning, etc.).
RadialProfile
See documentation of the __init__
function.
__init__(*, radius_pixel_map, radial_parameters)
Radial average calculation.
This algorithm stores all the parameters needed to calculate the pixel-based radial profile of a detector data frame. After the algorithm has been initialized, it can be invoked to compute the radial profile of a data frame.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
radius_pixel_map |
NDArray[numpy.float_]
|
A pixel map storing radius information for the detector data frame on which the algorithm is applied.
|
required |
radial_parameters |
Dict[str, Any]
|
A set of OM configuration parameters collected together in a parameter group. The parameter group must contain the following entries:
|
required |
get_radial_bin_labels()
Gets the radial bin label information.
This function returns an array, with the same shape as the data frame on which the algorithm is applied, containing bin labelling information. Each element of the array corresponds to a pixel in the data frame, and stores the index of the radial bin in which the pixel falls according to the radius information provided to the algorithm.
Returns:
Type | Description |
---|---|
NDArray[numpy.int_]
|
An array containing the bin labelling information. |
get_bad_pixel_map()
Gets the bad pixel map provided to the algorithm.
This function returns the bad pixel map provided to the algorithm at initialization. If no bad pixel map was provided, the function returns None.
Returns:
Type | Description |
---|---|
Union[NDArray[numpy.bool_], None]
|
The bad pixel map provided to the algorithm at initialization, or None if |
Union[NDArray[numpy.bool_], None]
|
no map was provided. |
calculate_profile(data)
Calculates the radial profile for a detector data frame.
This function calculates the radial profile of a provided detector data frame.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
Union[NDArray[numpy.float_], NDArray[numpy.int_]]
|
the detector data frame for which the radial profile must be calculated. |
required |
Returns:
Type | Description |
---|---|
NDArray[numpy.float_]
|
The radial profile. |
Binning
See documentation of the __init__
function.
__init__(*, layout_info, parameters)
Binning of detector data frames.
This algorithm stores all the parameters needed to bin the data in a detector data frame. After the algorithm has been initialized, it can be invoked to bin the data in a data frame, or to generate pixel maps and masks that are compatible with the binned data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
layout_info |
TypeDetectorLayoutInformation
|
An object storing information about the internal data layout of the detector frame on which the algorithm is applied (number and size of ASICs, etc.). |
required |
parameters |
Dict[str, Any]
|
A set of OM configuration parameters collected together in a parameter group. The parameter group must contain the following entries:
|
required |
is_passthrough()
Whether the algorithm performs a simple passthrough operation.
This function returns information on whether the algorithm performs a simple passthrough operation (See BinningPassthrough). For this algorithm, the function always returns False.
Returns:
Type | Description |
---|---|
bool
|
Whether the algorithm performs a simple passthrough operation. |
get_bin_size()
Gets the size of the binning area.
This function returns the size of the area in the original data that gets
transformed in a single pixel in the binned data. Specifically, the function
returns the length of the edge of the area: if an area of size
bin size x bin size
in the original data ends up in a single binned pixel,
the function returns the value of bin_size
.
Returns:
Type | Description |
---|---|
int
|
The length of the edge of the binning area. |
get_binned_layout_info()
Gets the data layout information for the binned data frame.
This function returns information about the internal data layout of a binned frame generated by the algorithm.
Returns:
Type | Description |
---|---|
TypeDetectorLayoutInformation
|
A dictionary with the data layout information for the binned frame. |
bin_detector_data(*, data)
Computes a binned version of the detector data frame.
This function computes the binned version of a provided detector data frame. For each binning area in the original data frame, the function initially computes the average value of all pixels, excluding the ones that are must be ignored. It then multiplies the calculated average value by the total number of pixels in the binning area. The result is used to fill, in the binned frame, the binned pixel corresponding to the original area. If, however, the binned pixel is determined to be invalid (too many pixels in the original area must be ignored), this function uses a fallback value to fill it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
Union[NDArray[numpy.float_], NDArray[numpy.int_]]
|
The detector data frame on which the binning must be performed. |
required |
Returns:
Type | Description |
---|---|
NDArray[numpy.float_]
|
A binned version of the detector data frame. |
bin_bad_pixel_map(*, mask)
Computes a bad pixel map for a binned data frame.
Starting from a bad pixel map designed for the original detector frame, this function calculates a bad pixel map that can be used with a binned data frame generated by the algorithm.
In the bad pixel map computed by this function, only binned pixels originating from binning areas containing exclusively good pixels are marked as good. If even a single bad pixel was present in the original binning area, this function labels the corresponding binned pixel as bad.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mask |
Union[NDArray[numpy.int_], None]
|
An array storing a bad pixel map for the original data frame.
|
required |
Returns:
Type | Description |
---|---|
Union[NDArray[numpy.int_], None]
|
Either an array containing the binned map or None if the |
Union[NDArray[numpy.int_], None]
|
argument is None. |
bin_pixel_maps(*, pixel_maps)
Computes pixel maps for a binned data frame.
Starting from pixel maps designed for the original detector frame, this function calculates pixel maps that can be used with a binned data frame generated by the algorithm.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pixel_maps |
TypePixelMaps
|
A dictionary storing the pixel maps for the original detector frame. |
required |
Returns:
Type | Description |
---|---|
TypePixelMaps
|
A dictionary storing the pixel maps for the binned frame. |
bin_peak_positions(peak_list)
Computes peaks positions for a binned data frame.
Starting from a list of peaks detected in the original detector frame, this function calculates the coordinates of the same peaks in a binned data frame generated by the algorithm.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
peak_list |
TypePeakList
|
An dictionary storing information about a set of peaks detected in the original detector frame. |
required |
Returns:
Type | Description |
---|---|
TypePeakList
|
A dictionary storing information about the detected peaks in the binned |
TypePeakList
|
data frame. |
BinningPassthrough
See documentation of the __init__
function.
__init__(*, layout_info)
Passthrough binning of detector data frames.
This algorithm has the same interface as the Binning algorithm. All the functions, however, perform no operation at all, simply returning the original detector layout information, detector data frame, bad pixel map, or pixel maps.
This algorithm exists to avoid filling the code base with if statements that just check if binning is required and call the Binning algorithm accordingly.
After a single initial check of the form:
if binning_required:
binning = Binning(...)
else:
binning = BinningPassthrough(...)
The rest of the code can avoid performing checks and simply call the methods of
the binning
instance, expecting the correct behavior.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
layout_info |
TypeDetectorLayoutInformation
|
An object storing information about the internal layout of the detector data frame on which the algorithm is applied (number and size of ASICs, etc.). |
required |
is_passthrough()
Whether the algorithm performs a passthrough operation.
This function returns information on whether the algorithm performs a simple passthrough operation. For this algorithm, the function always returns True.
Returns:
Type | Description |
---|---|
bool
|
Whether the algorithm performs a simple passthrough operation. |
get_bin_size()
Gets the size of the binning area.
This function returns the size of the area in the original data that gets transformed in a single pixel in the binned data.
Since the BinningPassthrough
algorithm performs no binning operation at all,
this function always returns 1.
Returns:
Type | Description |
---|---|
int
|
The size of the edge of binning area. |
get_binned_layout_info()
Gets the data layout information for the binned data frame.
This function returns information about the internal data layout of a binned frame generated by the algorithm.
Since the BinningPassthrough
algorithm performs no binning operation at all,
this function always returns the layout information initially provided to the
algorithm.
Returns:
Type | Description |
---|---|
TypeDetectorLayoutInformation
|
A dictionary with the data layout information for the binned frame. |
bin_detector_data(*, data)
Computes a binned version of the detector data frame.
This function generates the binned version of a provided detector data frame.
Since the BinningPassthrough
algorithm performs no binning operation at all,
this function always returns the detector data frame provided as input.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
Union[NDArray[numpy.float_], NDArray[numpy.int_]]
|
The detector data frame on which the binning must be performed. |
required |
Returns:
Type | Description |
---|---|
NDArray[numpy.float_]
|
A binned version of the detector data frame. |
bin_bad_pixel_map(*, mask)
Computes a bad pixel map for the binned data frame.
Starting from a bad pixel map designed for the original detector frame, this function calculates a bad pixel map that can be used with a binned data frame generated by the algorithm.
Since the BinningPassthrough
algorithm performs no binning operation at all,
this function always returns the bad pixel map provided as input.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mask |
Union[NDArray[numpy.int_], None]
|
An array storing a bad pixel map for the original data frame.
|
required |
Returns:
Type | Description |
---|---|
Union[NDArray[numpy.int_], None]
|
Either an array containing the binned map or None if the |
Union[NDArray[numpy.int_], None]
|
argument is None. |
bin_pixel_maps(*, pixel_maps)
Computes pixel maps for a binned data frame.
Starting from pixel maps designed for the original detector frame, this function calculates pixel maps that can be used with a binned data frame generated by the algorithm.
Since the BinningPassthrough
algorithm performs no binning operation at all,
this function always returns the pixel maps provided as input.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pixel_maps |
TypePixelMaps
|
A dictionary storing the pixel maps for the original detector frame. |
required |
Returns:
Type | Description |
---|---|
TypePixelMaps
|
A dictionary storing the pixel maps for the binned frame. |
bin_peak_positions(peak_list)
Computes peaks positions for a binned data frame.
Starting from a list of peaks detected in the original detector frame, this function calculates the coordinates of the same peaks in a binned data frame generated by the algorithm.
Since the BinningPassthrough
algorithm performs no binning operation at all,
this function always returns the peak list provided as input.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
peak_list |
TypePeakList
|
An dictionary storing information about a set of peaks detected in the original detector frame. |
required |
Returns:
Type | Description |
---|---|
TypePeakList
|
A dictionary storing information about the detected peaks in the binned |
TypePeakList
|
data frame. |