Skip to main content

pygidFIT: Gaussian fitting for grazing incidence diffraction (GID) data

Python version

A Python package for fitting Gaussian functions to GID (Grazing-Incidence Wide-Angle X-ray and Neutron Scattering) data. pygidFIT is part of the comprehensive machine learning pipeline for automated analysis of GID data. The focus is on multiparallel execution for real-time sequential processing at the synchrotron and neutron facilities.

pygidFIT

Installation

Install using pip

pip install pygidfit

Install from source

First, clone the repository:

git clone git@github.com:mlgid-project/pygidFIT.git

Then, to install all required modules, navigate to the cloned directory and execute:

git clone git@github.com:mlgid-project/pygidFIT.git
cd pygidFIT
pip install -e .

Usage

Images from pygid NeXus file

from pygidfit import ProcessDataFromFile

filename = './example/BA2PbI4.h5'
analysis = ProcessDataFromFile(
    filename,                           # NeXus file with converted images and detected boxes (after pygid and mlgidDETECT)
    entry='entry_0000',                 # Entry to process (if None, processes all entries)
    frame_num=0,                        # Image frame to process (if None, processes all frames)
    crit_angle=2,                       # Critical angle to shift the sample horizon (in degrees)
    clustering_distance_rings=10,       # Distance for ring clustering (in pixels)
    clustering_distance_peaks=10,       # Distance for segments clustering (in pixels)
    clustering_extend=2,                # Number of pixels to extend the cluster size
    use_pool=False,                     # Whether to use peak pool from the previous image 
    debug=False,                        # Whether to plot fitting result and parameters)
    theta_fixed=True,                   # Whether to fix Gaussian tilt angle to 0° (azimuthal direction) during fitting. Default is True
)

Fit single image

from pygidfit import fit_data

img_container_fit = fit_data(
    polar_img=polar_img,              # 2D polar-transformed scattering image. Axis 0: polar angle (0–90°). Axis 1: radial coordinate |q| (Å⁻¹)
    radius=radius,                    # 1D array of radial centers of peak boxes (Å⁻¹)
    radius_width=radius_width,        # 1D array of radial widths of peak boxes (Å⁻¹)
    angle=angle,                      # 1D array of angular centers of peak boxes (degrees)
    angle_width=angle_width,          # 1D array of angular widths of peak boxes (degrees)
    wavelength=1e-10,                 # X-ray wavelength in meters. Used for missing-wedge calculation
    q_xy_max=3.5,                     # Upper cutoff for q_xy (Å⁻¹) used in peak classification
    q_z_max=3.5,                      # Upper cutoff for q_z (Å⁻¹) used in peak classification
    clustering_distance_peaks=10,     # Distance for ring clustering (in pixels)
    clustering_distance_rings=10,     # Distance for segments clustering (in pixels)
    clustering_extend=2,              # Number of pixels to extend the cluster size
    debug=False,                      # Whether to plot fitting result and parameters)
    peaks_pool=None,                  # List of pygidfit.Boxes or None (if don't use pool) 
    theta_fixed=True,                 # Whether to fix Gaussian tilt angle to 0° (azimuthal direction) during fitting. Default is True
)

This package is included in the mlgidBASE package and can be used as part of the mlgid pipeline.

Overview

pygidFIT is part of the machine learning pipeline for automated analysis of GID data. It is designed to analyze scattering data by fitting Gaussian profiles to peaks in both 1D and 2D data. It refines the peak positions revealed by the deep learning-based peak detection by automated conventional fitting during the postprocessing stage.

Key Features

  • Peak clustering: Groups spatially close peaks to improve fitting stability

  • Parameter reuse: Caches fit parameters from previous frames to accelerate time-series analysis

  • Parallel execution: Supports multiprocessing for efficient processing of large datasets

  • HDF5 compatibility: Operates directly on HDF5 files generated by pygid.DataSaver

Authors

License

MIT License

Metadata

Release files for pygidfit 0.1.7

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

Source distribution (sdist)

Source distribution for pygidfit 0.1.7
File Size Uploaded Provenance Actions
pygidfit-0.1.7.tar.gz 30.2 kB Without provenance Details for pygidfit-0.1.7.tar.gz

Built distribution (wheel)

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

Total release size: 60.9 kB

Release files / pygidfit-0.1.7.tar.gz

Download URL pygidfit-0.1.7.tar.gz
Size 30.2 kB
Tags Source
SHA-256 checksum
How to use checksums
2c633659b2011e9d2fda89ae4bb911aa66aed4d17ac552e96ae014011d0856d9
BLAKE2b-256 checksum
How to use checksums
82dcaf79e9cbc7676d3d174ccdcbfeafd32062814c964ae6873c4d9dd8bb9398
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / pygidfit-0.1.7-py3-none-any.whl

Download URL pygidfit-0.1.7-py3-none-any.whl
Size 30.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
175753dd38576daeb9e25699b686aa8d536d7ed7aaaa34e72f0cba67ee7d94df
BLAKE2b-256 checksum
How to use checksums
5678580a9a0ba20f8aa3f667ee412732a7ec9131ad315e8ac7dcd6ce1bba76f0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Security for pygidfit 0.1.7

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.

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