In this notebook you will:
Below, we will connect to EPICS IOC(s) controlling simulated hardware in lieu of actual motors, detectors. The IOCs should already be running in the background. Run this command to verify that they are running: it should produce output with RUNNING on each line. In the event of a problem, edit this command to replace status
with restart all
and run again.
!supervisorctl -c supervisor/supervisord.conf status
%run scripts/beamline_configuration.py
RE(scan([ph], motor_ph, -1, 1, 5), sample_comp='Ni', barcode='12345')
import suitcase.csv
suitcase.csv.export(db[-1].documents(fill=True), 'my_exported_files/')
suitcase.csv.export(db[-1].documents(fill=True), 'my_exported_files/', file_prefix='{start[sample_comp]}-{start[barcode]}-')
suitcase.csv.export(db[-1].documents(fill=True), 'my_exported_files/', file_prefix='{start[sample_comp]}/{start[barcode]}-')
RE(scan([spot], mtr_spotx, -1, 1, 5), sample_comp='Ni', barcode='12345')
import suitcase.tiff_stack
suitcase.tiff_stack.export(db[-1].documents(fill=True), 'my_exported_files/', file_prefix='{start[sample_comp]}/{start[barcode]}-')
import suitcase.tiff_series
Unlike CSV or TIFF stack, this exporter creates separate file per row (Event document). We can include information from a specific Event in the filename. Here, we include the motor position.
suitcase.tiff_series.export(db[-1].documents(fill=True), 'my_exported_files/', file_prefix='{start[sample_comp]}/{start[barcode]}/{event[data][motor_spotx]}-')
We plan to streamline this in the future, but here is a demonstration that it is possible.
# Execute this once to configure RE to send data to an exporter.
# At the beamline, this would normally be done in a script automatically at startup.
from event_model import RunRouter
from databroker.core import discover_handlers
def factory(name, start_doc):
serializer = suitcase.tiff_series.Serializer(
'my_exported_files/', file_prefix='{start[sample_comp]}/{start[barcode]}-{start[uid]:.8}-')
def cb(name, doc):
serializer(name, doc)
return [cb], []
rr = RunRouter([factory], discover_handlers())
RE.subscribe(rr)
RE(count([spot], num=30, delay=1), sample_comp='Lab6', barcode='12345')