ChessAnalysisPipeline 0.0.17.dev3__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 (70) hide show
  1. CHAP/TaskManager.py +216 -0
  2. CHAP/__init__.py +27 -0
  3. CHAP/common/__init__.py +57 -0
  4. CHAP/common/models/__init__.py +8 -0
  5. CHAP/common/models/common.py +124 -0
  6. CHAP/common/models/integration.py +659 -0
  7. CHAP/common/models/map.py +1291 -0
  8. CHAP/common/processor.py +2869 -0
  9. CHAP/common/reader.py +658 -0
  10. CHAP/common/utils.py +110 -0
  11. CHAP/common/writer.py +730 -0
  12. CHAP/edd/__init__.py +23 -0
  13. CHAP/edd/models.py +876 -0
  14. CHAP/edd/processor.py +3069 -0
  15. CHAP/edd/reader.py +1023 -0
  16. CHAP/edd/select_material_params_gui.py +348 -0
  17. CHAP/edd/utils.py +1572 -0
  18. CHAP/edd/writer.py +26 -0
  19. CHAP/foxden/__init__.py +19 -0
  20. CHAP/foxden/models.py +71 -0
  21. CHAP/foxden/processor.py +124 -0
  22. CHAP/foxden/reader.py +224 -0
  23. CHAP/foxden/utils.py +80 -0
  24. CHAP/foxden/writer.py +168 -0
  25. CHAP/giwaxs/__init__.py +11 -0
  26. CHAP/giwaxs/models.py +491 -0
  27. CHAP/giwaxs/processor.py +776 -0
  28. CHAP/giwaxs/reader.py +8 -0
  29. CHAP/giwaxs/writer.py +8 -0
  30. CHAP/inference/__init__.py +7 -0
  31. CHAP/inference/processor.py +69 -0
  32. CHAP/inference/reader.py +8 -0
  33. CHAP/inference/writer.py +8 -0
  34. CHAP/models.py +227 -0
  35. CHAP/pipeline.py +479 -0
  36. CHAP/processor.py +125 -0
  37. CHAP/reader.py +124 -0
  38. CHAP/runner.py +277 -0
  39. CHAP/saxswaxs/__init__.py +7 -0
  40. CHAP/saxswaxs/processor.py +8 -0
  41. CHAP/saxswaxs/reader.py +8 -0
  42. CHAP/saxswaxs/writer.py +8 -0
  43. CHAP/server.py +125 -0
  44. CHAP/sin2psi/__init__.py +7 -0
  45. CHAP/sin2psi/processor.py +8 -0
  46. CHAP/sin2psi/reader.py +8 -0
  47. CHAP/sin2psi/writer.py +8 -0
  48. CHAP/tomo/__init__.py +15 -0
  49. CHAP/tomo/models.py +210 -0
  50. CHAP/tomo/processor.py +3862 -0
  51. CHAP/tomo/reader.py +9 -0
  52. CHAP/tomo/writer.py +59 -0
  53. CHAP/utils/__init__.py +6 -0
  54. CHAP/utils/converters.py +188 -0
  55. CHAP/utils/fit.py +2947 -0
  56. CHAP/utils/general.py +2655 -0
  57. CHAP/utils/material.py +274 -0
  58. CHAP/utils/models.py +595 -0
  59. CHAP/utils/parfile.py +224 -0
  60. CHAP/writer.py +122 -0
  61. MLaaS/__init__.py +0 -0
  62. MLaaS/ktrain.py +205 -0
  63. MLaaS/mnist_img.py +83 -0
  64. MLaaS/tfaas_client.py +371 -0
  65. chessanalysispipeline-0.0.17.dev3.dist-info/LICENSE +60 -0
  66. chessanalysispipeline-0.0.17.dev3.dist-info/METADATA +29 -0
  67. chessanalysispipeline-0.0.17.dev3.dist-info/RECORD +70 -0
  68. chessanalysispipeline-0.0.17.dev3.dist-info/WHEEL +5 -0
  69. chessanalysispipeline-0.0.17.dev3.dist-info/entry_points.txt +2 -0
  70. chessanalysispipeline-0.0.17.dev3.dist-info/top_level.txt +2 -0
