Skip to content

Commit 0242c2f

Browse files
authored
Merge pull request #176 from rolfverberg/hdrm
Hdrm
2 parents 130b2fb + b4184ee commit 0242c2f

File tree

14 files changed

+705
-106
lines changed

14 files changed

+705
-106
lines changed

CHAP/common/models/map.py

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -311,15 +311,17 @@ class PointByPointScanData(CHAPBaseModel):
311311
:type units: str
312312
:ivar data_type: Represents how these data were recorded at time
313313
of data collection.
314-
:type data_type: Literal['spec_motor', 'scan_column', 'smb_par']
314+
:type data_type: Literal['spec_motor', 'spec_motor_absolute',
315+
'scan_column', 'smb_par', 'expression', 'detector_log_timestamps']
315316
:ivar name: Represents the name with which these raw data were
316317
recorded at time of data collection.
317318
:type name: str
318319
"""
319320
label: constr(min_length=1)
320321
units: constr(strip_whitespace=True, min_length=1)
321-
data_type: Literal['spec_motor', 'spec_motor_absolute', 'scan_column',
322-
'smb_par', 'expression', 'detector_log_timestamps']
322+
data_type: Literal[
323+
'spec_motor', 'spec_motor_absolute', 'scan_column', 'smb_par',
324+
'expression', 'detector_log_timestamps']
323325
name: constr(strip_whitespace=True, min_length=1)
324326
ndigits: Optional[conint(ge=0)] = None
325327

@@ -359,7 +361,7 @@ def validate_for_station(self, station):
359361
f'{self.__class__.__name__}.data_type may not be "smb_par" '
360362
f'when station is "{station}"')
361363
if (not station.lower() == 'id3b'
362-
and self.data_type == 'detector_log_timestamps'):
364+
and self.data_type == 'detector_log_timestamps'):
363365
raise TypeError(
364366
f'{self.__class__.__name__}.data_type may not be'
365367
+ f' "detector_log_timestamps" when station is "{station}"')
@@ -493,7 +495,6 @@ def get_value(
493495
return timestamps
494496
return None
495497

496-
497498
@cache
498499
def get_spec_motor_value(
499500
spec_file, scan_number, scan_step_index, spec_mnemonic,
@@ -548,7 +549,6 @@ def get_spec_motor_value(
548549
motor_value = np.round(motor_value, ndigits)
549550
return motor_value
550551

551-
552552
@cache
553553
def get_spec_counter_value(
554554
spec_file, scan_number, scan_step_index, spec_column_label):
@@ -573,7 +573,6 @@ def get_spec_counter_value(
573573
return scanparser.spec_scan_data[spec_column_label][scan_step_index]
574574
return scanparser.spec_scan_data[spec_column_label]
575575

576-
577576
@cache
578577
def get_smb_par_value(spec_file, scan_number, par_name):
579578
"""Return the value recorded for a specific scan in SMB-tyle .par
@@ -593,7 +592,6 @@ def get_smb_par_value(spec_file, scan_number, par_name):
593592
scanparser = get_scanparser(spec_file, scan_number)
594593
return scanparser.pars[par_name]
595594

