essdiffraction 23.12.0__py3-none-any.whl

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.
ess/dream/data.py ADDED
@@ -0,0 +1,34 @@
1
+ # SPDX-License-Identifier: BSD-3-Clause
2
+ # Copyright (c) 2023 Scipp contributors (https://github.com/scipp)
3
+ _version = '1'
4
+
5
+ __all__ = ['get_path']
6
+
7
+
8
+ def _make_pooch():
9
+ import pooch
10
+
11
+ return pooch.create(
12
+ path=pooch.os_cache('ess/powgen'),
13
+ env='ESS_DATA_DIR',
14
+ base_url='https://public.esss.dk/groups/scipp/ess/dream/{version}/',
15
+ version=_version,
16
+ registry={
17
+ 'DREAM_nexus_sorted-2023-12-07.nxs': 'md5:22824e14f6eb950d24a720b2a0e2cb66',
18
+ },
19
+ )
20
+
21
+
22
+ _pooch = _make_pooch()
23
+
24
+
25
+ def get_path(name: str, unzip: bool = False) -> str:
26
+ """
27
+ Return the path to a data file bundled with ess.dream.
28
+
29
+ This function only works with example data and cannot handle
30
+ paths to custom files.
31
+ """
32
+ import pooch
33
+
34
+ return _pooch.fetch(name, processor=pooch.Unzip() if unzip else None)
ess/dream/io.py ADDED
@@ -0,0 +1,133 @@
1
+ # SPDX-License-Identifier: BSD-3-Clause
2
+ # Copyright (c) 2023 Scipp contributors (https://github.com/scipp)
3
+
4
+ import os
5
+ from typing import Any, Dict, Union
6
+
7
+ import scipp as sc
8
+ import scippnexus as snx
9
+
10
+
11
+ def load_nexus(
12
+ path: Union[str, os.PathLike],
13
+ *,
14
+ load_pixel_shape: bool = False,
15
+ entry: str = 'entry',
16
+ fold_detectors: bool = True,
17
+ ) -> sc.DataGroup:
18
+ """
19
+ Load an unprocessed DREAM NeXus file.
20
+
21
+ See https://confluence.esss.lu.se/pages/viewpage.action?pageId=462000005
22
+ and the ICD DREAM interface specification for details.
23
+
24
+ Notes (2023-12-06):
25
+
26
+ - Mounting-unit, cassette, and counter roughly correspond to the azimuthal angle
27
+ in the mantle detector. However, counter is reversed in the current files. This
28
+ may also be the case in the other detectors.
29
+ - The endcap detectors have a irregular structure that cannot be fully folded.
30
+ This is not a problem but note again that the counter may be reversed. It is
31
+ currently not clear if this is a bug in the file.
32
+ - The high-resolution detector has a very odd numbering scheme. The SANS detector
33
+ is using the same, but is not populated in the current files. The scheme
34
+ attempts to follows some sort of physical ordering in space (x,y,z), but it
35
+ looks partially messed up.
36
+
37
+ Parameters
38
+ ----------
39
+ path:
40
+ Path to the NeXus file.
41
+ load_pixel_shape:
42
+ If True, load the pixel shape from the file's NXoff_geometry group. This is
43
+ often unused by would slow down file loading. Default is False.
44
+ entry:
45
+ Name of the entry to load. Default is "entry".
46
+ fold_detectors:
47
+ If True, fold the detector data to (partially) mimic the logical detector
48
+ structure. Default is True.
49
+
50
+ Returns
51
+ -------
52
+ :
53
+ A data group with the loaded file contents.
54
+ """
55
+ definitions = snx.base_definitions()
56
+ if not load_pixel_shape:
57
+ definitions["NXdetector"] = FilteredDetector
58
+
59
+ with snx.File(path, definitions=definitions) as f:
60
+ dg = f[entry][()]
61
+ dg = snx.compute_positions(dg)
62
+ return fold_nexus_detectors(dg) if fold_detectors else dg
63
+
64
+
65
+ def fold_nexus_detectors(dg: sc.DataGroup) -> sc.DataGroup:
66
+ """
67
+ Fold the detector data in a DREAM NeXus file.
68
+
69
+ The detector banks in the returned data group will have a multi-dimensional shape,
70
+ following the logical structure as far as possible. Note that the full structure
71
+ cannot be folded, as some dimensions are irregular.
72
+ """
73
+ dg = dg.copy()
74
+ dg['instrument'] = dg['instrument'].copy()
75
+ instrument = dg['instrument']
76
+ mantle = instrument['mantle_detector']
77
+ mantle['mantle_event_data'] = mantle['mantle_event_data'].fold(
78
+ dim='detector_number',
79
+ sizes={
80
+ 'wire': 32,
81
+ 'mounting_unit': 5,
82
+ 'cassette': 6,
83
+ 'counter': 2,
84
+ 'strip': 256,
85
+ },
86
+ )
87
+ for direction in ('backward', 'forward'):
88
+ endcap = instrument[f'endcap_{direction}_detector']
89
+ endcap[f'endcap_{direction}_event_data'] = endcap[
90
+ f'endcap_{direction}_event_data'
91
+ ].fold(
92
+ dim='detector_number',
93
+ sizes={
94
+ 'strip': 16,
95
+ 'wire': 16,
96
+ 'sector': 5 if direction == 'forward' else 11,
97
+ 'sumo_cass_ctr': -1, # sumo*cassette*counter, irregular, cannot fold
98
+ },
99
+ )
100
+ high_resolution = instrument['high_resolution_detector']
101
+ high_resolution['high_resolution_event_data'] = high_resolution[
102
+ 'high_resolution_event_data'
103
+ ].fold(
104
+ dim='detector_number',
105
+ sizes={
106
+ 'strip': 32,
107
+ 'other': -1, # some random order that is hard to follow
108
+ },
109
+ )
110
+ sans = instrument['sans_detector']
111
+ sans['sans_event_data'] = sans['sans_event_data'].fold(
112
+ dim='detector_number',
113
+ sizes={
114
+ 'strip': 32,
115
+ 'other': -1, # some random order that is hard to follow
116
+ },
117
+ )
118
+ return dg
119
+
120
+
121
+ def _skip(name: str, obj: Union[snx.Field, snx.Group]) -> bool:
122
+ skip_classes = (snx.NXoff_geometry,)
123
+ return isinstance(obj, snx.Group) and (obj.nx_class in skip_classes)
124
+
125
+
126
+ class FilteredDetector(snx.NXdetector):
127
+ def __init__(
128
+ self, attrs: Dict[str, Any], children: Dict[str, Union[snx.Field, snx.Group]]
129
+ ):
130
+ children = {
131
+ name: child for name, child in children.items() if not _skip(name, child)
132
+ }
133
+ super().__init__(attrs=attrs, children=children)
@@ -0,0 +1,29 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2023, Scipp contributors (https://github.com/scipp)
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
8
+
9
+ 1. Redistributions of source code must retain the above copyright notice, this
10
+ list of conditions and the following disclaimer.
11
+
12
+ 2. Redistributions in binary form must reproduce the above copyright notice,
13
+ this list of conditions and the following disclaimer in the documentation
14
+ and/or other materials provided with the distribution.
15
+
16
+ 3. Neither the name of the copyright holder nor the names of its
17
+ contributors may be used to endorse or promote products derived from
18
+ this software without specific prior written permission.
19
+
20
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,77 @@
1
+ Metadata-Version: 2.1
2
+ Name: essdiffraction
3
+ Version: 23.12.0
4
+ Summary: Diffraction data reduction for the European Spallation Source
5
+ Author: Scipp contributors
6
+ License: BSD 3-Clause License
7
+
8
+ Copyright (c) 2023, Scipp contributors (https://github.com/scipp)
9
+ All rights reserved.
10
+
11
+ Redistribution and use in source and binary forms, with or without
12
+ modification, are permitted provided that the following conditions are met:
13
+
14
+ 1. Redistributions of source code must retain the above copyright notice, this
15
+ list of conditions and the following disclaimer.
16
+
17
+ 2. Redistributions in binary form must reproduce the above copyright notice,
18
+ this list of conditions and the following disclaimer in the documentation
19
+ and/or other materials provided with the distribution.
20
+
21
+ 3. Neither the name of the copyright holder nor the names of its
22
+ contributors may be used to endorse or promote products derived from
23
+ this software without specific prior written permission.
24
+
25
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
29
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35
+
36
+ Project-URL: Bug Tracker, https://github.com/scipp/essdiffraction/issues
37
+ Project-URL: Documentation, https://scipp.github.io/essdiffraction
38
+ Project-URL: Source, https://github.com/scipp/essdiffraction
39
+ Classifier: Intended Audience :: Science/Research
40
+ Classifier: License :: OSI Approved :: BSD License
41
+ Classifier: Natural Language :: English
42
+ Classifier: Operating System :: OS Independent
43
+ Classifier: Programming Language :: Python :: 3
44
+ Classifier: Programming Language :: Python :: 3 :: Only
45
+ Classifier: Programming Language :: Python :: 3.9
46
+ Classifier: Programming Language :: Python :: 3.10
47
+ Classifier: Programming Language :: Python :: 3.11
48
+ Classifier: Topic :: Scientific/Engineering
49
+ Classifier: Typing :: Typed
50
+ Requires-Python: >=3.9
51
+ Description-Content-Type: text/markdown
52
+ License-File: LICENSE
53
+ Requires-Dist: dask
54
+ Requires-Dist: graphviz
55
+ Requires-Dist: plopp
56
+ Requires-Dist: pythreejs
57
+ Requires-Dist: sciline >=23.9.1
58
+ Requires-Dist: scipp >=23.8.0
59
+ Requires-Dist: scippneutron >=23.9.0
60
+ Requires-Dist: scippnexus >=23.12.0
61
+
62
+ [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](CODE_OF_CONDUCT.md)
63
+ [![PyPI badge](http://img.shields.io/pypi/v/essdiffraction.svg)](https://pypi.python.org/pypi/essdiffraction)
64
+ [![Anaconda-Server Badge](https://anaconda.org/scipp/essdiffraction/badges/version.svg)](https://anaconda.org/scipp/essdiffraction)
65
+ [![License: BSD 3-Clause](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](LICENSE)
66
+
67
+ # ESSdiffraction
68
+
69
+ ## About
70
+
71
+ Diffraction data reduction for the European Spallation Source
72
+
73
+ ## Installation
74
+
75
+ ```sh
76
+ python -m pip install essdiffraction
77
+ ```
@@ -0,0 +1,26 @@
1
+ ess/diffraction/__init__.py,sha256=gB4jijezIbncdlqBkDJn8Mm01f8_e_OEEBnPg65ZZK8,1564
2
+ ess/diffraction/correction.py,sha256=ynplPubxrfg7ZgGfhSySWV1xfFrwMl6onO0p9-EAeXg,3568
3
+ ess/diffraction/filtering.py,sha256=cnMIcGYBPh00_RHmPi4EFrl1D743XP79AEAuTpFlSVY,3684
4
+ ess/diffraction/grouping.py,sha256=iSMR7zeXBkjfAcynbVM-oQ3c5qIJTlA7xt3A2eb1TdE,1914
5
+ ess/diffraction/logging.py,sha256=9OWz5TTgveyKnDLhnxrdagYK9TjVQcDRSThLC00SBnw,330
6
+ ess/diffraction/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
+ ess/diffraction/smoothing.py,sha256=YrVD0fSqJvyMNDqYo31TRa1xKqGPTn5uE_RAc9j92Ww,2684
8
+ ess/diffraction/types.py,sha256=9Ecf-aZBMHQ-Iz4TpI8xbqtTJ4qsccOsjonHkfKAnNE,3369
9
+ ess/diffraction/uncertainty.py,sha256=OMbjL-xabOq7OvxlhHO5DnpENOocEce3mcCGH7UMvWU,597
10
+ ess/diffraction/external/__init__.py,sha256=Nr_SLAAEsY_Ouovk6bCmlE62IrsA3zfpKDsKPGJOAVs,4536
11
+ ess/diffraction/external/powgen/__init__.py,sha256=bYG8LvTrOwa7kmLU0pB_CcWMOMniHIHt6PdloCnGFvY,540
12
+ ess/diffraction/external/powgen/beamline.py,sha256=kzeNZouXyM97oZTmVKl-TB6o1FjwZ7eSTdX94S2KASM,1958
13
+ ess/diffraction/external/powgen/data.py,sha256=7SmCsDZO7k0ihsdac681lF0fOjdg1GHv2c7diKhpNOI,4599
14
+ ess/diffraction/external/powgen/instrument_view.py,sha256=8BNWTmvsv723MVLOYGFmDsfy9AO4bukdhNcdELqnlac,1336
15
+ ess/diffraction/external/powgen/types.py,sha256=qU0ngbWlWNvqEbgfvrFzr1wKFfXbbJDrWeazlKBCWnM,526
16
+ ess/diffraction/powder/__init__.py,sha256=xptLLs6Iz0SwTtkytjVgSDVHd2fC-gkJ2Ed_uWHzIXo,491
17
+ ess/diffraction/powder/conversion.py,sha256=RXZaMNnAledLqJBjw0hO3cLueLtEp1_TB_cSbw3GZYI,4356
18
+ ess/diffraction/powder/correction.py,sha256=MMQeE9aVrBKbYx7j3xSb9b0WhKRaOxnTjJUNO_UAX94,1449
19
+ ess/dream/__init__.py,sha256=yskWk3C5fIRHnI3hjTFbvht385X9nQ2FINbKxQFx2Kc,470
20
+ ess/dream/data.py,sha256=UaVfXrKIor6CvCE_cFmGMg1nOKEx0IfAFzrv5g_V8uo,849
21
+ ess/dream/io.py,sha256=r4-KCS_z95kQPtft-pB3ofe1NLWlZCwhDWqQgQqIWKU,4552
22
+ essdiffraction-23.12.0.dist-info/LICENSE,sha256=pvkUUgjLqx3ORl0XbYGk7JVRgZHw3MfbvzbDhlfOnWw,1553
23
+ essdiffraction-23.12.0.dist-info/METADATA,sha256=USGfYfv1wOC7fLg9ck0w94rGNCo2dAMlzJ9j5DMm7iU,3592
24
+ essdiffraction-23.12.0.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
25
+ essdiffraction-23.12.0.dist-info/top_level.txt,sha256=0JxTCgMKPLKtp14wb1-RKisQPQWX7i96innZNvHBr-s,4
26
+ essdiffraction-23.12.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: bdist_wheel (0.42.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ ess