CHAP/tomo/models.py ADDED
@@ -0,0 +1,210 @@
1
+ """Tomography Pydantic model classes."""
2
+
3
+ # Third party imports
4
+ from typing import (
5
+ Literal,
6
+ Optional,
7
+ )
8
+ from pydantic import (
9
+ conint,
10
+ conlist,
11
+ confloat,
12
+ constr,
13
+ )
14
+
15
+ # Local modules
16
+ from CHAP.models import CHAPBaseModel
17
+
18
+
19
+ class Detector(CHAPBaseModel):
20
+ """
21
+ Detector class to represent the detector used in the experiment.
22
+ The image origin is assumed to be in the top-left corner, with
23
+ rows down (-z in lab frame) and columns sideways (+x in lab frame).
24
+
25
+ :ivar prefix: Prefix of the detector in the SPEC file.
26
+ :type prefix: str
27
+ :ivar rows: Number of pixel rows on the detector.
28
+ :type rows: int
29
+ :ivar columns: Number of pixel columns on the detector.
30
+ :type columns: int
31
+ :ivar pixel_size: Pixel size of the detector in mm.
32
+ :type pixel_size: int or list[int]
33
+ :ivar lens_magnification: Lens magnification for the detector,
34
+ defaults to `1.0`.
35
+ :type lens_magnification: float, optional
36
+ """
37
+ prefix: constr(strip_whitespace=True, min_length=1)
38
+ rows: conint(gt=0)
39
+ columns: conint(gt=0)
40
+ pixel_size: conlist(
41
+ item_type=confloat(gt=0, allow_inf_nan=False),
42
+ min_length=1, max_length=2)
43
+ lens_magnification: confloat(gt=0, allow_inf_nan=False) = 1.0
44
+
45
+
46
+ class TomoReduceConfig(CHAPBaseModel):
47
+ """
48
+ Class representing the configuration for the tomography image
49
+ reduction processor.
50
+
51
+ :ivar img_row_bounds: Detector image bounds in the row-direction
52
+ (ignored for id1a3 and id3a).
53
+ :type img_row_bounds: list[int], optional
54
+ :ivar delta_theta: Rotation angle increment in image reduction
55
+ in degrees.
56
+ :type delta_theta: float, optional
57
+ """
58
+ img_row_bounds: Optional[
59
+ conlist(item_type=conint(ge=-1), min_length=2, max_length=2)] = None
60
+ delta_theta: Optional[confloat(gt=0, allow_inf_nan=False)] = None
61
+
62
+
63
+ class TomoFindCenterConfig(CHAPBaseModel):
64
+ """
65
+ Class representing the configuration for the tomography center axis
66
+ finding processor.
67
+
68
+ :ivar center_stack_index: Stack index of the tomography set to find
69
+ the center axis.
70
+ :type center_stack_index: int, optional
71
+ :ivar center_rows: Row indices for the center finding processor.
72
+ :type center_rows: list[int, int], optional
73
+ :ivar center_offsets: Centers at the center finding row indices in
74
+ pixels.
75
+ :type center_offsets: list[float, float], optional
76
+ :ivar center_offset_min: Minimum value of center_offset in center
77
+ axis finding search in pixels.
78
+ :type center_offset_min: float, optional
79
+ :ivar center_offset_max: Maximum value of center_offset in center
80
+ axis finding search in pixels.
81
+ :type center_offset_max: float, optional
82
+ :ivar gaussian_sigma: Standard deviation for the Gaussian filter
83
+ applied to image reconstruction visualizations, defaults to no
84
+ filtering performed.
85
+ :type gaussian_sigma: float, optional
86
+ :ivar ring_width: Maximum width of rings to be filtered in the image
87
+ reconstruction in pixels, defaults to no filtering performed.
88
+ :type ring_width: float, optional
89
+ """
90
+ center_stack_index: Optional[conint(ge=0)] = None
91
+ center_rows: Optional[conlist(
92
+ item_type=conint(ge=0), min_length=2, max_length=2)] = None
93
+ center_offsets: Optional[conlist(
94
+ item_type=confloat(allow_inf_nan=False),
95
+ min_length=2, max_length=2)] = None
96
+ center_offset_min: Optional[confloat(allow_inf_nan=False)] = None
97
+ center_offset_max: Optional[confloat(allow_inf_nan=False)] = None
98
+ center_search_range: Optional[conlist(
99
+ item_type=confloat(allow_inf_nan=False),
100
+ min_length=1, max_length=3)] = None
101
+ gaussian_sigma: Optional[confloat(ge=0, allow_inf_nan=False)] = None
102
+ ring_width: Optional[confloat(ge=0, allow_inf_nan=False)] = None
103
+
104
+
105
+ class TomoReconstructConfig(CHAPBaseModel):
106
+ """
107
+ Class representing the configuration for the tomography image
108
+ reconstruction processor.
109
+
110
+ :ivar x_bounds: Reconstructed image bounds in the x-direction.
111
+ :type x_bounds: list[int], optional
112
+ :ivar y_bounds: Reconstructed image bounds in the y-direction.
113
+ :type y_bounds: list[int], optional
114
+ :ivar z_bounds: Reconstructed image bounds in the z-direction.
115
+ :type z_bounds: list[int], optional
116
+ :ivar secondary_iters: Number of secondary iterations in the tomopy
117
+ image reconstruction algorithm, defaults to `0`.
118
+ :type secondary_iters: int, optional
119
+ :ivar gaussian_sigma: Standard deviation for the Gaussian filter
120
+ applied to image reconstruction visualizations, defaults to no
121
+ filtering performed.
122
+ :type gaussian_sigma: float, optional
123
+ :ivar remove_stripe_sigma: Damping parameter in Fourier space in
124
+ tomopy's horizontal stripe removal tool, defaults to no
125
+ correction performed.
126
+ :type remove_stripe_sigma: float, optional
127
+ :ivar ring_width: Maximum width of rings to be filtered in the image
128
+ reconstruction in pixels, defaults to no filtering performed.
129
+ :type ring_width: float, optional
130
+ """
131
+ x_bounds: Optional[
132
+ conlist(item_type=conint(ge=-1), min_length=2, max_length=2)] = None
133
+ y_bounds: Optional[
134
+ conlist(item_type=conint(ge=-1), min_length=2, max_length=2)] = None
135
+ z_bounds: Optional[
136
+ conlist(item_type=conint(ge=-1), min_length=2, max_length=2)] = None
137
+ secondary_iters: conint(ge=0) = 0
138
+ gaussian_sigma: Optional[confloat(ge=0, allow_inf_nan=False)] = None
139
+ remove_stripe_sigma: Optional[confloat(ge=0, allow_inf_nan=False)] = None
140
+ ring_width: Optional[confloat(ge=0, allow_inf_nan=False)] = None
141
+
142
+
143
+ class TomoCombineConfig(CHAPBaseModel):
144
+ """
145
+ Class representing the configuration for the combined tomography
146
+ stacks processor.
147
+
148
+ :ivar x_bounds: Combined image bounds in the x-direction.
149
+ :type x_bounds: list[int], optional
150
+ :ivar y_bounds: Combined image bounds in the y-direction.
151
+ :type y_bounds: list[int], optional
152
+ :ivar z_bounds: Combined image bounds in the z-direction.
153
+ :type z_bounds: list[int], optional
154
+ """
155
+ x_bounds: Optional[
156
+ conlist(item_type=conint(ge=-1), min_length=2, max_length=2)] = None
157
+ y_bounds: Optional[
158
+ conlist(item_type=conint(ge=-1), min_length=2, max_length=2)] = None
159
+ z_bounds: Optional[
160
+ conlist(item_type=conint(ge=-1), min_length=2, max_length=2)] = None
161
+
162
+
163
+ class TomoSimConfig(CHAPBaseModel):
164
+ """
165
+ Class representing the configuration for the tomography simulator.
166
+
167
+ :ivar station: The station name (in 'idxx' format).
168
+ :type station: Literal['id1a3', 'id3a', 'id3b']
169
+ :ivar detector: Detector used in the tomography experiment.
170
+ :type detector: Detector
171
+ :ivar sample_type: Sample type for the tomography simulator.
172
+ :type sample_type: Literal['square_rod', 'square_pipe',
173
+ 'hollow_cube', 'hollow_brick', 'hollow_pyramid']
174
+ :ivar sample_size: Size of each sample dimension in mm (internally
175
+ converted to an integer number of pixels). Enter three values
176
+ for sample_type == `'hollow_pyramid'`, the height and the side
177
+ at the respective bottom and the top of the pyramid.
178
+ :type sample_size: list[float]
179
+ :ivar wall_thickness: Wall thickness for pipe, cube, and brick in
180
+ mm (internally converted to an integer number of pixels).
181
+ :type wall_thickness: float
182
+ :ivar mu: Linear attenuation coefficient in mm^-1, defaults to
183
+ `0.05`.
184
+ :type mu: float, optional
185
+ :ivar theta_step: Rotation angle increment in the tomography
186
+ simulation in degrees.
187
+ :type theta_step: float
188
+ :ivar beam_intensity: Initial beam intensity in counts,
189
+ defaults to `1.e9`.
190
+ :type beam_intensity: float, optional
191
+ :ivar background_intensity: Background intensity in counts,
192
+ defaults to `20`.
193
+ :type background_intensity: float, optional
194
+ :ivar slit_size: Vertical beam height in mm, defaults to `1.0`.
195
+ :type slit_size: float, optional
196
+ """
197
+ station: Literal['id1a3', 'id3a', 'id3b']
198
+ detector: Detector.model_construct()
199
+ sample_type: Literal[
200
+ 'square_rod', 'square_pipe', 'hollow_cube', 'hollow_brick',
201
+ 'hollow_pyramid']
202
+ sample_size: conlist(
203
+ item_type=confloat(gt=0, allow_inf_nan=False),
204
+ min_length=1, max_length=3)
205
+ wall_thickness: Optional[confloat(ge=0, allow_inf_nan=False)] = None
206
+ mu: Optional[confloat(gt=0, allow_inf_nan=False)] = 0.05
207
+ theta_step: confloat(gt=0, allow_inf_nan=False)
208
+ beam_intensity: Optional[confloat(gt=0, allow_inf_nan=False)] = 1.e9
209
+ background_intensity: Optional[confloat(gt=0, allow_inf_nan=False)] = 20
210
+ slit_size: Optional[confloat(gt=0, allow_inf_nan=False)] = 1.0