Skip to main content

Simple yet powerful package for neutron resonance fitting

Project description

nbragg

nbragg logo

Documentation Status

nbragg is a package designed for fitting neutron Bragg edge data using NCrystal cross-sections. This tool provides a straightforward way to analyze neutron transmission through polycrystalline materials, leveraging Bragg edges to extract information on material structure and composition.

Features

  • Flexible Cross-Section Calculations: Interfaces with NCrystal to fetch cross-sections for crystalline materials.
  • Built-In Tools for Response and Background Functions: Includes predefined models for instrument response (e.g., Jorgensen, square) and background components (polynomial functions).
  • LMFit Integration: Allows flexible, nonlinear fitting of experimental data using the powerful lmfit library.
  • Rietveld-type analysis: Enables iterative, parametric refinement of Bragg edge data using the Rietveld method, accumulating parameters across stages for robust fitting.
  • Pythonic API: Simple-to-use, yet flexible enough for custom modeling.
  • Plotting Utilities: Provides ready-to-use plotting functions for easy visualization of results.
  • Bragg Edge Analysis: Perform Bragg edge fitting to extract information such as d-spacing, strain, and texture.

Installation

To install from the source:

git clone https://github.com/TsvikiHirsh/nbragg
cd nbragg
pip install .

Alternatively, you can install directly using pip:

pip install git+https://github.com/TsvikiHirsh/nbragg.git

Usage

Here's a quick example to get started:

import nbragg
data = nbragg.Data.from_transmission("iron_powder.csv")                         # read data
xs = nbragg.CrossSection(iron="Fe_sg229_Iron-alpha.ncmat")                      # define sample
model = nbragg.TransmissionModel(xs, vary_background=True, vary_response=True)  # define model
result = model.fit(data)                                                        # perform fit
result.plot()                                                                   # plot results

Fit Results

Tutorials and Documentation

For more detailed examples and advanced usage, including custom stage definitions and Rietveld fitting, please refer to our documentation page and check out the updated Jupyter notebook tutorial.

License

nbragg is licensed under the MIT License.

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

nbragg-0.3.0.tar.gz (45.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nbragg-0.3.0-py3-none-any.whl (43.0 kB view details)

Uploaded Python 3

File details

Details for the file nbragg-0.3.0.tar.gz.

File metadata

  • Download URL: nbragg-0.3.0.tar.gz
  • Upload date:
  • Size: 45.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for nbragg-0.3.0.tar.gz
Algorithm Hash digest
SHA256 a9781d68e60a76fc501e37fc4f0c0db831b656593168abf4339fc3bf0822ad35
MD5 a964006c652f9e2f1a7dd4f0a62417ea
BLAKE2b-256 b6046d3a06d7edc38bd3c67e4fcea64d1b0bcdbb30739abd76cd945bf8041536

See more details on using hashes here.

Provenance

The following attestation bundles were made for nbragg-0.3.0.tar.gz:

Publisher: python-publish.yml on TsvikiHirsh/nbragg

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nbragg-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: nbragg-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 43.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for nbragg-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8a989ed96a2a7df966e2012f67b5aa5d47bef56aa74a3c5e5a19d5f16ba6449d
MD5 93dceeacd328177cc24ed960f49429b9
BLAKE2b-256 4d2ea5a03c7788f1e90de120f088c4c8ce900e31a5f6d33b0cd56f107850cd4c

See more details on using hashes here.

Provenance

The following attestation bundles were made for nbragg-0.3.0-py3-none-any.whl:

Publisher: python-publish.yml on TsvikiHirsh/nbragg

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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