Skip to main content

beambusters library to refine the detector center for crystallography data processing.

Project description

beambusters library

beambusters library. It refines the detector center of diffraction patterns.

Python version

Python 3.10.5

Installation

pip install bblib

Usage

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 follow snippet shows the expected structure for both:

config = {
    "plots_flag": ...,
	"force_center": {
		"mode": ...,
		"x": ...,
		"y": ...
		},
	"search_radius": ...,
	"pf8": {
		"max_num_peaks": ...,
		"adc_threshold": ...,
		"minimum_snr": ...,
		"min_pixel_count": ...,
		"max_pixel_count": ...,
		"local_bg_radius": ...,
		"min_res": ...,
		"max_res": ...
		},
	"starting_frame": ...,
	"offset": {
		"x": ...,
		"y": ...
		},
	"peak_region":{
		"min": ...,
		"max": ...
		},
	"outlier_distance": ...,
	"canny":{
		"sigma": ...,
		"low_threshold": ...,
		"high_threshold": ...
		},	
	"method": ...,
	"bragg_peaks_positions_for_center_of_mass_calculation": ...,
	"pixels_for_mask_of_bragg_peaks": ...,
	"skip_methods": ...,
	"polarization": {
		"skip": ...,
		"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 =  {
	"file_name": ...,
	"folder_name": ...,
	"root_path": ...
}

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= ...
                    )

Author:

Ana Carolina Rodrigues (2021 - )

email: ana.rodrigues@desy.de

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bblib-1.1.0.tar.gz (27.8 kB view hashes)

Uploaded Source

Built Distribution

bblib-1.1.0-py3-none-any.whl (27.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page