GitLab will be upgraded on June 23rd evening. During the upgrade the service will be unavailable, sorry for the inconvenience.

Commit 2a88a20f authored by Wout De Nolf's avatar Wout De Nolf Committed by Linus Pithan

[writer] positioners have their own category

parent c9b58b37
Pipeline #20345 passed with stages
in 54 minutes and 23 seconds
......@@ -356,13 +356,6 @@ class NexusScanWriterBase(base_subscriber.BaseSubscriber):
else:
return []
@property
def instrument_info(self):
"""
Instrument information publish by the Bliss core library
"""
return self.get_info("instrument", default={})
@property
def config_devices(self):
return {}
......@@ -903,6 +896,14 @@ class NexusScanWriterBase(base_subscriber.BaseSubscriber):
def instrument_name(self):
return ""
@property
def positioner_info(self):
return self.get_info("positioners", {})
@property
def motors(self):
return list(self.positioner_info.get("positioners_start", {}).keys())
@contextmanager
def nxinstrument(self, subscan):
"""
......@@ -1683,51 +1684,35 @@ class NexusScanWriterBase(base_subscriber.BaseSubscriber):
if dproxy.data_type != "principal":
yield fullname, dproxy
@property
def positioners_start(self):
positioners = self.instrument_info.get("positioners", {})
units = self.instrument_info.get("positioners_units", {})
return positioners, units
@property
def positioners_dial_start(self):
positioners = self.instrument_info.get("positioners_dial", {})
units = self.instrument_info.get("positioners_units", {})
return positioners, units
@property
def positioners_end(self):
return {}, {}
@property
def positioners_dial_end(self):
return {}, {}
def _save_positioners(self, subscan):
"""
Save fixed snapshots of motor positions.
:param Subscan subscan:
"""
info = self.positioner_info
units = info.get("positioners_units", {})
# Positions at the beginning of the scan
positioners, units = self.positioners_start
positioners = info.get("positioners_start", {})
subscan.logger.info("Save {} motor positions".format(len(positioners)))
self._save_positioners_snapshot(
subscan, positioners, units, "_start", overwrite=False
)
self._save_positioners_snapshot(
subscan, positioners, units, "", overwrite=False
)
positioners, units = self.positioners_dial_start
positioners = info.get("positioners_dial_start", {})
self._save_positioners_snapshot(
subscan, positioners, units, "_dial_start", overwrite=False
)
# Positions at the end of the scan
positioners, units = self.positioners_end
positioners = info.get("positioners_end", {})
self._save_positioners_snapshot(
subscan, positioners, units, "_end", overwrite=True
)
positioners, units = self.positioners_dial_end
positioners = info.get("positioners_dial_end", {})
self._save_positioners_snapshot(
subscan, positioners, units, "_dial_end", overwrite=True
)
......@@ -1749,11 +1734,6 @@ class NexusScanWriterBase(base_subscriber.BaseSubscriber):
with self.nxpositioners(subscan, suffix=suffix) as nxpositioners:
if nxpositioners is None:
return
subscan.logger.info(
"Save motor positions snapshot {} (overwrite: {})".format(
repr(nexus.h5Name(nxpositioners)), overwrite
)
)
for mot, pos in positions.items():
unit = units.get(mot, None)
exists = mot in nxpositioners
......@@ -1802,8 +1782,7 @@ class NexusScanWriterBase(base_subscriber.BaseSubscriber):
# Positioners should always be there under
# a different name when not in positioners
# snapshot
motors = self.instrument_info.get("positioners", {})
if linkname not in motors:
if linkname not in self.motors:
linknames.append("pos_" + linkname)
# Principle positioners which are masters should
# be there under their normal name
......@@ -1846,9 +1825,6 @@ class NexusScanWriterBase(base_subscriber.BaseSubscriber):
scan_meta = {}
for cat in categories:
add = info.get(cat, {})
if cat == "instrument":
# TODO: remove when positioners are outside
add.pop("positioners")
if set(add.keys()) - {"NX_class", "@NX_class"}:
scan_meta[cat] = add
if scan_meta:
......
......@@ -134,18 +134,6 @@ class NexusScanWriterConfigurable(scan_writer_base.NexusScanWriterBase):
)
return signaldict
@property
def positioners_end(self):
positioners = self.config_writer.get("positioners", {})
units = self.config_writer.get("positioners_units", {})
return positioners, units
@property
def positioners_dial_end(self):
positioners = self.config_writer.get("positioners_dial", {})
units = self.config_writer.get("positioners_units", {})
return positioners, units
def _init_subscan(self, subscan):
"""
Things that can already be saved right after
......
......@@ -42,31 +42,13 @@ def register_metadata_generators(generators):
:param bliss.scanning.scan_meta.ScanMeta generators:
"""
instrument = generators.instrument
instrument.set("positioners", fill_positioners) # start of scan
generators = generators.nexuswriter
generators.set("instrument", fill_instrument_name)
generators.set("positioners", fill_positioners) # end of scan
generators.set("device_info", fill_device_info)
generators.set("technique", fill_technique_info)
generators.set("filenames", fill_filenames)
def fill_positioners(scan):
"""
:param bliss.scanning.scan.Scan scan:
"""
logger.debug("fill motor positions")
data = {}
data["positioners"] = positions = {}
data["positioners_dial"] = dials = {}
data["positioners_units"] = units = {}
for name, pos, dial, unit in global_map.get_axes_positions_iter(on_error="ERR"):
positions[name] = pos
dials[name] = dial
units[name] = unit
return data
def fill_instrument_name(scan):
"""
:param bliss.scanning.scan.Scan scan:
......
......@@ -327,9 +327,13 @@ def validate_instrument(
:param str master_name:
"""
# Positioner groups
expected_posg = {"positioners", "positioners_start", "positioners_dial_start"}
if config:
expected_posg |= {"positioners_end", "positioners_dial_end"}
expected_posg = {
"positioners",
"positioners_start",
"positioners_dial_start",
"positioners_end",
"positioners_dial_end",
}
# Detectors
expected_dets = expected_detectors(
config=config, technique=technique, detectors=detectors
......
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