本文整理汇总了Python中Analysis.offset_correction方法的典型用法代码示例。如果您正苦于以下问题:Python Analysis.offset_correction方法的具体用法?Python Analysis.offset_correction怎么用?Python Analysis.offset_correction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Analysis
的用法示例。
在下文中一共展示了Analysis.offset_correction方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: tesana
# 需要导入模块: import Analysis [as 别名]
# 或者: from Analysis import offset_correction [as 别名]
#.........这里部分代码省略.........
header='Time (s), Template (A.U.)', delimiter='\t')
np.savetxt('%s-sn.dat' % session, np.vstack((np.arange(len(sn))*df, sn/np.sqrt(df))).T,
header='Frequency (Hz), S/N (/srHz)', delimiter='\t')
if plotting:
# Plot template
figure()
plot(t, tmpl)
xlabel('Time$\quad$(s)')
ylabel('Template$\quad$(A.U.)')
tight_layout()
savefig('%s-template.pdf' % session)
# Plot SNR
figure()
plot(np.arange(len(sn))*df, sn/np.sqrt(df))
loglog()
xlabel('Frequency$\quad$(Hz)')
ylabel('S/N$\quad$(/$\sqrt{\mathrm{Hz}}$)')
tight_layout()
savefig('%s-sn.pdf' % session)
# Calculate baseline resolution
print "Resolving power: %.2f (%.2f eV @ 5.9 keV)" % (np.sqrt((sn**2).sum()*2), Analysis.baseline(sn))
# Perform optimal filtering
pha_p = Filter.optimal_filter(p, tmpl, max_shift=max_shift)
pha_n = Filter.optimal_filter(n, tmpl, max_shift=0)
# Offset correction
(a, b), coef = Analysis.fit_offset(pha_p, offset, sigma=sigma, method=ocmethod, flip=flip)
if coef > thre:
oc_pha_p = Analysis.offset_correction(pha_p, offset, b)
oc_pha_n = Analysis.offset_correction(pha_n, offset, b)
print "Offset correction with: PHA = %f * (1 + %f * Offset)" % (a, b)
if plotting:
figure()
ka = Analysis.ka(np.vstack((pha_p, offset)).T, sigma=sigma)
plot(ka.T[1], ka.T[0], '.', c='k')
x_min, x_max = xlim()
ofs = np.linspace(x_min, x_max)
label = '$\mathrm{PHA}=%.2f\\times(1+%.2f\\times\mathrm{Offset})$' % (a, b)
plot(ofs, a*(1+b*ofs), 'r-', label=label)
xlabel('Offset$\quad$(V)')
ylabel('PHA$\quad$(V)')
legend(frameon=False)
tight_layout()
savefig('%s-offset.pdf' % session)
else:
oc_pha_p = pha_p
oc_pha_n = pha_n
print "Skipped offset correction: correlation coefficient (%f) is too small" % coef
# Check line database
if "%sKa" % atom not in Constants.LE.keys() or "%sKb" % atom not in Constants.LE.keys():
raise ValueError('Unsupported atom: %s' % atom)
# Linearity correction
pha_line_center = np.asarray([ np.median(Analysis.ka(oc_pha_p, sigma=sigma)), np.median(Analysis.kb(oc_pha_p, sigma=sigma)) ])
line_energy = np.asarray([ Constants.LE['%sKa' % atom], Constants.LE['%sKb' % atom] ])
if ignorekb:
a, b = Analysis.fit_linearity([pha_line_center[0]], [line_energy[0]], deg=1)
print "Linearity correction with: PHA = %e * E" % (b)