@ValidateLarchPlugin
def read_gsexdi(fname, _larch=None, nmca=4, bad=None, **kws):
    """Read GSE XDI Scan Data to larch group,
    summing ROI data for MCAs and apply deadtime corrections
    """
    group = _larch.symtable.create_group()
    group.__name__ ='GSE XDI Data file %s' % fname
    xdi = XDIFile(str(fname))

    group._xdi = xdi
    group.filename = fname
    group.npts = xdi.npts
    group.bad_channels = bad
    group.dtc_taus = XSPRESS3_TAUS
    if _larch.symtable.has_symbol('_sys.gsecars.xspress3_taus'):
        group.dtc_taus = _larch.symtable._sys.gsecars.xspress3_taus

    for family in ('scan', 'mono', 'facility'):
        for key, val in xdi.attrs.get(family, {}).items():
            if '||' in val:
                val, addr = val.split('||')
            try:
                val = float(val)
            except:
                pass
            setattr(group, "%s_%s" % (family, key), val)

    ocrs, icrs = [], []
    try:
        ctime = xdi.CountTime
    except __HOLE__:
        ctime = xdi.TSCALER / 5.e7
    is_xspress3 = any(['13QX4' in a[1] for a in xdi.attrs['column'].items()])
    group.with_xspress3 = is_xspress3
    for i in range(nmca):
        ocr = getattr(xdi, 'OutputCounts_mca%i' % (i+1), None)
        if ocr is None:
            ocr = ctime
        ocr = ocr/ctime
        icr = getattr(xdi, 'InputCounts_mca%i' % (i+1), None)
        if icr is not None:
            icr = icr/ctime
        else:
            icr = 1.0*ocr
            if is_xspress3:
                tau = group.dtc_taus[i]
                icr = estimate_icr(ocr*1.00, tau, niter=7)
        ocrs.append(ocr)
        icrs.append(icr)
    labels = []
    sums = OrderedDict()
    for i, arrname in enumerate(xdi.array_labels):
        dat = getattr(xdi, arrname)
        aname = sumname = rawname = arrname.lower()
        if ('_mca' in aname and 'outputcounts' not in aname and
            'clock' not in aname):
            sumname, imca = sumname.split('_mca')
            imca = int(imca) - 1
            datraw = dat*1.0
            rawname = sumname + '_nodtc'
            dat   = dat * icrs[imca]/ ocrs[imca]
            if any(np.isnan(dat)):
                nan_pts = np.where(np.isnan(dat))[0]
                dat[nan_pts] = datraw[nan_pts]
            
        setattr(group, aname, dat)
        if sumname not in labels:
            labels.append(sumname)
            sums[sumname] = dat
            if rawname != sumname:
                sums[rawname] = datraw
                if rawname not in labels:
                    labels.append(rawname)

        else:
            sums[sumname] = sums[sumname] + dat
            if rawname != sumname:
                sums[rawname] = sums[rawname] + datraw

    for name, dat in sums.items():
        if not hasattr(group, name):
            setattr(group, name, dat)

    for arrname in xdi.array_labels:
        sname = arrname.lower()
        if sname not in labels:
            labels.append(sname)

    for imca in range(nmca):
        setattr(group, 'ocr_mca%i' % (imca+1), ocrs[imca])
        setattr(group, 'icr_mca%i' % (imca+1), icrs[imca])


    group.array_labels = labels
    return group
dataset/ETHPy150Open xraypy/xraylarch/plugins/io/gse_xdiscan.py/read_gsexdi