%matplotlib widget
%run startup.py
# Set up simulated hardware.
from ophyd.sim import SynGauss, SynAxis
motor = SynAxis(name='motor')
det = SynGauss('det', motor, 'motor', center=0, Imax=1,
noise='uniform', sigma=1, noise_multiplier=0.1)
# Generate an Excel spreadsheet we can use.
import pandas as pd
SAMPLE_MAP = {'sample1': {'name': 'AS-21_Spent', 'pos': 252},
'sample2': {'name': 'AS-21', 'pos': 259},
'sample3': {'name': 'AS-4-1_Spent', 'pos': 267},
'sample4': {'name': '30CoCeO2', 'pos': 276},
'sample5': {'name': '8CoCeO2', 'pos': 282},
'sample6': {'name': '2CoCeO2', 'pos': 290},
}
pd.DataFrame.from_dict(SAMPLE_MAP, orient='index').to_excel('samples.xlsx')
samples = pd.read_excel('samples.xlsx')
samples
def multi_sample_count(detectors, samples, position_motor,
md=None, **kwargs):
"For a table (DataFrame) of samples, move to the sample location and 'count'."
dets = list(detectors) + [position_motor]
for i, sample in samples.iterrows():
# Combine sample metadata with any user-specified metadata.
_md = dict(sample)
_md.update(md or {})
# Extract the sample position from the table and move the motor there.
pos = sample['pos']
yield from mv(position_motor, pos)
# Count.
yield from count(dets, md=_md, **kwargs)
RE(multi_sample_count([det], samples, motor))
# All of the data
db.get_table(db())
# Filter by 'name' metadata (originally extracted from spreadsheet)
db.get_table(db(name='AS-21'))
# another example
db.get_table(db(name='30CoCeO2'))
multi_sample_count
named multi_sample_scan
that scans motor
from -1 to 1 relative to the sample position.plan_name='multi_sample_scan'
to narrow search results to scans (excluding previous data from counts).multi_sample_count
that is a list of sample names. Then make it skip any rows in the spreadsheet that with sample names not in that whitelist.