Skip to main content

beambusters library

PyPI pyversions

The beambusters library (bblib) is a library that contains methods to determine the detector center directly from still diffraction patterns collected in serial crystallography experiments.

You can find more information about beambusters on this page.

Installation

To install bblib, run the following command in a terminal:

pip install bblib

Usage

Configuration dictionaries

To utilize the methods CenterOfMass, FriedelPairs, MinimizePeakFWHM and CircleDetection it is required to have two configuration dictionaries, one for PeakFinder8 and another one for this library itself. The following snippet shows the general structure for both (parameters not used in your case can be omitted):

config = {
    "plots_flag": ...,
	"search_radius": ...,
	"pf8": {
		"max_num_peaks": ...,
		"adc_threshold": ...,
		"minimum_snr": ...,
		"min_pixel_count": ...,
		"max_pixel_count": ...,
		"local_bg_radius": ...,
		"min_res": ...,
		"max_res": ...
		},
	"peak_region":{
		"min": ...,
		"max": ...
		},
	"grid_search_radius": ...,
	"canny":{
		"sigma": ...,
		"low_threshold": ...,
		"high_threshold": ...
		},
	"hough_rank": ...,
	"bragg_peaks_for_center_of_mass_calculation": ...,
	"pixels_for_mask_of_bragg_peaks": ...,
	"polarization": {
		"apply_polarization_correction": ...,
		"axis": ...,
		"value": ...
		}
}

PF8Info = {
	"max_num_peaks":
	"adc_threshold":
	"minimum_snr": ...,
	"min_pixel_count": ...,
	"max_pixel_count": ...,
	"local_bg_radius": ...,
	"min_res": ...,
	"max_res": ...,
	"pf8_detector_info": ...,
	"bad_pixel_map_filename": ...,
	"bad_pixel_map_hdf5_path": ...,
	"pixel_maps": ...,
	"pixel_resolution": ...,
	"_shifted_pixel_maps":...
}

The pf8_detector_info parameter is a dictionary containing the detector layout information:

pf8_detector_info =  {
	"asic_nx": ...,
	"asic_ny": ...,
	"nasics_x": ...,
	"nasics_y": ...
}

The pixel_maps parameter is a dictionary containing the pixel maps numpy array:

pixel_maps =  {
	"x": ...,
	"y": ...,
	"z": ...,
	"radius": ...,
	"phi": ...
}

The methods FriedelPairs, MinimizePeakFWHM and CircleDetection need a plots_info parameter if you want to save plots:

plots_info =  {
	"filename": ...,
	"folder_name": ...,
	"root_path": ...,
	"value_auto": ...,
	"value_max": ...,
	"value_min": ...,
	"axis_lim_auto": ...,
	"xlim_min": ...,
	"xlim_max": ...,
	"ylim_min": ...,
	"ylim_max": ...,
	"color_map": ...,
	"marker_size": ...
}

Calling the methods

To calculate the refined detector center of raw data frame as a numpy array using the following methods:

from bblib.methods import CenterOfMass
center_of_mass_method = CenterOfMass(config=config, PF8Config=PF8Config, plots_info=plots_info)
center_coordinates_from_center_of_mass = center_of_mass_method(
                        data = ...
                    )

from bblib.methods import CircleDetection
circle_detection_method = CircleDetection(config=config, PF8Config=PF8Config, plots_info=plots_info)
center_coordinates_from_circle_detection = circle_detection_method(
                        data = ...
                    )

The FriedelPairs and MinimizePeakFWHMmethod need an initial guess for the refined detector center coordinates initial_guess = [x_0, y_0]

from bblib.methods import MinimizePeakFWHM
minimize_peak_fwhm_method = MinimizePeakFWHM(
                        config=config, PF8Config=PF8Config, plots_info=plots_info
                    )
center_coordinates_from_minimize_peak_fwhm = minimize_peak_fwhm_method(
                        data = ..., initial_guess = ...
                    )


from bblib.methods import FriedelPairs
friedel_pairs_method = FriedelPairs(
                        config=config, PF8Config=PF8Config, plots_info=plots_info
                    )
center_coordinates_from_friedel_pairs = friedel_pairs_method(
                        data = ..., initial_guess= ...
                    )

Contact

Ana Carolina Rodrigues led the development of bblib from 2021 to 2025 at the Deutsches Elektronen-Synchrotron (DESY) in Hamburg, Germany.

For questions, please contact:

Email: sc.anarodrigues@gmail.com

Metadata

Release files for bblib 3.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bblib 3.1.0
File Size Uploaded Provenance Actions
bblib-3.1.0.tar.gz 29.9 kB Without provenance Details for bblib-3.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bblib 3.1.0
File Interpreter ABI Platform Actions
bblib-3.1.0-py3-none-any.whl Python 3 none any Details for bblib-3.1.0-py3-none-any.whl

Total release size: 60.1 kB

Release files / bblib-3.1.0.tar.gz

Download URL bblib-3.1.0.tar.gz
Size 29.9 kB
Tags Source
SHA-256 checksum
How to use checksums
12bde0dc23bbc62d7eb329948af5c0be941e614cc7d974e19b4afe276d2e0da1
BLAKE2b-256 checksum
How to use checksums
8314c7a426ebb141820fa9584fc3b8339343582d3d715cd33abf44427bc8bed8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.4 CPython/3.10.18 Linux/6.11.0-1018-azure

Release files / bblib-3.1.0-py3-none-any.whl

Download URL bblib-3.1.0-py3-none-any.whl
Size 30.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7db41339d5befe78aee7b5b54069355d0948894b1b2c8374e5f0c54fc4f5a555
BLAKE2b-256 checksum
How to use checksums
360ca7fa6f7b9ec1f53abf890adfdb82f704db60da943654ce369207dc934d53
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.4 CPython/3.10.18 Linux/6.11.0-1018-azure

Security for bblib 3.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

3.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page