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


Python PDFCalculator.setScatteringFactorTableByType方法代码示例

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


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

示例1: _makePDFCalculator

# 需要导入模块: from diffpy.srreal.pdfcalculator import PDFCalculator [as 别名]
# 或者: from diffpy.srreal.pdfcalculator.PDFCalculator import setScatteringFactorTableByType [as 别名]
def _makePDFCalculator(crst, cfgdict):
    '''Return a PDFCalculator object evaluated for a pyobjcryst.Crystal crst.
    '''
    inpdfcalc = lambda kv: kv[0] not in ('biso', 'type')
    pdfcargs = dict(filter(inpdfcalc, cfgdict.items()))
    pdfc = PDFCalculator(**pdfcargs)
    if 'biso' in cfgdict:
        setbiso = lambda sc: sc.mpScattPow.SetBiso(cfgdict['biso'])
        map(setbiso, crst.GetScatteringComponentList())
    if 'type' in cfgdict:
        pdfc.setScatteringFactorTableByType(cfgdict['type'])
    pdfc.eval(crst)
    # avoid metadata override by PDFFitStructure
    for k, v in pdfcargs.items():
        setattr(pdfc, k, v)
    return pdfc
开发者ID:XiaohaoYang,项目名称:diffpy.srreal,代码行数:18,代码来源:testpdfcalcobjcryst.py

示例2: testGenerator

# 需要导入模块: from diffpy.srreal.pdfcalculator import PDFCalculator [as 别名]
# 或者: from diffpy.srreal.pdfcalculator.PDFCalculator import setScatteringFactorTableByType [as 别名]
    def testGenerator(self):
        qmax = 27.0
        gen = PDFGenerator()
        gen.setScatteringType('N')
        self.assertEqual('N', gen.getScatteringType())
        gen.setQmax(qmax)
        self.assertAlmostEqual(qmax, gen.getQmax())
        from diffpy.Structure import PDFFitStructure
        stru = PDFFitStructure()
        ciffile = datafile("ni.cif")
        stru.read(ciffile)
        for i in range(4):
            stru[i].Bisoequiv = 1
        gen.setStructure(stru)

        calc = gen._calc
        # Test parameters
        for par in gen.iterPars(recurse = False):
            pname = par.name
            defval = calc._getDoubleAttr(pname)
            self.assertEquals(defval, par.getValue())
            # Test setting values
            par.setValue(1.0)
            self.assertEquals(1.0, par.getValue())
            par.setValue(defval)
            self.assertEquals(defval, par.getValue())

        r = numpy.arange(0, 10, 0.1)
        y = gen(r)

        # Now create a reference PDF. Since the calculator is testing its
        # output, we just have to make sure we can calculate from the
        # PDFGenerator interface.
        from diffpy.srreal.pdfcalculator import PDFCalculator
        calc = PDFCalculator()
        calc.rstep = r[1] - r[0]
        calc.rmin = r[0]
        calc.rmax = r[-1] + 0.5 * calc.rstep
        calc.qmax = qmax
        calc.setScatteringFactorTableByType('N')
        calc.eval(stru)
        yref = calc.pdf

        diff = y - yref
        res = numpy.dot(diff, diff)
        self.assertAlmostEquals(0, res)
        return
开发者ID:alperkinaci,项目名称:diffpy.srfit,代码行数:49,代码来源:testpdf.py


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