xpcs-correlator 0.1.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.
- xpcs_correlator-0.1.0/.gitignore +39 -0
- xpcs_correlator-0.1.0/LICENSE +21 -0
- xpcs_correlator-0.1.0/PKG-INFO +146 -0
- xpcs_correlator-0.1.0/README.md +116 -0
- xpcs_correlator-0.1.0/pyproject.toml +48 -0
- xpcs_correlator-0.1.0/setup.cfg +4 -0
- xpcs_correlator-0.1.0/src/xpcs_correlator.egg-info/PKG-INFO +146 -0
- xpcs_correlator-0.1.0/src/xpcs_correlator.egg-info/SOURCES.txt +29 -0
- xpcs_correlator-0.1.0/src/xpcs_correlator.egg-info/dependency_links.txt +1 -0
- xpcs_correlator-0.1.0/src/xpcs_correlator.egg-info/requires.txt +12 -0
- xpcs_correlator-0.1.0/src/xpcs_correlator.egg-info/top_level.txt +1 -0
- xpcs_correlator-0.1.0/src/xpcscorr/__init__.py +32 -0
- xpcs_correlator-0.1.0/src/xpcscorr/benchmark/chunking/__init__.py +0 -0
- xpcs_correlator-0.1.0/src/xpcscorr/benchmark/chunking/chunking.py +947 -0
- xpcs_correlator-0.1.0/src/xpcscorr/benchmark/chunking/utils.py +258 -0
- xpcs_correlator-0.1.0/src/xpcscorr/benchmark/utils/mkl.py +252 -0
- xpcs_correlator-0.1.0/src/xpcscorr/core/__init__.py +0 -0
- xpcs_correlator-0.1.0/src/xpcscorr/core/base.py +36 -0
- xpcs_correlator-0.1.0/src/xpcscorr/core/utils.py +334 -0
- xpcs_correlator-0.1.0/src/xpcscorr/correlators/dense/__init__.py +0 -0
- xpcs_correlator-0.1.0/src/xpcscorr/correlators/dense/base.py +300 -0
- xpcs_correlator-0.1.0/src/xpcscorr/correlators/dense/chunked.py +783 -0
- xpcs_correlator-0.1.0/src/xpcscorr/correlators/dense/reference.py +276 -0
- xpcs_correlator-0.1.0/src/xpcscorr/correlators/sparse/__init__.py +9 -0
- xpcs_correlator-0.1.0/tests/conftest.py +10 -0
- xpcs_correlator-0.1.0/tests/old/test_chunking.py +12 -0
- xpcs_correlator-0.1.0/tests/old/test_mkl.py +82 -0
- xpcs_correlator-0.1.0/tests/old/test_reference.py +85 -0
- xpcs_correlator-0.1.0/tests/test_core_utils.py +93 -0
- xpcs_correlator-0.1.0/tests/test_correlator_dens_chunk.py +136 -0
- xpcs_correlator-0.1.0/tests/test_correlator_dens_ref.py +56 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Ignore Python bytecode and cache files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*.pyo
|
|
5
|
+
*.pyd
|
|
6
|
+
|
|
7
|
+
# Ignore virtual environment directories
|
|
8
|
+
venv/
|
|
9
|
+
env/
|
|
10
|
+
*.egg-info/
|
|
11
|
+
.eggs/
|
|
12
|
+
|
|
13
|
+
# Ignore Jupyter Notebook checkpoints
|
|
14
|
+
.ipynb_checkpoints/
|
|
15
|
+
|
|
16
|
+
# Ignore temporary or backup files
|
|
17
|
+
*.swp
|
|
18
|
+
*.swo
|
|
19
|
+
*.bak
|
|
20
|
+
*.tmp
|
|
21
|
+
*.log
|
|
22
|
+
|
|
23
|
+
# Ignore compiled Cython files
|
|
24
|
+
*.so
|
|
25
|
+
*.c
|
|
26
|
+
*.cpp
|
|
27
|
+
|
|
28
|
+
# Ignore test coverage and profiling files
|
|
29
|
+
.coverage
|
|
30
|
+
*.prof
|
|
31
|
+
*.profraw
|
|
32
|
+
|
|
33
|
+
# Ignore build artifacts
|
|
34
|
+
build/
|
|
35
|
+
dist/
|
|
36
|
+
*.egg
|
|
37
|
+
|
|
38
|
+
# Ignore vscode settings
|
|
39
|
+
.vscode/
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Maciej Jankowski
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: xpcs-correlator
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: XPCS correlation calculations for synchrotron experiments
|
|
5
|
+
Author-email: Maciej Jankowski <maciej.jankowski@esrf.fr>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Repository, https://gitlab.esrf.fr/mj/xpcs_developments/xpcscorr
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: Topic :: Scientific/Engineering
|
|
15
|
+
Requires-Python: >=3.10
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
License-File: LICENSE
|
|
18
|
+
Requires-Dist: numpy
|
|
19
|
+
Requires-Dist: dask
|
|
20
|
+
Requires-Dist: dask_jobqueue
|
|
21
|
+
Requires-Dist: h5py
|
|
22
|
+
Requires-Dist: hdf5plugin
|
|
23
|
+
Requires-Dist: threadpoolctl
|
|
24
|
+
Provides-Extra: dev
|
|
25
|
+
Requires-Dist: pytest; extra == "dev"
|
|
26
|
+
Requires-Dist: memory_profiler; extra == "dev"
|
|
27
|
+
Requires-Dist: line_profiler; extra == "dev"
|
|
28
|
+
Requires-Dist: ruff; extra == "dev"
|
|
29
|
+
Dynamic: license-file
|
|
30
|
+
|
|
31
|
+
# xpcs-correlator
|
|
32
|
+
|
|
33
|
+
[](LICENSE) [](https://gitlab.esrf.fr/mj/xpcs_developments/xpcscorr)
|
|
34
|
+
|
|
35
|
+
## Table of contents
|
|
36
|
+
- About
|
|
37
|
+
- Features
|
|
38
|
+
- Requirements
|
|
39
|
+
- Installation
|
|
40
|
+
- Quickstart
|
|
41
|
+
- Configuration / Logging
|
|
42
|
+
- Tests
|
|
43
|
+
- Contributing
|
|
44
|
+
- License
|
|
45
|
+
- Contact
|
|
46
|
+
|
|
47
|
+
## About
|
|
48
|
+
This package consolidates ongoing development of correlators for XPCS data analysis at ESRF, with a focus on the ID02 and ID10-coh beamlines.
|
|
49
|
+
|
|
50
|
+
## Features
|
|
51
|
+
- Dense frames data reference and chunked correlator implementations.
|
|
52
|
+
- Calculates g2, g2 errors, and ttcf (2-time correlation function).
|
|
53
|
+
- The ttcf calculations support linear binning for t1,t2 format and hybrid linear log binning for age,lag format.
|
|
54
|
+
- Designed to handle large frame stacks via chunked (partitioned) processing.
|
|
55
|
+
- Supports Dask for both cluster (SLURM) and local parallel execution
|
|
56
|
+
|
|
57
|
+
## Requirements
|
|
58
|
+
- Python 3.10+ (recommended: 3.10, 3.11, 3.12)
|
|
59
|
+
- numpy
|
|
60
|
+
- dask
|
|
61
|
+
- dask_jobqueue
|
|
62
|
+
- h5py
|
|
63
|
+
- hdf5plugin
|
|
64
|
+
- threadpoolctl
|
|
65
|
+
|
|
66
|
+
## Installation
|
|
67
|
+
Install in editable/develop mode (recommended during development):
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
pip install -e .
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Install with development extras (for running tests and linters):
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
pip install -e .[dev]
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
When published to PyPI the package can be installed with:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
pip install xpcs-correlator
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Quickstart
|
|
86
|
+
Basic usage example — adapt to your data shape and correlator options:
|
|
87
|
+
|
|
88
|
+
```python
|
|
89
|
+
import numpy as np
|
|
90
|
+
from xpcscorr import correlator_dense_reference, correlator_dense_chunked
|
|
91
|
+
|
|
92
|
+
# Replace with your frames array; shape here is (n_frames, nx_pixels, ny_pixels)
|
|
93
|
+
frames = np.random.random((100,512, 512))
|
|
94
|
+
roimask= np.ones((512,512), dtype=bool)
|
|
95
|
+
|
|
96
|
+
# Run reference correlator
|
|
97
|
+
result_ref = correlator_dense_reference(frames, roimask)
|
|
98
|
+
|
|
99
|
+
# Run chunked correlator (handles large data in chunks)
|
|
100
|
+
extra_options = {'chunks_N': 3}
|
|
101
|
+
result_chunked = correlator_dense_chunked(frames, roimask, extra_options=extra_options)
|
|
102
|
+
|
|
103
|
+
print(type(result_ref), type(result_chunked))
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Notes:
|
|
107
|
+
- Replace the synthetic `frames` with your real dataset (HDF5 dataset or numpy array).
|
|
108
|
+
- Check correlator function docstrings for exact argument names and options.
|
|
109
|
+
|
|
110
|
+
## Configuration / Logging
|
|
111
|
+
Control logging with environment variables used by the package (see `src/xpcscorr/__init__.py`):
|
|
112
|
+
|
|
113
|
+
- `XPCSCORR_LOG_TO_CLI` — set to `1` to enable logging to stdout (default in development)
|
|
114
|
+
- `XPCSCORR_LOG_TO_FILE` — set to `1` to enable logging to a file named `xpcscorr.log`
|
|
115
|
+
|
|
116
|
+
Example:
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
export XPCSCORR_LOG_TO_CLI=1
|
|
120
|
+
export XPCSCORR_LOG_TO_FILE=0
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Tests
|
|
124
|
+
Run tests with pytest:
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
pip install -e .[dev]
|
|
128
|
+
pytest -q
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
There are unit tests under `tests/` that exercise correlator behavior and core utilities.
|
|
132
|
+
|
|
133
|
+
## Contributing
|
|
134
|
+
- Open issues for bugs or feature requests.
|
|
135
|
+
- Fork the repo, create a feature branch, add tests, and submit a pull request.
|
|
136
|
+
- Keep changes small, document API changes, and add tests for new behavior.
|
|
137
|
+
|
|
138
|
+
## License
|
|
139
|
+
This project is licensed under the MIT License — see the `LICENSE` file for details.
|
|
140
|
+
|
|
141
|
+
## Contact
|
|
142
|
+
Maintainer: Maciej Jankowski — maciej.jankowski@esrf.fr
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
<!-- EOF -->
|
|
146
|
+
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# xpcs-correlator
|
|
2
|
+
|
|
3
|
+
[](LICENSE) [](https://gitlab.esrf.fr/mj/xpcs_developments/xpcscorr)
|
|
4
|
+
|
|
5
|
+
## Table of contents
|
|
6
|
+
- About
|
|
7
|
+
- Features
|
|
8
|
+
- Requirements
|
|
9
|
+
- Installation
|
|
10
|
+
- Quickstart
|
|
11
|
+
- Configuration / Logging
|
|
12
|
+
- Tests
|
|
13
|
+
- Contributing
|
|
14
|
+
- License
|
|
15
|
+
- Contact
|
|
16
|
+
|
|
17
|
+
## About
|
|
18
|
+
This package consolidates ongoing development of correlators for XPCS data analysis at ESRF, with a focus on the ID02 and ID10-coh beamlines.
|
|
19
|
+
|
|
20
|
+
## Features
|
|
21
|
+
- Dense frames data reference and chunked correlator implementations.
|
|
22
|
+
- Calculates g2, g2 errors, and ttcf (2-time correlation function).
|
|
23
|
+
- The ttcf calculations support linear binning for t1,t2 format and hybrid linear log binning for age,lag format.
|
|
24
|
+
- Designed to handle large frame stacks via chunked (partitioned) processing.
|
|
25
|
+
- Supports Dask for both cluster (SLURM) and local parallel execution
|
|
26
|
+
|
|
27
|
+
## Requirements
|
|
28
|
+
- Python 3.10+ (recommended: 3.10, 3.11, 3.12)
|
|
29
|
+
- numpy
|
|
30
|
+
- dask
|
|
31
|
+
- dask_jobqueue
|
|
32
|
+
- h5py
|
|
33
|
+
- hdf5plugin
|
|
34
|
+
- threadpoolctl
|
|
35
|
+
|
|
36
|
+
## Installation
|
|
37
|
+
Install in editable/develop mode (recommended during development):
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
pip install -e .
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Install with development extras (for running tests and linters):
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
pip install -e .[dev]
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
When published to PyPI the package can be installed with:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
pip install xpcs-correlator
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Quickstart
|
|
56
|
+
Basic usage example — adapt to your data shape and correlator options:
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
import numpy as np
|
|
60
|
+
from xpcscorr import correlator_dense_reference, correlator_dense_chunked
|
|
61
|
+
|
|
62
|
+
# Replace with your frames array; shape here is (n_frames, nx_pixels, ny_pixels)
|
|
63
|
+
frames = np.random.random((100,512, 512))
|
|
64
|
+
roimask= np.ones((512,512), dtype=bool)
|
|
65
|
+
|
|
66
|
+
# Run reference correlator
|
|
67
|
+
result_ref = correlator_dense_reference(frames, roimask)
|
|
68
|
+
|
|
69
|
+
# Run chunked correlator (handles large data in chunks)
|
|
70
|
+
extra_options = {'chunks_N': 3}
|
|
71
|
+
result_chunked = correlator_dense_chunked(frames, roimask, extra_options=extra_options)
|
|
72
|
+
|
|
73
|
+
print(type(result_ref), type(result_chunked))
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Notes:
|
|
77
|
+
- Replace the synthetic `frames` with your real dataset (HDF5 dataset or numpy array).
|
|
78
|
+
- Check correlator function docstrings for exact argument names and options.
|
|
79
|
+
|
|
80
|
+
## Configuration / Logging
|
|
81
|
+
Control logging with environment variables used by the package (see `src/xpcscorr/__init__.py`):
|
|
82
|
+
|
|
83
|
+
- `XPCSCORR_LOG_TO_CLI` — set to `1` to enable logging to stdout (default in development)
|
|
84
|
+
- `XPCSCORR_LOG_TO_FILE` — set to `1` to enable logging to a file named `xpcscorr.log`
|
|
85
|
+
|
|
86
|
+
Example:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
export XPCSCORR_LOG_TO_CLI=1
|
|
90
|
+
export XPCSCORR_LOG_TO_FILE=0
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Tests
|
|
94
|
+
Run tests with pytest:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
pip install -e .[dev]
|
|
98
|
+
pytest -q
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
There are unit tests under `tests/` that exercise correlator behavior and core utilities.
|
|
102
|
+
|
|
103
|
+
## Contributing
|
|
104
|
+
- Open issues for bugs or feature requests.
|
|
105
|
+
- Fork the repo, create a feature branch, add tests, and submit a pull request.
|
|
106
|
+
- Keep changes small, document API changes, and add tests for new behavior.
|
|
107
|
+
|
|
108
|
+
## License
|
|
109
|
+
This project is licensed under the MIT License — see the `LICENSE` file for details.
|
|
110
|
+
|
|
111
|
+
## Contact
|
|
112
|
+
Maintainer: Maciej Jankowski — maciej.jankowski@esrf.fr
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
<!-- EOF -->
|
|
116
|
+
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools", "setuptools-scm", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "xpcs-correlator"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
authors = [
|
|
9
|
+
{ name = "Maciej Jankowski", email = "maciej.jankowski@esrf.fr" }
|
|
10
|
+
]
|
|
11
|
+
description = "XPCS correlation calculations for synchrotron experiments"
|
|
12
|
+
readme = { file = "README.md", content-type = "text/markdown" }
|
|
13
|
+
requires-python = ">=3.10"
|
|
14
|
+
|
|
15
|
+
license = "MIT"
|
|
16
|
+
license-files = ["LICENSE"]
|
|
17
|
+
|
|
18
|
+
urls = { "Repository" = "https://gitlab.esrf.fr/mj/xpcs_developments/xpcscorr" }
|
|
19
|
+
|
|
20
|
+
classifiers = [
|
|
21
|
+
"Development Status :: 3 - Alpha",
|
|
22
|
+
"Programming Language :: Python :: 3",
|
|
23
|
+
"Programming Language :: Python :: 3.10",
|
|
24
|
+
"Programming Language :: Python :: 3.11",
|
|
25
|
+
"Programming Language :: Python :: 3.12",
|
|
26
|
+
"Intended Audience :: Science/Research",
|
|
27
|
+
"Topic :: Scientific/Engineering"
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
dependencies = [
|
|
31
|
+
"numpy",
|
|
32
|
+
"dask",
|
|
33
|
+
"dask_jobqueue",
|
|
34
|
+
"h5py",
|
|
35
|
+
"hdf5plugin",
|
|
36
|
+
"threadpoolctl",
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
[project.optional-dependencies]
|
|
40
|
+
dev = ["pytest",
|
|
41
|
+
"memory_profiler",
|
|
42
|
+
"line_profiler",
|
|
43
|
+
"ruff"
|
|
44
|
+
]
|
|
45
|
+
|
|
46
|
+
[tool.setuptools]
|
|
47
|
+
packages = ["xpcscorr"]
|
|
48
|
+
package-dir = {"" = "src"}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: xpcs-correlator
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: XPCS correlation calculations for synchrotron experiments
|
|
5
|
+
Author-email: Maciej Jankowski <maciej.jankowski@esrf.fr>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Repository, https://gitlab.esrf.fr/mj/xpcs_developments/xpcscorr
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: Topic :: Scientific/Engineering
|
|
15
|
+
Requires-Python: >=3.10
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
License-File: LICENSE
|
|
18
|
+
Requires-Dist: numpy
|
|
19
|
+
Requires-Dist: dask
|
|
20
|
+
Requires-Dist: dask_jobqueue
|
|
21
|
+
Requires-Dist: h5py
|
|
22
|
+
Requires-Dist: hdf5plugin
|
|
23
|
+
Requires-Dist: threadpoolctl
|
|
24
|
+
Provides-Extra: dev
|
|
25
|
+
Requires-Dist: pytest; extra == "dev"
|
|
26
|
+
Requires-Dist: memory_profiler; extra == "dev"
|
|
27
|
+
Requires-Dist: line_profiler; extra == "dev"
|
|
28
|
+
Requires-Dist: ruff; extra == "dev"
|
|
29
|
+
Dynamic: license-file
|
|
30
|
+
|
|
31
|
+
# xpcs-correlator
|
|
32
|
+
|
|
33
|
+
[](LICENSE) [](https://gitlab.esrf.fr/mj/xpcs_developments/xpcscorr)
|
|
34
|
+
|
|
35
|
+
## Table of contents
|
|
36
|
+
- About
|
|
37
|
+
- Features
|
|
38
|
+
- Requirements
|
|
39
|
+
- Installation
|
|
40
|
+
- Quickstart
|
|
41
|
+
- Configuration / Logging
|
|
42
|
+
- Tests
|
|
43
|
+
- Contributing
|
|
44
|
+
- License
|
|
45
|
+
- Contact
|
|
46
|
+
|
|
47
|
+
## About
|
|
48
|
+
This package consolidates ongoing development of correlators for XPCS data analysis at ESRF, with a focus on the ID02 and ID10-coh beamlines.
|
|
49
|
+
|
|
50
|
+
## Features
|
|
51
|
+
- Dense frames data reference and chunked correlator implementations.
|
|
52
|
+
- Calculates g2, g2 errors, and ttcf (2-time correlation function).
|
|
53
|
+
- The ttcf calculations support linear binning for t1,t2 format and hybrid linear log binning for age,lag format.
|
|
54
|
+
- Designed to handle large frame stacks via chunked (partitioned) processing.
|
|
55
|
+
- Supports Dask for both cluster (SLURM) and local parallel execution
|
|
56
|
+
|
|
57
|
+
## Requirements
|
|
58
|
+
- Python 3.10+ (recommended: 3.10, 3.11, 3.12)
|
|
59
|
+
- numpy
|
|
60
|
+
- dask
|
|
61
|
+
- dask_jobqueue
|
|
62
|
+
- h5py
|
|
63
|
+
- hdf5plugin
|
|
64
|
+
- threadpoolctl
|
|
65
|
+
|
|
66
|
+
## Installation
|
|
67
|
+
Install in editable/develop mode (recommended during development):
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
pip install -e .
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Install with development extras (for running tests and linters):
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
pip install -e .[dev]
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
When published to PyPI the package can be installed with:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
pip install xpcs-correlator
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Quickstart
|
|
86
|
+
Basic usage example — adapt to your data shape and correlator options:
|
|
87
|
+
|
|
88
|
+
```python
|
|
89
|
+
import numpy as np
|
|
90
|
+
from xpcscorr import correlator_dense_reference, correlator_dense_chunked
|
|
91
|
+
|
|
92
|
+
# Replace with your frames array; shape here is (n_frames, nx_pixels, ny_pixels)
|
|
93
|
+
frames = np.random.random((100,512, 512))
|
|
94
|
+
roimask= np.ones((512,512), dtype=bool)
|
|
95
|
+
|
|
96
|
+
# Run reference correlator
|
|
97
|
+
result_ref = correlator_dense_reference(frames, roimask)
|
|
98
|
+
|
|
99
|
+
# Run chunked correlator (handles large data in chunks)
|
|
100
|
+
extra_options = {'chunks_N': 3}
|
|
101
|
+
result_chunked = correlator_dense_chunked(frames, roimask, extra_options=extra_options)
|
|
102
|
+
|
|
103
|
+
print(type(result_ref), type(result_chunked))
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Notes:
|
|
107
|
+
- Replace the synthetic `frames` with your real dataset (HDF5 dataset or numpy array).
|
|
108
|
+
- Check correlator function docstrings for exact argument names and options.
|
|
109
|
+
|
|
110
|
+
## Configuration / Logging
|
|
111
|
+
Control logging with environment variables used by the package (see `src/xpcscorr/__init__.py`):
|
|
112
|
+
|
|
113
|
+
- `XPCSCORR_LOG_TO_CLI` — set to `1` to enable logging to stdout (default in development)
|
|
114
|
+
- `XPCSCORR_LOG_TO_FILE` — set to `1` to enable logging to a file named `xpcscorr.log`
|
|
115
|
+
|
|
116
|
+
Example:
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
export XPCSCORR_LOG_TO_CLI=1
|
|
120
|
+
export XPCSCORR_LOG_TO_FILE=0
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Tests
|
|
124
|
+
Run tests with pytest:
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
pip install -e .[dev]
|
|
128
|
+
pytest -q
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
There are unit tests under `tests/` that exercise correlator behavior and core utilities.
|
|
132
|
+
|
|
133
|
+
## Contributing
|
|
134
|
+
- Open issues for bugs or feature requests.
|
|
135
|
+
- Fork the repo, create a feature branch, add tests, and submit a pull request.
|
|
136
|
+
- Keep changes small, document API changes, and add tests for new behavior.
|
|
137
|
+
|
|
138
|
+
## License
|
|
139
|
+
This project is licensed under the MIT License — see the `LICENSE` file for details.
|
|
140
|
+
|
|
141
|
+
## Contact
|
|
142
|
+
Maintainer: Maciej Jankowski — maciej.jankowski@esrf.fr
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
<!-- EOF -->
|
|
146
|
+
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
.gitignore
|
|
2
|
+
LICENSE
|
|
3
|
+
README.md
|
|
4
|
+
pyproject.toml
|
|
5
|
+
src/xpcs_correlator.egg-info/PKG-INFO
|
|
6
|
+
src/xpcs_correlator.egg-info/SOURCES.txt
|
|
7
|
+
src/xpcs_correlator.egg-info/dependency_links.txt
|
|
8
|
+
src/xpcs_correlator.egg-info/requires.txt
|
|
9
|
+
src/xpcs_correlator.egg-info/top_level.txt
|
|
10
|
+
src/xpcscorr/__init__.py
|
|
11
|
+
src/xpcscorr/benchmark/chunking/__init__.py
|
|
12
|
+
src/xpcscorr/benchmark/chunking/chunking.py
|
|
13
|
+
src/xpcscorr/benchmark/chunking/utils.py
|
|
14
|
+
src/xpcscorr/benchmark/utils/mkl.py
|
|
15
|
+
src/xpcscorr/core/__init__.py
|
|
16
|
+
src/xpcscorr/core/base.py
|
|
17
|
+
src/xpcscorr/core/utils.py
|
|
18
|
+
src/xpcscorr/correlators/dense/__init__.py
|
|
19
|
+
src/xpcscorr/correlators/dense/base.py
|
|
20
|
+
src/xpcscorr/correlators/dense/chunked.py
|
|
21
|
+
src/xpcscorr/correlators/dense/reference.py
|
|
22
|
+
src/xpcscorr/correlators/sparse/__init__.py
|
|
23
|
+
tests/conftest.py
|
|
24
|
+
tests/test_core_utils.py
|
|
25
|
+
tests/test_correlator_dens_chunk.py
|
|
26
|
+
tests/test_correlator_dens_ref.py
|
|
27
|
+
tests/old/test_chunking.py
|
|
28
|
+
tests/old/test_mkl.py
|
|
29
|
+
tests/old/test_reference.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
xpcscorr
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
import sys, os
|
|
3
|
+
|
|
4
|
+
# Configure logging based on environment variables
|
|
5
|
+
os.environ["XPCSCORR_LOG_TO_CLI"] = "1"
|
|
6
|
+
|
|
7
|
+
logger = logging.getLogger("xpcscorr")
|
|
8
|
+
logger.propagate = False # <--- Set propagate to False immediately after getting the logger
|
|
9
|
+
logger.setLevel(logging.INFO)
|
|
10
|
+
|
|
11
|
+
if logger.hasHandlers():
|
|
12
|
+
logger.handlers.clear()
|
|
13
|
+
|
|
14
|
+
if os.environ.get("XPCSCORR_LOG_TO_FILE", "0") == "1":
|
|
15
|
+
file_handler = logging.FileHandler("xpcscorr.log")
|
|
16
|
+
file_formatter = logging.Formatter('%(asctime)s %(levelname)s: %(message)s')
|
|
17
|
+
file_handler.setFormatter(file_formatter)
|
|
18
|
+
logger.addHandler(file_handler)
|
|
19
|
+
|
|
20
|
+
if os.environ.get("XPCSCORR_LOG_TO_CLI", "0") == "1":
|
|
21
|
+
stream_handler = logging.StreamHandler(sys.stdout)
|
|
22
|
+
stream_formatter = logging.Formatter('%(asctime)s %(levelname)s: %(message)s')
|
|
23
|
+
stream_handler.setFormatter(stream_formatter)
|
|
24
|
+
logger.addHandler(stream_handler)
|
|
25
|
+
|
|
26
|
+
# Easy access to main correlator functions
|
|
27
|
+
from .correlators.dense.base import _create_correlator_function
|
|
28
|
+
from .correlators.dense.reference import CorrelatorDenseReference
|
|
29
|
+
from .correlators.dense.chunked import CorrelatorDenseChunked
|
|
30
|
+
|
|
31
|
+
correlator_dense_reference = _create_correlator_function(CorrelatorDenseReference)
|
|
32
|
+
correlator_dense_chunked = _create_correlator_function(CorrelatorDenseChunked)
|
|
File without changes
|