orGUI 1.0.1__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.
Files changed (83) hide show
  1. orGUI-1.0.1.dist-info/LICENSE +21 -0
  2. orGUI-1.0.1.dist-info/METADATA +147 -0
  3. orGUI-1.0.1.dist-info/RECORD +83 -0
  4. orGUI-1.0.1.dist-info/WHEEL +5 -0
  5. orGUI-1.0.1.dist-info/entry_points.txt +2 -0
  6. orGUI-1.0.1.dist-info/top_level.txt +1 -0
  7. orgui/__init__.py +36 -0
  8. orgui/app/ArrayTableDialog.py +433 -0
  9. orgui/app/QReflectionSelector.py +538 -0
  10. orgui/app/QScanSelector.py +692 -0
  11. orgui/app/QUBCalculator.py +1210 -0
  12. orgui/app/__init__.py +36 -0
  13. orgui/app/database.py +487 -0
  14. orgui/app/orGUI.py +2613 -0
  15. orgui/app/qutils.py +51 -0
  16. orgui/backend/__init__.py +32 -0
  17. orgui/backend/backends.py +157 -0
  18. orgui/backend/beamline/ID31DiffractLinTilt.py +77 -0
  19. orgui/backend/beamline/P212_tools.py +577 -0
  20. orgui/backend/beamline/__init__.py +36 -0
  21. orgui/backend/beamline/fio_reader.py +110 -0
  22. orgui/backend/beamline/id31_tools.py +651 -0
  23. orgui/backend/scans.py +95 -0
  24. orgui/backend/udefaults.py +163 -0
  25. orgui/backend/universalScanLoader.py +105 -0
  26. orgui/datautils/__init__.py +32 -0
  27. orgui/datautils/util.py +705 -0
  28. orgui/datautils/xrayutils/CTRcalc.py +3022 -0
  29. orgui/datautils/xrayutils/CTRopt.py +623 -0
  30. orgui/datautils/xrayutils/CTRplotutil.py +904 -0
  31. orgui/datautils/xrayutils/DetectorCalibration.py +685 -0
  32. orgui/datautils/xrayutils/HKLVlieg.py +1360 -0
  33. orgui/datautils/xrayutils/ReciprocalNavigation.py +401 -0
  34. orgui/datautils/xrayutils/_CTRcalc_accel.py +181 -0
  35. orgui/datautils/xrayutils/__init__.py +46 -0
  36. orgui/datautils/xrayutils/element_data.py +213 -0
  37. orgui/datautils/xrayutils/test/__init__.py +57 -0
  38. orgui/datautils/xrayutils/test/test_CTRcalc.py +152 -0
  39. orgui/datautils/xrayutils/test/test_DetectorCalibration.py +336 -0
  40. orgui/datautils/xrayutils/test/test_HKLcalc.py +88 -0
  41. orgui/datautils/xrayutils/unitcells/Fe3O4(100).bul +59 -0
  42. orgui/datautils/xrayutils/unitcells/Pt100.bul +7 -0
  43. orgui/datautils/xrayutils/unitcells/Pt100_small.bul +5 -0
  44. orgui/datautils/xrayutils/unitcells/Pt110.bul +5 -0
  45. orgui/datautils/xrayutils/unitcells/Pt111.bul +6 -0
  46. orgui/datautils/xrayutils/unitcells/Pt310.bul +13 -0
  47. orgui/datautils/xrayutils/unitcells/Pt3O4(100).bul +19 -0
  48. orgui/datautils/xrayutils/unitcells/PtO(001).bul +9 -0
  49. orgui/datautils/xrayutils/unitcells/PtO(010).bul +9 -0
  50. orgui/datautils/xrayutils/unitcells/PtO(100).bul +9 -0
  51. orgui/datautils/xrayutils/unitcells/__init__.py +67 -0
  52. orgui/datautils/xrayutils/unitcells/a-PtO2(0001).bul +6 -0
  53. orgui/main.py +101 -0
  54. orgui/resources/__init__.py +40 -0
  55. orgui/resources/icons/alpha.png +0 -0
  56. orgui/resources/icons/alpha.svg +67 -0
  57. orgui/resources/icons/diffractometer_v3.png +0 -0
  58. orgui/resources/icons/disable-image.png +0 -0
  59. orgui/resources/icons/disable-image.svg +68 -0
  60. orgui/resources/icons/document-nx-open.png +0 -0
  61. orgui/resources/icons/document-nx-open.svg +152 -0
  62. orgui/resources/icons/document-nx-save.png +0 -0
  63. orgui/resources/icons/document-nx-save.svg +73 -0
  64. orgui/resources/icons/logo.png +0 -0
  65. orgui/resources/icons/logo.svg +808 -0
  66. orgui/resources/icons/max_image.png +0 -0
  67. orgui/resources/icons/max_image.svg +77 -0
  68. orgui/resources/icons/max_image2.png +0 -0
  69. orgui/resources/icons/max_image2.svg +83 -0
  70. orgui/resources/icons/search-image.png +0 -0
  71. orgui/resources/icons/search-image.svg +94 -0
  72. orgui/resources/icons/search-reflection.png +0 -0
  73. orgui/resources/icons/search-reflection.svg +126 -0
  74. orgui/resources/icons/search.png +0 -0
  75. orgui/resources/icons/search.svg +91 -0
  76. orgui/resources/icons/select-image.png +0 -0
  77. orgui/resources/icons/select-image.svg +60 -0
  78. orgui/resources/icons/set-reflection.png +0 -0
  79. orgui/resources/icons/set-reflection.svg +91 -0
  80. orgui/resources/icons/sum_image.png +0 -0
  81. orgui/resources/icons/sum_image.svg +63 -0
  82. orgui/resources/icons/sum_image2.png +0 -0
  83. orgui/resources/icons/sum_image2.svg +75 -0
