-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_scicat_ingestor.py
76 lines (66 loc) · 21.8 KB
/
test_scicat_ingestor.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
from unittest import TestCase
from scicat_ingestor import get_nested_value, get_nested_value_with_default
import logging
import logging.handlers
class Test(TestCase):
def setUp(self):
self.metadata = {
"extra": {
"/entry/instrument/flir_camera/image_key:average_value":0.0,
"/entry/instrument/flir_camera/image_key:maximum_value":0.0,
"/entry/instrument/flir_camera/image_key:minimum_value":0.0,
"/entry/instrument/mini_chopper/rotation_speed:average_value":-0.000415910966694355,
"/entry/instrument/mini_chopper/rotation_speed:maximum_value":-0.000415910966694355,
"/entry/instrument/mini_chopper/rotation_speed:minimum_value":-0.000415910966694355,
"/entry/sample/transformations/rotation:average_value":180.46657592243739,
"/entry/sample/transformations/rotation:maximum_value":360.00030863342005,
"/entry/sample/transformations/rotation:minimum_value":-5.0162045752574186e-05,
"/entry/sample/transformations/x_translation:average_value":39.46592500000003,
"/entry/sample/transformations/x_translation:maximum_value":39.46592500000003,
"/entry/sample/transformations/x_translation:minimum_value":39.46592500000003,
"/entry/sample/transformations/y_translation:average_value":0.05726562500001364,
"/entry/sample/transformations/y_translation:maximum_value":0.05726562500001364,
"/entry/sample/transformations/y_translation:minimum_value":0.05726562500001364,
"/entry/sample/transformations/z_translation:average_value":0.1,
"/entry/sample/transformations/z_translation:maximum_value":0.1,
"/entry/sample/transformations/z_translation:minimum_value":0.1,
":approx_file_size_mb":330
},
"file_being_written":"531404_00000005.hdf",
#"hdf_structure": "{\\"children\\": [{\\"name\\": \\"entry\\", \\"type\\": \\"group\\", \\"attributes\\": [{\\"name\\": \\"NX_class\\", \\"dtype\\": \\"string\\", \\"values\\": \\"NXentry\\"}], \\"children\\": [{\\"module\\": \\"dataset\\", \\"config\\": {\\"name\\": \\"title\\", \\"values\\": \\"I want beamtime\\", \\"type\\": \\"string\\"}}, {\\"module\\": \\"dataset\\", \\"config\\": {\\"name\\": \\"experiment_identifier\\", \\"values\\": \\"531404\\", \\"type\\": \\"string\\"}}, {\\"module\\": \\"dataset\\", \\"config\\": {\\"name\\": \\"definition\\", \\"values\\": \\"NXtomo\\", \\"type\\": \\"string\\"}}, {\\"name\\": \\"instrument\\", \\"type\\": \\"group\\", \\"attributes\\": [{\\"name\\": \\"NX_class\\", \\"dtype\\": \\"string\\", \\"values\\": \\"NXinstrument\\"}], \\"children\\": [{\\"name\\": \\"light_source\\", \\"type\\": \\"group\\", \\"attributes\\": [{\\"name\\": \\"NX_class\\", \\"dtype\\": \\"string\\", \\"values\\": \\"NXsource\\"}], \\"children\\": [{\\"module\\": \\"dataset\\", \\"config\\": {\\"name\\": \\"probe\\", \\"values\\": \\"visible light\\", \\"type\\": \\"string\\"}}]}, {\\"name\\": \\"flir_camera\\", \\"type\\": \\"group\\", \\"attributes\\": [{\\"name\\": \\"NX_class\\", \\"dtype\\": \\"string\\", \\"values\\": \\"NXdetector\\"}], \\"children\\": [{\\"name\\": \\"image_key\\", \\"type\\": \\"group\\", \\"attributes\\": [{\\"name\\": \\"NX_class\\", \\"dtype\\": \\"string\\", \\"values\\": \\"NXlog\\"}], \\"children\\": [{\\"module\\": \\"f142\\", \\"config\\": {\\"source\\": \\"flir_image_type\\", \\"topic\\": \\"ymir_nicos_devices\\", \\"dtype\\": \\"int16\\"}}]}, {\\"name\\": \\"data\\", \\"type\\": \\"group\\", \\"attributes\\": [{\\"name\\": \\"NX_class\\", \\"dtype\\": \\"string\\", \\"values\\": \\"NXlog\\"}], \\"children\\": [{\\"module\\": \\"ADAr\\", \\"config\\": {\\"source\\": \\"some_source\\", \\"topic\\": \\"ymir_camera\\", \\"array_size\\": [480, 830]}}]}]}, {\\"name\\": \\"mini_chopper\\", \\"type\\": \\"group\\", \\"attributes\\": [{\\"name\\": \\"NX_class\\", \\"dtype\\": \\"string\\", \\"values\\": \\"NXdisk_chopper\\"}], \\"children\\": [{\\"module\\": \\"dataset\\", \\"config\\": {\\"name\\": \\"slits\\", \\"values\\": 1, \\"type\\": \\"int64\\"}}, {\\"module\\": \\"dataset\\", \\"config\\": {\\"name\\": \\"slit_height\\", \\"values\\": 0.03, \\"type\\": \\"double\\"}, \\"attributes\\": [{\\"name\\": \\"units\\", \\"dtype\\": \\"string\\", \\"values\\": \\"m\\"}]}, {\\"module\\": \\"dataset\\", \\"config\\": {\\"name\\": \\"radius\\", \\"values\\": 0.15, \\"type\\": \\"double\\"}, \\"attributes\\": [{\\"name\\": \\"units\\", \\"dtype\\": \\"string\\", \\"values\\": \\"m\\"}]}, {\\"module\\": \\"dataset\\", \\"config\\": {\\"name\\": \\"slit_edges\\", \\"values\\": [0.0, 15.0], \\"type\\": \\"double\\"}, \\"attributes\\": [{\\"name\\": \\"units\\", \\"dtype\\": \\"string\\", \\"values\\": \\"deg\\"}]}, {\\"name\\": \\"rotation_speed\\", \\"type\\": \\"group\\", \\"attributes\\": [{\\"name\\": \\"NX_class\\", \\"dtype\\": \\"string\\", \\"values\\": \\"NXlog\\"}], \\"children\\": [{\\"module\\": \\"f142\\", \\"config\\": {\\"source\\": \\"YMIR-ChpSy1:Chop-MIC-101:Spd_SP\\", \\"topic\\": \\"ymir_motion\\", \\"dtype\\": \\"double\\"}, \\"attributes\\": [{\\"name\\": \\"units\\", \\"dtype\\": \\"string\\", \\"values\\": \\"1/s\\"}]}]}, {\\"type\\": \\"group\\", \\"name\\": \\"transformations\\", \\"children\\": [{\\"module\\": \\"dataset\\", \\"config\\": {\\"name\\": \\"translation\\", \\"values\\": -5.0, \\"type\\": \\"double\\"}, \\"attributes\\": [{\\"name\\": \\"transformation_type\\", \\"dtype\\": \\"string\\", \\"values\\": \\"translation\\"}, {\\"name\\": \\"units\\", \\"dtype\\": \\"string\\", \\"values\\": \\"m\\"}, {\\"name\\": \\"vector\\", \\"dtype\\": \\"string\\", \\"values\\": [0.0, 0.0, 1.0]}]}], \\"attributes\\": [{\\"name\\": \\"NX_class\\", \\"values\\": \\"NXtransformations\\"}]}, {\\"module\\": \\"dataset\\", \\"config\\": {\\"name\\": \\"depends_on\\", \\"dtype\\": \\"string\\", \\"values\\": \\"/entry/instrument/mini_chopper/transformations/translation\\"}}]}, {\\"name\\": \\"laser_monitor\\", \\"type\\": \\"group\\", \\"attributes\\": [{\\"name\\": \\"NX_class\\", \\"dtype\\": \\"string\\", \\"values\\": \\"NXmonitor\\"}], \\"children\\": [{\\"name\\": \\"data\\", \\"type\\": \\"group\\", \\"attributes\\": [{\\"name\\": \\"NX_class\\", \\"dtype\\": \\"string\\", \\"values\\": \\"NXlog\\"}], \\"children\\": [{\\"module\\": \\"senv\\", \\"config\\": {\\"source\\": \\"plc-ts:PLC:value\\", \\"topic\\": \\"ymir_motion\\", \\"dtype\\": \\"double\\"}}]}]}, {\\"name\\": \\"laser_source\\", \\"type\\": \\"group\\", \\"attributes\\": [{\\"name\\": \\"NX_class\\", \\"dtype\\": \\"string\\", \\"values\\": \\"NXsource\\"}], \\"children\\": [{\\"module\\": \\"dataset\\", \\"config\\": {\\"name\\": \\"probe\\", \\"values\\": \\"visible_light\\", \\"type\\": \\"string\\"}}, {\\"type\\": \\"group\\", \\"name\\": \\"transformations\\", \\"children\\": [{\\"module\\": \\"dataset\\", \\"config\\": {\\"name\\": \\"translation\\", \\"values\\": -1.0, \\"type\\": \\"double\\"}, \\"attributes\\": [{\\"name\\": \\"transformation_type\\", \\"dtype\\": \\"string\\", \\"values\\": \\"translation\\"}, {\\"name\\": \\"units\\", \\"dtype\\": \\"string\\", \\"values\\": \\"m\\"}, {\\"name\\": \\"vector\\", \\"dtype\\": \\"string\\", \\"values\\": [0.0, 0.0, 1.0]}, {\\"name\\": \\"depends_on\\", \\"values\\": \\"/entry/instrument/mini_chopper/transformations/translation\\", \\"dtype\\": \\"string\\"}]}], \\"attributes\\": [{\\"name\\": \\"NX_class\\", \\"values\\": \\"NXtransformations\\"}]}, {\\"module\\": \\"dataset\\", \\"config\\": {\\"name\\": \\"depends_on\\", \\"dtype\\": \\"string\\", \\"values\\": \\"/entry/instrument/laser_source/transformations/translation\\"}}]}]}, {\\"name\\": \\"sample\\", \\"type\\": \\"group\\", \\"attributes\\": [{\\"name\\": \\"NX_class\\", \\"dtype\\": \\"string\\", \\"values\\": \\"NXsample\\"}], \\"children\\": [{\\"module\\": \\"dataset\\", \\"config\\": {\\"name\\": \\"name\\", \\"values\\": \\"lego\\", \\"type\\": \\"string\\"}}, {\\"type\\": \\"group\\", \\"name\\": \\"transformations\\", \\"children\\": [{\\"name\\": \\"rotation\\", \\"type\\": \\"group\\", \\"attributes\\": [{\\"name\\": \\"NX_class\\", \\"dtype\\": \\"string\\", \\"values\\": \\"NXlog\\"}, {\\"name\\": \\"transformation_type\\", \\"dtype\\": \\"string\\", \\"values\\": \\"rotation\\"}, {\\"name\\": \\"units\\", \\"dtype\\": \\"string\\", \\"values\\": \\"degrees\\"}, {\\"name\\": \\"vector\\", \\"dtype\\": \\"string\\", \\"values\\": [0.0, 1.0, 0.0]}, {\\"name\\": \\"depends_on\\", \\"values\\": \\"/entry/sample/transformations/x_translation\\", \\"dtype\\": \\"string\\"}], \\"children\\": [{\\"module\\": \\"f142\\", \\"config\\": {\\"source\\": \\"YMIR-SpRot:MC-Rz-01:m.RBV\\", \\"topic\\": \\"ymir_motion\\", \\"dtype\\": \\"double\\"}, \\"attributes\\": [{\\"name\\": \\"units\\", \\"dtype\\": \\"string\\", \\"values\\": \\"degrees\\"}]}]}, {\\"name\\": \\"x_translation\\", \\"type\\": \\"group\\", \\"attributes\\": [{\\"name\\": \\"NX_class\\", \\"dtype\\": \\"string\\", \\"values\\": \\"NXlog\\"}, {\\"name\\": \\"transformation_type\\", \\"dtype\\": \\"string\\", \\"values\\": \\"translation\\"}, {\\"name\\": \\"units\\", \\"dtype\\": \\"string\\", \\"values\\": \\"mm\\"}, {\\"name\\": \\"vector\\", \\"dtype\\": \\"string\\", \\"values\\": [1.0, 0.0, 0.0]}, {\\"name\\": \\"depends_on\\", \\"values\\": \\"/entry/sample/transformations/y_translation\\", \\"dtype\\": \\"string\\"}], \\"children\\": [{\\"module\\": \\"f142\\", \\"config\\": {\\"source\\": \\"YMIR-SpScn:MC-Y-01:m.RBV\\", \\"topic\\": \\"ymir_motion\\", \\"dtype\\": \\"double\\"}, \\"attributes\\": [{\\"name\\": \\"units\\", \\"dtype\\": \\"string\\", \\"values\\": \\"mm\\"}]}]}, {\\"name\\": \\"y_translation\\", \\"type\\": \\"group\\", \\"attributes\\": [{\\"name\\": \\"NX_class\\", \\"dtype\\": \\"string\\", \\"values\\": \\"NXlog\\"}, {\\"name\\": \\"transformation_type\\", \\"dtype\\": \\"string\\", \\"values\\": \\"translation\\"}, {\\"name\\": \\"units\\", \\"dtype\\": \\"string\\", \\"values\\": \\"mm\\"}, {\\"name\\": \\"vector\\", \\"dtype\\": \\"string\\", \\"values\\": [0.0, 1.0, 0.0]}, {\\"name\\": \\"depends_on\\", \\"values\\": \\"/entry/sample/transformations/z_translation\\", \\"dtype\\": \\"string\\"}], \\"children\\": [{\\"module\\": \\"f142\\", \\"config\\": {\\"source\\": \\"YMIR-SpScn:MC-Z-01:m.RBV\\", \\"topic\\": \\"ymir_motion\\", \\"dtype\\": \\"double\\"}, \\"attributes\\": [{\\"name\\": \\"units\\", \\"dtype\\": \\"string\\", \\"values\\": \\"mm\\"}]}]}, {\\"name\\": \\"z_translation\\", \\"type\\": \\"group\\", \\"attributes\\": [{\\"name\\": \\"NX_class\\", \\"dtype\\": \\"string\\", \\"values\\": \\"NXlog\\"}, {\\"name\\": \\"transformation_type\\", \\"dtype\\": \\"string\\", \\"values\\": \\"translation\\"}, {\\"name\\": \\"units\\", \\"dtype\\": \\"string\\", \\"values\\": \\"mm\\"}, {\\"name\\": \\"vector\\", \\"dtype\\": \\"string\\", \\"values\\": [0.0, 0.0, 1.0]}], \\"children\\": [{\\"module\\": \\"f142\\", \\"config\\": {\\"source\\": \\"YMIR-SpScn:MC-X-01:m.RBV\\", \\"topic\\": \\"ymir_motion\\", \\"dtype\\": \\"double\\"}, \\"attributes\\": [{\\"name\\": \\"units\\", \\"dtype\\": \\"string\\", \\"values\\": \\"mm\\"}]}]}], \\"attributes\\": [{\\"name\\": \\"NX_class\\", \\"values\\": \\"NXtransformations\\"}]}, {\\"module\\": \\"dataset\\", \\"config\\": {\\"name\\": \\"depends_on\\", \\"dtype\\": \\"string\\", \\"values\\": \\"/entry/sample/transformations/rotation\\"}}]}, {\\"name\\": \\"data\\", \\"type\\": \\"group\\", \\"attributes\\": [{\\"name\\": \\"NX_class\\", \\"dtype\\": \\"string\\", \\"values\\": \\"NXdata\\"}], \\"children\\": [{\\"module\\": \\"link\\", \\"config\\": {\\"name\\": \\"data\\", \\"source\\": \\"/entry/instrument/detector/data\\"}}, {\\"module\\": \\"link\\", \\"config\\": {\\"name\\": \\"rotation_angle\\", \\"source\\": \\"/entry/sample/rotation_angle\\"}}, {\\"module\\": \\"link\\", \\"config\\": {\\"name\\": \\"image_key\\", \\"source\\": \\"/entry/instrument/detector/image_key\\"}}]}, {\\"type\\": \\"group\\", \\"name\\": \\"user_CarlBolmsten\\", \\"attributes\\": {\\"NX_class\\": \\"NXuser\\"}, \\"children\\": [{\\"module\\": \\"dataset\\", \\"config\\": {\\"name\\": \\"name\\", \\"values\\": \\"Carl Bolmsten\\", \\"dtype\\": \\"string\\"}}, {\\"module\\": \\"dataset\\", \\"config\\": {\\"name\\": \\"email\\", \\"values\\": \\"\\", \\"dtype\\": \\"string\\"}}, {\\"module\\": \\"dataset\\", \\"config\\": {\\"name\\": \\"affiliation\\", \\"values\\": \\"European Spallation Source ERIC (ESS)\\", \\"dtype\\": \\"string\\"}}, {\\"module\\": \\"dataset\\", \\"config\\": {\\"name\\": \\"facility_user_id\\", \\"values\\": \\"carlbolmsten\\", \\"dtype\\": \\"string\\"}}]}]}]}",
"job_id": "4baba870-448f-11ed-ab42-fa163e943f63",
"start_time":1664961775832,"state":"writing",
"stop_time":1664961884666
}
self.hdf_structure = {"children": [{"name": "entry", "type": "group", "attributes": [{"name": "NX_class", "dtype": "string","values": "NXentry"}], "children": [{"module": "dataset", "config": {"name": "title", "values": "I want beamtime", "type": "string"}}, {"module": "dataset", "config": {"name": "experiment_identifier", "values": "531404", "type": "string"}}, {"module": "dataset", "config": {"name": "definition", "values": "NXtomo", "type": "string"}}, {"name": "instrument", "type": "group", "attributes": [{"name": "NX_class", "dtype": "string", "values": "NXinstrument"}], "children": [{"name": "light_source", "type": "group", "attributes": [{"name": "NX_class", "dtype": "string", "values": "NXsource"}], "children": [{"module": "dataset", "config": {"name": "probe", "values": "visible light", "type": "string"}}]}, {"name": "flir_camera", "type": "group", "attributes": [{"name": "NX_class", "dtype": "string", "values": "NXdetector"}], "children": [{"name": "image_key", "type": "group", "attributes": [{"name": "NX_class", "dtype": "string", "values": "NXlog"}], "children": [{"module": "f142", "config": {"source": "flir_image_type", "topic": "ymir_nicos_devices", "dtype": "int16"}}]}, {"name": "data", "type": "group", "attributes": [{"name": "NX_class", "dtype": "string", "values": "NXlog"}], "children": [{"module": "ADAr", "config": {"source": "some_source", "topic": "ymir_camera", "array_size": [480, 830]}}]}]}, {"name": "mini_chopper", "type": "group", "attributes": [{"name": "NX_class", "dtype": "string", "values": "NXdisk_chopper"}], "children": [{"module": "dataset", "config": {"name": "slits", "values": 1, "type": "int64"}}, {"module": "dataset", "config": {"name": "slit_height", "values": 0.03, "type": "double"}, "attributes": [{"name": "units", "dtype": "string", "values": "m"}]}, {"module": "dataset", "config": {"name": "radius", "values": 0.15, "type": "double"}, "attributes": [{"name": "units", "dtype": "string", "values": "m"}]}, {"module": "dataset", "config": {"name": "slit_edges", "values": [0.0, 15.0], "type": "double"}, "attributes": [{"name": "units", "dtype": "string", "values": "deg"}]}, {"name": "rotation_speed", "type": "group", "attributes": [{"name": "NX_class", "dtype": "string", "values": "NXlog"}], "children": [{"module": "f142", "config": {"source": "YMIR-ChpSy1:Chop-MIC-101:Spd_SP", "topic": "ymir_motion", "dtype": "double"}, "attributes": [{"name": "units", "dtype": "string", "values": "1/s"}]}]}, {"type": "group", "name": "transformations", "children": [{"module": "dataset", "config": {"name": "translation", "values": -5.0, "type": "double"}, "attributes": [{"name": "transformation_type", "dtype": "string", "values": "translation"}, {"name": "units", "dtype": "string", "values": "m"}, {"name": "vector", "dtype": "string", "values": [0.0, 0.0, 1.0]}]}], "attributes": [{"name": "NX_class", "values": "NXtransformations"}]}, {"module": "dataset", "config": {"name": "depends_on", "dtype": "string","values": "/entry/instrument/mini_chopper/transformations/translation"}}]}, {"name": "laser_monitor", "type": "group", "attributes": [{"name": "NX_class", "dtype": "string", "values": "NXmonitor"}], "children": [{"name": "data", "type": "group", "attributes": [{"name": "NX_class", "dtype": "string", "values": "NXlog"}], "children": [{"module": "senv", "config": {"source": "plc-ts:PLC:value", "topic": "ymir_motion", "dtype": "double"}}]}]}, {"name": "laser_source", "type": "group", "attributes": [{"name": "NX_class", "dtype": "string", "values": "NXsource"}], "children": [{"module": "dataset", "config": {"name": "probe", "values": "visible_light", "type": "string"}}, {"type": "group", "name": "transformations", "children": [{"module": "dataset", "config": {"name": "translation", "values": -1.0, "type": "double"}, "attributes": [{"name": "transformation_type", "dtype": "string", "values": "translation"}, {"name": "units", "dtype": "string", "values": "m"}, {"name": "vector", "dtype": "string", "values": [0.0, 0.0, 1.0]}, {"name": "depends_on", "values": "/entry/instrument/mini_chopper/transformations/translation", "dtype": "string"}]}], "attributes": [{"name": "NX_class", "values": "NXtransformations"}]}, {"module": "dataset", "config": {"name": "depends_on", "dtype": "string", "values": "/entry/instrument/laser_source/transformations/translation"}}]}]}, {"name": "sample", "type": "group", "attributes": [{"name": "NX_class", "dtype": "string", "values": "NXsample"}], "children": [{"module": "dataset", "config": {"name": "name", "values": "lego", "type": "string"}}, {"type": "group", "name": "transformations", "children": [{"name": "rotation", "type": "group", "attributes": [{"name": "NX_class", "dtype": "string", "values": "NXlog"}, {"name": "transformation_type", "dtype": "string", "values": "rotation"}, {"name": "units", "dtype": "string", "values": "degrees"}, {"name": "vector", "dtype": "string", "values": [0.0, 1.0, 0.0]}, {"name": "depends_on", "values": "/entry/sample/transformations/x_translation", "dtype": "string"}], "children": [{"module": "f142", "config": {"source": "YMIR-SpRot:MC-Rz-01:m.RBV", "topic": "ymir_motion", "dtype": "double"}, "attributes": [{"name": "units", "dtype": "string", "values": "degrees"}]}]}, {"name": "x_translation", "type": "group", "attributes": [{"name": "NX_class", "dtype": "string", "values": "NXlog"}, {"name": "transformation_type", "dtype": "string", "values": "translation"}, {"name": "units", "dtype": "string", "values": "mm"}, {"name": "vector", "dtype": "string", "values": [1.0, 0.0, 0.0]}, {"name": "depends_on", "values": "/entry/sample/transformations/y_translation", "dtype": "string"}], "children": [{"module": "f142", "config": {"source": "YMIR-SpScn:MC-Y-01:m.RBV", "topic": "ymir_motion", "dtype": "double"}, "attributes": [{"name": "units", "dtype": "string", "values": "mm"}]}]}, {"name": "y_translation", "type": "group", "attributes": [{"name": "NX_class", "dtype": "string", "values": "NXlog"}, {"name": "transformation_type", "dtype": "string", "values": "translation"}, {"name": "units", "dtype": "string", "values": "mm"}, {"name": "vector", "dtype": "string", "values": [0.0, 1.0, 0.0]}, {"name": "depends_on", "values": "/entry/sample/transformations/z_translation", "dtype": "string"}], "children": [{"module": "f142", "config": {"source": "YMIR-SpScn:MC-Z-01:m.RBV", "topic": "ymir_motion", "dtype": "double"}, "attributes": [{"name": "units", "dtype": "string", "values": "mm"}]}]}, {"name": "z_translation", "type": "group", "attributes": [{"name": "NX_class", "dtype": "string", "values": "NXlog"}, {"name": "transformation_type", "dtype": "string", "values": "translation"}, {"name": "units", "dtype": "string", "values": "mm"}, {"name": "vector", "dtype": "string", "values": [0.0, 0.0, 1.0]}], "children": [{"module": "f142", "config": {"source": "YMIR-SpScn:MC-X-01:m.RBV", "topic": "ymir_motion", "dtype": "double"}, "attributes": [{"name": "units", "dtype": "string", "values": "mm"}]}]}], "attributes": [{"name": "NX_class", "values": "NXtransformations"}]}, {"module": "dataset", "config": {"name": "depends_on", "dtype": "string", "values": "/entry/sample/transformations/rotation"}}]}, {"name": "data", "type": "group", "attributes": [{"name": "NX_class", "dtype": "string", "values": "NXdata"}], "children": [{"module": "link", "config": {"name": "data", "source": "/entry/instrument/detector/data"}}, {"module": "link", "config": {"name": "rotation_angle", "source": "/entry/sample/rotation_angle"}}, {"module": "link", "config": {"name": "image_key", "source": "/entry/instrument/detector/image_key"}}]}, {"type": "group", "name": "user_CarlBolmsten", "attributes": {"NX_class": "NXuser"}, "children": [{"module": "dataset", "config":{"name": "name", "values": "Carl Bolmsten", "dtype": "string"}}, {"module": "dataset", "config": {"name": "email", "values": "", "dtype": "string"}}, {"module": "dataset", "config": {"name": "affiliation", "values": "European Spallation Source ERIC (ESS)", "dtype": "string"}}, {"module": "dataset", "config": {"name": "facility_user_id", "values": "carlbolmsten", "dtype": "string"}}]}]}]}
# instantiate logger
self.logger = logging.getLogger('esd extract parameters')
self.logger.setLevel("DEBUG")
formatter = logging.Formatter('Unit testing - %(asctime)s - %(name)s - %(levelname)s - %(message)s')
ch = logging.StreamHandler()
ch.setLevel("DEBUG")
ch.setFormatter(formatter)
self.logger.addHandler(ch)
def test_get_nested_value_with_proposal_id(self):
selector = [
"children",
("children", "name", "entry"),
("config", "module","dataset"),
(None,"name","experiment_identifier","values")
]
proposal_id = int(get_nested_value(
self.hdf_structure,
selector,
self.logger
))
self.assertEqual(proposal_id,531404)
def test_get_nested_value_with_default_with_file_size(self):
selector = ['extra',":approx_file_size_mb"]
# extract estimated file size from message
file_size = get_nested_value_with_default(
self.metadata,
selector,
0,
self.logger
)
self.assertEqual(file_size, 330)