Ejemplo n.º 1
0
from databroker import Broker
import numpy as np
import sys, os
import h5py
try:
    from nsls2ptycho.core.widgets.imgTools import rm_outlier_pixels
except ModuleNotFoundError:
    # for test purpose
    from widgets.imgTools import rm_outlier_pixels

from hxntools.handlers import register
try:
    # new mongo database
    hxn_db = Broker.named('hxn')
    register(hxn_db)
except FileNotFoundError:
    print("hxn.yml not found. Unable to access HXN's database.", file=sys.stderr)
    hxn_db = None

#######################################


def load_metadata(db, scan_num:int, det_name:str):
    '''
    Get all metadata for the given scan number and detector name

    Parameters:
        - db: 
            a Broker instance. For HXN experiments they are db1, db2, and db_old
        - scan_num: int
            the scan number
from hxntools.detectors.merlin import MerlinDetector
from hxntools.handlers import register
import itertools
from pathlib import PurePath
from hxntools.detectors.xspress3 import (XspressTrigger, Xspress3Detector,
                                         Xspress3Channel, Xspress3FileStore,
                                         logger)
from databroker.assets.handlers import Xspress3HDF5Handler, HandlerBase
from ophyd.signal import set_and_wait
from enum import Enum
from ophyd.signal import set_and_wait
from collections import OrderedDict
from ophyd import Staged
from ophyd.status import DeviceStatus

register(db)


class TESMode(Enum):
    step = 1
    fly = 2


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'][:]