xrayscatteringtools 0.3.0__tar.gz → 1.0.1__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.
- xrayscatteringtools-1.0.1/.github/workflows/tests.yml +28 -0
- {xrayscatteringtools-0.3.0 → xrayscatteringtools-1.0.1}/LICENSE +2 -2
- xrayscatteringtools-1.0.1/PKG-INFO +133 -0
- xrayscatteringtools-1.0.1/README.md +106 -0
- {xrayscatteringtools-0.3.0 → xrayscatteringtools-1.0.1}/pyproject.toml +7 -4
- xrayscatteringtools-1.0.1/src/xrayscatteringtools/__init__.py +5 -0
- xrayscatteringtools-1.0.1/src/xrayscatteringtools/calib/__init__.py +4 -0
- xrayscatteringtools-1.0.1/src/xrayscatteringtools/calib/data/attenuation_lengths.h5 +0 -0
- xrayscatteringtools-1.0.1/src/xrayscatteringtools/calib/masking.py +796 -0
- {xrayscatteringtools-0.3.0 → xrayscatteringtools-1.0.1}/src/xrayscatteringtools/calib/scattering_corrections.py +15 -126
- xrayscatteringtools-1.0.1/src/xrayscatteringtools/calib/timetool_calibration.py +252 -0
- {xrayscatteringtools-0.3.0 → xrayscatteringtools-1.0.1}/src/xrayscatteringtools/io.py +81 -57
- {xrayscatteringtools-0.3.0 → xrayscatteringtools-1.0.1}/src/xrayscatteringtools/plotting.py +45 -0
- {xrayscatteringtools-0.3.0 → xrayscatteringtools-1.0.1}/src/xrayscatteringtools/theory/iam.py +25 -17
- {xrayscatteringtools-0.3.0 → xrayscatteringtools-1.0.1}/src/xrayscatteringtools/theory/patterns.py +27 -15
- {xrayscatteringtools-0.3.0 → xrayscatteringtools-1.0.1}/src/xrayscatteringtools/theory/patterns.pyi +3 -2
- {xrayscatteringtools-0.3.0 → xrayscatteringtools-1.0.1}/src/xrayscatteringtools/utils.py +77 -3
- {xrayscatteringtools-0.3.0/tests → xrayscatteringtools-1.0.1/tests/old}/DMP_D.xyz +24 -24
- {xrayscatteringtools-0.3.0/tests → xrayscatteringtools-1.0.1/tests/old}/DMP_L1.xyz +24 -24
- {xrayscatteringtools-0.3.0/tests → xrayscatteringtools-1.0.1/tests/old}/DMP_L2.xyz +24 -24
- xrayscatteringtools-1.0.1/tests/test_geometries.py +179 -0
- xrayscatteringtools-1.0.1/tests/test_geometry_calibration.py +267 -0
- xrayscatteringtools-1.0.1/tests/test_iam.py +271 -0
- xrayscatteringtools-1.0.1/tests/test_io.py +327 -0
- xrayscatteringtools-1.0.1/tests/test_masking.py +507 -0
- xrayscatteringtools-1.0.1/tests/test_patterns.py +221 -0
- xrayscatteringtools-1.0.1/tests/test_plotting.py +233 -0
- xrayscatteringtools-1.0.1/tests/test_scattering_corrections.py +254 -0
- xrayscatteringtools-1.0.1/tests/test_timetool_calibration.py +444 -0
- xrayscatteringtools-1.0.1/tests/test_utils.py +438 -0
- xrayscatteringtools-0.3.0/PKG-INFO +0 -108
- xrayscatteringtools-0.3.0/README.md +0 -81
- xrayscatteringtools-0.3.0/src/xrayscatteringtools/__init__.py +0 -5
- xrayscatteringtools-0.3.0/src/xrayscatteringtools/calib/__init__.py +0 -3
- xrayscatteringtools-0.3.0/src/xrayscatteringtools/calib/masking.py +0 -497
- {xrayscatteringtools-0.3.0 → xrayscatteringtools-1.0.1}/.gitattributes +0 -0
- {xrayscatteringtools-0.3.0 → xrayscatteringtools-1.0.1}/.gitignore +0 -0
- {xrayscatteringtools-0.3.0 → xrayscatteringtools-1.0.1}/src/xrayscatteringtools/calib/data/Zn_attenuation_length.h5 +0 -0
- {xrayscatteringtools-0.3.0 → xrayscatteringtools-1.0.1}/src/xrayscatteringtools/calib/geometry_calibration.py +0 -0
- {xrayscatteringtools-0.3.0 → xrayscatteringtools-1.0.1}/src/xrayscatteringtools/data/Jungfrau4M.h5 +0 -0
- {xrayscatteringtools-0.3.0 → xrayscatteringtools-1.0.1}/src/xrayscatteringtools/epicsArch.py +0 -0
- {xrayscatteringtools-0.3.0 → xrayscatteringtools-1.0.1}/src/xrayscatteringtools/theory/__init__.py +0 -0
- {xrayscatteringtools-0.3.0 → xrayscatteringtools-1.0.1}/src/xrayscatteringtools/theory/data/IAM/Compton_Factors.npy +0 -0
- {xrayscatteringtools-0.3.0 → xrayscatteringtools-1.0.1}/src/xrayscatteringtools/theory/data/IAM/Scattering_Factors.npy +0 -0
- {xrayscatteringtools-0.3.0 → xrayscatteringtools-1.0.1}/src/xrayscatteringtools/theory/data/geometries/SF6__CCSD_T_DHK__aug_cc_pV5Z_DK.h5 +0 -0
- {xrayscatteringtools-0.3.0 → xrayscatteringtools-1.0.1}/src/xrayscatteringtools/theory/data/geometries/make_geometry_h5.py +0 -0
- {xrayscatteringtools-0.3.0 → xrayscatteringtools-1.0.1}/src/xrayscatteringtools/theory/data/patterns/SF6__CCSD__aug_cc_pVDZ.h5 +0 -0
- {xrayscatteringtools-0.3.0 → xrayscatteringtools-1.0.1}/src/xrayscatteringtools/theory/data/patterns/SF6__HF__aug_cc_pVDZ.h5 +0 -0
- {xrayscatteringtools-0.3.0 → xrayscatteringtools-1.0.1}/src/xrayscatteringtools/theory/data/patterns/SF6__MP2__aug_cc_pVDZ.h5 +0 -0
- {xrayscatteringtools-0.3.0 → xrayscatteringtools-1.0.1}/src/xrayscatteringtools/theory/data/patterns/convert_ab_initio_to_h5.py +0 -0
- {xrayscatteringtools-0.3.0 → xrayscatteringtools-1.0.1}/src/xrayscatteringtools/theory/geometries.py +0 -0
- {xrayscatteringtools-0.3.0 → xrayscatteringtools-1.0.1}/src/xrayscatteringtools/theory/geometries.pyi +0 -0
- {xrayscatteringtools-0.3.0 → xrayscatteringtools-1.0.1}/tests/__init__.py +0 -0
- {xrayscatteringtools-0.3.0/tests → xrayscatteringtools-1.0.1/tests/old}/DMP_ground.xyz +0 -0
- {xrayscatteringtools-0.3.0/tests → xrayscatteringtools-1.0.1/tests/old}/azav_test.ipynb +0 -0
- {xrayscatteringtools-0.3.0/tests → xrayscatteringtools-1.0.1/tests/old}/calib_test.ipynb +0 -0
- {xrayscatteringtools-0.3.0/tests → xrayscatteringtools-1.0.1/tests/old}/geometries_test.ipynb +0 -0
- {xrayscatteringtools-0.3.0/tests → xrayscatteringtools-1.0.1/tests/old}/iam_oriented_test.ipynb +0 -0
- {xrayscatteringtools-0.3.0/tests → xrayscatteringtools-1.0.1/tests/old}/iam_pattern_test.ipynb +0 -0
- {xrayscatteringtools-0.3.0/tests → xrayscatteringtools-1.0.1/tests/old}/patterns_test.ipynb +0 -0
- {xrayscatteringtools-0.3.0 → xrayscatteringtools-1.0.1}/tests/sf6_test.xyz +0 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
name: Tests
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
strategy:
|
|
13
|
+
matrix:
|
|
14
|
+
python-version: ["3.9", "3.10", "3.11", "3.12"]
|
|
15
|
+
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
|
|
19
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
20
|
+
uses: actions/setup-python@v5
|
|
21
|
+
with:
|
|
22
|
+
python-version: ${{ matrix.python-version }}
|
|
23
|
+
|
|
24
|
+
- name: Install dependencies
|
|
25
|
+
run: pip install -e ".[dev]"
|
|
26
|
+
|
|
27
|
+
- name: Run tests
|
|
28
|
+
run: python -m pytest tests/ -v
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2025 David Romano
|
|
3
|
+
Copyright (c) 2025-2026 David Romano
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
18
18
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: xrayscatteringtools
|
|
3
|
+
Version: 1.0.1
|
|
4
|
+
Summary: A library for gas phase analysis at the CXI endstation
|
|
5
|
+
Project-URL: Homepage, https://github.com/Weber-Group/xrayscatteringtools
|
|
6
|
+
Project-URL: Issues, https://github.com/Weber-Group/xrayscatteringtools/issues
|
|
7
|
+
Author-email: David Romano <david_j_romano@brown.edu>
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Requires-Python: >=3.9
|
|
11
|
+
Requires-Dist: h5py
|
|
12
|
+
Requires-Dist: ipython
|
|
13
|
+
Requires-Dist: matplotlib
|
|
14
|
+
Requires-Dist: numpy
|
|
15
|
+
Requires-Dist: pyyaml
|
|
16
|
+
Requires-Dist: requests
|
|
17
|
+
Requires-Dist: ruamel-yaml
|
|
18
|
+
Requires-Dist: scipy>=1.11
|
|
19
|
+
Requires-Dist: tqdm
|
|
20
|
+
Requires-Dist: xraylib
|
|
21
|
+
Provides-Extra: dev
|
|
22
|
+
Requires-Dist: black>=24.0; extra == 'dev'
|
|
23
|
+
Requires-Dist: mypy>=1.9; extra == 'dev'
|
|
24
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
25
|
+
Requires-Dist: ruff>=0.3; extra == 'dev'
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
|
|
28
|
+
# X-Ray Scattering Tools
|
|
29
|
+
|
|
30
|
+
[](https://github.com/Weber-Group/xrayscatteringtools/actions/workflows/tests.yml)
|
|
31
|
+
|
|
32
|
+
`xrayscatteringtools` is a Python library for gas-phase X-ray scattering data analysis. It provides tools for data I/O, visualization, detector calibration, masking, and theoretical modeling. It is designed to work alongside the [CXI-Template](https://github.com/Weber-Group/CXI-Template) repository for analyzing data from the Coherent X-ray Imaging (CXI) endstation at the [Linac Coherent Light Source (LCLS)](https://lcls.slac.stanford.edu/).
|
|
33
|
+
|
|
34
|
+
## Features
|
|
35
|
+
|
|
36
|
+
- **Data I/O** — Read and write `.xyz` and `.mol` molecular geometry files, combine multi-run HDF5 experimental data, and manage YAML-based experiment configurations.
|
|
37
|
+
- **Visualization** — Plot Jungfrau 4M detector images with proper tiled geometry.
|
|
38
|
+
- **Calibration** — Geometry calibration, interactive pixel masking, per-material scattering corrections, and timetool arrival-time calibration.
|
|
39
|
+
- **Theoretical Modeling** — Compute elastic and inelastic scattering patterns via the Independent Atom Model (IAM), load _ab initio_ scattering data and optimized molecular geometries.
|
|
40
|
+
- **Utilities** — Unit conversions (keV, Å, a.u., _q_, _θ_), momentum-transfer maps, azimuthal binning, molecular transformations, and element lookups.
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Installation
|
|
45
|
+
|
|
46
|
+
Install from PyPI:
|
|
47
|
+
```bash
|
|
48
|
+
pip install xrayscatteringtools
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Or install from source:
|
|
52
|
+
```bash
|
|
53
|
+
git clone https://github.com/Weber-Group/xrayscatteringtools.git
|
|
54
|
+
cd xrayscatteringtools
|
|
55
|
+
pip install .
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
For development (includes pytest, black, mypy, ruff):
|
|
59
|
+
```bash
|
|
60
|
+
pip install -e ".[dev]"
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
**Requirements:** Python ≥ 3.9
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## Modules Overview
|
|
68
|
+
|
|
69
|
+
### `xrayscatteringtools.io`
|
|
70
|
+
Data input and output:
|
|
71
|
+
- `combineRuns` — Combine data from multiple LCLS experimental runs (HDF5).
|
|
72
|
+
- `read_xyz` / `write_xyz` — Read and write `.xyz` molecular geometry files.
|
|
73
|
+
- `read_mol` — Parse `.mol` / `.molden` files.
|
|
74
|
+
- `get_leaves` — Inspect the dataset tree of an HDF5 file.
|
|
75
|
+
- `get_data_paths` — Resolve run-specific data paths from a YAML config.
|
|
76
|
+
- `get_config` / `get_config_for_runs` — Load experiment configuration values.
|
|
77
|
+
|
|
78
|
+
### `xrayscatteringtools.plotting`
|
|
79
|
+
Detector visualization:
|
|
80
|
+
- `plot_j4m` — Plot a Jungfrau 4M image using the stored pixel geometry.
|
|
81
|
+
- `plot_jungfrau` — Plot arbitrary Jungfrau panel data with custom coordinates.
|
|
82
|
+
- `compute_pixel_edges` / `edges_from_centers` — Derive pixel-edge arrays for `pcolormesh`.
|
|
83
|
+
|
|
84
|
+
### `xrayscatteringtools.utils`
|
|
85
|
+
General-purpose utilities:
|
|
86
|
+
- **Unit conversions** — `keV2Angstroms`, `Angstroms2keV`, `au2invAngstroms`, `invAngstroms2au`, `q2theta`, `theta2q`.
|
|
87
|
+
- **Detector geometry** — `compute_q_map`, `azimuthalBinning`.
|
|
88
|
+
- **Molecular transforms** — `translate_molecule`, `rotate_molecule`.
|
|
89
|
+
- **Element lookups** — `element_symbol_to_number`, `element_number_to_symbol`.
|
|
90
|
+
- **Other** — `compress_ranges`, `enable_underscore_cleanup`, `J4M` (lazy-loaded Jungfrau 4M geometry).
|
|
91
|
+
|
|
92
|
+
### `xrayscatteringtools.calib`
|
|
93
|
+
Calibration and correction tools:
|
|
94
|
+
- **`geometry_calibration`** — Fit beam center and detector distance via azimuthally-averaged scattering patterns (`run_geometry_calibration`, `thompson_correction`, `geometry_correction`).
|
|
95
|
+
- **`masking`** — `MaskMaker` class for step-by-step pixel masking: dark, background, polygon, and per-_q_-ring sample masks.
|
|
96
|
+
- **`scattering_corrections`** — Per-material correction factors (Si, Al, Be, Kapton HN, sample cell), attenuation-length lookups, and `J4M_efficiency`.
|
|
97
|
+
- **`timetool_calibration`** — `fast_erf_fit` for edge detection, `apply_timetool_correction` for per-shot arrival-time correction, and `add_calibration_to_yaml` for persisting calibration parameters.
|
|
98
|
+
|
|
99
|
+
### `xrayscatteringtools.theory`
|
|
100
|
+
Theoretical scattering models:
|
|
101
|
+
- **`iam`** — Independent Atom Model: isotropic and oriented elastic/inelastic scattering patterns (`iam_elastic_pattern`, `iam_inelastic_pattern`, `iam_total_pattern`, and their `_oriented` variants), plus `iam_compton_spectrum`.
|
|
102
|
+
- **`geometries`** — Lazy-loaded optimized molecular geometries from bundled HDF5 data (accessed as module-level attributes, e.g. `geometries.SF6`).
|
|
103
|
+
- **`patterns`** — Lazy-loaded _ab initio_ scattering patterns from bundled HDF5 data (accessed as module-level attributes, e.g. `patterns.SF6__HF__aug_cc_pVDZ`).
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## Testing
|
|
108
|
+
|
|
109
|
+
The test suite uses [pytest](https://docs.pytest.org/) and covers all modules (360+ tests):
|
|
110
|
+
```bash
|
|
111
|
+
pip install -e ".[dev]"
|
|
112
|
+
python -m pytest tests/
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Tests run automatically via GitHub Actions on every push and pull request to `main`.
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## Contributing
|
|
120
|
+
|
|
121
|
+
Contributions are welcome! Please fork the repository and submit a pull request with your changes.
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## License
|
|
126
|
+
|
|
127
|
+
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## Acknowledgments
|
|
132
|
+
|
|
133
|
+
This library was created by [David J. Romano](https://david.lizaanddavid.com) by compiling and standardizing code from previous data analysis pipelines. Maintained by the [Weber Research Group](https://sites.brown.edu/weber-lab/) and developed by collaborators to facilitate X-ray scattering research.
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# X-Ray Scattering Tools
|
|
2
|
+
|
|
3
|
+
[](https://github.com/Weber-Group/xrayscatteringtools/actions/workflows/tests.yml)
|
|
4
|
+
|
|
5
|
+
`xrayscatteringtools` is a Python library for gas-phase X-ray scattering data analysis. It provides tools for data I/O, visualization, detector calibration, masking, and theoretical modeling. It is designed to work alongside the [CXI-Template](https://github.com/Weber-Group/CXI-Template) repository for analyzing data from the Coherent X-ray Imaging (CXI) endstation at the [Linac Coherent Light Source (LCLS)](https://lcls.slac.stanford.edu/).
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **Data I/O** — Read and write `.xyz` and `.mol` molecular geometry files, combine multi-run HDF5 experimental data, and manage YAML-based experiment configurations.
|
|
10
|
+
- **Visualization** — Plot Jungfrau 4M detector images with proper tiled geometry.
|
|
11
|
+
- **Calibration** — Geometry calibration, interactive pixel masking, per-material scattering corrections, and timetool arrival-time calibration.
|
|
12
|
+
- **Theoretical Modeling** — Compute elastic and inelastic scattering patterns via the Independent Atom Model (IAM), load _ab initio_ scattering data and optimized molecular geometries.
|
|
13
|
+
- **Utilities** — Unit conversions (keV, Å, a.u., _q_, _θ_), momentum-transfer maps, azimuthal binning, molecular transformations, and element lookups.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
Install from PyPI:
|
|
20
|
+
```bash
|
|
21
|
+
pip install xrayscatteringtools
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Or install from source:
|
|
25
|
+
```bash
|
|
26
|
+
git clone https://github.com/Weber-Group/xrayscatteringtools.git
|
|
27
|
+
cd xrayscatteringtools
|
|
28
|
+
pip install .
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
For development (includes pytest, black, mypy, ruff):
|
|
32
|
+
```bash
|
|
33
|
+
pip install -e ".[dev]"
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
**Requirements:** Python ≥ 3.9
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Modules Overview
|
|
41
|
+
|
|
42
|
+
### `xrayscatteringtools.io`
|
|
43
|
+
Data input and output:
|
|
44
|
+
- `combineRuns` — Combine data from multiple LCLS experimental runs (HDF5).
|
|
45
|
+
- `read_xyz` / `write_xyz` — Read and write `.xyz` molecular geometry files.
|
|
46
|
+
- `read_mol` — Parse `.mol` / `.molden` files.
|
|
47
|
+
- `get_leaves` — Inspect the dataset tree of an HDF5 file.
|
|
48
|
+
- `get_data_paths` — Resolve run-specific data paths from a YAML config.
|
|
49
|
+
- `get_config` / `get_config_for_runs` — Load experiment configuration values.
|
|
50
|
+
|
|
51
|
+
### `xrayscatteringtools.plotting`
|
|
52
|
+
Detector visualization:
|
|
53
|
+
- `plot_j4m` — Plot a Jungfrau 4M image using the stored pixel geometry.
|
|
54
|
+
- `plot_jungfrau` — Plot arbitrary Jungfrau panel data with custom coordinates.
|
|
55
|
+
- `compute_pixel_edges` / `edges_from_centers` — Derive pixel-edge arrays for `pcolormesh`.
|
|
56
|
+
|
|
57
|
+
### `xrayscatteringtools.utils`
|
|
58
|
+
General-purpose utilities:
|
|
59
|
+
- **Unit conversions** — `keV2Angstroms`, `Angstroms2keV`, `au2invAngstroms`, `invAngstroms2au`, `q2theta`, `theta2q`.
|
|
60
|
+
- **Detector geometry** — `compute_q_map`, `azimuthalBinning`.
|
|
61
|
+
- **Molecular transforms** — `translate_molecule`, `rotate_molecule`.
|
|
62
|
+
- **Element lookups** — `element_symbol_to_number`, `element_number_to_symbol`.
|
|
63
|
+
- **Other** — `compress_ranges`, `enable_underscore_cleanup`, `J4M` (lazy-loaded Jungfrau 4M geometry).
|
|
64
|
+
|
|
65
|
+
### `xrayscatteringtools.calib`
|
|
66
|
+
Calibration and correction tools:
|
|
67
|
+
- **`geometry_calibration`** — Fit beam center and detector distance via azimuthally-averaged scattering patterns (`run_geometry_calibration`, `thompson_correction`, `geometry_correction`).
|
|
68
|
+
- **`masking`** — `MaskMaker` class for step-by-step pixel masking: dark, background, polygon, and per-_q_-ring sample masks.
|
|
69
|
+
- **`scattering_corrections`** — Per-material correction factors (Si, Al, Be, Kapton HN, sample cell), attenuation-length lookups, and `J4M_efficiency`.
|
|
70
|
+
- **`timetool_calibration`** — `fast_erf_fit` for edge detection, `apply_timetool_correction` for per-shot arrival-time correction, and `add_calibration_to_yaml` for persisting calibration parameters.
|
|
71
|
+
|
|
72
|
+
### `xrayscatteringtools.theory`
|
|
73
|
+
Theoretical scattering models:
|
|
74
|
+
- **`iam`** — Independent Atom Model: isotropic and oriented elastic/inelastic scattering patterns (`iam_elastic_pattern`, `iam_inelastic_pattern`, `iam_total_pattern`, and their `_oriented` variants), plus `iam_compton_spectrum`.
|
|
75
|
+
- **`geometries`** — Lazy-loaded optimized molecular geometries from bundled HDF5 data (accessed as module-level attributes, e.g. `geometries.SF6`).
|
|
76
|
+
- **`patterns`** — Lazy-loaded _ab initio_ scattering patterns from bundled HDF5 data (accessed as module-level attributes, e.g. `patterns.SF6__HF__aug_cc_pVDZ`).
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## Testing
|
|
81
|
+
|
|
82
|
+
The test suite uses [pytest](https://docs.pytest.org/) and covers all modules (360+ tests):
|
|
83
|
+
```bash
|
|
84
|
+
pip install -e ".[dev]"
|
|
85
|
+
python -m pytest tests/
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Tests run automatically via GitHub Actions on every push and pull request to `main`.
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## Contributing
|
|
93
|
+
|
|
94
|
+
Contributions are welcome! Please fork the repository and submit a pull request with your changes.
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## License
|
|
99
|
+
|
|
100
|
+
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## Acknowledgments
|
|
105
|
+
|
|
106
|
+
This library was created by [David J. Romano](https://david.lizaanddavid.com) by compiling and standardizing code from previous data analysis pipelines. Maintained by the [Weber Research Group](https://sites.brown.edu/weber-lab/) and developed by collaborators to facilitate X-ray scattering research.
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "xrayscatteringtools"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "1.0.1"
|
|
8
8
|
description = "A library for gas phase analysis at the CXI endstation"
|
|
9
9
|
authors = [
|
|
10
10
|
{ name = "David Romano", email = "david_j_romano@brown.edu" }
|
|
@@ -14,16 +14,16 @@ license = "MIT"
|
|
|
14
14
|
license-files = ["LICEN[CS]E*"]
|
|
15
15
|
requires-python = ">=3.9"
|
|
16
16
|
dependencies = [
|
|
17
|
-
"numpy
|
|
17
|
+
"numpy",
|
|
18
18
|
"scipy>=1.11",
|
|
19
|
-
"pathlib",
|
|
20
19
|
"IPython",
|
|
21
20
|
"matplotlib",
|
|
22
21
|
"tqdm",
|
|
23
22
|
"h5py",
|
|
24
23
|
"requests",
|
|
25
24
|
"xraylib",
|
|
26
|
-
"pyyaml"
|
|
25
|
+
"pyyaml",
|
|
26
|
+
"ruamel.yaml"
|
|
27
27
|
]
|
|
28
28
|
|
|
29
29
|
[project.optional-dependencies]
|
|
@@ -44,6 +44,9 @@ where = ["src"]
|
|
|
44
44
|
[tool.pytest.ini_options]
|
|
45
45
|
testpaths = ["tests"]
|
|
46
46
|
addopts = "-ra -q"
|
|
47
|
+
filterwarnings = [
|
|
48
|
+
"ignore::RuntimeWarning:xrayscatteringtools.calib.scattering_corrections",
|
|
49
|
+
]
|
|
47
50
|
|
|
48
51
|
[tool.black]
|
|
49
52
|
line-length = 88
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
from .io import combineRuns, get_leaves, read_xyz, write_xyz, read_mol, get_data_paths, get_config_for_runs, get_config
|
|
2
|
+
from .plotting import plot_j4m, plot_jungfrau, compute_pixel_edges, edges_from_centers
|
|
3
|
+
from .utils import enable_underscore_cleanup, compute_q_map, azimuthalBinning, au2invAngstroms, invAngstroms2au, keV2Angstroms, Angstroms2keV, q2theta, theta2q, element_number_to_symbol, element_symbol_to_number, translate_molecule, rotate_molecule, J4M, compress_ranges
|
|
4
|
+
from . import theory
|
|
5
|
+
from . import calib
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
from .geometry_calibration import run_geometry_calibration, model
|
|
2
|
+
from .scattering_corrections import correction_factor, J4M_efficiency
|
|
3
|
+
from .masking import MaskMaker, mask_maker # mask_maker kept for backward compat
|
|
4
|
+
from .timetool_calibration import fast_erf_fit, add_calibration_to_yaml, apply_timetool_correction
|