@@ -0,0 +1,213 @@
1
+ # The data in these tables were taken from from
2
+ # Cordero B, Gómez V, Platero-Prats AE, Revés M, Echeverría J, Cremades E, Barragán F, Alvarez S.
3
+ # Covalent radii revisited. Dalton Trans. 2008 Jun 7;(21):2832-8. doi: 10.1039/b801115j. Epub 2008 Apr 7. PMID: 18478144.
4
+ import numpy as np
5
+ cov_radii_array = np.array([
6
+ [1 , 'H' , 0.31, 5 ],
7
+ [2 , 'He', 0.28, -1 ],
8
+ [3 , 'Li', 1.28, 7 ],
9
+ [4 , 'Be', 0.96, 3 ],
10
+ [5 , 'B' , 0.84, 3 ],
11
+ [6 , 'C' , 0.76, 1 ],
12
+ [7 , 'N' , 0.71, 1 ],
13
+ [8 , 'O' , 0.66, 2 ],
14
+ [9 , 'F' , 0.57, 3 ],
15
+ [10, 'Ne', 0.58, -1 ],
16
+ [11, 'Na', 1.66, 9 ],
17
+ [12, 'Mg', 1.41, 7 ],
18
+ [13, 'Al', 1.21, 4 ],
19
+ [14, 'Si', 1.11, 2 ],
20
+ [15, 'P' , 1.07, 3 ],
21
+ [16, 'S' , 1.05, 3 ],
22
+ [17, 'Cl', 1.02, 4 ],
23
+ [18, 'Ar', 1.06, 10 ],
24
+ [19, 'K' , 2.03, 12 ],
25
+ [20, 'Ca', 1.76, 10 ],
26
+ [21, 'Sc', 1.70, 7 ],
27
+ [22, 'Ti', 1.60, 8 ],
28
+ [23, 'V' , 1.53, 8 ],
29
+ [24, 'Cr', 1.39, 5 ],
30
+ [25, 'Mn', 1.61, 8 ],
31
+ [26, 'Fe', 1.52, 6 ],
32
+ [27, 'Co', 1.26, 3 ],
33
+ [28, 'Ni', 1.24, 4 ],
34
+ [29, 'Cu', 1.32, 4 ],
35
+ [30, 'Zn', 1.22, 4 ],
36
+ [31, 'Ga', 1.22, 3 ],
37
+ [32, 'Ge', 1.20, 4 ],
38
+ [33, 'As', 1.19, 4 ],
39
+ [34, 'Se', 1.20, 4 ],
40
+ [35, 'Br', 1.20, 3 ],
41
+ [36, 'Kr', 1.16, 4 ],
42
+ [37, 'Rb', 2.20, 9 ],
43
+ [38, 'Sr', 1.95, 10 ],
44
+ [39, 'Y' , 1.90, 7 ],
45
+ [40, 'Zr', 1.75, 7 ],
46
+ [41, 'Nb', 1.64, 6 ],
47
+ [42, 'Mo', 1.54, 5 ],
48
+ [43, 'Tc', 1.47, 7 ],
49
+ [44, 'Ru', 1.46, 7 ],
50
+ [45, 'Rh', 1.42, 7 ],
51
+ [46, 'Pd', 1.39, 6 ],
52
+ [47, 'Ag', 1.45, 5 ],
53
+ [48, 'Cd', 1.44, 9 ],
54
+ [49, 'In', 1.42, 5 ],
55
+ [50, 'Sn', 1.39, 4 ],
56
+ [51, 'Sb', 1.39, 5 ],
57
+ [52, 'Te', 1.38, 4 ],
58
+ [53, 'I' , 1.39, 3 ],
59
+ [54, 'Xe', 1.40, 9 ],
60
+ [55, 'Cs', 2.44, 11 ],
61
+ [56, 'Ba', 2.15, 11 ],
62
+ [57, 'La', 2.07, 8 ],
63
+ [58, 'Ce', 2.04, 9 ],
64
+ [59, 'Pr', 2.03, 7 ],
65
+ [60, 'Nd', 2.01, 6 ],
66
+ [61, 'Pm', 1.99, -1 ],
67
+ [62, 'Sm', 1.98, 8 ],
68
+ [63, 'Eu', 1.98, 6 ],
69
+ [64, 'Gd', 1.96, 6 ],
70
+ [65, 'Tb', 1.94, 5 ],
71
+ [66, 'Dy', 1.92, 7 ],
72
+ [67, 'Ho', 1.92, 7 ],
73
+ [68, 'Er', 1.89, 6 ],
74
+ [69, 'Tm', 1.90, 10 ],
75
+ [70, 'Yb', 1.87, 8 ],
76
+ [71, 'Lu', 1.87, 8 ],
77
+ [72, 'Hf', 1.75, 10 ],
78
+ [73, 'Ta', 1.70, 8 ],
79
+ [74, 'W' , 1.62, 7 ],
80
+ [75, 'Re', 1.51, 7 ],
81
+ [76, 'Os', 1.44, 4 ],
82
+ [77, 'Ir', 1.41, 6 ],
83
+ [78, 'Pt', 1.36, 5 ],
84
+ [79, 'Au', 1.36, 6 ],
85
+ [80, 'Hg', 1.32, 5 ],
86
+ [81, 'Tl', 1.45, 7 ],
87
+ [82, 'Pb', 1.46, 5 ],
88
+ [83, 'Bi', 1.48, 4 ],
89
+ [84, 'Po', 1.40, 4 ],
90
+ [85, 'At', 1.50, -1 ],
91
+ [86, 'Rn', 1.50, -1 ],
92
+ [87, 'Fr', 2.60, -1 ],
93
+ [88, 'Ra', 2.21, 2 ],
94
+ [89, 'Ac', 2.15, -1 ],
95
+ [90, 'Th', 2.06, 6 ],
96
+ [91, 'Pa', 2.00, -1 ],
97
+ [92, 'U' , 1.96, 7 ],
98
+ [93, 'Np', 1.90, 1 ],
99
+ [94, 'Pu', 1.87, 1 ],
100
+ [95, 'Am', 1.80, 6 ],
101
+ [96, 'Cm', 1.69, 3 ]
102
+ ], dtype=object)
103
+
104
+ rgb_array = np.array(
105
+ [(1.0, 1.0, 1.0),
106
+ (0.8509803921568627, 1.0, 1.0),
107
+ (0.8, 0.5019607843137255, 1.0),
108
+ (0.7607843137254902, 1.0, 0.0),
109
+ (1.0, 0.7098039215686275, 0.7098039215686275),
110
+ (0.5647058823529412, 0.5647058823529412, 0.5647058823529412),
111
+ (0.18823529411764706, 0.3137254901960784, 0.9725490196078431),
112
+ (1.0, 0.050980392156862744, 0.050980392156862744),
113
+ (0.5647058823529412, 0.8784313725490196, 0.3137254901960784),
114
+ (0.7019607843137254, 0.8901960784313725, 0.9607843137254902),
115
+ (0.6705882352941176, 0.3607843137254902, 0.9490196078431372),
116
+ (0.5411764705882353, 1.0, 0.0),
117
+ (0.7490196078431373, 0.6509803921568628, 0.6509803921568628),
118
+ (0.9411764705882353, 0.7843137254901961, 0.6274509803921569),
119
+ (1.0, 0.5019607843137255, 0.0),
120
+ (1.0, 1.0, 0.18823529411764706),
121
+ (0.12156862745098039, 0.9411764705882353, 0.12156862745098039),
122
+ (0.5019607843137255, 0.8196078431372549, 0.8901960784313725),
123
+ (0.5607843137254902, 0.25098039215686274, 0.8313725490196079),
124
+ (0.23921568627450981, 1.0, 0.0),
125
+ (0.9019607843137255, 0.9019607843137255, 0.9019607843137255),
126
+ (0.7490196078431373, 0.7607843137254902, 0.7803921568627451),
127
+ (0.6509803921568628, 0.6509803921568628, 0.6705882352941176),
128
+ (0.5411764705882353, 0.6, 0.7803921568627451),
129
+ (0.611764705882353, 0.47843137254901963, 0.7803921568627451),
130
+ (0.8784313725490196, 0.4, 0.2),
131
+ (0.9411764705882353, 0.5647058823529412, 0.6274509803921569),
132
+ (0.3137254901960784, 0.8156862745098039, 0.3137254901960784),
133
+ (0.7843137254901961, 0.5019607843137255, 0.2),
134
+ (0.49019607843137253, 0.5019607843137255, 0.6901960784313725),
135
+ (0.7607843137254902, 0.5607843137254902, 0.5607843137254902),
136
+ (0.4, 0.5607843137254902, 0.5607843137254902),
137
+ (0.7411764705882353, 0.5019607843137255, 0.8901960784313725),
138
+ (1.0, 0.6313725490196078, 0.0),
139
+ (0.6509803921568628, 0.1607843137254902, 0.1607843137254902),
140
+ (0.3607843137254902, 0.7215686274509804, 0.8196078431372549),
141
+ (0.4392156862745098, 0.1803921568627451, 0.6901960784313725),
142
+ (0.0, 1.0, 0.0),
143
+ (0.5803921568627451, 1.0, 1.0),
144
+ (0.5803921568627451, 0.8784313725490196, 0.8784313725490196),
145
+ (0.45098039215686275, 0.7607843137254902, 0.788235294117647),
146
+ (0.32941176470588235, 0.7098039215686275, 0.7098039215686275),
147
+ (0.23137254901960785, 0.6196078431372549, 0.6196078431372549),
148
+ (0.1411764705882353, 0.5607843137254902, 0.5607843137254902),
149
+ (0.0392156862745098, 0.49019607843137253, 0.5490196078431373),
150
+ (0.0, 0.4117647058823529, 0.5215686274509804),
151
+ (0.7529411764705882, 0.7529411764705882, 0.7529411764705882),
152
+ (1.0, 0.8509803921568627, 0.5607843137254902),
153
+ (0.6509803921568628, 0.4588235294117647, 0.45098039215686275),
154
+ (0.4, 0.5019607843137255, 0.5019607843137255),
155
+ (0.6196078431372549, 0.38823529411764707, 0.7098039215686275),
156
+ (0.8313725490196079, 0.47843137254901963, 0.0),
157
+ (0.5803921568627451, 0.0, 0.5803921568627451),
158
+ (0.25882352941176473, 0.6196078431372549, 0.6901960784313725),
159
+ (0.3411764705882353, 0.09019607843137255, 0.5607843137254902),
160
+ (0.0, 0.788235294117647, 0.0),
161
+ (0.4392156862745098, 0.8313725490196079, 1.0),
162
+ (1.0, 1.0, 0.7803921568627451),
163
+ (0.8509803921568627, 1.0, 0.7803921568627451),
164
+ (0.7803921568627451, 1.0, 0.7803921568627451),
165
+ (0.6392156862745098, 1.0, 0.7803921568627451),
166
+ (0.5607843137254902, 1.0, 0.7803921568627451),
167
+ (0.3803921568627451, 1.0, 0.7803921568627451),
168
+ (0.27058823529411763, 1.0, 0.7803921568627451),
169
+ (0.18823529411764706, 1.0, 0.7803921568627451),
170
+ (0.12156862745098039, 1.0, 0.7803921568627451),
171
+ (0.0, 1.0, 0.611764705882353),
172
+ (0.0, 0.9019607843137255, 0.4588235294117647),
173
+ (0.0, 0.8313725490196079, 0.3215686274509804),
174
+ (0.0, 0.7490196078431373, 0.2196078431372549),
175
+ (0.0, 0.6705882352941176, 0.1411764705882353),
176
+ (0.30196078431372547, 0.7607843137254902, 1.0),
177
+ (0.30196078431372547, 0.6509803921568628, 1.0),
178
+ (0.12941176470588237, 0.5803921568627451, 0.8392156862745098),
179
+ (0.14901960784313725, 0.49019607843137253, 0.6705882352941176),
180
+ (0.14901960784313725, 0.4, 0.5882352941176471),
181
+ (0.09019607843137255, 0.32941176470588235, 0.5294117647058824),
182
+ (0.8156862745098039, 0.8156862745098039, 0.8784313725490196),
183
+ (1.0, 0.8196078431372549, 0.13725490196078433),
184
+ (0.7215686274509804, 0.7215686274509804, 0.8156862745098039),
185
+ (0.6509803921568628, 0.32941176470588235, 0.30196078431372547),
186
+ (0.3411764705882353, 0.34901960784313724, 0.3803921568627451),
187
+ (0.6196078431372549, 0.30980392156862746, 0.7098039215686275),
188
+ (0.6705882352941176, 0.3607843137254902, 0.0),
189
+ (0.4588235294117647, 0.30980392156862746, 0.27058823529411763),
190
+ (0.25882352941176473, 0.5098039215686274, 0.5882352941176471),
191
+ (0.25882352941176473, 0.0, 0.4),
192
+ (0.0, 0.49019607843137253, 0.0),
193
+ (0.4392156862745098, 0.6705882352941176, 0.9803921568627451),
194
+ (0.0, 0.7294117647058823, 1.0),
195
+ (0.0, 0.6313725490196078, 1.0),
196
+ (0.0, 0.5607843137254902, 1.0),
197
+ (0.0, 0.5019607843137255, 1.0),
198
+ (0.0, 0.4196078431372549, 1.0),
199
+ (0.32941176470588235, 0.3607843137254902, 0.9490196078431372),
200
+ (0.47058823529411764, 0.3607843137254902, 0.8901960784313725),
201
+ (0.5411764705882353, 0.30980392156862746, 0.8901960784313725),
202
+ (0.6313725490196078, 0.21176470588235294, 0.8313725490196079),
203
+ (0.7019607843137254, 0.12156862745098039, 0.8313725490196079),
204
+ (0.7019607843137254, 0.12156862745098039, 0.7294117647058823),
205
+ (0.7019607843137254, 0.050980392156862744, 0.6509803921568628),
206
+ (0.7411764705882353, 0.050980392156862744, 0.5294117647058824),
207
+ (0.7803921568627451, 0.0, 0.4),
208
+ (0.8, 0.0, 0.34901960784313724),
209
+ (0.8196078431372549, 0.0, 0.30980392156862746),
210
+ (0.8509803921568627, 0.0, 0.27058823529411763),
211
+ (0.8784313725490196, 0.0, 0.2196078431372549),
212
+ (0.9019607843137255, 0.0, 0.1803921568627451),
213
+ (0.9215686274509803, 0.0, 0.14901960784313725)])
@@ -0,0 +1,57 @@
1
+ # -*- coding: utf-8 -*-
2
+ # /*##########################################################################
3
+ #
4
+ # Copyright (c) 2020-2024 Timo Fuchs
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ # of this software and associated documentation files (the "Software"), to deal
8
+ # in the Software without restriction, including without limitation the rights
9
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ # copies of the Software, and to permit persons to whom the Software is
11
+ # furnished to do so, subject to the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be included in
14
+ # all copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ # THE SOFTWARE.
23
+ #
24
+ # ###########################################################################*/
25
+ __author__ = "Timo Fuchs"
26
+ __copyright__ = "Copyright 2020-2024 Timo Fuchs"
27
+ __license__ = "MIT License"
28
+ __version__ = "1.0.0"
29
+ __maintainer__ = "Timo Fuchs"
30
+ __email__ = "fuchs@physik.uni-kiel.de"
31
+
32
+ import logging
33
+
34
+
35
+ try:
36
+ import pytest
37
+ except ImportError:
38
+ logging.getLogger(__name__).error(
39
+ "pytest is required to run the tests, please install it.")
40
+ raise
41
+
42
+ def run_tests(module: str='silx', verbosity: int=0, args=()):
43
+ """Run tests
44
+
45
+ :param module: Name of the silx module to test (default: 'silx')
46
+ :param verbosity: Requested level of verbosity
47
+ :param args: List of extra arguments to pass to `pytest`
48
+ """
49
+ return pytest.main([
50
+ '--pyargs',
51
+ module,
52
+ '--verbosity',
53
+ str(verbosity),
54
+ '-o python_files=["test/test*.py","test/Test*.py"]',
55
+ '-o python_classes=["Test"]',
56
+ '-o python_functions=["Test"]',
57
+ ] + list(args))
@@ -0,0 +1,152 @@
1
+ # -*- coding: utf-8 -*-
2
+ # /*##########################################################################
3
+ #
4
+ # Copyright (c) 2020-2024 Timo Fuchs
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ # of this software and associated documentation files (the "Software"), to deal
8
+ # in the Software without restriction, including without limitation the rights
9
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ # copies of the Software, and to permit persons to whom the Software is
11
+ # furnished to do so, subject to the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be included in
14
+ # all copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ # THE SOFTWARE.
23
+ #
24
+ # ###########################################################################*/
25
+ __author__ = "Timo Fuchs"
26
+ __copyright__ = "Copyright 2020-2024 Timo Fuchs"
27
+ __license__ = "MIT License"
28
+ __version__ = "1.0.0"
29
+ __maintainer__ = "Timo Fuchs"
30
+ __email__ = "fuchs@physik.uni-kiel.de"
31
+
32
+ import unittest
33
+
34
+ from .. import CTRcalc, CTRplotutil
35
+ from ... import util
36
+
37
+ import numpy as np
38
+ import os
39
+
40
+
41
+ class TestReadSXRDCrystal(unittest.TestCase):
42
+
43
+ xpr_file = """E = 68.00000 keV
44
+ # UnitCell relaxations
45
+ 0000 occupancy = 1.00000 +- nan
46
+ return
47
+ Coherent 1.00000 1.00000 2.00000 3.00000 4.00000 5.00000 6.00000 7.00000 8.00000 9.00000 10.00000 11.00000 0.00000
48
+ 2.7748 2.7748 3.9242 90.0000 90.0000 90.0000
49
+ Name x/frac y/frac z/frac iDW oDW occup
50
+ 00 Pt (0.00000 +- nan) (0.00000 +- nan) (0.00249 +- 0.00007) (0.4871 +- nan) (0.5663 +- nan) (1.0000 +- nan)
51
+ 01 Pt (0.50000 +- nan) (0.50000 +- nan) (0.51591 +- 0.00010) (0.7070 +- nan) (0.8379 +- nan) (1.0000 +- nan)
52
+
53
+ # UnitCell adsorbates
54
+ 0001 occupancy = 1.00000 +- nan
55
+ return
56
+ Coherent 0.50000 1.00000 0.00000 0.00000 0.00000 1.00000 0.00000 0.00000 0.00000 1.00000 0.00000 0.00000 0.00000
57
+ Coherent 0.50000 0.00000 -1.00000 0.00000 1.00000 0.00000 0.00000 0.00000 0.00000 1.00000 0.00000 0.00000 0.00000
58
+ 2.7748 2.7748 3.9242 90.0000 90.0000 90.0000
59
+ Name x/frac y/frac z/frac iDW oDW occup
60
+ 00 O (0.00000 +- nan) (0.50000 +- nan) (1.00100 +- nan) (0.4350 +- nan) (0.4350 +- nan) (0.0000 +- nan)
61
+
62
+ # UnitCell bulk
63
+ return
64
+ Coherent 1.00000 1.00000 0.00000 0.00000 0.00000 1.00000 0.00000 0.00000 0.00000 1.00000 0.00000 0.00000 0.00000
65
+ 2.7748 2.7748 3.9242 90.0000 90.0000 90.0000
66
+ Name x/frac y/frac z/frac iDW oDW occup
67
+ 00 Pt (0.00000 +- nan) (0.00000 +- nan) (-1.00000 +- nan) (0.4350 +- nan) (0.4350 +- nan) (1.0000 +- nan)
68
+ 01 Pt (0.50000 +- nan) (0.50000 +- nan) (-0.50000 +- nan) (0.4350 +- nan) (0.4350 +- nan) (1.0000 +- nan)
69
+ """
70
+
71
+ xpr_file_orig = """E = 68.00000 keV
72
+ # UnitCell relaxations
73
+ 0000 occupancy = 1.00000 +- nan
74
+ return
75
+ Coherent 1.00000 1.00000 0.00000 0.00000 0.00000 1.00000 0.00000 0.00000 0.00000 1.00000 0.00000 0.00000 0.00000
76
+ 2.7748 2.7748 3.9242 90.0000 90.0000 90.0000
77
+ Name x/frac y/frac z/frac iDW oDW occup
78
+ 00 Pt (0.00000 +- nan) (0.00000 +- nan) (0.00249 +- 0.00007) (0.4871 +- nan) (0.5663 +- nan) (1.0000 +- nan)
79
+ 01 Pt (0.50000 +- nan) (0.50000 +- nan) (0.51591 +- 0.00010) (0.7070 +- nan) (0.8379 +- nan) (1.0000 +- nan)
80
+
81
+ # UnitCell adsorbates
82
+ 0001 occupancy = 1.00000 +- nan
83
+ return
84
+ Coherent 0.50000 1.00000 0.00000 0.00000 0.00000 1.00000 0.00000 0.00000 0.00000 1.00000 0.00000 0.00000 0.00000
85
+ Coherent 0.50000 0.00000 -1.00000 0.00000 1.00000 0.00000 0.00000 0.00000 0.00000 1.00000 0.00000 0.00000 0.00000
86
+ 2.7748 2.7748 3.9242 90.0000 90.0000 90.0000
87
+ Name x/frac y/frac z/frac iDW oDW occup
88
+ 00 O (0.00000 +- nan) (0.50000 +- nan) (1.00100 +- nan) (0.4350 +- nan) (0.4350 +- nan) (0.0000 +- nan)
89
+
90
+ # UnitCell bulk
91
+ return
92
+ Coherent 1.00000 1.00000 0.00000 0.00000 0.00000 1.00000 0.00000 0.00000 0.00000 1.00000 0.00000 0.00000 0.00000
93
+ 2.7748 2.7748 3.9242 90.0000 90.0000 90.0000
94
+ Name x/frac y/frac z/frac iDW oDW occup
95
+ 00 Pt (0.00000 +- nan) (0.00000 +- nan) (-1.00000 +- nan) (0.4350 +- nan) (0.4350 +- nan) (1.0000 +- nan)
96
+ 01 Pt (0.50000 +- nan) (0.50000 +- nan) (-0.50000 +- nan) (0.4350 +- nan) (0.4350 +- nan) (1.0000 +- nan)
97
+ """
98
+
99
+ def testFromStr(self):
100
+ xtal = CTRcalc.SXRDCrystal.fromStr(TestReadSXRDCrystal.xpr_file)
101
+ self.assertIsInstance(xtal['relaxations'], CTRcalc.UnitCell)
102
+ with self.assertRaises(ValueError):
103
+ uc = xtal['notexisting']
104
+ self.assertEqual(str(xtal), TestReadSXRDCrystal.xpr_file)
105
+
106
+ self.assertTrue(np.array_equal(xtal['relaxations'].coherentDomainMatrix[0],
107
+ np.array([[1.00000, 2.00000, 3.00000, 10.00000],
108
+ [4.00000, 5.00000, 6.00000, 11.00000],
109
+ [7.00000, 8.00000, 9.00000, 0.00000]])))
110
+
111
+ def testFromFile(self):
112
+ fp = os.path.split(__file__)[0]
113
+ xtal = CTRcalc.SXRDCrystal.fromFile(os.path.join(fp,"testdata/0V12_calculated.xpr"))
114
+ self.assertEqual(str(xtal), TestReadSXRDCrystal.xpr_file_orig)
115
+
116
+
117
+
118
+ class TestCTRcalculationNumPy(unittest.TestCase):
119
+ def setUp(self):
120
+ fp = os.path.split(__file__)[0]
121
+ self.xtal_unitcells = CTRcalc.SXRDCrystal.fromFile(os.path.join(fp,"testdata/0V12_calculated.xpr"))
122
+ self.CTRs = CTRplotutil.CTRCollection.fromANAROD(os.path.join(fp,"testdata/0V12_calculated.dat"), RODexport=True)
123
+ pt100 = CTRcalc.UnitCell([3.9242, 3.9242, 3.9242] ,[90.0000 ,90.0000, 90.0000])
124
+ self.xtal_unitcells.setGlobalReferenceUnitCell(pt100,util.z_rotation(np.deg2rad(45.)))
125
+ CTRcalc.HAS_NUMBA_ACCEL = False
126
+
127
+ def testStructureFactorEqual(self):
128
+ calc_CTRs = self.CTRs.generateCollectionFromXtal(self.xtal_unitcells)
129
+
130
+ for calc, reference in zip(calc_CTRs, self.CTRs):
131
+ self.assertTrue(np.allclose(calc.sfI, reference.sfI, rtol=1e-02))
132
+
133
+
134
+ class TestCTRcalculationNumba(unittest.TestCase):
135
+ def setUp(self):
136
+ fp = os.path.split(__file__)[0]
137
+ self.xtal_unitcells = CTRcalc.SXRDCrystal.fromFile(os.path.join(fp,"testdata/0V12_calculated.xpr"))
138
+ self.CTRs = CTRplotutil.CTRCollection.fromANAROD(os.path.join(fp,"testdata/0V12_calculated.dat"), RODexport=True)
139
+ pt100 = CTRcalc.UnitCell([3.9242, 3.9242, 3.9242] ,[90.0000 ,90.0000, 90.0000])
140
+ self.xtal_unitcells.setGlobalReferenceUnitCell(pt100,util.z_rotation(np.deg2rad(45.)))
141
+ if hasattr(CTRcalc, "_CTRcalc_accel"):
142
+ CTRcalc.HAS_NUMBA_ACCEL = True
143
+ else:
144
+ raise Exception("Can not perform Numba tests: _CTRcalc_accel library not imported. Is Numba installed?")
145
+
146
+ def testStructureFactorEqual(self):
147
+ calc_CTRs = self.CTRs.generateCollectionFromXtal(self.xtal_unitcells)
148
+
149
+ for calc, reference in zip(calc_CTRs, self.CTRs):
150
+ self.assertTrue(np.allclose(calc.sfI, reference.sfI, rtol=1e-02))
151
+
152
+