ChessAnalysisPipeline 0.0.3__py3-none-any.whl → 0.0.5__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.
Potentially problematic release.
This version of ChessAnalysisPipeline might be problematic. Click here for more details.
- CHAP/common/models/__init__.py +0 -2
- CHAP/common/models/map.py +11 -10
- CHAP/common/processor.py +2 -2
- CHAP/common/utils/__init__.py +0 -37
- CHAP/common/utils/fit.py +120 -83
- CHAP/common/utils/general.py +1225 -0
- CHAP/common/utils/scanparsers.py +19 -1
- CHAP/edd/models.py +3 -3
- CHAP/edd/processor.py +6 -7
- CHAP/pipeline.py +1 -1
- CHAP/tomo/__init__.py +5 -0
- CHAP/tomo/models.py +125 -0
- CHAP/tomo/processor.py +2007 -0
- CHAP/tomo/reader.py +5 -0
- CHAP/tomo/writer.py +5 -0
- {ChessAnalysisPipeline-0.0.3.dist-info → ChessAnalysisPipeline-0.0.5.dist-info}/METADATA +1 -1
- {ChessAnalysisPipeline-0.0.3.dist-info → ChessAnalysisPipeline-0.0.5.dist-info}/RECORD +21 -15
- {ChessAnalysisPipeline-0.0.3.dist-info → ChessAnalysisPipeline-0.0.5.dist-info}/LICENSE +0 -0
- {ChessAnalysisPipeline-0.0.3.dist-info → ChessAnalysisPipeline-0.0.5.dist-info}/WHEEL +0 -0
- {ChessAnalysisPipeline-0.0.3.dist-info → ChessAnalysisPipeline-0.0.5.dist-info}/entry_points.txt +0 -0
- {ChessAnalysisPipeline-0.0.3.dist-info → ChessAnalysisPipeline-0.0.5.dist-info}/top_level.txt +0 -0
CHAP/common/utils/scanparsers.py
CHANGED
|
@@ -513,6 +513,19 @@ class RotationScanParser(ScanParser):
|
|
|
513
513
|
class FMBRotationScanParser(RotationScanParser, FMBScanParser):
|
|
514
514
|
def __init__(self, spec_file_name, scan_number):
|
|
515
515
|
super().__init__(spec_file_name, scan_number)
|
|
516
|
+
def get_spec_scan_npts(self):
|
|
517
|
+
if self.spec_macro == 'flyscan':
|
|
518
|
+
if len(self.spec_args) == 2:
|
|
519
|
+
# Flat field (dark or bright)
|
|
520
|
+
return(int(self.spec_args[0])+1)
|
|
521
|
+
elif len(self.spec_args) == 5:
|
|
522
|
+
return(int(self.spec_args[3])+1)
|
|
523
|
+
else:
|
|
524
|
+
raise(RuntimeError(f'{self.scan_title}: cannot obtain number of points from '+
|
|
525
|
+
f'{self.spec_macro} with arguments {self.spec_args}'))
|
|
526
|
+
else:
|
|
527
|
+
raise(RuntimeError(f'{self.scan_title}: cannot determine number of points for scans '+
|
|
528
|
+
f'of type {self.spec_macro}'))
|
|
516
529
|
def get_theta_vals(self):
|
|
517
530
|
if self.spec_macro == 'flyscan':
|
|
518
531
|
if len(self.spec_args) == 2:
|
|
@@ -525,7 +538,7 @@ class FMBRotationScanParser(RotationScanParser, FMBScanParser):
|
|
|
525
538
|
raise(RuntimeError(f'{self.scan_title}: cannot obtain theta values from '+
|
|
526
539
|
f'{self.spec_macro} with arguments {self.spec_args}'))
|
|
527
540
|
else:
|
|
528
|
-
raise(RuntimeError(f'{self.scan_title}: cannot determine
|
|
541
|
+
raise(RuntimeError(f'{self.scan_title}: cannot determine theta values for scans '+
|
|
529
542
|
f'of type {self.spec_macro}'))
|
|
530
543
|
def get_horizontal_shift(self):
|
|
531
544
|
return(0.0)
|
|
@@ -578,6 +591,11 @@ class SMBRotationScanParser(RotationScanParser, SMBScanParser):
|
|
|
578
591
|
def __init__(self, spec_file_name, scan_number):
|
|
579
592
|
super().__init__(spec_file_name, scan_number)
|
|
580
593
|
self.par_file_pattern = f'id*-*tomo*-{self.scan_name}'
|
|
594
|
+
def get_spec_scan_npts(self):
|
|
595
|
+
if self.spec_macro == 'slew_ome' or self.spec_macro == 'rams4_slew_ome':
|
|
596
|
+
return(int(self.pars['nframes_real']))
|
|
597
|
+
else:
|
|
598
|
+
raise(RuntimeError(f'{self.scan_title}: cannot determine number of points for scans of type {self.spec_macro}'))
|
|
581
599
|
def get_scan_type(self):
|
|
582
600
|
try:
|
|
583
601
|
return(self.pars['tomo_type'])
|
CHAP/edd/models.py
CHANGED
|
@@ -154,13 +154,13 @@ class MCACeriaCalibrationConfig(BaseModel):
|
|
|
154
154
|
return(interpolation_function)
|
|
155
155
|
|
|
156
156
|
def material(self):
|
|
157
|
-
'''Get CeO2 as a `CHAP.common.utils.Material` object.
|
|
157
|
+
'''Get CeO2 as a `CHAP.common.utils.material.Material` object.
|
|
158
158
|
|
|
159
159
|
:return: CeO2 material
|
|
160
|
-
:rtype: CHAP.common.utils.Material
|
|
160
|
+
:rtype: CHAP.common.utils.material.Material
|
|
161
161
|
'''
|
|
162
162
|
|
|
163
|
-
from CHAP.common.utils import Material
|
|
163
|
+
from CHAP.common.utils.material import Material
|
|
164
164
|
material = Material(material_name=self.hexrd_h5_material_name,
|
|
165
165
|
material_file=self.hexrd_h5_material_file,
|
|
166
166
|
lattice_parameters_angstroms=self.lattice_parameter_angstrom)
|
CHAP/edd/processor.py
CHANGED
|
@@ -8,10 +8,7 @@ Description: Module for Processors used only by EDD experiments
|
|
|
8
8
|
'''
|
|
9
9
|
|
|
10
10
|
# system modules
|
|
11
|
-
import argparse
|
|
12
11
|
import json
|
|
13
|
-
import logging
|
|
14
|
-
import sys
|
|
15
12
|
|
|
16
13
|
# local modules
|
|
17
14
|
from CHAP.processor import Processor
|
|
@@ -86,7 +83,7 @@ class MCACeriaCalibrationProcessor(Processor):
|
|
|
86
83
|
:rtype: float, float, float
|
|
87
84
|
'''
|
|
88
85
|
|
|
89
|
-
from CHAP.common.utils import Fit, FitMultipeak
|
|
86
|
+
from CHAP.common.utils.fit import Fit, FitMultipeak
|
|
90
87
|
import numpy as np
|
|
91
88
|
from scipy.constants import physical_constants
|
|
92
89
|
|
|
@@ -130,7 +127,8 @@ class MCACeriaCalibrationProcessor(Processor):
|
|
|
130
127
|
fit_mca_intensities,
|
|
131
128
|
fit_E0,
|
|
132
129
|
x=fit_mca_energies,
|
|
133
|
-
fit_type='uniform'
|
|
130
|
+
fit_type='uniform',
|
|
131
|
+
plot=False)
|
|
134
132
|
|
|
135
133
|
# Extract values of interest from the best values for the uniform fit
|
|
136
134
|
# parameters
|
|
@@ -152,7 +150,8 @@ class MCACeriaCalibrationProcessor(Processor):
|
|
|
152
150
|
fit_mca_intensities,
|
|
153
151
|
uniform_fit_centers,
|
|
154
152
|
x=fit_mca_energies,
|
|
155
|
-
fit_type='unconstrained'
|
|
153
|
+
fit_type='unconstrained',
|
|
154
|
+
plot=False)
|
|
156
155
|
|
|
157
156
|
# Extract values of interest from the best values for the
|
|
158
157
|
# unconstrained fit parameters
|
|
@@ -227,7 +226,7 @@ class MCADataProcessor(Processor):
|
|
|
227
226
|
:rtype: tuple[MapConfig, MCACeriaCalibrationConfig]
|
|
228
227
|
'''
|
|
229
228
|
|
|
230
|
-
from CHAP.common.models import MapConfig
|
|
229
|
+
from CHAP.common.models.map import MapConfig
|
|
231
230
|
from CHAP.edd.models import MCACeriaCalibrationConfig
|
|
232
231
|
|
|
233
232
|
map_config = False
|
CHAP/pipeline.py
CHANGED
|
@@ -50,7 +50,7 @@ class Pipeline():
|
|
|
50
50
|
self.logger.info(f'Calling "write" on {item}')
|
|
51
51
|
data = item.write(data, **kwargs)
|
|
52
52
|
|
|
53
|
-
self.logger.info(f'
|
|
53
|
+
self.logger.info(f'Executed "execute" in {time()-t0:.3f} seconds')
|
|
54
54
|
|
|
55
55
|
class PipelineObject():
|
|
56
56
|
"""
|
CHAP/tomo/__init__.py
ADDED
CHAP/tomo/models.py
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# system modules
|
|
2
|
+
|
|
3
|
+
# third party imports
|
|
4
|
+
from pydantic import (
|
|
5
|
+
BaseModel,
|
|
6
|
+
StrictBool,
|
|
7
|
+
conint,
|
|
8
|
+
conlist,
|
|
9
|
+
confloat,
|
|
10
|
+
constr,
|
|
11
|
+
)
|
|
12
|
+
from typing import Literal, Optional
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class Detector(BaseModel):
|
|
16
|
+
"""
|
|
17
|
+
Detector class to represent the detector used in the experiment.
|
|
18
|
+
|
|
19
|
+
:ivar prefix: Prefix of the detector in the SPEC file.
|
|
20
|
+
:type prefix: str
|
|
21
|
+
:ivar rows: Number of pixel rows on the detector
|
|
22
|
+
:type rows: int
|
|
23
|
+
:ivar columns: Number of pixel columns on the detector
|
|
24
|
+
:type columns: int
|
|
25
|
+
:ivar pixel_size: Pixel size of the detector in mm
|
|
26
|
+
:type pixel_size: int or list[int]
|
|
27
|
+
:ivar lens_magnification: Lens magnification for the detector
|
|
28
|
+
:type lens_magnification: float, optional
|
|
29
|
+
"""
|
|
30
|
+
prefix: constr(strip_whitespace=True, min_length=1)
|
|
31
|
+
rows: conint(gt=0)
|
|
32
|
+
columns: conint(gt=0)
|
|
33
|
+
pixel_size: conlist(item_type=confloat(gt=0, allow_inf_nan=False), min_items=1, max_items=2)
|
|
34
|
+
lens_magnification: confloat(gt=0, allow_inf_nan=False) = 1.0
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class TomoSetupConfig(BaseModel):
|
|
38
|
+
"""
|
|
39
|
+
Class representing the configuration for the tomography reconstruction setup.
|
|
40
|
+
|
|
41
|
+
:ivar detectors: Detector used in the tomography experiment
|
|
42
|
+
:type detectors: Detector
|
|
43
|
+
"""
|
|
44
|
+
detector: Detector.construct()
|
|
45
|
+
include_raw_data: Optional[StrictBool] = False
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class TomoReduceConfig(BaseModel):
|
|
49
|
+
"""
|
|
50
|
+
Class representing the configuration for tomography image reductions.
|
|
51
|
+
|
|
52
|
+
:ivar tool_type: Type of tomography reconstruction tool; always set to "reduce_data"
|
|
53
|
+
:type tool_type: str, optional
|
|
54
|
+
:ivar detectors: Detector used in the tomography experiment
|
|
55
|
+
:type detectors: Detector
|
|
56
|
+
:ivar img_x_bounds: Detector image bounds in the x-direction
|
|
57
|
+
:type img_x_bounds: list[int], optional
|
|
58
|
+
"""
|
|
59
|
+
tool_type: Literal['reduce_data'] = 'reduce_data'
|
|
60
|
+
detector: Detector = Detector.construct()
|
|
61
|
+
img_x_bounds: Optional[conlist(item_type=conint(ge=0), min_items=2, max_items=2)]
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class TomoFindCenterConfig(BaseModel):
|
|
65
|
+
"""
|
|
66
|
+
Class representing the configuration for tomography find center axis.
|
|
67
|
+
|
|
68
|
+
:ivar tool_type: Type of tomography reconstruction tool; always set to "find_center"
|
|
69
|
+
:type tool_type: str, optional
|
|
70
|
+
:ivar center_stack_index: Stack index of tomography set to find center axis (offset 1)
|
|
71
|
+
:type center_stack_index: int, optional
|
|
72
|
+
:ivar lower_row: Lower row index for center finding
|
|
73
|
+
:type lower_row: int, optional
|
|
74
|
+
:ivar lower_center_offset: Center at lower row index
|
|
75
|
+
:type lower_center_offset: float, optional
|
|
76
|
+
:ivar upper_row: Upper row index for center finding
|
|
77
|
+
:type upper_row: int, optional
|
|
78
|
+
:ivar upper_center_offset: Center at upper row index
|
|
79
|
+
:type upper_center_offset: float, optional
|
|
80
|
+
"""
|
|
81
|
+
tool_type: Literal['find_center'] = 'find_center'
|
|
82
|
+
center_stack_index: Optional[conint(ge=1)]
|
|
83
|
+
lower_row: Optional[conint(ge=-1)]
|
|
84
|
+
lower_center_offset: Optional[confloat(allow_inf_nan=False)]
|
|
85
|
+
upper_row: Optional[conint(ge=-1)]
|
|
86
|
+
upper_center_offset: Optional[confloat(allow_inf_nan=False)]
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
class TomoReconstructConfig(BaseModel):
|
|
90
|
+
"""
|
|
91
|
+
Class representing the configuration for tomography image reconstruction.
|
|
92
|
+
|
|
93
|
+
:ivar tool_type: Type of tomography reconstruction tool; always set to "reconstruct_data"
|
|
94
|
+
:type tool_type: str, optional
|
|
95
|
+
:ivar x_bounds: Reconstructed image bounds in the x-direction
|
|
96
|
+
:type x_bounds: list[int], optional
|
|
97
|
+
:ivar y_bounds: Reconstructed image bounds in the y-direction
|
|
98
|
+
:type y_bounds: list[int], optional
|
|
99
|
+
:ivar z_bounds: Reconstructed image bounds in the z-direction
|
|
100
|
+
:type z_bounds: list[int], optional
|
|
101
|
+
"""
|
|
102
|
+
tool_type: Literal['reconstruct_data'] = 'reconstruct_data'
|
|
103
|
+
x_bounds: Optional[conlist(item_type=conint(ge=-1), min_items=2, max_items=2)]
|
|
104
|
+
y_bounds: Optional[conlist(item_type=conint(ge=-1), min_items=2, max_items=2)]
|
|
105
|
+
z_bounds: Optional[conlist(item_type=conint(ge=-1), min_items=2, max_items=2)]
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
class TomoCombineConfig(BaseModel):
|
|
109
|
+
"""
|
|
110
|
+
Class representing the configuration for combined tomography stacks.
|
|
111
|
+
|
|
112
|
+
:ivar tool_type: Type of tomography reconstruction tool; always set to "combine_data"
|
|
113
|
+
:type tool_type: str, optional
|
|
114
|
+
:ivar x_bounds: Reconstructed image bounds in the x-direction
|
|
115
|
+
:type x_bounds: list[int], optional
|
|
116
|
+
:ivar y_bounds: Reconstructed image bounds in the y-direction
|
|
117
|
+
:type y_bounds: list[int], optional
|
|
118
|
+
:ivar z_bounds: Reconstructed image bounds in the z-direction
|
|
119
|
+
:type z_bounds: list[int], optional
|
|
120
|
+
"""
|
|
121
|
+
tool_type: Literal['combine_data'] = 'combine_data'
|
|
122
|
+
x_bounds: Optional[conlist(item_type=conint(ge=-1), min_items=2, max_items=2)]
|
|
123
|
+
y_bounds: Optional[conlist(item_type=conint(ge=-1), min_items=2, max_items=2)]
|
|
124
|
+
z_bounds: Optional[conlist(item_type=conint(ge=-1), min_items=2, max_items=2)]
|
|
125
|
+
|