cfelpyutils.geometry_utils module¶
Geometry utilities.
Functions that load, manipulate and apply geometry information to detector pixel data.
-
class
cfelpyutils.geometry_utils.
PixelMaps
(x, y, r)¶ Bases:
tuple
A namedtuple used for pixel maps objects.
Pixel maps are arrays of the same shape of the data whose geometry they describe. Each cell in the array holds the coordinate, in the reference system of the physical detector, of the corresponding pixel in the data array.
The first two fields store the pixel maps for the x coordinate and the y coordinate respectively. The third field is instead a pixel map storing the distance of each pixel in the data array from the center of the reference system.
-
r
¶ Alias for field number 2
-
x
¶ Alias for field number 0
-
y
¶ Alias for field number 1
-
-
cfelpyutils.geometry_utils.
adjust_pixel_maps_for_pyqtgraph
(pixel_maps)¶ Adjust pixel maps for visualization of the data in a pyqtgraph widget.
The adjusted maps can be used for a Pyqtgraph ImageView widget. Essentially, the origin of the reference system is moved to the top-left of the image.
Parameters: pixel_maps (PixelMaps) – pixel maps, as returned by the compute_pixel_maps
function in this module.Returns: a PixelMaps tuple containing the ajusted pixel maps for the x and y coordinates in the first two fields, and the value None in the third. Return type: PixelMaps
-
cfelpyutils.geometry_utils.
apply_pixel_maps
(data, pixel_maps, output_array=None)¶ Apply geometry in pixel map format to the input data.
Turn an array of detector pixel values into an array containing a representation of the physical layout of the detector.
Parameters: - data (ndarray) – array containing the data on which the geometry will be applied.
- pixel_maps (PixelMaps) – a pixelmap tuple, as returned by the
compute_pixel_maps
function in this module. - output_array (Optional[ndarray]) – a preallocated array (of dtype numpy.float32) to store the function output. If provided, this array will be filled by the function and returned to the user. If not provided, the function will create a new array automatically and return it to the user. Defaults to None (No array provided).
Returns: a numpy.float32 array containing the geometry information applied to the input data (i.e.: a physical representation of the layout of the detector).
Return type: ndarray
-
cfelpyutils.geometry_utils.
compute_minimum_array_size
(pixel_maps)¶ Compute the minimum size of an array that can store the applied geometry.
Return the minimum size of an array that can store data on which the geometry information described by the pixel maps has been applied.
The returned array shape is big enough to display all the input pixel values in the reference system of the physical detector. The array is supposed to be centered at the center of the reference system of the detector (i.e: the beam interaction point).
Parameters: pixel_maps (PixelMaps) – a PixelMaps tuple, as returned by the compute_pixel_maps
function in this module.Returns: numpy shape-like tuple storing the minimum array size. Return type: tuple
-
cfelpyutils.geometry_utils.
compute_pixel_maps
(geometry)¶ Compute pixel maps from a CrystFEL geometry object.
Take as input a CrystFEL-style geometry object (A dictionary returned by the function load_crystfel_geometry function in the crystfel_utils module) and return a PixelMap tuple . The origin the reference system used by the pixel maps is set at the beam interaction point.
Parameters: geometry (dict) – A CrystFEL geometry object (A dictionary returned by the cfelpyutils.crystfel_utils.load_crystfel_geometry
function).Returns: a PixelMaps tuple. Return type: PixelMaps