nbragg 0.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- nbragg-0.3.0/LICENSE +19 -0
- nbragg-0.3.0/PKG-INFO +100 -0
- nbragg-0.3.0/README.md +64 -0
- nbragg-0.3.0/pyproject.toml +120 -0
- nbragg-0.3.0/setup.cfg +4 -0
- nbragg-0.3.0/src/nbragg/__init__.py +18 -0
- nbragg-0.3.0/src/nbragg/cross_section.py +967 -0
- nbragg-0.3.0/src/nbragg/data.py +252 -0
- nbragg-0.3.0/src/nbragg/models.py +2220 -0
- nbragg-0.3.0/src/nbragg/py.typed +0 -0
- nbragg-0.3.0/src/nbragg/response.py +598 -0
- nbragg-0.3.0/src/nbragg/utils.py +137 -0
- nbragg-0.3.0/src/nbragg.egg-info/PKG-INFO +100 -0
- nbragg-0.3.0/src/nbragg.egg-info/SOURCES.txt +17 -0
- nbragg-0.3.0/src/nbragg.egg-info/dependency_links.txt +1 -0
- nbragg-0.3.0/src/nbragg.egg-info/requires.txt +12 -0
- nbragg-0.3.0/src/nbragg.egg-info/top_level.txt +1 -0
- nbragg-0.3.0/tests/test_cross_section.py +185 -0
- nbragg-0.3.0/tests/test_models.py +99 -0
nbragg-0.3.0/LICENSE
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright 2024 Tsviki Y. Hirsh
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
4
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
5
|
+
the Software without restriction, including without limitation the rights to
|
|
6
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
7
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
|
8
|
+
so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
+
SOFTWARE.
|
nbragg-0.3.0/PKG-INFO
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: nbragg
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: Simple yet powerful package for neutron resonance fitting
|
|
5
|
+
Author-email: "Tsviki Y. Hirsh" <tsviki.hirsh@gmail.com>
|
|
6
|
+
Project-URL: Homepage, https://github.com/TsvikiHirsh/nbragg
|
|
7
|
+
Project-URL: Bug Tracker, https://github.com/TsvikiHirsh/nbragg/issues
|
|
8
|
+
Project-URL: Discussions, https://github.com/TsvikiHirsh/nbragg/discussions
|
|
9
|
+
Project-URL: Changelog, https://github.com/TsvikiHirsh/nbragg/releases
|
|
10
|
+
Classifier: Development Status :: 1 - Planning
|
|
11
|
+
Classifier: Intended Audience :: Science/Research
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering
|
|
21
|
+
Requires-Python: >=3.8
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Requires-Dist: scipy
|
|
25
|
+
Requires-Dist: pandas
|
|
26
|
+
Requires-Dist: numpy
|
|
27
|
+
Requires-Dist: lmfit
|
|
28
|
+
Requires-Dist: setuptools
|
|
29
|
+
Requires-Dist: ncrystal
|
|
30
|
+
Requires-Dist: tqdm
|
|
31
|
+
Provides-Extra: dev
|
|
32
|
+
Requires-Dist: pytest>=6; extra == "dev"
|
|
33
|
+
Requires-Dist: pytest-cov>=3; extra == "dev"
|
|
34
|
+
Requires-Dist: pre-commit; extra == "dev"
|
|
35
|
+
Dynamic: license-file
|
|
36
|
+
|
|
37
|
+
# nbragg
|
|
38
|
+
|
|
39
|
+
<p align="center">
|
|
40
|
+
<img src="docs/source/_static/nbragg_logo.png" alt="nbragg logo" width="200"/>
|
|
41
|
+
</p>
|
|
42
|
+
|
|
43
|
+
[](https://nbragg.readthedocs.io/en/latest/?badge=latest)
|
|
44
|
+
<!-- [![PyPI version][pypi-version]][pypi-link]
|
|
45
|
+
[![PyPI platforms][pypi-platforms]][pypi-link] -->
|
|
46
|
+
|
|
47
|
+
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.
|
|
48
|
+
|
|
49
|
+
## Features
|
|
50
|
+
|
|
51
|
+
- **Flexible Cross-Section Calculations**: Interfaces with NCrystal to fetch cross-sections for crystalline materials.
|
|
52
|
+
- **Built-In Tools for Response and Background Functions**: Includes predefined models for instrument response (e.g., Jorgensen, square) and background components (polynomial functions).
|
|
53
|
+
- **LMFit Integration**: Allows flexible, nonlinear fitting of experimental data using the powerful lmfit library.
|
|
54
|
+
- **Rietveld-type analysis**: Enables iterative, parametric refinement of Bragg edge data using the Rietveld method, accumulating parameters across stages for robust fitting.
|
|
55
|
+
- **Pythonic API**: Simple-to-use, yet flexible enough for custom modeling.
|
|
56
|
+
- **Plotting Utilities**: Provides ready-to-use plotting functions for easy visualization of results.
|
|
57
|
+
- **Bragg Edge Analysis**: Perform Bragg edge fitting to extract information such as d-spacing, strain, and texture.
|
|
58
|
+
|
|
59
|
+
## Installation
|
|
60
|
+
|
|
61
|
+
To install from the source:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
git clone https://github.com/TsvikiHirsh/nbragg
|
|
65
|
+
cd nbragg
|
|
66
|
+
pip install .
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Alternatively, you can install directly using pip:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
pip install git+https://github.com/TsvikiHirsh/nbragg.git
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Usage
|
|
76
|
+
|
|
77
|
+
Here's a quick example to get started:
|
|
78
|
+
|
|
79
|
+
```python
|
|
80
|
+
import nbragg
|
|
81
|
+
data = nbragg.Data.from_transmission("iron_powder.csv") # read data
|
|
82
|
+
xs = nbragg.CrossSection(iron="Fe_sg229_Iron-alpha.ncmat") # define sample
|
|
83
|
+
model = nbragg.TransmissionModel(xs, vary_background=True, vary_response=True) # define model
|
|
84
|
+
result = model.fit(data) # perform fit
|
|
85
|
+
result.plot() # plot results
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+

|
|
89
|
+
|
|
90
|
+
## Tutorials and Documentation
|
|
91
|
+
|
|
92
|
+
For more detailed examples and advanced usage, including custom stage definitions and Rietveld fitting, please refer to our [documentation page](https://nbragg.readthedocs.io) and check out the updated [Jupyter notebook tutorial](notebooks/nbragg_tutorial.ipynb).
|
|
93
|
+
|
|
94
|
+
## License
|
|
95
|
+
|
|
96
|
+
nbragg is licensed under the MIT License.
|
|
97
|
+
|
|
98
|
+
[pypi-version]: https://img.shields.io/pypi/v/nbragg.svg
|
|
99
|
+
[pypi-link]: https://pypi.org/project/nbragg/
|
|
100
|
+
[pypi-platforms]: https://img.shields.io/badge/platforms-linux%20%7C%20osx%20%7C%20windows-blue.svg
|
nbragg-0.3.0/README.md
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# nbragg
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<img src="docs/source/_static/nbragg_logo.png" alt="nbragg logo" width="200"/>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
[](https://nbragg.readthedocs.io/en/latest/?badge=latest)
|
|
8
|
+
<!-- [![PyPI version][pypi-version]][pypi-link]
|
|
9
|
+
[![PyPI platforms][pypi-platforms]][pypi-link] -->
|
|
10
|
+
|
|
11
|
+
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.
|
|
12
|
+
|
|
13
|
+
## Features
|
|
14
|
+
|
|
15
|
+
- **Flexible Cross-Section Calculations**: Interfaces with NCrystal to fetch cross-sections for crystalline materials.
|
|
16
|
+
- **Built-In Tools for Response and Background Functions**: Includes predefined models for instrument response (e.g., Jorgensen, square) and background components (polynomial functions).
|
|
17
|
+
- **LMFit Integration**: Allows flexible, nonlinear fitting of experimental data using the powerful lmfit library.
|
|
18
|
+
- **Rietveld-type analysis**: Enables iterative, parametric refinement of Bragg edge data using the Rietveld method, accumulating parameters across stages for robust fitting.
|
|
19
|
+
- **Pythonic API**: Simple-to-use, yet flexible enough for custom modeling.
|
|
20
|
+
- **Plotting Utilities**: Provides ready-to-use plotting functions for easy visualization of results.
|
|
21
|
+
- **Bragg Edge Analysis**: Perform Bragg edge fitting to extract information such as d-spacing, strain, and texture.
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
|
|
25
|
+
To install from the source:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
git clone https://github.com/TsvikiHirsh/nbragg
|
|
29
|
+
cd nbragg
|
|
30
|
+
pip install .
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Alternatively, you can install directly using pip:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pip install git+https://github.com/TsvikiHirsh/nbragg.git
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Usage
|
|
40
|
+
|
|
41
|
+
Here's a quick example to get started:
|
|
42
|
+
|
|
43
|
+
```python
|
|
44
|
+
import nbragg
|
|
45
|
+
data = nbragg.Data.from_transmission("iron_powder.csv") # read data
|
|
46
|
+
xs = nbragg.CrossSection(iron="Fe_sg229_Iron-alpha.ncmat") # define sample
|
|
47
|
+
model = nbragg.TransmissionModel(xs, vary_background=True, vary_response=True) # define model
|
|
48
|
+
result = model.fit(data) # perform fit
|
|
49
|
+
result.plot() # plot results
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+

|
|
53
|
+
|
|
54
|
+
## Tutorials and Documentation
|
|
55
|
+
|
|
56
|
+
For more detailed examples and advanced usage, including custom stage definitions and Rietveld fitting, please refer to our [documentation page](https://nbragg.readthedocs.io) and check out the updated [Jupyter notebook tutorial](notebooks/nbragg_tutorial.ipynb).
|
|
57
|
+
|
|
58
|
+
## License
|
|
59
|
+
|
|
60
|
+
nbragg is licensed under the MIT License.
|
|
61
|
+
|
|
62
|
+
[pypi-version]: https://img.shields.io/pypi/v/nbragg.svg
|
|
63
|
+
[pypi-link]: https://pypi.org/project/nbragg/
|
|
64
|
+
[pypi-platforms]: https://img.shields.io/badge/platforms-linux%20%7C%20osx%20%7C%20windows-blue.svg
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61", "wheel>=0.41.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
[project]
|
|
7
|
+
name = "nbragg"
|
|
8
|
+
version = "0.3.0"
|
|
9
|
+
authors = [
|
|
10
|
+
{ name = "Tsviki Y. Hirsh", email = "tsviki.hirsh@gmail.com" },
|
|
11
|
+
]
|
|
12
|
+
description = "Simple yet powerful package for neutron resonance fitting"
|
|
13
|
+
readme = "README.md"
|
|
14
|
+
requires-python = ">=3.8"
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 1 - Planning",
|
|
17
|
+
"Intended Audience :: Science/Research",
|
|
18
|
+
"License :: OSI Approved :: MIT License",
|
|
19
|
+
"Operating System :: OS Independent",
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"Programming Language :: Python :: 3.9",
|
|
22
|
+
"Programming Language :: Python :: 3.10",
|
|
23
|
+
"Programming Language :: Python :: 3.11",
|
|
24
|
+
"Programming Language :: Python :: 3.12",
|
|
25
|
+
"Programming Language :: Python :: 3.13",
|
|
26
|
+
"Topic :: Scientific/Engineering",
|
|
27
|
+
]
|
|
28
|
+
dependencies = [
|
|
29
|
+
"scipy",
|
|
30
|
+
"pandas",
|
|
31
|
+
"numpy",
|
|
32
|
+
"lmfit",
|
|
33
|
+
"setuptools",
|
|
34
|
+
"ncrystal",
|
|
35
|
+
"tqdm"
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
[project.optional-dependencies]
|
|
39
|
+
dev = [
|
|
40
|
+
"pytest >=6",
|
|
41
|
+
"pytest-cov >=3",
|
|
42
|
+
"pre-commit",
|
|
43
|
+
]
|
|
44
|
+
|
|
45
|
+
[project.urls]
|
|
46
|
+
Homepage = "https://github.com/TsvikiHirsh/nbragg"
|
|
47
|
+
"Bug Tracker" = "https://github.com/TsvikiHirsh/nbragg/issues"
|
|
48
|
+
Discussions = "https://github.com/TsvikiHirsh/nbragg/discussions"
|
|
49
|
+
Changelog = "https://github.com/TsvikiHirsh/nbragg/releases"
|
|
50
|
+
|
|
51
|
+
[tool.pytest.ini_options]
|
|
52
|
+
minversion = "6.0"
|
|
53
|
+
addopts = ["-ra", "--showlocals", "--strict-markers", "--strict-config"]
|
|
54
|
+
xfail_strict = true
|
|
55
|
+
filterwarnings = [
|
|
56
|
+
"error",
|
|
57
|
+
]
|
|
58
|
+
log_cli_level = "INFO"
|
|
59
|
+
testpaths = [
|
|
60
|
+
"tests",
|
|
61
|
+
]
|
|
62
|
+
|
|
63
|
+
[tool.coverage]
|
|
64
|
+
run.source = ["nbragg"]
|
|
65
|
+
port.exclude_lines = [
|
|
66
|
+
'pragma: no cover',
|
|
67
|
+
'\.\.\.',
|
|
68
|
+
'if typing.TYPE_CHECKING:',
|
|
69
|
+
]
|
|
70
|
+
|
|
71
|
+
[tool.mypy]
|
|
72
|
+
files = ["src", "tests"]
|
|
73
|
+
python_version = "3.8"
|
|
74
|
+
show_error_codes = true
|
|
75
|
+
warn_unreachable = true
|
|
76
|
+
disallow_untyped_defs = false
|
|
77
|
+
disallow_incomplete_defs = false
|
|
78
|
+
check_untyped_defs = true
|
|
79
|
+
strict = false
|
|
80
|
+
|
|
81
|
+
[tool.ruff]
|
|
82
|
+
src = ["src"]
|
|
83
|
+
exclude = []
|
|
84
|
+
line-length = 88
|
|
85
|
+
|
|
86
|
+
[tool.ruff.format]
|
|
87
|
+
docstring-code-format = true
|
|
88
|
+
|
|
89
|
+
[tool.ruff.lint]
|
|
90
|
+
select = [
|
|
91
|
+
"E", "F", "W",
|
|
92
|
+
"B",
|
|
93
|
+
"I",
|
|
94
|
+
"ARG",
|
|
95
|
+
"C4",
|
|
96
|
+
"EM",
|
|
97
|
+
"ICN",
|
|
98
|
+
"ISC",
|
|
99
|
+
"G",
|
|
100
|
+
"PGH",
|
|
101
|
+
"PIE",
|
|
102
|
+
"PL",
|
|
103
|
+
"PT",
|
|
104
|
+
"RET",
|
|
105
|
+
"RUF",
|
|
106
|
+
"SIM",
|
|
107
|
+
"UP",
|
|
108
|
+
"YTT",
|
|
109
|
+
"EXE",
|
|
110
|
+
]
|
|
111
|
+
ignore = [
|
|
112
|
+
"PLR",
|
|
113
|
+
"ISC001",
|
|
114
|
+
]
|
|
115
|
+
unfixable = [
|
|
116
|
+
"F401",
|
|
117
|
+
"F841",
|
|
118
|
+
]
|
|
119
|
+
flake8-unused-arguments.ignore-variadic-names = true
|
|
120
|
+
isort.required-imports = ["from __future__ import annotations"]
|
nbragg-0.3.0/setup.cfg
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"""
|
|
2
|
+
nbragg: Simple yet powerful package for neutron resonance fitting
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
from importlib.metadata import version
|
|
7
|
+
|
|
8
|
+
__all__ = ("__version__",)
|
|
9
|
+
__version__ = version(__name__)
|
|
10
|
+
|
|
11
|
+
from nbragg.cross_section import CrossSection
|
|
12
|
+
from nbragg.response import Response, Background
|
|
13
|
+
from nbragg.models import TransmissionModel
|
|
14
|
+
from nbragg.data import Data
|
|
15
|
+
import nbragg.utils as utils
|
|
16
|
+
from nbragg.utils import materials, register_material
|
|
17
|
+
|
|
18
|
+
|