ChessAnalysisPipeline 0.0.15__py3-none-any.whl → 0.0.16__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/__init__.py +1 -1
- CHAP/common/__init__.py +4 -0
- CHAP/common/models/integration.py +29 -26
- CHAP/common/models/map.py +186 -255
- CHAP/common/processor.py +956 -160
- CHAP/common/reader.py +93 -27
- CHAP/common/writer.py +15 -5
- CHAP/edd/__init__.py +2 -2
- CHAP/edd/models.py +299 -449
- CHAP/edd/processor.py +639 -448
- CHAP/edd/reader.py +232 -15
- CHAP/giwaxs/__init__.py +8 -0
- CHAP/giwaxs/models.py +100 -0
- CHAP/giwaxs/processor.py +520 -0
- CHAP/giwaxs/reader.py +5 -0
- CHAP/giwaxs/writer.py +5 -0
- CHAP/pipeline.py +47 -9
- CHAP/runner.py +160 -71
- CHAP/tomo/models.py +25 -25
- CHAP/tomo/processor.py +51 -79
- CHAP/utils/general.py +18 -0
- CHAP/utils/models.py +76 -49
- CHAP/utils/parfile.py +10 -2
- {ChessAnalysisPipeline-0.0.15.dist-info → ChessAnalysisPipeline-0.0.16.dist-info}/METADATA +1 -1
- {ChessAnalysisPipeline-0.0.15.dist-info → ChessAnalysisPipeline-0.0.16.dist-info}/RECORD +29 -25
- {ChessAnalysisPipeline-0.0.15.dist-info → ChessAnalysisPipeline-0.0.16.dist-info}/WHEEL +1 -1
- CHAP/utils/scanparsers.py +0 -1544
- {ChessAnalysisPipeline-0.0.15.dist-info → ChessAnalysisPipeline-0.0.16.dist-info}/LICENSE +0 -0
- {ChessAnalysisPipeline-0.0.15.dist-info → ChessAnalysisPipeline-0.0.16.dist-info}/entry_points.txt +0 -0
- {ChessAnalysisPipeline-0.0.15.dist-info → ChessAnalysisPipeline-0.0.16.dist-info}/top_level.txt +0 -0
CHAP/tomo/processor.py
CHANGED
|
@@ -146,6 +146,8 @@ class TomoCHESSMapConverter(Processor):
|
|
|
146
146
|
|
|
147
147
|
# Validate map
|
|
148
148
|
map_config = MapConfig(**loads(str(tomofields.map_config)))
|
|
149
|
+
assert len(map_config.spec_scans) == 1
|
|
150
|
+
num_tomo_stack = len(map_config.spec_scans[0].scan_numbers)
|
|
149
151
|
|
|
150
152
|
# Check available independent dimensions
|
|
151
153
|
independent_dimensions = tomofields.data.attrs['axes']
|
|
@@ -165,8 +167,6 @@ class TomoCHESSMapConverter(Processor):
|
|
|
165
167
|
f'({rotation_angle_data_type})')
|
|
166
168
|
matched_dimensions.pop(matched_dimensions.index('rotation_angles'))
|
|
167
169
|
if 'x_translation' in independent_dimensions:
|
|
168
|
-
x_translation_index = \
|
|
169
|
-
tomofields.data.axes.index('x_translation')
|
|
170
170
|
x_translation_data_type = \
|
|
171
171
|
tomofields.data.x_translation.attrs['data_type']
|
|
172
172
|
x_translation_name = \
|
|
@@ -178,8 +178,6 @@ class TomoCHESSMapConverter(Processor):
|
|
|
178
178
|
else:
|
|
179
179
|
x_translation_data_type = None
|
|
180
180
|
if 'z_translation' in independent_dimensions:
|
|
181
|
-
z_translation_index = \
|
|
182
|
-
tomofields.data.axes.index('z_translation')
|
|
183
181
|
z_translation_data_type = \
|
|
184
182
|
tomofields.data.z_translation.attrs['data_type']
|
|
185
183
|
z_translation_name = \
|
|
@@ -224,17 +222,12 @@ class TomoCHESSMapConverter(Processor):
|
|
|
224
222
|
|
|
225
223
|
# Add an NXdetector to the NXinstrument
|
|
226
224
|
# (do not fill in data fields yet)
|
|
225
|
+
detector_names = list(np.asarray(tomofields.detector_names, dtype=str))
|
|
227
226
|
detector_prefix = detector_config.prefix
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
f'unavailable (available detectors: {detectors})')
|
|
233
|
-
tomo_stacks = tomofields.data[detector_prefix]
|
|
234
|
-
tomo_stack_shape = tomo_stacks.shape
|
|
235
|
-
assert len(tomo_stack_shape) == 2+len(independent_dimensions)
|
|
236
|
-
assert tomo_stack_shape[-2] == detector_config.rows
|
|
237
|
-
assert tomo_stack_shape[-1] == detector_config.columns
|
|
227
|
+
if detector_prefix not in detector_names:
|
|
228
|
+
raise ValueError(
|
|
229
|
+
f'Data for detector {detector_prefix} is unavailable '
|
|
230
|
+
f'(available detectors: {detector_names})')
|
|
238
231
|
nxdetector = NXdetector()
|
|
239
232
|
nxinstrument.detector = nxdetector
|
|
240
233
|
nxdetector.local_name = detector_prefix
|
|
@@ -272,10 +265,9 @@ class TomoCHESSMapConverter(Processor):
|
|
|
272
265
|
x_translations = []
|
|
273
266
|
z_translations = []
|
|
274
267
|
if darkfield is not None:
|
|
275
|
-
nxentry.dark_field_config = darkfield.
|
|
268
|
+
nxentry.dark_field_config = darkfield.config
|
|
276
269
|
for scan_name, scan in darkfield.spec_scans.items():
|
|
277
270
|
for scan_number, nxcollection in scan.items():
|
|
278
|
-
scan_columns = loads(str(nxcollection.scan_columns))
|
|
279
271
|
data_shape = nxcollection.data[detector_prefix].shape
|
|
280
272
|
assert len(data_shape) == 3
|
|
281
273
|
assert data_shape[1] == detector_config.rows
|
|
@@ -284,7 +276,7 @@ class TomoCHESSMapConverter(Processor):
|
|
|
284
276
|
image_keys += num_image*[2]
|
|
285
277
|
sequence_numbers += list(range(num_image))
|
|
286
278
|
image_stacks.append(
|
|
287
|
-
nxcollection.data[detector_prefix])
|
|
279
|
+
nxcollection.data[detector_prefix].nxdata)
|
|
288
280
|
rotation_angles += num_image*[0.0]
|
|
289
281
|
if (x_translation_data_type == 'spec_motor' or
|
|
290
282
|
z_translation_data_type == 'spec_motor'):
|
|
@@ -312,10 +304,9 @@ class TomoCHESSMapConverter(Processor):
|
|
|
312
304
|
num_image*[smb_pars[z_translation_name]]
|
|
313
305
|
|
|
314
306
|
# Collect bright field data
|
|
315
|
-
nxentry.bright_field_config = brightfield.
|
|
307
|
+
nxentry.bright_field_config = brightfield.config
|
|
316
308
|
for scan_name, scan in brightfield.spec_scans.items():
|
|
317
309
|
for scan_number, nxcollection in scan.items():
|
|
318
|
-
scan_columns = loads(str(nxcollection.scan_columns))
|
|
319
310
|
data_shape = nxcollection.data[detector_prefix].shape
|
|
320
311
|
assert len(data_shape) == 3
|
|
321
312
|
assert data_shape[1] == detector_config.rows
|
|
@@ -324,7 +315,7 @@ class TomoCHESSMapConverter(Processor):
|
|
|
324
315
|
image_keys += num_image*[1]
|
|
325
316
|
sequence_numbers += list(range(num_image))
|
|
326
317
|
image_stacks.append(
|
|
327
|
-
nxcollection.data[detector_prefix])
|
|
318
|
+
nxcollection.data[detector_prefix].nxdata)
|
|
328
319
|
rotation_angles += num_image*[0.0]
|
|
329
320
|
if (x_translation_data_type == 'spec_motor' or
|
|
330
321
|
z_translation_data_type == 'spec_motor'):
|
|
@@ -352,65 +343,46 @@ class TomoCHESSMapConverter(Processor):
|
|
|
352
343
|
num_image*[smb_pars[z_translation_name]]
|
|
353
344
|
|
|
354
345
|
# Collect tomography fields data
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
# if len(list(tomofields.data.z_translation)):
|
|
363
|
-
# z_trans = list(tomofields.data.z_translation)
|
|
364
|
-
# else:
|
|
365
|
-
# z_trans = [float(tomofields.data.z_translation)]
|
|
366
|
-
if rotation_angles_index < z_translation_index:
|
|
367
|
-
tomo_stacks = np.swapaxes(
|
|
368
|
-
tomo_stacks, rotation_angles_index,
|
|
369
|
-
z_translation_index)
|
|
370
|
-
tomo_stacks = np.expand_dims(tomo_stacks, z_translation_index)
|
|
371
|
-
elif z_translation_data_type is None:
|
|
372
|
-
z_trans = [0.0]
|
|
373
|
-
if rotation_angles_index < x_translation_index:
|
|
374
|
-
tomo_stacks = np.swapaxes(
|
|
375
|
-
tomo_stacks, rotation_angles_index, x_translation_index)
|
|
376
|
-
tomo_stacks = np.expand_dims(tomo_stacks, 0)
|
|
377
|
-
else:
|
|
378
|
-
x_trans = tomofields.data.x_translation.nxdata
|
|
379
|
-
z_trans = tomofields.data.z_translation.nxdata
|
|
380
|
-
#if tomofields.data.x_translation.size > 1:
|
|
381
|
-
# x_trans = list(tomofields.data.x_translation)
|
|
382
|
-
#else:
|
|
383
|
-
# x_trans = [float(tomofields.data.x_translation)]
|
|
384
|
-
#if len(list(tomofields.data.z_translation)):
|
|
385
|
-
# z_trans = list(tomofields.data.z_translation)
|
|
386
|
-
#else:
|
|
387
|
-
# z_trans = [float(tomofields.data.z_translation)]
|
|
388
|
-
if (rotation_angles_index
|
|
389
|
-
< max(x_translation_index, z_translation_index)):
|
|
390
|
-
tomo_stacks = np.swapaxes(
|
|
391
|
-
tomo_stacks, rotation_angles_index,
|
|
392
|
-
max(x_translation_index, z_translation_index))
|
|
393
|
-
if x_translation_index < z_translation_index:
|
|
394
|
-
tomo_stacks = np.swapaxes(
|
|
395
|
-
tomo_stacks, x_translation_index, z_translation_index)
|
|
346
|
+
tomo_stacks = tomofields.data.detector_data.nxdata[
|
|
347
|
+
detector_names.index(detector_prefix)]
|
|
348
|
+
tomo_stack_shape = tomo_stacks.shape
|
|
349
|
+
assert len(tomo_stack_shape) == 3
|
|
350
|
+
assert tomo_stack_shape[-2] == detector_config.rows
|
|
351
|
+
assert tomo_stack_shape[-1] == detector_config.columns
|
|
352
|
+
assert not tomo_stack_shape[0] % num_tomo_stack
|
|
396
353
|
# Restrict to 180 degrees set of data for now to match old code
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
354
|
+
thetas_stacks = tomofields.data.rotation_angles.nxdata
|
|
355
|
+
num_theta = tomo_stack_shape[0] // num_tomo_stack
|
|
356
|
+
assert num_theta > 2
|
|
357
|
+
thetas = thetas_stacks[0:num_theta]
|
|
358
|
+
delta_theta = thetas[1] - thetas[0]
|
|
359
|
+
if thetas[num_theta-1] - thetas[0] > 180 - delta_theta:
|
|
360
|
+
image_end = index_nearest(thetas, thetas[0] + 180)
|
|
402
361
|
else:
|
|
403
|
-
image_end =
|
|
362
|
+
image_end = thetas.size
|
|
404
363
|
thetas = thetas[:image_end]
|
|
405
|
-
num_image =
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
364
|
+
num_image = thetas.size
|
|
365
|
+
n_start = 0
|
|
366
|
+
image_keys += num_tomo_stack * num_image * [0]
|
|
367
|
+
sequence_numbers += num_tomo_stack * list(range(num_image))
|
|
368
|
+
if x_translation_data_type is None:
|
|
369
|
+
x_translations += num_tomo_stack * num_image * [0.0]
|
|
370
|
+
if z_translation_data_type is None:
|
|
371
|
+
z_translations += num_tomo_stack * num_image * [0.0]
|
|
372
|
+
for i in range(num_tomo_stack):
|
|
373
|
+
image_stacks.append(tomo_stacks[n_start:n_start+num_image])
|
|
374
|
+
if not np.array_equal(
|
|
375
|
+
thetas, thetas_stacks[n_start:n_start+num_image]):
|
|
376
|
+
raise RuntimeError(
|
|
377
|
+
'Inconsistent thetas among tomography image stacks')
|
|
378
|
+
rotation_angles += list(thetas)
|
|
379
|
+
if x_translation_data_type is not None:
|
|
380
|
+
x_translations += list(
|
|
381
|
+
tomofields.data.x_translation[n_start:n_start+num_image])
|
|
382
|
+
if z_translation_data_type is not None:
|
|
383
|
+
z_translations += list(
|
|
384
|
+
tomofields.data.z_translation[n_start:n_start+num_image])
|
|
385
|
+
n_start += num_theta
|
|
414
386
|
|
|
415
387
|
# Add image data to NXdetector
|
|
416
388
|
nxinstrument.detector.image_key = image_keys
|
|
@@ -456,7 +428,7 @@ class TomoDataProcessor(Processor):
|
|
|
456
428
|
for tomographic image reduction.
|
|
457
429
|
:type data: list[PipelineData]
|
|
458
430
|
:param outputdir: Output folder name, defaults to '.'.
|
|
459
|
-
:type outputdir
|
|
431
|
+
:type outputdir: str, optional
|
|
460
432
|
:param interactive: Allows for user interactions,
|
|
461
433
|
defaults to False.
|
|
462
434
|
:type interactive: bool, optional
|
|
@@ -664,7 +636,7 @@ class Tomo:
|
|
|
664
636
|
:param num_core: Number of processors.
|
|
665
637
|
:type num_core: int
|
|
666
638
|
:param outputdir: Output folder name, defaults to '.'.
|
|
667
|
-
:type outputdir
|
|
639
|
+
:type outputdir: str, optional
|
|
668
640
|
:param save_figs: Safe figures to file ('yes' or 'only') and/or
|
|
669
641
|
display figures ('yes' or 'no'), defaults to 'no'.
|
|
670
642
|
:type save_figs: Literal['yes', 'no', 'only'], optional
|
|
@@ -2078,7 +2050,7 @@ class Tomo:
|
|
|
2078
2050
|
evaluate('-log(tomo_stack)', out=tomo_stack)
|
|
2079
2051
|
|
|
2080
2052
|
# Get rid of nans/infs that may be introduced by normalization
|
|
2081
|
-
np.where(np.isfinite(tomo_stack), tomo_stack, 0.)
|
|
2053
|
+
tomo_stack = np.where(np.isfinite(tomo_stack), tomo_stack, 0.)
|
|
2082
2054
|
|
|
2083
2055
|
# Downsize tomography stack to smaller size
|
|
2084
2056
|
tomo_stack = tomo_stack.astype('float32', copy=False)
|
CHAP/utils/general.py
CHANGED
|
@@ -611,6 +611,24 @@ def string_to_list(
|
|
|
611
611
|
return l_of_i
|
|
612
612
|
|
|
613
613
|
|
|
614
|
+
def list_to_string(a):
|
|
615
|
+
"""Return a list of pairs of integers marking consecutive ranges
|
|
616
|
+
of integers in string notation."""
|
|
617
|
+
int_ranges = get_consecutive_int_range(a)
|
|
618
|
+
if not len(int_ranges):
|
|
619
|
+
return ''
|
|
620
|
+
if int_ranges[0][0] == int_ranges[0][1]:
|
|
621
|
+
s = f'{int_ranges[0][0]}'
|
|
622
|
+
else:
|
|
623
|
+
s = f'{int_ranges[0][0]}-{int_ranges[0][1]}'
|
|
624
|
+
for int_range in int_ranges[1:]:
|
|
625
|
+
if int_range[0] == int_range[1]:
|
|
626
|
+
s += f', {int_range[0]}'
|
|
627
|
+
else:
|
|
628
|
+
s += f', {int_range[0]}-{int_range[1]}'
|
|
629
|
+
return s
|
|
630
|
+
|
|
631
|
+
|
|
614
632
|
def get_trailing_int(string):
|
|
615
633
|
"""Get the trailing integer in a string."""
|
|
616
634
|
index_regex = re_compile(r'\d+$')
|
CHAP/utils/models.py
CHANGED
|
@@ -4,19 +4,21 @@
|
|
|
4
4
|
import numpy as np
|
|
5
5
|
from pydantic import (
|
|
6
6
|
BaseModel,
|
|
7
|
+
Field,
|
|
7
8
|
PrivateAttr,
|
|
8
9
|
StrictBool,
|
|
9
10
|
conint,
|
|
10
11
|
conlist,
|
|
11
12
|
confloat,
|
|
12
13
|
constr,
|
|
13
|
-
|
|
14
|
+
field_validator,
|
|
14
15
|
)
|
|
15
16
|
from typing import (
|
|
16
17
|
Literal,
|
|
17
18
|
Optional,
|
|
18
19
|
Union,
|
|
19
20
|
)
|
|
21
|
+
from typing_extensions import Annotated
|
|
20
22
|
|
|
21
23
|
# Local modules
|
|
22
24
|
from CHAP.utils.general import not_zero, tiny
|
|
@@ -125,11 +127,13 @@ def rectangle(
|
|
|
125
127
|
return amplitude*rect
|
|
126
128
|
|
|
127
129
|
|
|
128
|
-
def validate_parameters(parameters,
|
|
130
|
+
def validate_parameters(parameters, info):
|
|
129
131
|
"""Validate the parameters
|
|
130
132
|
|
|
131
133
|
:param parameters: Fit model parameters.
|
|
132
134
|
:type parameters: list[FitParameter]
|
|
135
|
+
:param info: Pydantic validator info object.
|
|
136
|
+
:type info: pydantic_core._pydantic_core.ValidationInfo
|
|
133
137
|
:return: List of fit model parameters.
|
|
134
138
|
:rtype: list[FitParameter]
|
|
135
139
|
"""
|
|
@@ -137,7 +141,10 @@ def validate_parameters(parameters, values):
|
|
|
137
141
|
import inspect
|
|
138
142
|
from copy import deepcopy
|
|
139
143
|
|
|
140
|
-
|
|
144
|
+
if 'model' in info.data:
|
|
145
|
+
model = info.data['model']
|
|
146
|
+
else:
|
|
147
|
+
model = None
|
|
141
148
|
if model is None or model == 'expression':
|
|
142
149
|
return parameters
|
|
143
150
|
sig = {
|
|
@@ -173,17 +180,18 @@ class FitParameter(BaseModel):
|
|
|
173
180
|
|
|
174
181
|
"""
|
|
175
182
|
name: constr(strip_whitespace=True, min_length=1)
|
|
176
|
-
value: Optional[confloat(allow_inf_nan=False)]
|
|
183
|
+
value: Optional[confloat(allow_inf_nan=False)] = None
|
|
177
184
|
min: Optional[confloat()] = -np.inf
|
|
178
185
|
max: Optional[confloat()] = np.inf
|
|
179
186
|
vary: StrictBool = True
|
|
180
|
-
expr: Optional[constr(strip_whitespace=True, min_length=1)]
|
|
187
|
+
expr: Optional[constr(strip_whitespace=True, min_length=1)] = None
|
|
181
188
|
_default: float = PrivateAttr()
|
|
182
189
|
_init_value: float = PrivateAttr()
|
|
183
190
|
_prefix: str = PrivateAttr()
|
|
184
191
|
_stderr: float = PrivateAttr()
|
|
185
192
|
|
|
186
|
-
@
|
|
193
|
+
@field_validator('min')
|
|
194
|
+
@classmethod
|
|
187
195
|
def validate_min(cls, value):
|
|
188
196
|
"""Validate the specified min.
|
|
189
197
|
|
|
@@ -196,7 +204,8 @@ class FitParameter(BaseModel):
|
|
|
196
204
|
return -np.inf
|
|
197
205
|
return value
|
|
198
206
|
|
|
199
|
-
@
|
|
207
|
+
@field_validator('max')
|
|
208
|
+
@classmethod
|
|
200
209
|
def validate_max(cls, value):
|
|
201
210
|
"""Validate the specified max.
|
|
202
211
|
|
|
@@ -309,11 +318,13 @@ class Constant(BaseModel):
|
|
|
309
318
|
:type prefix: str, optional
|
|
310
319
|
"""
|
|
311
320
|
model: Literal['constant']
|
|
312
|
-
parameters:
|
|
321
|
+
parameters: Annotated[
|
|
322
|
+
conlist(item_type=FitParameter),
|
|
323
|
+
Field(validate_default=True)] = []
|
|
313
324
|
prefix: Optional[str] = ''
|
|
314
325
|
|
|
315
|
-
_validate_parameters_parameters =
|
|
316
|
-
'parameters'
|
|
326
|
+
_validate_parameters_parameters = field_validator(
|
|
327
|
+
'parameters')(validate_parameters)
|
|
317
328
|
|
|
318
329
|
|
|
319
330
|
class Linear(BaseModel):
|
|
@@ -331,11 +342,13 @@ class Linear(BaseModel):
|
|
|
331
342
|
:type prefix: str, optional
|
|
332
343
|
"""
|
|
333
344
|
model: Literal['linear']
|
|
334
|
-
parameters:
|
|
345
|
+
parameters: Annotated[
|
|
346
|
+
conlist(item_type=FitParameter),
|
|
347
|
+
Field(validate_default=True)] = []
|
|
335
348
|
prefix: Optional[str] = ''
|
|
336
349
|
|
|
337
|
-
_validate_parameters_parameters =
|
|
338
|
-
'parameters'
|
|
350
|
+
_validate_parameters_parameters = field_validator(
|
|
351
|
+
'parameters')(validate_parameters)
|
|
339
352
|
|
|
340
353
|
|
|
341
354
|
class Quadratic(BaseModel):
|
|
@@ -353,11 +366,13 @@ class Quadratic(BaseModel):
|
|
|
353
366
|
:type prefix: str, optional
|
|
354
367
|
"""
|
|
355
368
|
model: Literal['quadratic']
|
|
356
|
-
parameters:
|
|
369
|
+
parameters: Annotated[
|
|
370
|
+
conlist(item_type=FitParameter),
|
|
371
|
+
Field(validate_default=True)] = []
|
|
357
372
|
prefix: Optional[str] = ''
|
|
358
373
|
|
|
359
|
-
_validate_parameters_parameters =
|
|
360
|
-
'parameters'
|
|
374
|
+
_validate_parameters_parameters = field_validator(
|
|
375
|
+
'parameters')(validate_parameters)
|
|
361
376
|
|
|
362
377
|
|
|
363
378
|
class Exponential(BaseModel):
|
|
@@ -375,11 +390,13 @@ class Exponential(BaseModel):
|
|
|
375
390
|
:type prefix: str, optional
|
|
376
391
|
"""
|
|
377
392
|
model: Literal['exponential']
|
|
378
|
-
parameters:
|
|
393
|
+
parameters: Annotated[
|
|
394
|
+
conlist(item_type=FitParameter),
|
|
395
|
+
Field(validate_default=True)] = []
|
|
379
396
|
prefix: Optional[str] = ''
|
|
380
397
|
|
|
381
|
-
_validate_parameters_parameters =
|
|
382
|
-
'parameters'
|
|
398
|
+
_validate_parameters_parameters = field_validator(
|
|
399
|
+
'parameters')(validate_parameters)
|
|
383
400
|
|
|
384
401
|
|
|
385
402
|
class Gaussian(BaseModel):
|
|
@@ -397,11 +414,13 @@ class Gaussian(BaseModel):
|
|
|
397
414
|
:type prefix: str, optional
|
|
398
415
|
"""
|
|
399
416
|
model: Literal['gaussian']
|
|
400
|
-
parameters:
|
|
417
|
+
parameters: Annotated[
|
|
418
|
+
conlist(item_type=FitParameter),
|
|
419
|
+
Field(validate_default=True)] = []
|
|
401
420
|
prefix: Optional[str] = ''
|
|
402
421
|
|
|
403
|
-
_validate_parameters_parameters =
|
|
404
|
-
'parameters'
|
|
422
|
+
_validate_parameters_parameters = field_validator(
|
|
423
|
+
'parameters')(validate_parameters)
|
|
405
424
|
|
|
406
425
|
|
|
407
426
|
class Lorentzian(BaseModel):
|
|
@@ -419,11 +438,13 @@ class Lorentzian(BaseModel):
|
|
|
419
438
|
:type prefix: str, optional
|
|
420
439
|
"""
|
|
421
440
|
model: Literal['lorentzian']
|
|
422
|
-
parameters:
|
|
441
|
+
parameters: Annotated[
|
|
442
|
+
conlist(item_type=FitParameter),
|
|
443
|
+
Field(validate_default=True)] = []
|
|
423
444
|
prefix: Optional[str] = ''
|
|
424
445
|
|
|
425
|
-
_validate_parameters_parameters =
|
|
426
|
-
'parameters'
|
|
446
|
+
_validate_parameters_parameters = field_validator(
|
|
447
|
+
'parameters')(validate_parameters)
|
|
427
448
|
|
|
428
449
|
|
|
429
450
|
class Rectangle(BaseModel):
|
|
@@ -441,11 +462,13 @@ class Rectangle(BaseModel):
|
|
|
441
462
|
:type prefix: str, optional
|
|
442
463
|
"""
|
|
443
464
|
model: Literal['rectangle']
|
|
444
|
-
parameters:
|
|
465
|
+
parameters: Annotated[
|
|
466
|
+
conlist(item_type=FitParameter),
|
|
467
|
+
Field(validate_default=True)] = []
|
|
445
468
|
prefix: Optional[str] = ''
|
|
446
469
|
|
|
447
|
-
_validate_parameters_parameters =
|
|
448
|
-
'parameters'
|
|
470
|
+
_validate_parameters_parameters = field_validator(
|
|
471
|
+
'parameters')(validate_parameters)
|
|
449
472
|
|
|
450
473
|
|
|
451
474
|
class Expression(BaseModel):
|
|
@@ -467,20 +490,22 @@ class Expression(BaseModel):
|
|
|
467
490
|
"""
|
|
468
491
|
model: Literal['expression']
|
|
469
492
|
expr: constr(strip_whitespace=True, min_length=1)
|
|
470
|
-
parameters:
|
|
493
|
+
parameters: Annotated[
|
|
494
|
+
conlist(item_type=FitParameter),
|
|
495
|
+
Field(validate_default=True)] = []
|
|
471
496
|
prefix: Optional[str] = ''
|
|
472
497
|
|
|
473
|
-
_validate_parameters_parameters =
|
|
474
|
-
'parameters'
|
|
498
|
+
_validate_parameters_parameters = field_validator(
|
|
499
|
+
'parameters')(validate_parameters)
|
|
475
500
|
|
|
476
501
|
|
|
477
502
|
class Multipeak(BaseModel):
|
|
478
503
|
model: Literal['multipeak']
|
|
479
|
-
centers: conlist(item_type=confloat(allow_inf_nan=False),
|
|
504
|
+
centers: conlist(item_type=confloat(allow_inf_nan=False), min_length=1)
|
|
480
505
|
fit_type: Optional[Literal['uniform', 'unconstrained']] = 'unconstrained'
|
|
481
|
-
centers_range: Optional[confloat(allow_inf_nan=False)]
|
|
482
|
-
fwhm_min: Optional[confloat(allow_inf_nan=False)]
|
|
483
|
-
fwhm_max: Optional[confloat(allow_inf_nan=False)]
|
|
506
|
+
centers_range: Optional[confloat(allow_inf_nan=False)] = None
|
|
507
|
+
fwhm_min: Optional[confloat(allow_inf_nan=False)] = None
|
|
508
|
+
fwhm_max: Optional[confloat(allow_inf_nan=False)] = None
|
|
484
509
|
peak_models: Literal['gaussian', 'lorentzian'] = 'gaussian'
|
|
485
510
|
|
|
486
511
|
|
|
@@ -538,30 +563,32 @@ class FitConfig(BaseModel):
|
|
|
538
563
|
parameters: conlist(item_type=FitParameter) = []
|
|
539
564
|
models: conlist(item_type=Union[
|
|
540
565
|
Constant, Linear, Quadratic, Exponential, Gaussian, Lorentzian,
|
|
541
|
-
Rectangle, Expression, Multipeak],
|
|
566
|
+
Rectangle, Expression, Multipeak], min_length=1)
|
|
542
567
|
method: Literal[
|
|
543
568
|
'leastsq', 'trf', 'dogbox', 'lm', 'least_squares'] = 'leastsq'
|
|
544
|
-
rel_height_cutoff: Optional[
|
|
569
|
+
rel_height_cutoff: Optional[
|
|
570
|
+
confloat(gt=0, lt=1.0, allow_inf_nan=False)] = None
|
|
545
571
|
num_proc: conint(gt=0) = 1
|
|
546
572
|
plot: StrictBool = False
|
|
547
573
|
print_report: StrictBool = False
|
|
548
574
|
|
|
549
|
-
@
|
|
550
|
-
|
|
575
|
+
@field_validator('method')
|
|
576
|
+
@classmethod
|
|
577
|
+
def validate_method(cls, method, info):
|
|
551
578
|
"""Validate the specified method.
|
|
552
579
|
|
|
553
|
-
:param
|
|
554
|
-
:type
|
|
555
|
-
:param
|
|
556
|
-
:type
|
|
580
|
+
:param method: The value of `method` to validate.
|
|
581
|
+
:type method: str
|
|
582
|
+
:param info: Pydantic validator info object.
|
|
583
|
+
:type info: pydantic_core._pydantic_core.ValidationInfo
|
|
557
584
|
:return: Fit method.
|
|
558
585
|
:rtype: str
|
|
559
586
|
"""
|
|
560
|
-
code =
|
|
587
|
+
code = info.data['code']
|
|
561
588
|
if code == 'lmfit':
|
|
562
|
-
if
|
|
563
|
-
|
|
564
|
-
elif
|
|
565
|
-
|
|
589
|
+
if method not in ('leastsq', 'least_squares'):
|
|
590
|
+
method = 'leastsq'
|
|
591
|
+
elif method == 'least_squares':
|
|
592
|
+
method = 'leastsq'
|
|
566
593
|
|
|
567
|
-
return
|
|
594
|
+
return method
|
CHAP/utils/parfile.py
CHANGED
|
@@ -2,10 +2,13 @@
|
|
|
2
2
|
as input
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
|
+
# System modules
|
|
5
6
|
import csv
|
|
6
|
-
import json
|
|
7
7
|
import os
|
|
8
8
|
|
|
9
|
+
# Third party modules
|
|
10
|
+
import json
|
|
11
|
+
|
|
9
12
|
class ParFile():
|
|
10
13
|
"""Representation of a .par file
|
|
11
14
|
|
|
@@ -78,9 +81,12 @@ class ParFile():
|
|
|
78
81
|
:return: a map configuration
|
|
79
82
|
:rtype: CHAP.common.models.map.MapConfig
|
|
80
83
|
"""
|
|
84
|
+
# Third party modules
|
|
81
85
|
import numpy as np
|
|
86
|
+
|
|
87
|
+
# Local modules
|
|
82
88
|
from CHAP.common.models.map import MapConfig
|
|
83
|
-
from
|
|
89
|
+
from chess_scanparsers import SMBScanParser
|
|
84
90
|
|
|
85
91
|
scanparser = SMBScanParser(self.spec_file, 1)
|
|
86
92
|
good_scans = self.good_scan_numbers()
|
|
@@ -156,7 +162,9 @@ class ParFile():
|
|
|
156
162
|
:return: reshaped array of values
|
|
157
163
|
:rtype: np.ndarray
|
|
158
164
|
"""
|
|
165
|
+
# Third party modules
|
|
159
166
|
import numpy as np
|
|
167
|
+
|
|
160
168
|
good_scans = self.good_scan_numbers()
|
|
161
169
|
if len(values) != len(good_scans):
|
|
162
170
|
raise ValueError('number of values provided ({len(values)}) does '
|
|
@@ -1,27 +1,32 @@
|
|
|
1
1
|
CHAP/TaskManager.py,sha256=NEqg2jAq10kbScE18XtzY3liqkIdAtysaR-gMG5tBzs,6803
|
|
2
|
-
CHAP/__init__.py,sha256=
|
|
3
|
-
CHAP/pipeline.py,sha256=
|
|
2
|
+
CHAP/__init__.py,sha256=hadJMmJS333LbHm-fvaZqkB8KuMleckTibFgubmru3Q,1073
|
|
3
|
+
CHAP/pipeline.py,sha256=zS4m2tfWn3g_5Pp0AtIHnAfQC6NnyH9-j8xlyXoQZDA,10363
|
|
4
4
|
CHAP/processor.py,sha256=nqg1uK5jvADl35xuR6VIdU5uVGFVt-rzivnaZyOWruA,2639
|
|
5
5
|
CHAP/reader.py,sha256=wGzAl_p5UnR7fC7Cie29S7RZTFFLcdOuhbViNDzH-4s,2534
|
|
6
|
-
CHAP/runner.py,sha256=
|
|
6
|
+
CHAP/runner.py,sha256=GB_0sCAbv-DpOFzaRvC-3he2uaCxOMSVo7axuT64-PI,11443
|
|
7
7
|
CHAP/server.py,sha256=JAh5a7ZPh_Vx7fm0uI_g2WHLVxLn8s1uwBX8oMJ3G9c,3648
|
|
8
8
|
CHAP/writer.py,sha256=9hed3_51AwSSH3kNisMR6Wq6mLInNGpgktPG5G_s-DM,2589
|
|
9
|
-
CHAP/common/__init__.py,sha256=
|
|
10
|
-
CHAP/common/processor.py,sha256=
|
|
11
|
-
CHAP/common/reader.py,sha256=
|
|
12
|
-
CHAP/common/writer.py,sha256=
|
|
9
|
+
CHAP/common/__init__.py,sha256=qxmX8YxggWmvFb1JBHidR_-jw_ZUr8qwjZcqViM1QDc,1369
|
|
10
|
+
CHAP/common/processor.py,sha256=t9PHYlj0NnL_WOy8JcCaEsXAK2_-ZbAZTuuuWhr-fNA,124191
|
|
11
|
+
CHAP/common/reader.py,sha256=lND31bcy1WpNYSGYcVZPiB8B0OSazgUcV08wHrw88sg,22937
|
|
12
|
+
CHAP/common/writer.py,sha256=y4A_iQxwHcH15I3Hmrei0NcijDQ4Qxu7J0dZlR9iUbs,19485
|
|
13
13
|
CHAP/common/models/__init__.py,sha256=MpmtY6biXgC7AaedznoSqFJJZ54YU8tBPgwzYJIVJ1c,200
|
|
14
|
-
CHAP/common/models/integration.py,sha256=
|
|
15
|
-
CHAP/common/models/map.py,sha256=
|
|
16
|
-
CHAP/edd/__init__.py,sha256=
|
|
17
|
-
CHAP/edd/models.py,sha256=
|
|
18
|
-
CHAP/edd/processor.py,sha256=
|
|
19
|
-
CHAP/edd/reader.py,sha256=
|
|
14
|
+
CHAP/common/models/integration.py,sha256=sEFl8e8rF7-BMaaCmbephf0-86tdqR8rVXfioziulR8,27086
|
|
15
|
+
CHAP/common/models/map.py,sha256=Z_v-vX1emOIbtxFhqmm9-AyHLO4iS0MmMDrlwep1hkA,47216
|
|
16
|
+
CHAP/edd/__init__.py,sha256=BBOJLG4Hvbm6KLE0lKbIrJOQm8rExnfn0re3RPM1suU,923
|
|
17
|
+
CHAP/edd/models.py,sha256=rfrymbYeuOoEYBm-A1bKg0Iso2jI0naQ9OT9kpvnuA4,45358
|
|
18
|
+
CHAP/edd/processor.py,sha256=sJnJLYicv6RzBwLroUA46nc49XRYrtNtTu_PTTI6YZ0,151842
|
|
19
|
+
CHAP/edd/reader.py,sha256=WVikplFGys5MGYK857vK8-buY85BqNTf8N7xZSKW8a8,38401
|
|
20
20
|
CHAP/edd/utils.py,sha256=jF8kz-feR16QIc-MbZEgl0jmTcBs63Bfnb2a0DrS4vU,66377
|
|
21
21
|
CHAP/edd/writer.py,sha256=Y1CXWMRU87XeeDp4g4-sUgPP2UbCguYZUR_Cg5Ci6l8,94
|
|
22
22
|
CHAP/foxden/__init__.py,sha256=6H6mqd_-qu8BiBDM0aRx5edcYLOse6Z_x3TsDf7E4J0,149
|
|
23
23
|
CHAP/foxden/processor.py,sha256=-wHpgtiru1zJYaf1zd9pUl5bxjetu-yH_cAIKaEnqB4,1058
|
|
24
24
|
CHAP/foxden/writer.py,sha256=jijYSaVAK0EwIichgYFk2Bh3ytPbBAmL_wy8aQRKY8I,2151
|
|
25
|
+
CHAP/giwaxs/__init__.py,sha256=-AOy8RUNunuC3Xh6jFeJHPtCRgJA1A_9Qaf6jmQ4k08,255
|
|
26
|
+
CHAP/giwaxs/models.py,sha256=3ZTjRmpLZFjH6-ZKxl2qOhynrJwtW1YAoEZbtIo4DDI,3023
|
|
27
|
+
CHAP/giwaxs/processor.py,sha256=dzKrD5KKpb7x_MNtp88WFAOLn0oG0w3oLYrQpRgzmn4,22957
|
|
28
|
+
CHAP/giwaxs/reader.py,sha256=O0KeZcqACsZ8ngrliPU6I3u8SeQT0Aq866jCTbruXqc,94
|
|
29
|
+
CHAP/giwaxs/writer.py,sha256=Y1CXWMRU87XeeDp4g4-sUgPP2UbCguYZUR_Cg5Ci6l8,94
|
|
25
30
|
CHAP/inference/__init__.py,sha256=GwpEKEMHY1-3AE7HWKBdBz_i7N1sz7xwve6y9tZ7Skk,263
|
|
26
31
|
CHAP/inference/processor.py,sha256=TYYPtZ3YlZS1kgvGr6I_9RvSaR0kn9PKL98A3QwqeDI,2065
|
|
27
32
|
CHAP/inference/reader.py,sha256=O0KeZcqACsZ8ngrliPU6I3u8SeQT0Aq866jCTbruXqc,94
|
|
@@ -35,24 +40,23 @@ CHAP/sin2psi/processor.py,sha256=6ytGpsK5u6tyUTzOJqAlcRdaimA4QfXZ6xpwGf2QMFo,97
|
|
|
35
40
|
CHAP/sin2psi/reader.py,sha256=O0KeZcqACsZ8ngrliPU6I3u8SeQT0Aq866jCTbruXqc,94
|
|
36
41
|
CHAP/sin2psi/writer.py,sha256=Y1CXWMRU87XeeDp4g4-sUgPP2UbCguYZUR_Cg5Ci6l8,94
|
|
37
42
|
CHAP/tomo/__init__.py,sha256=7cwm1ufJkDKqrp2OPH_z7tKAOQ0S_RJbNainK0soKNo,328
|
|
38
|
-
CHAP/tomo/models.py,sha256=
|
|
39
|
-
CHAP/tomo/processor.py,sha256=
|
|
43
|
+
CHAP/tomo/models.py,sha256=H9V6ypeKXYOEn09s-QFAqs5iKG8Y2xi2vQHzptp8I4g,8640
|
|
44
|
+
CHAP/tomo/processor.py,sha256=DgrDx4BxZlIyZ0wfeaKLRZ-Mm6eqn0W5N3Yfs1t4HQQ,157631
|
|
40
45
|
CHAP/tomo/reader.py,sha256=7nNP_KyIR-ghrrajCR2k5IsJnrLm6BIy-eAXIDXrQe8,123
|
|
41
46
|
CHAP/tomo/writer.py,sha256=J7q_nmsqi_zbgAS-LvAciiBqtYD8hHJ4QmwS2oZAM2Q,123
|
|
42
47
|
CHAP/utils/__init__.py,sha256=0bV7tjiTk1h9y0NQm92PNFrGcs40lFB6CzISEXMczqU,223
|
|
43
48
|
CHAP/utils/fit.py,sha256=JZKx2n5GrPmtQFxxkorMD_mvtzrEvBUfRwgMCItp__E,122419
|
|
44
|
-
CHAP/utils/general.py,sha256=
|
|
49
|
+
CHAP/utils/general.py,sha256=DId5ANyBKU3lMjab5uq_ZlxA16yjvbEYhSxzuGsZF2w,84011
|
|
45
50
|
CHAP/utils/material.py,sha256=NnLHAin3PrDxZiG6of8v7vFma0nAeOIRZJuXxSN_xj8,11495
|
|
46
|
-
CHAP/utils/models.py,sha256=
|
|
47
|
-
CHAP/utils/parfile.py,sha256=
|
|
48
|
-
CHAP/utils/scanparsers.py,sha256=IJXTHPDyCm_n41LfNdnd5kMXodroijm3ltXTLLWDEAk,61950
|
|
51
|
+
CHAP/utils/models.py,sha256=XLdhFoYRjIQAY28U-g7HcpWLnNdgMrdVXUHmA7S7tfI,19321
|
|
52
|
+
CHAP/utils/parfile.py,sha256=vQrfQwYWdsPlftjI83OBlnM6hnUxjrL3Yp3yKo3ilcw,7348
|
|
49
53
|
MLaaS/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
50
54
|
MLaaS/ktrain.py,sha256=SPDUOQgjBDSx7sI8vZNXog9orvSyKmzpe6TdGHol9qM,7467
|
|
51
55
|
MLaaS/mnist_img.py,sha256=ppDtlo6yrNQy0oIhFZVOnLvHJrR3ZPZ3PjZTtJY8l0E,2738
|
|
52
56
|
MLaaS/tfaas_client.py,sha256=zpZ201wwcQBW1XkzDakD9Kl_NRSESAUdbnN6k6Ey15A,14889
|
|
53
|
-
ChessAnalysisPipeline-0.0.
|
|
54
|
-
ChessAnalysisPipeline-0.0.
|
|
55
|
-
ChessAnalysisPipeline-0.0.
|
|
56
|
-
ChessAnalysisPipeline-0.0.
|
|
57
|
-
ChessAnalysisPipeline-0.0.
|
|
58
|
-
ChessAnalysisPipeline-0.0.
|
|
57
|
+
ChessAnalysisPipeline-0.0.16.dist-info/LICENSE,sha256=IbeOUUh4pqaZbUvtbkPFMfTH2YYFlRUNtRKr0TQeUpg,3076
|
|
58
|
+
ChessAnalysisPipeline-0.0.16.dist-info/METADATA,sha256=sN1mSsF8G4Xiy_A9Qgbfq1Y47Rite7_4HOUXU-LHEZM,1542
|
|
59
|
+
ChessAnalysisPipeline-0.0.16.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
|
|
60
|
+
ChessAnalysisPipeline-0.0.16.dist-info/entry_points.txt,sha256=w-KIKdUjmj5GCobrFC4_jexCsFB4yMXYjrsMWrhI6Co,42
|
|
61
|
+
ChessAnalysisPipeline-0.0.16.dist-info/top_level.txt,sha256=BKhggOWLb9dD6oQm1RXrkJPnXm-zJxVzQef1iXYtt2k,11
|
|
62
|
+
ChessAnalysisPipeline-0.0.16.dist-info/RECORD,,
|