cohere-beamlines 4.2.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.
Files changed (46) hide show
  1. cohere_beamlines-4.2.1/LICENSE +18 -0
  2. cohere_beamlines-4.2.1/PKG-INFO +39 -0
  3. cohere_beamlines-4.2.1/README.md +4 -0
  4. cohere_beamlines-4.2.1/pyproject.toml +28 -0
  5. cohere_beamlines-4.2.1/setup.cfg +4 -0
  6. cohere_beamlines-4.2.1/src/cohere_beamlines/Petra3_P10/RSM_post_processing.py +300 -0
  7. cohere_beamlines-4.2.1/src/cohere_beamlines/Petra3_P10/__init__.py +0 -0
  8. cohere_beamlines-4.2.1/src/cohere_beamlines/Petra3_P10/beam_tabs.py +570 -0
  9. cohere_beamlines-4.2.1/src/cohere_beamlines/Petra3_P10/beam_verifier.py +410 -0
  10. cohere_beamlines-4.2.1/src/cohere_beamlines/Petra3_P10/detectors.py +230 -0
  11. cohere_beamlines-4.2.1/src/cohere_beamlines/Petra3_P10/diffractometers.py +256 -0
  12. cohere_beamlines-4.2.1/src/cohere_beamlines/Petra3_P10/instrument.py +149 -0
  13. cohere_beamlines-4.2.1/src/cohere_beamlines/Petra3_P10/p10_scan_reader.py +908 -0
  14. cohere_beamlines-4.2.1/src/cohere_beamlines/Petra3_P10/preprocessor.py +134 -0
  15. cohere_beamlines-4.2.1/src/cohere_beamlines/aps_1ide/__init__.py +0 -0
  16. cohere_beamlines-4.2.1/src/cohere_beamlines/aps_1ide/beam_tabs.py +617 -0
  17. cohere_beamlines-4.2.1/src/cohere_beamlines/aps_1ide/beam_verifier.py +484 -0
  18. cohere_beamlines-4.2.1/src/cohere_beamlines/aps_1ide/detectors.py +312 -0
  19. cohere_beamlines-4.2.1/src/cohere_beamlines/aps_1ide/diffractometers.py +235 -0
  20. cohere_beamlines-4.2.1/src/cohere_beamlines/aps_1ide/instrument.py +128 -0
  21. cohere_beamlines-4.2.1/src/cohere_beamlines/aps_1ide/preprocessor.py +134 -0
  22. cohere_beamlines-4.2.1/src/cohere_beamlines/aps_34idc/__init__.py +0 -0
  23. cohere_beamlines-4.2.1/src/cohere_beamlines/aps_34idc/beam_tabs.py +624 -0
  24. cohere_beamlines-4.2.1/src/cohere_beamlines/aps_34idc/beam_verifier.py +338 -0
  25. cohere_beamlines-4.2.1/src/cohere_beamlines/aps_34idc/detectors.py +433 -0
  26. cohere_beamlines-4.2.1/src/cohere_beamlines/aps_34idc/diffractometers.py +257 -0
  27. cohere_beamlines-4.2.1/src/cohere_beamlines/aps_34idc/instrument.py +190 -0
  28. cohere_beamlines-4.2.1/src/cohere_beamlines/aps_34idc/preprocessor.py +149 -0
  29. cohere_beamlines-4.2.1/src/cohere_beamlines/esrf_id01/__init__.py +0 -0
  30. cohere_beamlines-4.2.1/src/cohere_beamlines/esrf_id01/beam_tabs.py +272 -0
  31. cohere_beamlines-4.2.1/src/cohere_beamlines/esrf_id01/beam_verifier.py +3 -0
  32. cohere_beamlines-4.2.1/src/cohere_beamlines/esrf_id01/detectors.py +139 -0
  33. cohere_beamlines-4.2.1/src/cohere_beamlines/esrf_id01/diffractometers.py +204 -0
  34. cohere_beamlines-4.2.1/src/cohere_beamlines/esrf_id01/instrument.py +139 -0
  35. cohere_beamlines-4.2.1/src/cohere_beamlines/esrf_id01/preprocessor.py +107 -0
  36. cohere_beamlines-4.2.1/src/cohere_beamlines/simple/__init__.py +0 -0
  37. cohere_beamlines-4.2.1/src/cohere_beamlines/simple/beam_verifier.py +3 -0
  38. cohere_beamlines-4.2.1/src/cohere_beamlines/simple/detectors.py +216 -0
  39. cohere_beamlines-4.2.1/src/cohere_beamlines/simple/diffractometers.py +178 -0
  40. cohere_beamlines-4.2.1/src/cohere_beamlines/simple/instrument.py +133 -0
  41. cohere_beamlines-4.2.1/src/cohere_beamlines/simple/preprocessor.py +25 -0
  42. cohere_beamlines-4.2.1/src/cohere_beamlines.egg-info/PKG-INFO +39 -0
  43. cohere_beamlines-4.2.1/src/cohere_beamlines.egg-info/SOURCES.txt +44 -0
  44. cohere_beamlines-4.2.1/src/cohere_beamlines.egg-info/dependency_links.txt +1 -0
  45. cohere_beamlines-4.2.1/src/cohere_beamlines.egg-info/requires.txt +3 -0
  46. cohere_beamlines-4.2.1/src/cohere_beamlines.egg-info/top_level.txt +1 -0
