Utils
This module defines auxiliary funtions to process the data.
centering_converged(center)
This function receives the detector center coordinates and checks if the centering converged.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
center
|
tuple
|
Detector center coordinates determined by onxe of the bblib centering methods. |
required |
Returns:
Name | Type | Description |
---|---|---|
centering_flag |
bool
|
True if the centering converged, False if the centering didn't converge. |
Source code in beambusters/utils.py
create_simple_vds(input_file, data_hdf5_path, output_file)
This function shows an example how to create a file in the VDS format pointing a virtual dataset to a source. For European XFEL users there is a function in the Extra-data library to create VDS files of the measured runs.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input_file
|
str
|
Path to the source file. |
required |
data_hdf5_path
|
str
|
HDF5 path to the data in the source file. |
required |
output_file
|
str
|
Path to the VDS file. |
required |
Source code in beambusters/utils.py
expand_data_to_hyperslab(data, data_format)
This function takes the data in its original shape (VDS) and map each detector panel into the hyperslab that contains all detector panels in a single Numpy array.
Supported detectors correspond to the Jungfrau 4M of the SPB/SFX instrument of the European XFEL (vds_spb_jf4m
), see the Extra-geom Documentation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
array
|
Data array corresponding to one event. |
required |
data_format
|
str
|
Data format identification. Option: |
required |
Returns:
Name | Type | Description |
---|---|---|
hyperslab |
array
|
Data transformed from the original shape (VDS) to a single array containing all the detector panels. |
Source code in beambusters/utils.py
get_500k_slab(slab_name, offset_ss, offset_fs)
This function creates a Jungfrau panel of 500k pixels with the first pixel (of the first row) positioned at the upper-left corner of the slab. The panel can be translated from the origin by specifying offsets along the slow-scan and fast-scan axes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
slab_name
|
str
|
Identification of the panel or slab. |
required |
offset_ss
|
int
|
Number of indices to offset the panel along the slow-scan axis. |
required |
offset_fs
|
int
|
Number of indices to offset the panel along the fast-scan axis. |
required |
Returns:
Name | Type | Description |
---|---|---|
panel |
dict
|
A dictionary containg the panel identification and its slow-scan and fast-scan limits in the hyperslab. |
Source code in beambusters/utils.py
get_500k_slab_inverted(slab_name, offset_ss, offset_fs)
This function creates a Jungfrau panel of 500k pixels with the first pixel (of the first row) positioned at the bottom-right corner of the slab. The panel can be translated from the origin by specifying offsets along the slow-scan and fast-scan axes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
slab_name
|
str
|
Identification of the panel or slab. |
required |
offset_ss
|
int
|
Number of indices to offset the panel along the slow-scan axis. |
required |
offset_fs
|
int
|
Number of indices to offset the panel along the fast-scan axis. |
required |
Returns:
Name | Type | Description |
---|---|---|
panel |
dict
|
A dictionary containg the panel identification and its slow-scan and fast-scan limits in the hyperslab. |
Source code in beambusters/utils.py
get_slab_coordinates_in_hyperslab(slab_name, asic_name, key, detector_layout)
This function return the value of a key (min_ss
, max_ss
, min_fs
or max_fs
) from one detector layout dictionary, a slab identification and an asic identification.
Returns:
Name | Type | Description |
---|---|---|
value |
int
|
Value of the slow-scan and fast-scan limits in the hyperslab for a given detector layout, panel and asic. |
Source code in beambusters/utils.py
image_expand_frames(data_hdf5_path, file_name)
Expands the events of an HDF5 file by specifying the HDF5 path to the data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_name
|
str
|
Path to the HDF5 file. |
required |
data_hdf5_path
|
str
|
Path pointing to the data in the HDF5 file. |
required |
Returns:
Name | Type | Description |
---|---|---|
events_list |
ndarray
|
Array containing the number each listed event. |
num_events |
int
|
Total number of events in the HDF5 file. |
Source code in beambusters/utils.py
list_events(input_file, output_file, geometry_file)
Expands a list of filenames into a list of individual events. Similar to the list_events in CrystFEL.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input_file
|
str
|
Path to the file list containg the data filename. |
required |
output_file
|
str
|
Path to the output file list containing the individual events path. |
required |
geometry_file
|
str
|
Path to the geometry file in CrystFEL format. |
required |
Source code in beambusters/utils.py
reduce_hyperslab_to_vds(data, data_format)
This function takes the data in the hyperslab shape and reduce it to the original shape (VDS).
Supported detector is the Jungfrau 4M of the SPB/SFX instrument of the European XFEL (vds_spb_jf4m
), see the Extra-geom Documentation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
array
|
Data array in the hyperslab shape. |
required |
data_format
|
str
|
Data format identification. Option: |
required |
Returns:
Name | Type | Description |
---|---|---|
vds_slab |
array
|
Data transformed from the hyperslab shape to the original shape (VDS). |
Source code in beambusters/utils.py
slab_to_hyperslab()
Creates a dictionary containing all the panels of the detector and their corresponding slow-scan and fast-scan axis limits in the hyperslab.
Returns:
Name | Type | Description |
---|---|---|
jf_4m_in_hyperslab |
dict
|
A dictionary containg the panels of the Jungfrau 4M of the SPB/SFX instrument of the European XFEL, see the Extra-geom Documentation. |
Source code in beambusters/utils.py
translate_geom_to_hyperslab(geometry_filename)
Translates the geometry file (CrystFEL format), written for data in the original shape (VDS), to perform the same operations in the panels when using the data in the hyperslab shape.
Supported detector is the Jungfrau 4M of the SPB/SFX instrument of the European XFEL (vds_spb_jf4m
), see the Extra-geom Documentation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
geometry_filename
|
str
|
Path to the geometry file in CrystFEL format. |
required |
Returns:
Name | Type | Description |
---|---|---|
output_filename |
str
|
Path to the geometry file, in CrystFEL format, for operating the hyperslab. |