def __init__(self, mode='debug'): self.RE = bluesky.RunEngine({}) self.db = databroker.Broker.named("mongodb_config") self.RE.subscribe(self.db.insert) self.RE.subscribe(BestEffortCallback()) self._mode = mode from apstools.devices import ApsMachineParametersDevice self._aps = ApsMachineParametersDevice(name="APS") self.shutter = Experiment.get_shutter(mode) self.suspend_shutter = SuspendFloor(self.shutter.pss_state, 1)
from pygerm.handler import GeRMHandler, BinaryGeRMHandler import numpy as np import pandas as pd from lmfit import Model # generic configuration, is already on the beamline reg = Registry({'dbpath': '/tmp/fs.sqlite'}) reg.register_handler('GeRM', GeRMHandler) reg.register_handler('BinaryGeRM', BinaryGeRMHandler) mds = MDS({'directory': '/tmp/mds.sqlite', 'timezone': 'US/Eastern'}) db = Broker(mds, reg=reg) RE = bs.RunEngine() RE.subscribe(db.insert) # create the GeRM object germ = GeRM('XF:28IDC-ES:1{Det:GeRM1}', name='germ', read_attrs=[ 'filepath', 'last_file', 'chip', 'chan', 'td', 'pd', 'ts', 'count' ], configuration_attrs=['frametime']) # gaussian fit def gaussian(x, area, center, sigma):
import bluesky.callbacks as bc import csv from ophyd.sim import motor, det import matplotlib.pyplot as plt # Do this if running the example interactively; # skip it when building the documentation. import os if 'BUILDING_DOCS' not in os.environ: from bluesky.utils import install_qt_kicker # for notebooks, qt -> nb install_qt_kicker() plt.ion() det.exposure_time = .1 # simulate detector exposure time RE = bs.RunEngine({}) ############################################################################### # Define a callback class which writes out a CSV file class CSVWriter(bc.CallbackBase): def __init__(self, fields, fname_format, fpath): self._path = path.Path(fpath) os.makedirs(self._path, exist_ok=True) self._fname_fomat = fname_format self._fields = fields self._writer = None self._fout = None def close(self):
socket yaml for you, rejoice. ''') # ----- Setup base bluesky RunEngine and MongoDB ----- # # metadata streamed to MongoDB server over the network import databroker metadata_db = databroker.Broker.named("mongodb_config") keywords_vars['metadata_db'] = 'Default metadata handler' # setup RunEngine from bluesky.callbacks.best_effort import BestEffortCallback RE = bluesky.RunEngine({}) keywords_vars['RE'] = 'Default RunEngine instance' RE.subscribe(metadata_db.insert) RE.subscribe(BestEffortCallback()) RE.md['beamline_id'] = 'APS 6-BM-A' RE.md['proposal_id'] = 'internal test' RE.md['pid'] = os.getpid() RE.md['login_id'] = USERNAME + '@' + HOSTNAME RE.md['versions'] = {} RE.md['versions']['apstools'] = apstools.__version__ RE.md['versions']['bluesky'] = bluesky.__version__ RE.md['versions']['databroker'] = databroker.__version__ RE.md['versions']['matplotlib'] = matplotlib.__version__ RE.md['versions']['numpy'] = np.__version__ RE.md['versions']['ophyd'] = ophyd.__version__