@@ -0,0 +1,18 @@
1
+ Copyright © 2019, UChicago Argonne, LLC
2
+ All Rights Reserved
3
+ Software Name: CDI Reconstruction (cohere)
4
+ By: Argonne National Laboratory
5
+ OPEN SOURCE LICENSE
6
+
7
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
8
+
9
+ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
10
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
11
+ 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
12
+
13
+
14
+ ******************************************************************************************************
15
+ DISCLAIMER
16
+
17
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
18
+ ***************************************************************************************************
@@ -0,0 +1,39 @@
1
+ Metadata-Version: 2.4
2
+ Name: cohere_beamlines
3
+ Version: 4.2.1
4
+ Summary: cohere beamline support
5
+ Author-email: Barbara Frosik <bfrosik@anl.gov>, Ross Harder <rharder@anl.gov>
6
+ License: Copyright © 2019, UChicago Argonne, LLC
7
+ All Rights Reserved
8
+ Software Name: CDI Reconstruction (cohere)
9
+ By: Argonne National Laboratory
10
+ OPEN SOURCE LICENSE
11
+
12
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
13
+
14
+ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
15
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
16
+ 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
17
+
18
+
19
+ ******************************************************************************************************
20
+ DISCLAIMER
21
+
22
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
+ ***************************************************************************************************
24
+
25
+ Project-URL: Homepage, https://github.com/AdvancedPhotonSource/cohere_beamlines
26
+ Classifier: Programming Language :: Python :: 3
27
+ Classifier: Operating System :: OS Independent
28
+ Requires-Python: >=3.11
29
+ Description-Content-Type: text/markdown
30
+ License-File: LICENSE
31
+ Requires-Dist: pyqt5
32
+ Requires-Dist: scikit-image
33
+ Requires-Dist: xrayutilities
34
+ Dynamic: license-file
35
+
36
+ # cohere_beamlines
37
+
38
+ This repository keeps correction fiels for supported beamlines.
39
+ It is updated with a new event, such as new darkfield or whitefield file.
@@ -0,0 +1,4 @@
1
+ # cohere_beamlines
2
+
3
+ This repository keeps correction fiels for supported beamlines.
4
+ It is updated with a new event, such as new darkfield or whitefield file.
@@ -0,0 +1,28 @@
1
+ [build-system]
2
+ requires = ["setuptools >= 77.0.3"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "cohere_beamlines"
7
+ version = "4.2.1"
8
+ authors = [
9
+ { name="Barbara Frosik", email="bfrosik@anl.gov" },
10
+ { name="Ross Harder", email="rharder@anl.gov" }
11
+ ]
12
+ description = "cohere beamline support"
13
+ readme = "README.md"
14
+ requires-python = ">=3.11"
15
+ classifiers = [
16
+ "Programming Language :: Python :: 3",
17
+ "Operating System :: OS Independent",
18
+ ]
19
+ license = { file = "LICENSE" }
20
+
21
+ dependencies = [
22
+ 'pyqt5',
23
+ 'scikit-image',
24
+ 'xrayutilities',
25
+ ]
26
+
27
+ [project.urls]
28
+ Homepage = "https://github.com/AdvancedPhotonSource/cohere_beamlines"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,300 @@
1
+ #!/usr/local/bin/python2.7.3 -tttt
2
+ """
3
+ Functions to cut and plot the result RSM.
4
+ Created on Thu Apr 27 13:50:07 2023
5
+
6
+ @author: renzhe
7
+ @email: renzhe@ihep.ac.cn
8
+ """
9
+
10
+ import numpy as np
11
+ import matplotlib.pyplot as plt
12
+ from scipy.ndimage import measurements
13
+ import os
14
+
15
+
16
+ def check_cut_box_size(bs, peak_pos, data_shape):
17
+ """
18
+ Check the box size possible for the symmetrical cut around the given peak position in the data.
19
+
20
+ Parameters
21
+ ----------
22
+ bs : list
23
+ The Half width of the boxsize in [Z, Y, X] order.
24
+ peak_pos : list
25
+ The peak position in the dataset.
26
+ data_shape : Unions(list|tuple)
27
+ The shape of the data to be cutted.
28
+
29
+ Returns
30
+ -------
31
+ bs : list
32
+ The suggested box size according to the shape of the data.
33
+
34
+ """
35
+ bs[0] = int(np.amin([bs[0], peak_pos[0] * 0.95, 0.95 * (data_shape[0] - peak_pos[0])]))
36
+ bs[1] = int(np.amin([bs[1], peak_pos[1] * 0.95, 0.95 * (data_shape[1] - peak_pos[1])]))
37
+ bs[2] = int(np.amin([bs[2], peak_pos[2] * 0.95, 0.95 * (data_shape[2] - peak_pos[2])]))
38
+ return bs
39
+
40
+
41
+ def Cut_central(dataset, bs, cut_mode='maximum integration', peak_pos=None):
42
+ """
43
+ Cut the three dimensional dataset symmetrically with the box size given.
44
+
45
+ Parameters
46
+ ----------
47
+ dataset : ndarray
48
+ The three dimensional dataset to be cutted.
49
+ bs : list
50
+ The half width of the box size.
51
+ cut_mode : str, optional
52
+ The mode for choosing the center position for the cutting.
53
+ The cut mode can be 'maximum integration', 'maximum intensity', 'weight center' and 'given'.
54
+ 'maximum integration': The dataset is cutted around the maximum integrated intensity in each dimension.
55
+ 'maximum intensity': The dataset is cutted around the maximum intensity.
56
+ 'weight center': The dataset is cutted around weight center in the box.
57
+ 'given': The dataset is cutted around the given peak position.
58
+ The default is 'maximum integration'.
59
+ peak_pos : list, optional
60
+ The position for given peak position. The default is None.
61
+
62
+ Returns
63
+ -------
64
+ intcut : ndarray
65
+ The symmetrically cutted intensity.
66
+ peak_pos : list
67
+ The position of the peak position.
68
+ bs : list
69
+ The used box size for symmetrically cutting the dataset.
70
+
71
+ """
72
+ # Cutting the three dimensional data with the center of mass in the center of the intensity distribution
73
+ if cut_mode == 'maximum integration':
74
+ peak_pos = np.array([np.argmax(np.sum(dataset, axis=(1, 2))), np.argmax(np.sum(dataset, axis=(0, 2))), np.argmax(np.sum(dataset, axis=(0, 1)))], dtype=int)
75
+ print('finding the centeral position for the cutting')
76
+ bs = check_cut_box_size(bs, peak_pos, dataset.shape)
77
+ intcut = np.array(dataset[(peak_pos[0] - bs[0]):(peak_pos[0] + bs[0]), (peak_pos[1] - bs[1]):(peak_pos[1] + bs[1]), (peak_pos[2] - bs[2]):(peak_pos[2] + bs[2])])
78
+ elif cut_mode == 'maximum intensity':
79
+ peak_pos = np.unravel_index(np.argmax(dataset), dataset.shape)
80
+ bs = check_cut_box_size(bs, peak_pos, dataset.shape)
81
+ intcut = np.array(dataset[(peak_pos[0] - bs[0]):(peak_pos[0] + bs[0]), (peak_pos[1] - bs[1]):(peak_pos[1] + bs[1]), (peak_pos[2] - bs[2]):(peak_pos[2] + bs[2])])
82
+ elif cut_mode == 'weight center':
83
+ peak_pos = np.array(np.around(measurements.center_of_mass(dataset)), dtype=int)
84
+ bs = check_cut_box_size(bs, peak_pos, dataset.shape)
85
+ intcut = np.array(dataset[(peak_pos[0] - bs[0]):(peak_pos[0] + bs[0]), (peak_pos[1] - bs[1]):(peak_pos[1] + bs[1]), (peak_pos[2] - bs[2]):(peak_pos[2] + bs[2])])
86
+ print('cut according to the weight center')
87
+ i = 0
88
+ torlerence = 0.5
89
+ while not np.allclose(measurements.center_of_mass(intcut), np.array(bs, dtype=float) - 0.5, atol=torlerence):
90
+ peak_pos = np.array(peak_pos + np.around(measurements.center_of_mass(intcut) - np.array(bs, dtype=float) + 0.5), dtype=int)
91
+ bs = check_cut_box_size(bs, peak_pos, dataset.shape)
92
+ intcut = np.array(dataset[(peak_pos[0] - bs[0]):(peak_pos[0] + bs[0]), (peak_pos[1] - bs[1]):(peak_pos[1] + bs[1]), (peak_pos[2] - bs[2]):(peak_pos[2] + bs[2])])
93
+ i += 1
94
+ if i == 5:
95
+ print("Loosen the constrain for the weight center cutting")
96
+ torlerence = 1
97
+ elif i > 8:
98
+ print("could not find the weight center for the cutting")
99
+ break
100
+ elif cut_mode == 'given':
101
+ if peak_pos is None:
102
+ print('Could not find the given position for the cutting, please check it again!')
103
+ peak_pos = np.array((dataset.shape) / 2, dtype=int)
104
+ else:
105
+ peak_pos = np.array(peak_pos, dtype=int)
106
+ bs = check_cut_box_size(bs, peak_pos, dataset.shape)
107
+ intcut = np.array(dataset[(peak_pos[0] - bs[0]):(peak_pos[0] + bs[0]), (peak_pos[1] - bs[1]):(peak_pos[1] + bs[1]), (peak_pos[2] - bs[2]):(peak_pos[2] + bs[2])])
108
+ return intcut, peak_pos, bs
109
+
110
+
111
+ def plot_with_units(RSM_int, q_origin, unit, pathsavetmp, qmax=np.array([]), display_range=None):
112
+ """
113
+ Plot and save the diffraction pattern with correct units.
114
+
115
+ Parameters
116
+ ----------
117
+ RSM_int : ndarray
118
+ The diffraction pattern to be plotted.
119
+ q_origin : list
120
+ The minimum origin of the diffraction pattern.
121
+ unit : float
122
+ The unit of the diffraction pattern.
123
+ pathsavetmp : str
124
+ The template for saving the diffraction pattern.
125
+ The parameter should be the complete path with %s in the filename for the position indicating different cut directions.
126
+ qmax : list, optional
127
+ If given, the cutted diffraction pattern will be displayed around the given position.
128
+ Else the integrated diffraction intensity will be plotted.
129
+ The default is np.array([]).
130
+ display_range : list, optional
131
+ The half width of the display range in [qz, qy, qx] order. The default is None.
132
+
133
+ Returns
134
+ -------
135
+ None.
136
+
137
+ """
138
+ dz, dy, dx = RSM_int.shape
139
+ qz = np.arange(dz) * unit + q_origin[0]
140
+ qy = np.arange(dy) * unit + q_origin[1]
141
+ qx = np.arange(dx) * unit + q_origin[2]
142
+ # save the qx qy qz cut of the 3D intensity
143
+ print('Saving the qx qy qz cuts......')
144
+ plt.figure(figsize=(12, 12))
145
+ pathsaveimg = pathsavetmp % ('qz')
146
+ if len(qmax) == 0:
147
+ plt.contourf(qx, qy, np.log10(np.sum(RSM_int, axis=0) + 1.0), 150, cmap='jet')
148
+ else:
149
+ plt.contourf(qx, qy, np.log10(RSM_int[qmax[0], :, :] + 1.0), 150, cmap='jet')
150
+ plt.xlabel(r'Q$_x$ ($1/\AA$)', fontsize=20, fontstyle='italic', fontfamily='Arial', fontweight='bold')
151
+ plt.ylabel(r'Q$_y$ ($1/\AA$)', fontsize=20, fontstyle='italic', fontfamily='Arial', fontweight='bold')
152
+ plt.axis('scaled')
153
+ plt.tick_params(axis='both', labelsize=20)
154
+ if (display_range is not None) and (len(qmax) != 0):
155
+ plt.xlim(qmax[2] * unit + q_origin[2] - display_range[2], qmax[2] * unit + q_origin[2] + display_range[2])
156
+ plt.ylim(qmax[1] * unit + q_origin[1] - display_range[1], qmax[1] * unit + q_origin[1] + display_range[1])
157
+ plt.savefig(pathsaveimg)
158
+ plt.show()
159
+ # plt.close()
160
+
161
+ plt.figure(figsize=(12, 12))
162
+ pathsaveimg = pathsavetmp % ('qy')
163
+ if len(qmax) == 0:
164
+ plt.contourf(qx, qz, np.log10(np.sum(RSM_int, axis=1) + 1.0), 150, cmap='jet')
165
+ else:
166
+ plt.contourf(qx, qz, np.log10(RSM_int[:, qmax[1], :] + 1.0), 150, cmap='jet')
167
+ plt.xlabel(r'Q$_x$ ($1/\AA$)', fontsize=20, fontstyle='italic', fontfamily='Arial', fontweight='bold')
168
+ plt.ylabel(r'Q$_z$ ($1/\AA$)', fontsize=20, fontstyle='italic', fontfamily='Arial', fontweight='bold')
169
+ plt.axis('scaled')
170
+ plt.tick_params(axis='both', labelsize=20)
171
+ if (display_range is not None) and (len(qmax) != 0):
172
+ plt.xlim(qmax[2] * unit + q_origin[2] - display_range[2], qmax[2] * unit + q_origin[2] + display_range[2])
173
+ plt.ylim(qmax[0] * unit + q_origin[0] - display_range[0], qmax[0] * unit + q_origin[0] + display_range[0])
174
+ plt.savefig(pathsaveimg)
175
+ plt.show()
176
+ # plt.close()
177
+
178
+ plt.figure(figsize=(12, 12))
179
+ pathsaveimg = pathsavetmp % ('qx')
180
+ if len(qmax) == 0:
181
+ plt.contourf(qy, qz, np.log10(np.sum(RSM_int, axis=2) + 1.0), 150, cmap='jet')
182
+ else:
183
+ plt.contourf(qy, qz, np.log10(RSM_int[:, :, qmax[2]] + 1.0), 150, cmap='jet')
184
+ plt.xlabel(r'Q$_y$ ($1/\AA$)', fontsize=20, fontstyle='italic', fontfamily='Arial', fontweight='bold')
185
+ plt.ylabel(r'Q$_z$ ($1/\AA$)', fontsize=20, fontstyle='italic', fontfamily='Arial', fontweight='bold')
186
+ plt.axis('scaled')
187
+ plt.tick_params(axis='both', labelsize=20)
188
+ if (display_range is not None) and (len(qmax) != 0):
189
+ plt.xlim(qmax[1] * unit + q_origin[1] - display_range[1], qmax[1] * unit + q_origin[1] + display_range[1])
190
+ plt.ylim(qmax[0] * unit + q_origin[0] - display_range[0], qmax[0] * unit + q_origin[0] + display_range[0])
191
+ plt.savefig(pathsaveimg)
192
+ plt.show()
193
+ # plt.close()
194
+ return
195
+
196
+
197
+ def plot_without_units(RSM_int, mask, pathsavetmp):
198
+ """
199
+ Plot and save the diffraction pattern without units.
200
+
201
+ Parameters
202
+ ----------
203
+ RSM_int : ndarray
204
+ The diffraction pattern to be plotted.
205
+ mask : ndarray
206
+ The mask to be used. The masked pixels will be displayed by the red colors in the result plot.
207
+ pathsavetmp : str
208
+ The template for saving the diffraction pattern.
209
+ The parameter should be the complete path with %s in the filename for the position indicating different cut directions.
210
+
211
+ Returns
212
+ -------
213
+ None.
214
+
215
+ """
216
+ mask = np.ma.masked_where(mask == 0, mask)
217
+ dz, dy, dx = RSM_int.shape
218
+ # save the qx qy qz cut of the 3D intensity
219
+ print('Saving the qx qy qz cuts......')
220
+ plt.figure(figsize=(12, 12))
221
+ pathsaveimg = pathsavetmp % 'qz'
222
+ plt.imshow(np.log10(RSM_int[int(dz / 2), :, :] + 1.0), cmap='Blues')
223
+ if mask.ndim != 1:
224
+ plt.imshow(mask[int(dz / 2), :, :], cmap='Reds', alpha=0.5, vmin=0, vmax=1)
225
+ plt.xlabel(r'Q$_x$ (pixel)', fontsize=24)
226
+ plt.ylabel(r'Q$_y$ (pixel)', fontsize=24)
227
+ plt.axis('scaled')
228
+ plt.tick_params(axis='both', labelsize=24)
229
+ plt.savefig(pathsaveimg)
230
+ plt.show()
231
+ plt.close()
232
+
233
+ plt.figure(figsize=(12, 12))
234
+ pathsaveimg = pathsavetmp % 'qy'
235
+ plt.imshow(np.log10(RSM_int[:, int(dy / 2), :] + 1.0), cmap='Blues')
236
+ if mask.ndim != 1:
237
+ plt.imshow(mask[:, int(dy / 2), :], cmap='Reds', alpha=0.5, vmin=0, vmax=1)
238
+ plt.xlabel(r'Q$_x$ (pixel)', fontsize=24)
239
+ plt.ylabel(r'Q$_z$ (pixel)', fontsize=24)
240
+ plt.axis('scaled')
241
+ plt.tick_params(axis='both', labelsize=24)
242
+ plt.savefig(pathsaveimg)
243
+ plt.show()
244
+ plt.close()
245
+
246
+ plt.figure(figsize=(12, 12))
247
+ pathsaveimg = pathsavetmp % 'qx'
248
+ plt.imshow(np.log10(RSM_int[:, :, int(dx / 2)] + 1.0), cmap='Blues')
249
+ if mask.ndim != 1:
250
+ plt.imshow(mask[:, :, int(dx / 2)], cmap='Reds', alpha=0.5, vmin=0, vmax=1)
251
+ plt.xlabel(r'Q$_y$ (pixel)', fontsize=24)
252
+ plt.ylabel(r'Q$_z$ (pixel)', fontsize=24)
253
+ plt.axis('scaled')
254
+ plt.tick_params(axis='both', labelsize=24)
255
+ plt.savefig(pathsaveimg)
256
+ plt.show()
257
+ plt.close()
258
+ return
259
+
260
+
261
+ def RSM2vti(pathsave, RSM_dataset, filename, RSM_unit, origin=(0, 0, 0)):
262
+ """
263
+ Save the reciprocal space map to vti format for reading with paraview.
264
+
265
+ Parameters
266
+ ----------
267
+ pathsave : str
268
+ The folder path to save the RSM.
269
+ RSM_dataset : ndarray
270
+ The RSM to be saved.
271
+ filename : str
272
+ The filename for the saving.
273
+ RSM_unit : float
274
+ The unit of the RSM.
275
+ origin : list, optional
276
+ The origin of the RSM. The default is (0, 0, 0).
277
+
278
+ Returns
279
+ -------
280
+ None.
281
+
282
+ """
283
+ import vtk
284
+ from vtk.util.numpy_support import numpy_to_vtk
285
+
286
+ pathsave = os.path.join(pathsave, filename)
287
+ imdata = vtk.vtkImageData()
288
+ imdata.SetOrigin(origin[0], origin[1], origin[2])
289
+ imdata.SetSpacing(RSM_unit, RSM_unit, RSM_unit)
290
+ imdata.SetDimensions(RSM_dataset.shape)
291
+
292
+ RSM_vtk = numpy_to_vtk(np.ravel(np.transpose(np.log10(RSM_dataset + 1.0))), deep=True, array_type=vtk.VTK_DOUBLE)
293
+
294
+ imdata.GetPointData().SetScalars(RSM_vtk)
295
+ writer = vtk.vtkXMLImageDataWriter()
296
+ writer.SetFileName(pathsave)
297
+ writer.SetInputData(imdata)
298
+
299
+ writer.Write()
300
+ return