Commit 78c12bcf authored by Matias Guijarro's avatar Matias Guijarro

Merge branch 'patch-2' into 'master'

[HDF5] Correct instrument location in the nexus tree

See merge request !998
parents a3cca3c0 aca944a0
Pipeline #7157 passed with stages
in 20 minutes and 34 seconds
......@@ -39,7 +39,7 @@ class Writer(FileWriter):
self.close()
self.file = h5py.File(self.filename)
self.scan_entry = self.file.create_group(scan_name)
self.scan_entry.attrs["NX_class"] = "NXentry"
self.scan_entry.attrs["NX_class"] = u"NXentry"
scan_title = scan_info.get("title", "untitled")
utf8_dt = h5py.special_dtype(vlen=unicode)
self.scan_entry["title"] = scan_title.encode("utf-8")
......@@ -48,13 +48,13 @@ class Writer(FileWriter):
utc_time = local_time + "%+03d:00" % (time.altzone / 3600)
self.scan_entry["start_time"] = utc_time.encode("utf-8")
self.measurement = self.scan_entry.create_group("measurement")
self.measurement.attrs["NX_class"] = "NXcollection"
instrument = self.measurement.create_group("instrument")
instrument.attrs["NX_class"] = "NXinstrument"
self.measurement.attrs["NX_class"] = u"NXcollection"
instrument = self.scan_entry.create_group("instrument")
instrument.attrs["NX_class"] = u"NXinstrument"
positioners = instrument.create_group("positioners")
positioners.attrs["NX_class"] = "NXcollection"
positioners.attrs["NX_class"] = u"NXcollection"
positioners_dial = instrument.create_group("positioners_dial")
positioners_dial.attrs["NX_class"] = "NXcollection"
positioners_dial.attrs["NX_class"] = u"NXcollection"
positioners_dict = scan_info.get("positioners", {})
for pname, ppos in positioners_dict.iteritems():
if isinstance(ppos, float):
......
......@@ -36,13 +36,13 @@ def h5dump(scan_file):
ascan_dump = """{ascan}
NX_class: NXentry
{ascan}/instrument
NX_class: NXinstrument
{ascan}/measurement
NX_class: NXcollection
{ascan}/measurement/{group_name}
{ascan}/measurement/{group_name}/{group_name}:roby
{ascan}/measurement/{group_name}/timer
{ascan}/measurement/instrument
NX_class: NXinstrument
{ascan}/measurement/timer
{ascan}/measurement/timer/diode:diode
{ascan}/measurement/timer/simu1:spectrum_det0
......@@ -77,8 +77,8 @@ def test_hdf5_metadata(beacon, session):
assert dataset["title"].value == u"ascan roby 0 10 10 0.01"
assert dataset["start_time"].value.startswith(iso_start_time)
assert dataset["measurement"]
measurement = dataset["measurement"]
for name, pos in measurement["instrument"]["positioners"].items():
assert dataset["instrument"]
for name, pos in dataset["instrument/positioners"].items():
assert all_motors.pop(name) == pos.value
assert len(all_motors) == 0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment