Пример #1
0
try:
    from databroker.v0 import Broker
except ModuleNotFoundError:
    from databroker import Broker

from databroker._core import register_builtin_handlers

#  srx detector, to be moved to filestore
# from databroker.assets.handlers import Xspress3HDF5Handler
from databroker.assets.handlers import HandlerBase

import logging

logger = logging.getLogger(__name__)

db = Broker.named("tes")
try:
    register_builtin_handlers(db.reg)
except Exception as ex:
    logger.error(f"Error while registering default SRX handlers: {ex}")


class BulkXSPRESS(HandlerBase):
    HANDLER_NAME = "XPS3_FLY"

    def __init__(self, resource_fn):
        self._handle = h5py.File(resource_fn, "r")

    def __call__(self):
        return self._handle["entry/instrument/detector/data"][:]
Пример #2
0
try:
    from databroker.v0 import Broker
except ModuleNotFoundError:
    from databroker import Broker

from databroker._core import register_builtin_handlers

#  srx detector, to be moved to filestore
# from databroker.assets.handlers import Xspress3HDF5Handler
from databroker.assets.handlers import HandlerBase

import logging

logger = logging.getLogger(__name__)

db = Broker.named("srx")
try:
    register_builtin_handlers(db.reg)
except Exception as ex:
    logger.error(f"Error while registering default SRX handlers: {ex}")


class BulkXSPRESS(HandlerBase):
    HANDLER_NAME = "XPS3_FLY"

    def __init__(self, resource_fn):
        self._handle = h5py.File(resource_fn, "r")

    def __call__(self):
        return self._handle["entry/instrument/detector/data"][:]
Пример #3
0
try:
    from databroker.v0 import Broker
except ModuleNotFoundError:
    from databroker import Broker

from databroker._core import register_builtin_handlers

#  srx detector, to be moved to filestore
# from databroker.assets.handlers import Xspress3HDF5Handler
from databroker.assets.handlers import HandlerBase

import logging

logger = logging.getLogger(__name__)

db = Broker.named("xfm")
try:
    register_builtin_handlers(db.reg)
except Exception as ex:
    logger.error(f"Error while registering default SRX handlers: {ex}")


class BulkXSPRESS(HandlerBase):
    HANDLER_NAME = "XPS3_FLY"

    def __init__(self, resource_fn):
        self._handle = h5py.File(resource_fn, "r")

    def __call__(self):
        return self._handle["entry/instrument/detector/data"][:]
Пример #4
0
from ophyd.signal import EpicsSignalBase
# EpicsSignalBase.set_default_timeout(timeout=10, connection_timeout=10)  # old style
EpicsSignalBase.set_defaults(timeout=10, connection_timeout=10)  # new style

import nslsii
from datetime import datetime

# Register bluesky IPython magics.
from bluesky.magics import BlueskyMagics

get_ipython().register_magics(BlueskyMagics)

from bluesky.preprocessors import stage_decorator, run_decorator
from databroker.v0 import Broker
db = Broker.named('fxi')
del Broker

nslsii.configure_base(get_ipython().user_ns, db, bec=True)

# Make new RE.md storage available in old environments.
from pathlib import Path

import appdirs

try:
    from bluesky.utils import PersistentDict
except ImportError:
    import msgpack
    import msgpack_numpy
    import zict
from pathlib import Path
from timeit import default_timer as timer
import shlex, subprocess

import bluesky.plan_stubs as bps
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
plt.ion()

from ophyd import (ProsilicaDetector, SingleTrigger, Component as Cpt, Device,
                   EpicsSignal, EpicsSignalRO, ImagePlugin, StatsPlugin, ROIPlugin,
                   DeviceStatus)


db_archiver = Broker.named('iss-archiver')
arch_iss  = db_archiver.event_sources_by_name['arch_iss']

# args = shlex.split('python /home/xf08id/.ipython/profile_sample-environment/iocs/ioc_ramping.py')
# args = shlex.split('conda activate collection-2021-1.2; gnome-terminal -e "python /home/xf08id/.ipython/profile_sample-environment/iocs/ioc_ramping.py"')
# args = shlex.split('"python /home/xf08id/.ipython/profile_sample-environment/iocs/ioc_ramping.py"')
ioc_args = shlex.split('gnome-terminal -- python /home/xf08id/.ipython/profile_sample-environment/iocs/ioc_ramping.py')
ioc_process = subprocess.Popen(ioc_args)


def get_pid(input_args):
    input = ['pidof'] + input_args
    return list(map(int, subprocess.check_output(input).split()))[0]

def kill_pid_ioc():
    pid_ioc = get_pid(ioc_args)
Пример #6
0
try:
    from databroker.v0 import Broker
except ModuleNotFoundError:
    from databroker import Broker

try:
   from pyxrf.api_dev import db
except ImportError:
    db = None
    print("Error importing pyXRF. Continuing without import.")

if not db:
    # Register the data broker
    try:
        db = Broker.named("srx")
    except AttributeError:
        db = Broker.named("temp")
        print("Using temporary databroker.")

pyxrf_version = pyxrf.__version__


def _extract_metadata_from_header(hdr):
    """
    Extract metadata from start and stop document. Metadata extracted from other document
    in the scan are beamline specific and added to dictionary at later time.
    """
    start_document = hdr.start

    mdata = ScanMetadataXRF()
Пример #7
0
try:
    from databroker.v0 import Broker
except ModuleNotFoundError:
    from databroker import Broker

from hxntools.handlers.xspress3 import Xspress3HDF5Handler
from hxntools.handlers.timepix import TimepixHDF5Handler

db = Broker.named("hxn")
# db_analysis = Broker.named('hxn_analysis')

db.reg.register_handler(Xspress3HDF5Handler.HANDLER_NAME,
                        Xspress3HDF5Handler,
                        overwrite=True)
db.reg.register_handler(TimepixHDF5Handler._handler_name,
                        TimepixHDF5Handler,
                        overwrite=True)