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


Python PdfFit.pdfrange方法代码示例

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


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

示例1: save_resExceptions

# 需要导入模块: from diffpy.pdffit2 import PdfFit [as 别名]
# 或者: from diffpy.pdffit2.PdfFit import pdfrange [as 别名]
class save_resExceptions(unittest.TestCase):

    def setUp(self):
        self.P = PdfFit()
        self.resfile = "temp.res"

    def tearDown(self):
        del self.P

    def test_IOError(self):
        """raise IOError when residual file cannot be saved"""
        self.P.read_struct(datafile("Ni.stru"))
        self.P.read_data(datafile("Ni.dat"), 'X', 30.0, 0.0)
        self.P.constrain(self.P.lat(1), 1)
        self.P.setpar(1, 3.0)
        self.P.pdfrange(1,2.0,10.0)
        self.P.refine_step()
        self.assertRaises(IOError, self.P.save_res,
                "nodir183160/"+self.resfile)

    def test_unassignedError(self):
        """raise pdffit2.unassignedError when structure is undefined"""
        self.assertRaises(pdffit2.unassignedError, self.P.save_res,
        self.resfile)
开发者ID:cfarrow,项目名称:diffpy.pdffit2,代码行数:26,代码来源:ExceptionsTest.py

示例2: TestPdfFit

# 需要导入模块: from diffpy.pdffit2 import PdfFit [as 别名]
# 或者: from diffpy.pdffit2.PdfFit import pdfrange [as 别名]

#.........这里部分代码省略.........

    def test_num_datasets(self):
        """check PdfFit.num_datasets()
        """
        self.assertEqual(0, self.P.num_datasets())
        self.P.read_data(datafile('Ni.dat'), 'X', 25.0, 0.5)
        self.assertEqual(1, self.P.num_datasets())
        # failed data should not increase num_datasets
        try:
            self.P.read_data(datafile('badNi.dat'))
        except:
            pass
        self.assertEqual(1, self.P.num_datasets())
        # alloc should increase number of datasets
        # alloc requires a loaded structure
        self.P.read_struct(datafile('Ni.stru'))
        self.P.alloc('X', 30.0, 0.05, 2, 10, 100)
        self.assertEqual(2, self.P.num_datasets())
        self.P.reset()
        self.assertEqual(0, self.P.num_datasets())
        return

    def test_getcrw(self):
        """check PdfFit.getcrw()
        """
        import numpy
        self.assertEqual(0, self.P.num_datasets())
        # Setting qmax=0 so that partial crw are not disturbed by
        # termination ripples.
        self.P.read_data(datafile('Ni.dat'), 'X', 0.0, 0.0)
        # crw is empty before data refinement
        self.assertEqual([], self.P.getcrw())
        self.P.read_struct(datafile('Ni.stru'))
        self.P.pdfrange(1, 2, 19)
        self.P.refine()
        crw19 = numpy.array(self.P.getcrw())
        self.failUnless(numpy.all(crw19 >= 0.0))
        # check that crw19 is non decreasing
        self.failUnless(numpy.all(numpy.diff(crw19) >= 0.0))
        # check that crw19 and getrw give the same value
        rw19 = crw19[-1]
        self.assertAlmostEqual(self.P.getrw(), rw19, self.places)
        # renormalize cumulative Rw and compare with Rw at r=15
        Gobs19 = numpy.array(self.P.getpdf_obs())
        Gnorm19 = numpy.sqrt(numpy.sum(Gobs19**2))
        r = numpy.array(self.P.getR())
        idx = numpy.nonzero(r <= 15)[0]
        Gnorm15 = numpy.sqrt(numpy.sum(Gobs19[idx]**2))
        i15 = idx[-1]
        rw15 = crw19[i15] * Gnorm19 / Gnorm15
        self.P.pdfrange(1, 2, r[i15] + 1e-5)
        self.P.refine()
        self.assertAlmostEqual(self.P.getrw(), rw15, self.places)
        return

    def test_getcrw_two_datasets(self):
        """check that getcrw() and getrw() are consistent for two datasets.
        """
        self.P.read_data(datafile('Ni.dat'), 'X', 25.0, 0.0)
        self.P.pdfrange(1, 2, 8)
        self.P.read_data(datafile('300K.gr'), 'N', 32.0, 0.0)
        self.P.pdfrange(2, 1, 11)
        self.P.read_struct(datafile('Ni.stru'))
        # mess lattice parameters to have comparable Rw contributions
        self.P.setvar('lat(1)', 3)
        self.P.setvar('lat(2)', 3)
开发者ID:diffpy,项目名称:diffpy.pdffit2,代码行数:70,代码来源:TestPdfFit.py

示例3: range

# 需要导入模块: from diffpy.pdffit2 import PdfFit [as 别名]
# 或者: from diffpy.pdffit2.PdfFit import pdfrange [as 别名]
pf.setpar(21, 0.03)

# Refine sharpening factor for correlated motion of close atoms.
pf.constrain(pf.delta2, 22)
pf.setpar(22, 0.0003)

# Set all temperature factors isotropic and equal to @4
for idx in range(1, 5):
    pf.constrain(pf.u11(idx), '@4')
    pf.constrain(pf.u22(idx), '@4')
    pf.constrain(pf.u33(idx), '@4')
pf.setpar(4, pf.u11(1))

# Refine ---------------------------------------------------------------------

pf.pdfrange(1, 1.5, 19.99)
pf.refine()

# Save results ---------------------------------------------------------------

pf.save_pdf(1, "Ni_refinement.fgr")
pf.save_struct(1, "Ni_refinement.rstr")
pf.save_res("Ni_refinement.res")

# Plot results ---------------------------------------------------------------

# pylab is matplotlib interface with MATLAB-like plotting commands
import pylab

# obtain data from PdfFit calculator object
r = pf.getR()
开发者ID:cfarrow,项目名称:diffpy.pdffit2,代码行数:33,代码来源:Ni_refinement.py


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