Commit 6c8b5581 authored by Linus Pithan's avatar Linus Pithan

move positioners into separate scan_info categorie

parent 866d01ff
Pipeline #19783 failed with stages
in 58 minutes and 11 seconds
......@@ -1070,7 +1070,7 @@ class Scan:
for top_level_master in acq_chain.keys():
for scalar_master in acq_chain[top_level_master]["master"]["scalars"]:
ma = scalar_master.split(":")[-1]
if ma in self._scan_info["instrument"]["positioners"]:
if ma in self._scan_info["positioners"]["positioners_start"]:
master_axes.append(ma)
if len(master_axes) == 0:
......@@ -1158,7 +1158,10 @@ class Scan:
"scalars"
]:
axis_name = scalar_master.split(":")[-1]
if axis_name in self._scan_info["instrument"]["positioners"]:
if (
axis_name
in self._scan_info["positioners"]["positioners_start"]
):
raise StopIteration
except StopIteration:
axis = current_session.env_dict[axis_name]
......@@ -1403,7 +1406,7 @@ class Scan:
tmp = dev.fill_meta_at_scan_end(self.user_scan_meta)
if tmp:
update_node_info(self.nodes[dev], tmp)
self.user_scan_meta.instrument.remove("positioners")
# self.user_scan_meta.instrument.remove("positioners")
deep_update(self._scan_info, self.user_scan_meta.to_dict(self))
self._scan_info[
"scan_meta_categories"
......
......@@ -23,7 +23,7 @@ from bliss import global_map
USER_SCAN_META = None
CATEGORIES = enum.Enum(
"categories",
"INSTRUMENT SAMPLE SAMPLE_DESCRIPTION PROPOSAL TECHNIQUE NOTES NEXUSWRITER",
"INSTRUMENT POSITIONERS SAMPLE SAMPLE_DESCRIPTION PROPOSAL TECHNIQUE NEXUSWRITER NOTES",
)
......@@ -35,11 +35,12 @@ def get_user_scan_meta():
global USER_SCAN_META
if USER_SCAN_META is None:
USER_SCAN_META = scan_meta()
USER_SCAN_META.instrument.set("positioners", fill_positioners)
USER_SCAN_META.positioners.set("positioners", fill_positioners)
USER_SCAN_META.instrument.set("NX_class", {"NX_class": "NXinstrument"})
USER_SCAN_META.technique.set("NX_class", {"NX_class": "NXcollection"})
USER_SCAN_META.sample.set("NX_class", {"NX_class": "NXsample"})
USER_SCAN_META.proposal.set("NX_class", {"NX_class": "NXcollection"})
USER_SCAN_META.sample_description.set("NX_class", {"NX_class": "NXcollection"})
USER_SCAN_META.technique.set("NX_class", {"NX_class": "NXcollection"})
USER_SCAN_META.notes.set("NX_class", {"NX_class": "NXcollection"})
return USER_SCAN_META
......@@ -119,11 +120,20 @@ def scan_meta(info=None):
def fill_positioners(scan):
rd = {"positioners": dict(), "positioners_dial": dict()}
stuffix = "_start"
if scan.state == 3:
stuffix = "_end"
positioners = dict()
positioners_dial = dict()
for axis_name, axis_pos, axis_dial_pos, unit in global_map.get_axes_positions_iter(
on_error="ERR"
):
rd["positioners"][axis_name] = axis_pos
rd["positioners_dial"][axis_name] = axis_dial_pos
positioners[axis_name] = axis_pos
positioners_dial[axis_name] = axis_dial_pos
rd = {
"positioners" + stuffix: positioners,
"positioners_dial" + stuffix: positioners_dial,
}
return rd
......@@ -207,6 +207,12 @@ class Writer(FileWriter):
return d.setdefault(x, {"NX_class": "NXcollection"})
instrument_meta["chain_meta"] = {"NX_class": "NXcollection"}
instrument_meta["positioners"] = scan_info.get("positioners", {}).get(
"positioners_start", {}
)
instrument_meta["positioners_dial"] = scan_info.get("positioners", {}).get(
"positioners_dial_start", {}
)
base_db_name = scan.node.db_name
for dev in scan.acq_chain.nodes_list:
......
......@@ -319,6 +319,13 @@ class HDF5_Writer(object):
instrument_meta = self.scan_info_dict["instrument"]
instrument_meta["chain_meta"] = {"NX_class": "NXcollection"}
if "positioners" in self.scan_info_dict:
instrument_meta["positioners"] = self.scan_info_dict["positioners"].get(
"positioners_start"
)
instrument_meta["positioners_dial"] = self.scan_info_dict[
"positioners"
].get("positioners_dial_start")
base_db_name = self.scan_node.db_name
for node in self.scan_node.iterator.walk(wait=False):
......
......@@ -149,6 +149,8 @@ def test_scan_meta_master_and_device(session, scan_meta):
assert s.scan_info["instrument"] == {
**master_dict,
**device_dict,
"positioners": {},
"positioners_dial": {},
"chain_meta": {"NX_class": "NXcollection"},
}
......@@ -166,15 +168,21 @@ def test_positioners_in_scan_info(alias_session):
initial_robyy_position = robyy.position
s1.run()
assert "positioners" in s1.scan_info["instrument"]
assert s1.scan_info["instrument"]["positioners"]["robyy"] == initial_robyy_position
assert "positioners" in s1.scan_info
assert (
s1.scan_info["positioners"]["positioners_start"]["robyy"]
== initial_robyy_position
)
# test that positioners are remaining in for a counter that updates 'scan_info'
initial_robyy_position = robyy.position
s2 = scans.ascan(robyy, 0, 1, 3, .1, lima_simulator, run=False, save=False)
s2.run()
assert "positioners" in s2.scan_info["instrument"]
assert s2.scan_info["instrument"]["positioners"]["robyy"] == initial_robyy_position
assert "positioners" in s2.scan_info
assert (
s2.scan_info["positioners"]["positioners_start"]["robyy"]
== initial_robyy_position
)
def test_scan_saving_without_axis_in_session(default_session):
......@@ -183,5 +191,5 @@ def test_scan_saving_without_axis_in_session(default_session):
s = scans.loopscan(3, .1, diode, save=False)
assert "positioners" in s.scan_info["instrument"]
assert s.scan_info["instrument"]["positioners"] == {}
assert "positioners" in s.scan_info
assert s.scan_info["positioners"]["positioners_start"] == {}
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