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


Python Analysis.linearity_correction方法代码示例

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


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

示例1: tesana

# 需要导入模块: import Analysis [as 别名]
# 或者: from Analysis import linearity_correction [as 别名]

#.........这里部分代码省略.........
                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)
        else:
            a, b = Analysis.fit_linearity(pha_line_center, line_energy, deg=2)
            print "Linearity correction with: PHA = %e * E^2 + %e * E" % (a, b)
            print "MnKb saturation ratio: %.2f %%" % ((pha_line_center[1]/pha_line_center[0])/(line_energy[1]/line_energy[0])*100)

        lc_pha_p = Analysis.linearity_correction(oc_pha_p, a, b)
        lc_pha_n = Analysis.linearity_correction(oc_pha_n, a, b)

        if savedat:
            np.savetxt('%s-linearity.dat' % session, array([pha_line_center[0]]) if ignorekb else pha_line_center[np.newaxis,:],
                header='%sKa PHA' % atom if ignorekb else '%sKa PHA, %sKb PHA' % (atom, atom), delimiter='\t')
    
        if plotting:
            figure()
            x = np.linspace(0, 7e3)
            if ignorekb:
                plot(line_energy[0]/1e3, pha_line_center[0], '+', color='b')
                plot(x/1e3, x*b, 'r--')
            else:
                plot(line_energy/1e3, pha_line_center, '+', color='b')
                plot(x/1e3, x**2*a+x*b, 'r--')
            xlim((0, 7))
            xlabel('Energy$\quad$(keV)')
            ylabel('PHA$\quad$(a.u.)')
            tight_layout()
            savefig('%s-linearity.pdf' % session)
    
        # Energy Spectrum
        if plotting:
            figure()
            hcount, hbin, hpatch = hist(lc_pha_p[lc_pha_p==lc_pha_p]/1e3, bins=7000/binsize, histtype='stepfilled', color='y')
            xlim(0, 7)
            xlabel('Energy$\quad$(keV)')
            ylabel('Count')
            tight_layout()
            savefig('%s-spec.pdf' % session)

        if savedat:
开发者ID:robios,项目名称:PyTES,代码行数:70,代码来源:Util.py


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