本文整理汇总了Python中larch.Group.fl_raw方法的典型用法代码示例。如果您正苦于以下问题:Python Group.fl_raw方法的具体用法?Python Group.fl_raw怎么用?Python Group.fl_raw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类larch.Group
的用法示例。
在下文中一共展示了Group.fl_raw方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: gsexdi_deadtime_correct
# 需要导入模块: from larch import Group [as 别名]
# 或者: from larch.Group import fl_raw [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()
#.........这里部分代码省略.........