當前位置: 首頁>>代碼示例>>Python>>正文


Python PDFCalculator.rmax方法代碼示例

本文整理匯總了Python中diffpy.srreal.pdfcalculator.PDFCalculator.rmax方法的典型用法代碼示例。如果您正苦於以下問題:Python PDFCalculator.rmax方法的具體用法?Python PDFCalculator.rmax怎麽用?Python PDFCalculator.rmax使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在diffpy.srreal.pdfcalculator.PDFCalculator的用法示例。


在下文中一共展示了PDFCalculator.rmax方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test__getDoubleAttr

# 需要導入模塊: from diffpy.srreal.pdfcalculator import PDFCalculator [as 別名]
# 或者: from diffpy.srreal.pdfcalculator.PDFCalculator import rmax [as 別名]
 def test__getDoubleAttr(self):
     """check Attributes._getDoubleAttr()
     """
     pdfc = PDFCalculator()
     pdfc.foo = 11
     self.assertRaises(AttributeError, pdfc._getDoubleAttr, 'foo')
     pdfc._registerDoubleAttribute('foo')
     self.assertEqual(11, pdfc._getDoubleAttr('foo'))
     pdfc.rmax = 22
     self.assertEqual(22, pdfc._getDoubleAttr('rmax'))
     setattr(pdfc, 'rmax', 23)
     self.assertEqual(23, pdfc._getDoubleAttr('rmax'))
     self.assertRaises(Exception, setattr, pdfc, 'rmax', 'xxx')
     return
開發者ID:diffpy,項目名稱:diffpy.srreal,代碼行數:16,代碼來源:testattributes.py

示例2: testGenerator

# 需要導入模塊: from diffpy.srreal.pdfcalculator import PDFCalculator [as 別名]
# 或者: from diffpy.srreal.pdfcalculator.PDFCalculator import rmax [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

示例3: loadStructure

# 需要導入模塊: from diffpy.srreal.pdfcalculator import PDFCalculator [as 別名]
# 或者: from diffpy.srreal.pdfcalculator.PDFCalculator import rmax [as 別名]
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from diffpy.Structure import loadStructure
from diffpy.srreal.pdfcalculator import PDFCalculator
from matplotlib.pyplot import plot, show

cds = loadStructure('CdS_wurtzite.cif')
pc1 = PDFCalculator()
pc1.rmax = 20
pc1.scatteringfactortable.setCustomAs('S2-', 'S', 18)
pc1.scatteringfactortable.lookup('S2-')
r1, g1 = pc1(cds)
plot(r1, g1)

pc2 = pc1.copy()
cds2 = loadStructure('CdS_wurtzite.cif')
cds2.anisotropy = False
r2, g2 = pc2(cds2)
plot(r2, g2)
plot(r1, g1-g2)
show()
開發者ID:XiaohaoYang,項目名稱:srfit-demos,代碼行數:24,代碼來源:ex01.py


注:本文中的diffpy.srreal.pdfcalculator.PDFCalculator.rmax方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。