ewoksid31 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.
- ewoksid31-0.1.0/LICENSE.md +20 -0
- ewoksid31-0.1.0/PKG-INFO +29 -0
- ewoksid31-0.1.0/README.md +7 -0
- ewoksid31-0.1.0/pyproject.toml +6 -0
- ewoksid31-0.1.0/setup.cfg +68 -0
- ewoksid31-0.1.0/setup.py +4 -0
- ewoksid31-0.1.0/src/ewoksid31/__init__.py +1 -0
- ewoksid31-0.1.0/src/ewoksid31/tasks/__init__.py +0 -0
- ewoksid31-0.1.0/src/ewoksid31/tasks/flatfield.py +64 -0
- ewoksid31-0.1.0/src/ewoksid31/tests/__init__.py +0 -0
- ewoksid31-0.1.0/src/ewoksid31/tests/resources/__init__.py +7 -0
- ewoksid31-0.1.0/src/ewoksid31/tests/resources/flats.mat +0 -0
- ewoksid31-0.1.0/src/ewoksid31/tests/resources/flats_old.mat +0 -0
- ewoksid31-0.1.0/src/ewoksid31/tests/test_flatfield.py +16 -0
- ewoksid31-0.1.0/src/ewoksid31.egg-info/PKG-INFO +29 -0
- ewoksid31-0.1.0/src/ewoksid31.egg-info/SOURCES.txt +19 -0
- ewoksid31-0.1.0/src/ewoksid31.egg-info/dependency_links.txt +1 -0
- ewoksid31-0.1.0/src/ewoksid31.egg-info/entry_points.txt +2 -0
- ewoksid31-0.1.0/src/ewoksid31.egg-info/requires.txt +16 -0
- ewoksid31-0.1.0/src/ewoksid31.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# MIT License
|
|
2
|
+
|
|
3
|
+
**Copyright (c) 2023 European Synchrotron Radiation Facility**
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
7
|
+
the Software without restriction, including without limitation the rights to
|
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
10
|
+
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, FITNESS
|
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
ewoksid31-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: ewoksid31
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Data processing workflows for ID31
|
|
5
|
+
Home-page: https://gitlab.esrf.fr/workflow/ewoksid31/
|
|
6
|
+
Author: ESRF
|
|
7
|
+
Author-email: wout.de_nolf@esrf.fr
|
|
8
|
+
License: MIT
|
|
9
|
+
Project-URL: Source, https://gitlab.esrf.fr/workflow/ewoksid31/
|
|
10
|
+
Project-URL: Documentation, https://ewoksid31.readthedocs.io/
|
|
11
|
+
Project-URL: Tracker, https://gitlab.esrf.fr/workflow/ewoksid31/issues/
|
|
12
|
+
Keywords: ewoks
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Requires-Python: >=3.7
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
Provides-Extra: test
|
|
19
|
+
Provides-Extra: dev
|
|
20
|
+
Provides-Extra: doc
|
|
21
|
+
License-File: LICENSE.md
|
|
22
|
+
|
|
23
|
+
# ewoksid31
|
|
24
|
+
|
|
25
|
+
Data processing workflows for ID31
|
|
26
|
+
|
|
27
|
+
## Documentation
|
|
28
|
+
|
|
29
|
+
https://ewoksid31.readthedocs.io/
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
[metadata]
|
|
2
|
+
name = ewoksid31
|
|
3
|
+
version = attr: ewoksid31.__version__
|
|
4
|
+
author = ESRF
|
|
5
|
+
author_email = wout.de_nolf@esrf.fr
|
|
6
|
+
description = Data processing workflows for ID31
|
|
7
|
+
long_description = file: README.md
|
|
8
|
+
long_description_content_type = text/markdown
|
|
9
|
+
license = MIT
|
|
10
|
+
url = https://gitlab.esrf.fr/workflow/ewoksid31/
|
|
11
|
+
project_urls =
|
|
12
|
+
Source = https://gitlab.esrf.fr/workflow/ewoksid31/
|
|
13
|
+
Documentation = https://ewoksid31.readthedocs.io/
|
|
14
|
+
Tracker = https://gitlab.esrf.fr/workflow/ewoksid31/issues/
|
|
15
|
+
classifiers =
|
|
16
|
+
Intended Audience :: Science/Research
|
|
17
|
+
License :: OSI Approved :: MIT License
|
|
18
|
+
Programming Language :: Python :: 3
|
|
19
|
+
keywords =
|
|
20
|
+
ewoks
|
|
21
|
+
|
|
22
|
+
[options]
|
|
23
|
+
package_dir =
|
|
24
|
+
=src
|
|
25
|
+
packages = find:
|
|
26
|
+
python_requires = >=3.7
|
|
27
|
+
install_requires =
|
|
28
|
+
ewokscore
|
|
29
|
+
scipy
|
|
30
|
+
numpy
|
|
31
|
+
|
|
32
|
+
[options.packages.find]
|
|
33
|
+
where = src
|
|
34
|
+
|
|
35
|
+
[options.extras_require]
|
|
36
|
+
test =
|
|
37
|
+
pytest >=7
|
|
38
|
+
dev =
|
|
39
|
+
%(test)s
|
|
40
|
+
black >=22
|
|
41
|
+
flake8 >=4
|
|
42
|
+
doc =
|
|
43
|
+
%(test)s
|
|
44
|
+
sphinx >=4.5
|
|
45
|
+
sphinx-autodoc-typehints >=1.16
|
|
46
|
+
|
|
47
|
+
[options.entry_points]
|
|
48
|
+
ewoks.tasks.class =
|
|
49
|
+
ewoksid31.tasks.*=ewoksid31
|
|
50
|
+
|
|
51
|
+
[options.package_data]
|
|
52
|
+
* = *.mat
|
|
53
|
+
|
|
54
|
+
[flake8]
|
|
55
|
+
ignore = E501, E203, W503
|
|
56
|
+
max-line-length = 88
|
|
57
|
+
exclude =
|
|
58
|
+
.eggs
|
|
59
|
+
|
|
60
|
+
[coverage:run]
|
|
61
|
+
omit =
|
|
62
|
+
setup.py
|
|
63
|
+
*/tests/*
|
|
64
|
+
|
|
65
|
+
[egg_info]
|
|
66
|
+
tag_build =
|
|
67
|
+
tag_date = 0
|
|
68
|
+
|
ewoksid31-0.1.0/setup.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.1.0"
|
|
File without changes
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import numpy
|
|
2
|
+
from scipy.io import loadmat
|
|
3
|
+
from ewokscore import Task
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class FlatFieldFromEnergy(
|
|
7
|
+
Task,
|
|
8
|
+
input_names=["newflat", "oldflat", "energy"],
|
|
9
|
+
output_names=["flatfield"],
|
|
10
|
+
):
|
|
11
|
+
"""Interpolate an energy-stack of flat-field images.
|
|
12
|
+
|
|
13
|
+
The resulting flat-field image can be used as follows
|
|
14
|
+
to correct diffraction patterns for flat field:
|
|
15
|
+
|
|
16
|
+
.. code::
|
|
17
|
+
|
|
18
|
+
Icor = I / flatfield
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
def run(self):
|
|
22
|
+
energy = self.inputs.energy
|
|
23
|
+
new_flat = _interpolated_flatfield(self.inputs.newflat, "E", "F", energy)
|
|
24
|
+
old_flat = _interpolated_flatfield(self.inputs.oldflat, "Eold", "Fold", energy)
|
|
25
|
+
flatfield = old_flat / new_flat
|
|
26
|
+
flatfield[~numpy.isfinite(flatfield)] = 1
|
|
27
|
+
self.outputs.flatfield = flatfield
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def _interpolated_flatfield(
|
|
31
|
+
matlab_filename: str, energy_key: str, flatfield_key: str, energy: float
|
|
32
|
+
) -> numpy.ndarray:
|
|
33
|
+
"""
|
|
34
|
+
:param matlab_filename: matlab file from ID31 that contains an energy-stack of images
|
|
35
|
+
:param energy_key:
|
|
36
|
+
:param flatfield_key:
|
|
37
|
+
:param energy:
|
|
38
|
+
:return: interpolated image (nrow, ncol)
|
|
39
|
+
"""
|
|
40
|
+
m = loadmat(matlab_filename)
|
|
41
|
+
flatfields = m[flatfield_key]
|
|
42
|
+
energies = numpy.squeeze(m[energy_key]).astype(float)
|
|
43
|
+
return _interpolate_flatfields(energies, flatfields, energy)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def _interpolate_flatfields(
|
|
47
|
+
energies: numpy.ndarray, flatfields: numpy.ndarray, energy: float
|
|
48
|
+
) -> numpy.ndarray:
|
|
49
|
+
"""
|
|
50
|
+
:param energies: array of energies (nenergies,)
|
|
51
|
+
:param flatfields: stack of images (nrow, ncol, nenergies)
|
|
52
|
+
:param energy:
|
|
53
|
+
:return: interpolated image (nrow, ncol)
|
|
54
|
+
"""
|
|
55
|
+
j = numpy.argsort(abs(energies - energy))[0:2]
|
|
56
|
+
j.sort()
|
|
57
|
+
j_before, j_after = j
|
|
58
|
+
e_before = energies[j_before]
|
|
59
|
+
e_after = energies[j_after]
|
|
60
|
+
w_before = (e_after - energy) / (e_after - e_before)
|
|
61
|
+
w_after = (energy - e_before) / (e_after - e_before)
|
|
62
|
+
f_before = flatfields[..., j_before]
|
|
63
|
+
f_after = flatfields[..., j_after]
|
|
64
|
+
return w_before * f_before + w_after * f_after
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import numpy
|
|
2
|
+
from .resources import resource_filename
|
|
3
|
+
from ..tasks.flatfield import FlatFieldFromEnergy
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def test_flatfield():
|
|
7
|
+
inputs = {
|
|
8
|
+
"newflat": resource_filename("flats.mat"),
|
|
9
|
+
"oldflat": resource_filename("flats_old.mat"),
|
|
10
|
+
"energy": 90.0,
|
|
11
|
+
}
|
|
12
|
+
task = FlatFieldFromEnergy(inputs=inputs)
|
|
13
|
+
task.execute()
|
|
14
|
+
# Flat-field correction:
|
|
15
|
+
# Icor = I * 0.8115191925457376 = I / flatfield
|
|
16
|
+
numpy.testing.assert_allclose(1 / task.outputs.flatfield[0, 0], 0.8115191925457376)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: ewoksid31
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Data processing workflows for ID31
|
|
5
|
+
Home-page: https://gitlab.esrf.fr/workflow/ewoksid31/
|
|
6
|
+
Author: ESRF
|
|
7
|
+
Author-email: wout.de_nolf@esrf.fr
|
|
8
|
+
License: MIT
|
|
9
|
+
Project-URL: Source, https://gitlab.esrf.fr/workflow/ewoksid31/
|
|
10
|
+
Project-URL: Documentation, https://ewoksid31.readthedocs.io/
|
|
11
|
+
Project-URL: Tracker, https://gitlab.esrf.fr/workflow/ewoksid31/issues/
|
|
12
|
+
Keywords: ewoks
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Requires-Python: >=3.7
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
Provides-Extra: test
|
|
19
|
+
Provides-Extra: dev
|
|
20
|
+
Provides-Extra: doc
|
|
21
|
+
License-File: LICENSE.md
|
|
22
|
+
|
|
23
|
+
# ewoksid31
|
|
24
|
+
|
|
25
|
+
Data processing workflows for ID31
|
|
26
|
+
|
|
27
|
+
## Documentation
|
|
28
|
+
|
|
29
|
+
https://ewoksid31.readthedocs.io/
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
LICENSE.md
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
setup.cfg
|
|
5
|
+
setup.py
|
|
6
|
+
src/ewoksid31/__init__.py
|
|
7
|
+
src/ewoksid31.egg-info/PKG-INFO
|
|
8
|
+
src/ewoksid31.egg-info/SOURCES.txt
|
|
9
|
+
src/ewoksid31.egg-info/dependency_links.txt
|
|
10
|
+
src/ewoksid31.egg-info/entry_points.txt
|
|
11
|
+
src/ewoksid31.egg-info/requires.txt
|
|
12
|
+
src/ewoksid31.egg-info/top_level.txt
|
|
13
|
+
src/ewoksid31/tasks/__init__.py
|
|
14
|
+
src/ewoksid31/tasks/flatfield.py
|
|
15
|
+
src/ewoksid31/tests/__init__.py
|
|
16
|
+
src/ewoksid31/tests/test_flatfield.py
|
|
17
|
+
src/ewoksid31/tests/resources/__init__.py
|
|
18
|
+
src/ewoksid31/tests/resources/flats.mat
|
|
19
|
+
src/ewoksid31/tests/resources/flats_old.mat
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ewoksid31
|