<commit_before>from ophyd.device import (Component as Cpt)
from hxntools.detectors.xspress3 import (Xspress3Detector, XspressTrigger,
                                         Xspress3FileStore, Xspress3Channel)


class HxnXspress3Detector(XspressTrigger, Xspress3Detector):
    channel1 = Cpt(Xspress3Channel, 'C1_', channel_num=1)
    channel2 = Cpt(Xspress3Channel, 'C2_', channel_num=2)
    channel3 = Cpt(Xspress3Channel, 'C3_', channel_num=3)
    # Currently only using three channels. Uncomment these to enable more
    # channels:
    # channel4 = C(Xspress3Channel, 'C4_', channel_num=4)
    # channel5 = C(Xspress3Channel, 'C5_', channel_num=5)
    # channel6 = C(Xspress3Channel, 'C6_', channel_num=6)
    # channel7 = C(Xspress3Channel, 'C7_', channel_num=7)
    # channel8 = C(Xspress3Channel, 'C8_', channel_num=8)

    hdf5 = Cpt(Xspress3FileStore, 'HDF5:',
               write_path_template='/data/%Y/%m/%d/')

    def __init__(self, prefix, *, configuration_attrs=None, read_attrs=None,
                 **kwargs):
        if configuration_attrs is None:
            configuration_attrs = ['external_trig', 'total_points',
                                   'spectra_per_point']
        if read_attrs is None:
            read_attrs = ['channel1', 'channel2', 'channel3', 'hdf5']
        super().__init__(prefix, configuration_attrs=configuration_attrs,
                         read_attrs=read_attrs, **kwargs)


xspress3 = HxnXspress3Detector('XF:03IDC-ES{Xsp:1}:', name='xspress3')

# Create directories on the xspress3 server, otherwise scans can fail:
xspress3.make_directories.put(True)


def xspress3_roi_setup():
    for channel in [xspress3.channel1, xspress3.channel2, xspress3.channel3]:
        channel.set_roi(1, 9300, 9600, name='Pt')
        channel.set_roi(2, 1590, 1890, name='Si')
        channel.set_roi(3, 2150, 2450, name='S')
        channel.set_roi(4, 2000, 2300, name='Zr')<commit_msg>Update xspress3 config using hxn-specific detector<commit_after>from ophyd.device import (Component as Cpt)

from hxntools.detectors.xspress3 import (Xspress3FileStore,
                                         Xspress3Channel)
from hxntools.detectors.hxn_xspress3 import HxnXspress3DetectorBase


class HxnXspress3Detector(HxnXspress3DetectorBase):
    channel1 = Cpt(Xspress3Channel, 'C1_', channel_num=1)
    channel2 = Cpt(Xspress3Channel, 'C2_', channel_num=2)
    channel3 = Cpt(Xspress3Channel, 'C3_', channel_num=3)
    # Currently only using three channels. Uncomment these to enable more
    # channels:
    # channel4 = C(Xspress3Channel, 'C4_', channel_num=4)
    # channel5 = C(Xspress3Channel, 'C5_', channel_num=5)
    # channel6 = C(Xspress3Channel, 'C6_', channel_num=6)
    # channel7 = C(Xspress3Channel, 'C7_', channel_num=7)
    # channel8 = C(Xspress3Channel, 'C8_', channel_num=8)

    hdf5 = Cpt(Xspress3FileStore, 'HDF5:',
               write_path_template='/data/%Y/%m/%d/',
               mds_key_format='xspress3_ch{chan}',
               )

    def __init__(self, prefix, *, configuration_attrs=None, read_attrs=None,
                 **kwargs):
        if configuration_attrs is None:
            configuration_attrs = ['external_trig', 'total_points',
                                   'spectra_per_point']
        if read_attrs is None:
            read_attrs = ['channel1', 'channel2', 'channel3', 'hdf5']
        super().__init__(prefix, configuration_attrs=configuration_attrs,
                         read_attrs=read_attrs, **kwargs)


xspress3 = HxnXspress3Detector('XF:03IDC-ES{Xsp:1}:', name='xspress3')


# Create directories on the xspress3 server, otherwise scans can fail:
xspress3.make_directories.put(True)


def xspress3_roi_setup():
    for channel in [xspress3.channel1, xspress3.channel2, xspress3.channel3]:
        channel.set_roi(1, 9300, 9600, name='Pt')
        channel.set_roi(2, 1590, 1890, name='Si')
        channel.set_roi(3, 2150, 2450, name='S')
        channel.set_roi(4, 2000, 2300, name='Zr')
{'fraction_non_alphanumeric': 0.11721887550200803, 'fraction_numerical': 0.04894578313253012, 'mean_word_length': 3.2941810344827585, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5988333', 'n_tokens_mistral': 1470, 'n_tokens_neox': 1395, 'n_words': 262}