596-
597595
def get_expression_value(
598596
spec_scans, scan_number, scan_step_index, expression,
599597
scalar_data):
@@ -797,10 +795,11 @@ class SpecConfig(CHAPBaseModel):
797795
:type spec_scans: list[SpecScans]
798796
:ivar experiment_type: Experiment type.
799797
:type experiment_type: Literal['EDD', 'GIWAXS', 'SAXSWAXS', 'TOMO',
800-
'XRF']
798+
'XRF', 'HDRM']
801799
"""
802-
station: Literal['id1a3', 'id3a', 'id3b']
803-
experiment_type: Literal['EDD', 'GIWAXS', 'SAXSWAXS', 'TOMO', 'XRF']
800+
station: Literal['id1a3', 'id3a', 'id3b', 'id4b']
801+
experiment_type: Literal[
802+
'EDD', 'GIWAXS', 'SAXSWAXS', 'TOMO', 'XRF', 'HDRM']
804803
spec_scans: conlist(item_type=SpecScans, min_length=1)
805804

806805
@model_validator(mode='before')
@@ -854,6 +853,8 @@ def validate_experiment_type(cls, experiment_type, info):
854853
allowed_experiment_types = ['EDD', 'TOMO']
855854
elif station == 'id3b':
856855
allowed_experiment_types = ['GIWAXS', 'SAXSWAXS', 'TOMO', 'XRF']
856+
elif station == 'id4b':
857+
allowed_experiment_types = ['HDRM']
857858
else:
858859
allowed_experiment_types = []
859860
if experiment_type not in allowed_experiment_types:
@@ -873,10 +874,10 @@ class MapConfig(CHAPBaseModel):
873874
:type title: str
874875
:ivar station: The name of the station at which the map was
875876
collected.
876-
:type station: Literal['id1a3', 'id3a', 'id3b']
877+
:type station: Literal['id1a3', 'id3a', 'id3b', id4b]
877878
:ivar experiment_type: Experiment type.
878879
:type experiment_type: Literal['EDD', 'GIWAXS', 'SAXSWAXS', 'TOMO',
879-
'XRF']
880+
'XRF', 'HDRM']
880881
:ivar sample: The sample metadata configuration.
881882
:type sample: CHAP.commom.models.map.Sample
882883
:ivar spec_scans: A list of the SPEC scans that compose the map.
@@ -907,8 +908,9 @@ class MapConfig(CHAPBaseModel):
907908
:type attrs: dict, optional
908909
"""
909910
title: constr(strip_whitespace=True, min_length=1)
910-
station: Literal['id1a3', 'id3a', 'id3b']
911-
experiment_type: Literal['EDD', 'GIWAXS', 'SAXSWAXS', 'TOMO', 'XRF']
911+
station: Literal['id1a3', 'id3a', 'id3b', 'id4b']
912+
experiment_type: Literal[
913+
'EDD', 'GIWAXS', 'SAXSWAXS', 'TOMO', 'XRF', 'HDRM']
912914
sample: Sample
913915
spec_scans: conlist(item_type=SpecScans, min_length=1)
914916
scalar_data: Optional[conlist(item_type=PointByPointScanData)] = []
@@ -980,6 +982,8 @@ def validate_experiment_type(cls, experiment_type, info):
980982
allowed_experiment_types = ['EDD', 'TOMO']
981983
elif station == 'id3b':
982984
allowed_experiment_types = ['GIWAXS', 'SAXSWAXS', 'TOMO', 'XRF']
985+
elif station == 'id4b':
986+
allowed_experiment_types = ['HDRM']
983987
else:
984988
allowed_experiment_types = []
985989
if experiment_type not in allowed_experiment_types:
@@ -1252,7 +1256,7 @@ def import_scanparser(station, experiment):
12521256
:type station: str
12531257
:param experiment: The experiment type.
12541258
:type experiment: Literal[
1255-
'EDD', 'GIWAXS', 'SAXSWAXS', 'TOMO', 'XRF']
1259+
'EDD', 'GIWAXS', 'SAXSWAXS', 'TOMO', 'XRF', 'HDRM']
12561260
"""
12571261
# Third party modules
12581262
from chess_scanparsers import choose_scanparser

CHAP/common/processor.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1581,10 +1581,16 @@ def linkdims(nxgroup, nxdata_source):
15811581
detector_ids = []
15821582
for k, v in map_config.attrs.items():
15831583
nxdata.attrs[k] = v
1584+
min_ = np.min(data, axis=tuple(range(1, data.ndim)))
1585+
max_ = np.max(data, axis=tuple(range(1, data.ndim)))
15841586
for i, detector in enumerate(detector_config.detectors):
1585-
nxdata[detector.id] = NXfield(value=data[i], attrs=detector.attrs)
1587+
nxdata[detector.id] = NXfield(
1588+
value=data[i],
1589+
attrs={**detector.attrs, 'min': min_[i], 'max': max_[i]})
15861590
detector_ids.append(detector.id)
15871591
linkdims(nxdata, nxentry.independent_dimensions)
1592+
if len(detector_config.detectors) == 1:
1593+
nxdata.attrs['signal'] = detector_config.detectors[0].id
15881594
nxentry.detector_ids = detector_ids
15891595

15901596
return nxroot

CHAP/edd/models.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,9 @@ def validate_material(self):
232232

233233
self._material = make_material(
234234
self.material_name, self.sgnum, self.lattice_parameters)
235+
self.lattice_parameters = list([
236+
x.getVal('angstrom') if x.isLength() else x.getVal('radians')
237+
for x in self._material._lparms])
235238
return self
236239

237240

CHAP/giwaxs/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
processing workflows.
33
"""
44

5-
#from CHAP.giwaxs.models import GiwaxsConversionProcessorConfig
5+
#from CHAP.giwaxs.models import PyfaiIntegrationConfig
66
from CHAP.giwaxs.processor import (
77
GiwaxsConversionProcessor,
88
PyfaiIntegrationProcessor,

0 commit comments

Comments
 (0)