{"id":37668198,"url":"https://github.com/anananacr/bblib","last_synced_at":"2026-01-16T12:00:52.550Z","repository":{"id":185397850,"uuid":"673454540","full_name":"anananacr/bblib","owner":"anananacr","description":"beambusters library","archived":false,"fork":false,"pushed_at":"2025-08-28T18:33:28.000Z","size":25134,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-09T06:40:50.341Z","etag":null,"topics":["python","serial-crystallography","x-ray-diffraction"],"latest_commit_sha":null,"homepage":"https://anananacr.github.io/bblib/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/anananacr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-08-01T16:57:11.000Z","updated_at":"2025-08-28T18:33:22.000Z","dependencies_parsed_at":null,"dependency_job_id":"acd3c9a9-4f07-43cd-8736-6dd5ce457e5a","html_url":"https://github.com/anananacr/bblib","commit_stats":null,"previous_names":["anananacr/p09-utils","anananacr/bblib"],"tags_count":20,"template":false,"template_full_name":null,"purl":"pkg:github/anananacr/bblib","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anananacr%2Fbblib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anananacr%2Fbblib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anananacr%2Fbblib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anananacr%2Fbblib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anananacr","download_url":"https://codeload.github.com/anananacr/bblib/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anananacr%2Fbblib/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28478397,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T11:59:17.896Z","status":"ssl_error","status_checked_at":"2026-01-16T11:55:55.838Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["python","serial-crystallography","x-ray-diffraction"],"created_at":"2026-01-16T12:00:40.383Z","updated_at":"2026-01-16T12:00:52.546Z","avatar_url":"https://github.com/anananacr.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# beambusters library\n\n[![PyPI pyversions](https://img.shields.io/badge/python-3.10%2B-blue)](https://www.python.org/downloads/release/python-3100/)\n\nThe beambusters library (bblib) is a library that contains methods to determine the detector center directly from still diffraction patterns collected in serial crystallography experiments.\n\nYou can find more information about beambusters on [this page](https://anananacr.github.io/beambusters/).\n\n## Installation\n\nTo install bblib, run the following command in a terminal:\n\n```bash\npip install bblib\n```\n\n## Usage\n\n### Configuration dictionaries\n\nTo 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):\n\n```python\nconfig = {\n    \"plots_flag\": ...,\n\t\"search_radius\": ...,\n\t\"pf8\": {\n\t\t\"max_num_peaks\": ...,\n\t\t\"adc_threshold\": ...,\n\t\t\"minimum_snr\": ...,\n\t\t\"min_pixel_count\": ...,\n\t\t\"max_pixel_count\": ...,\n\t\t\"local_bg_radius\": ...,\n\t\t\"min_res\": ...,\n\t\t\"max_res\": ...\n\t\t},\n\t\"peak_region\":{\n\t\t\"min\": ...,\n\t\t\"max\": ...\n\t\t},\n\t\"grid_search_radius\": ...,\n\t\"canny\":{\n\t\t\"sigma\": ...,\n\t\t\"low_threshold\": ...,\n\t\t\"high_threshold\": ...\n\t\t},\n\t\"hough_rank\": ...,\n\t\"bragg_peaks_for_center_of_mass_calculation\": ...,\n\t\"pixels_for_mask_of_bragg_peaks\": ...,\n\t\"polarization\": {\n\t\t\"apply_polarization_correction\": ...,\n\t\t\"axis\": ...,\n\t\t\"value\": ...\n\t\t}\n}\n\nPF8Info = {\n\t\"max_num_peaks\":\n\t\"adc_threshold\":\n\t\"minimum_snr\": ...,\n\t\"min_pixel_count\": ...,\n\t\"max_pixel_count\": ...,\n\t\"local_bg_radius\": ...,\n\t\"min_res\": ...,\n\t\"max_res\": ...,\n\t\"pf8_detector_info\": ...,\n\t\"bad_pixel_map_filename\": ...,\n\t\"bad_pixel_map_hdf5_path\": ...,\n\t\"pixel_maps\": ...,\n\t\"pixel_resolution\": ...,\n\t\"_shifted_pixel_maps\":...\n}\n```\n\nThe `pf8_detector_info` parameter is a dictionary containing the detector layout information:\n```python\npf8_detector_info =  {\n\t\"asic_nx\": ...,\n\t\"asic_ny\": ...,\n\t\"nasics_x\": ...,\n\t\"nasics_y\": ...\n}\n```\n\nThe `pixel_maps` parameter is a dictionary containing the pixel maps numpy array:\n```python\npixel_maps =  {\n\t\"x\": ...,\n\t\"y\": ...,\n\t\"z\": ...,\n\t\"radius\": ...,\n\t\"phi\": ...\n}\n```\n\nThe methods `FriedelPairs`, `MinimizePeakFWHM` and  `CircleDetection ` need a `plots_info` parameter if you want to save plots:\n```python\nplots_info =  {\n\t\"filename\": ...,\n\t\"folder_name\": ...,\n\t\"root_path\": ...,\n\t\"value_auto\": ...,\n\t\"value_max\": ...,\n\t\"value_min\": ...,\n\t\"axis_lim_auto\": ...,\n\t\"xlim_min\": ...,\n\t\"xlim_max\": ...,\n\t\"ylim_min\": ...,\n\t\"ylim_max\": ...,\n\t\"color_map\": ...,\n\t\"marker_size\": ...\n}\n```\n\n### Calling the methods\n\nTo calculate the refined detector center of raw data frame as a numpy array using the following methods:\n\n```python\nfrom bblib.methods import CenterOfMass\ncenter_of_mass_method = CenterOfMass(config=config, PF8Config=PF8Config, plots_info=plots_info)\ncenter_coordinates_from_center_of_mass = center_of_mass_method(\n                        data = ...\n                    )\n\nfrom bblib.methods import CircleDetection\ncircle_detection_method = CircleDetection(config=config, PF8Config=PF8Config, plots_info=plots_info)\ncenter_coordinates_from_circle_detection = circle_detection_method(\n                        data = ...\n                    )\n```\n\nThe `FriedelPairs` and `MinimizePeakFWHMmethod` need an initial guess for the refined detector center coordinates ` initial_guess = [x_0, y_0]`\n\n```python\nfrom bblib.methods import MinimizePeakFWHM\nminimize_peak_fwhm_method = MinimizePeakFWHM(\n                        config=config, PF8Config=PF8Config, plots_info=plots_info\n                    )\ncenter_coordinates_from_minimize_peak_fwhm = minimize_peak_fwhm_method(\n                        data = ..., initial_guess = ...\n                    )\n\n\nfrom bblib.methods import FriedelPairs\nfriedel_pairs_method = FriedelPairs(\n                        config=config, PF8Config=PF8Config, plots_info=plots_info\n                    )\ncenter_coordinates_from_friedel_pairs = friedel_pairs_method(\n                        data = ..., initial_guess= ...\n                    )\n```\n\n## Contact\n\nAna Carolina Rodrigues led the development of bblib from 2021 to 2025 at the Deutsches Elektronen-Synchrotron (DESY) in Hamburg, Germany.\n\nFor questions, please contact:\n\n**Email**: sc.anarodrigues@gmail.com\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanananacr%2Fbblib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanananacr%2Fbblib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanananacr%2Fbblib/lists"}