当前位置: 首页>>代码示例>>Python>>正文


Python Group.fl_corr方法代码示例

本文整理汇总了Python中larch.Group.fl_corr方法的典型用法代码示例。如果您正苦于以下问题:Python Group.fl_corr方法的具体用法?Python Group.fl_corr怎么用?Python Group.fl_corr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在larch.Group的用法示例。


在下文中一共展示了Group.fl_corr方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: gsexdi_deadtime_correct

# 需要导入模块: from larch import Group [as 别名]
# 或者: from larch.Group import fl_corr [as 别名]
def gsexdi_deadtime_correct(fname, channelname, subdir='DT_Corrected',
                            bad=None, _larch=None):
    """convert GSE XDI fluorescence XAFS scans to dead time corrected files"""
    if not is_GSEXDI(fname):
        print("'%s' is not a GSE XDI scan file\n" % fname)
        return

    out = Group()
    out.orig_filename = fname
    try:
        xdi = read_gsexdi(fname, bad=bad, _larch=_larch)
    except:
        print('Could not read XDI file ', fname)
        return

    for attr in ('energy', 'i0', 'i1', 'i2', 'tscaler',
                 'counttime',  'scan_start_time', 'scan_end_time'):
        if hasattr(xdi, attr):
            setattr(out, attr, getattr(xdi, attr))

    # some scans may not record separate counttime, but TSCALER
    # is clock ticks for a 50MHz clock
    if not hasattr(out, 'counttime'):
        out.counttime = xdi.tscaler * 2.e-8

    if hasattr(xdi, 'energy_readback'):
        out.energy = xdi.energy_readback

    mono_cut = 'Si(111)'
    if xdi.mono_dspacing < 2:
        mono_cut = 'Si(311)'
    header_args = {'mono_dspace': xdi.mono_dspacing, 'mono_cut': mono_cut}

    arrname = None
    channelname = channelname.lower().replace(' ', '_')

    for arr in xdi.array_labels:
        if arr.lower().startswith(channelname):
            arrname = arr
            break
    if arrname is None:
        print('Cannot find Channel %s in file %s '% (channelname, fname))
        return

    out.fl_corr = getattr(xdi, arrname)
    out.fl_raw  = getattr(xdi, arrname)
    arrname_raw = arrname + '_nodtc'
    if arrname_raw  in xdi.array_labels:
        out.fl_raw  = getattr(xdi, arrname_raw)

    out.mufluor = out.fl_corr / out.i0

    npts   = len(out.energy)
    ncol   = 6

    arrlabel = ['#', ' energy ', ' mufluor ', ' i0  ', ' fluor_dtc',
                ' fluor_raw', ' counttime']

    header = DTC_header % header_args
    buff   = [l.strip() for l in header.split('\n')]

    has_i1, has_i2 = False, False
    if hasattr(out, 'i1'):
        ncol += 1
        buff.append('# Column.%i: itrans ' % ncol)
        arrlabel.append(' itrans ')
        has_i1 = True
    if hasattr(out, 'i2'):
        ncol += 1
        buff.append('# Column.%i: irefer ' % ncol)
        arrlabel.append(' irefer ')
        has_i2 = True
    arrlabel = '       '.join(arrlabel)

    buff.extend(["# Scan.start_time: %s" % out.scan_start_time,
                 "# ///",
                 "# summed %s fluorescence data from %s" % (channelname, fname),
                 "# Dead-time correction applied",
                 "#---------------------------------",
                 arrlabel])

    fmt = "   %11.3f %15.8f %14.3f %16.5f %14.2f %14.3f"
    for i in range(npts):
        dline = fmt % (out.energy[i],  out.mufluor[i], out.i0[i],
                       out.fl_corr[i], out.fl_raw[i], out.counttime[i])
        if has_i1:  dline = "%s %14.3f" % (dline, out.i1[i])
        if has_i2:  dline = "%s %14.3f" % (dline, out.i2[i])
        buff.append(dline)

    ofile = fname[:]
    if ofile.startswith('..'):
        ofile = ofile[3:]
    ofile = ofile.replace('.', '_') + '.dat'
    ofile = os.path.join(subdir, ofile)
    if not os.path.exists(subdir):
        os.mkdir(subdir)
    try:
       fout = open(ofile, 'w')
       fout.write("\n".join(buff))
       fout.close()
#.........这里部分代码省略.........
开发者ID:Henry0422,项目名称:xraylarch,代码行数:103,代码来源:gse_xdiscan.py


注:本文中的larch.Group.fl_corr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。