Fix of missing SE entry with empty array, minor modifiction of new file type structure
This commit is contained in:
+9
-5
@@ -33,7 +33,7 @@ NO_DEFAULT_VALUE = object() # just for allowing None default value in AmorHeader
|
||||
|
||||
class AmorHeader:
|
||||
"""
|
||||
Collects header information from Amor NeXus fiel without reading event data.
|
||||
Collects header information from Amor NeXus file without reading event data.
|
||||
"""
|
||||
# mapping of names to (hdf_path, dtype, nicos_key[, suffix])
|
||||
hdf_paths = dict(
|
||||
@@ -44,7 +44,7 @@ class AmorHeader:
|
||||
user_affiliation=('entry1/user/affiliation', str),
|
||||
sample_name=('entry1/sample/name', str),
|
||||
sample_model=('entry1/sample/model', str),
|
||||
sample_geometry=('entry1/sample/geometry', dict),
|
||||
sample_geometry=('entry1/sample/geometry', str),
|
||||
source_name=('entry1/Amor/source/name', str),
|
||||
start_time=('entry1/start_time', str),
|
||||
start_time_fallback=('entry1/Amor/measurement_configuration/start_time', str),
|
||||
@@ -52,7 +52,7 @@ class AmorHeader:
|
||||
|
||||
chopper_separation=('entry1/Amor/chopper/pair_separation', float),
|
||||
chopper_distance=('entry1/Amor/chopper/distance', float),
|
||||
detector_distance=('entry1/Amor/detector/transformation/distance', float),
|
||||
detector_distance=('entry1/Amor/detector_stage/transformation/distance', float),
|
||||
sample_temperature=('entry1/sample/environment/temperature', float),
|
||||
sample_magnetic_field=('entry1/sample/environment/magnetic_field', float),
|
||||
sample_current=('entry1/sample/environment/current', float),
|
||||
@@ -68,7 +68,7 @@ class AmorHeader:
|
||||
virtual_source_vertical=('entry1/Amor/virtual_source/vertical', float),
|
||||
ch1_trigger_phase=('entry1/Amor/chopper/ch1_trigger_phase', float, 'ch1_trigger_phase'),
|
||||
ch2_trigger_phase=('entry1/Amor/chopper/ch2_trigger_phase', float, 'ch2_trigger_phase'),
|
||||
chopper_speed=('entry1/Amor/chopper/rotation_speed', float, 'chopper_phase'),
|
||||
chopper_speed=('entry1/Amor/chopper/rotation_speed', float, 'chopper_speed'),
|
||||
chopper_phase=('entry1/Amor/chopper/phase', float, 'chopper_phase'),
|
||||
|
||||
polarization_config_label=('entry1/Amor/polarization/configuration', int, 'polarization_config_label', '/*'),
|
||||
@@ -262,7 +262,8 @@ class AmorHeader:
|
||||
)
|
||||
sample_geometry = self.rv('sample_geometry', default=None)
|
||||
if sample_geometry:
|
||||
self.sample.geometry = sample_geometry
|
||||
import yaml
|
||||
self.sample.geometry = yaml.safe_load(sample_geometry)
|
||||
# while event times are not evaluated, use first value reported in file for SEE
|
||||
for param in self.SEE_PARAMS:
|
||||
key = f'sample_{param}'
|
||||
@@ -488,8 +489,11 @@ class AmorEventData(AmorHeader):
|
||||
sample_keys = [f'sample_{param}' for param in self.SEE_PARAMS]
|
||||
relevant_items += sample_keys
|
||||
for key, log in self.data.device_logs.items():
|
||||
# if SE is missing there can be a missing key or empty dataset
|
||||
if key not in relevant_items:
|
||||
continue
|
||||
if log.value.size == 0:
|
||||
continue
|
||||
if log.value.dtype in [np.int8, np.int16, np.int32, np.int64]:
|
||||
# for integer items (flags) report the most common one
|
||||
value = np.bincount(log.value).argmax()
|
||||
|
||||
Reference in New Issue
Block a user