Scan metadata that lives only for one scan
If you register a function with USER_SCAN_META
which adds scan parameters to the Nexus file, you currently have to do either of these two things
- Check the scan in the metadata generating function:
from bliss.scanning.scan_meta import get_user_scan_meta
metadata = get_user_scan_meta()
def myscan_params(scan):
"""
:param bliss.scanning.scan.Scan scan:
:returns dict:
"""
if ...: # checks whether this is the correct scan
return {"scan_parameters", scan.scan_info["..."]}
else:
return {}
metadata.instrument.set("myscanparams", myscan_params)
- Register/unregister the metadata generating function in the function that launches the scan (this suffers from race conditions with parallel scans):
def myscan(...):
metadata.instrument.set("myscanparams", myscan_params)
try:
... # run the scan
finally:
metadata.instrument.remove("myscanparams")
@papillon asked for a better way. Something that only exists when the scan runs. Maybe scans should have a metadata method like controllers? Or maybe we reserve a special key in scan_info
which holds the metadata (you'll have some duplication)? @matias.guijarro @pithan Any suggestions?
Edited by Wout De Nolf