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


Python pdffit2.PdfFit类代码示例

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


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

示例1: pdfrangeExceptions

class pdfrangeExceptions(unittest.TestCase):

    def setUp(self):
        self.P = PdfFit()
        self.iset = 1
        self.rmin = 4.0
        self.rmax = 10.0

    def tearDown(self):
        del self.P

    def test_ValueError1(self):
        """raise ValueError when iset does not exist"""
        self.assertRaises(ValueError, self.P.pdfrange, self.iset, self.rmin,
                self.rmax)

    def test_ValueError2(self):
        """raise ValueError when rmax < rmin"""
        self.P.read_data(datafile("Ni.dat"), 'X', 25.0, 0.5)
        self.assertRaises(ValueError, self.P.pdfrange, self.iset, self.rmax,
                self.rmin)

    def test_ValueError3(self):
        """raise ValueError when range outside of data"""
        self.P.read_data(datafile("Ni.dat"), 'X', 25.0, 0.5)
        self.assertRaises(ValueError, self.P.pdfrange, self.iset, -self.rmin,
                self.rmax)
开发者ID:cfarrow,项目名称:diffpy.pdffit2,代码行数:27,代码来源:ExceptionsTest.py

示例2: load_ipython_extension

def load_ipython_extension(ipython):
    from diffpy.pdffit2 import PdfFit
    pf = PdfFit()
    pdf = EasyPDFPlotting(pf)
    print('        Type  help(pdffit)  or  help(topic)  for information.')
    print
    ns = dict(pdffit=PdfFit, pdf=pdf)
    pf._exportAll(ns)
    ipython.user_ns.update(ns)
    return
开发者ID:diffpy,项目名称:diffpy.pdffit2,代码行数:10,代码来源:ipy_ext.py

示例3: calcExceptions

class calcExceptions(unittest.TestCase):

    def setUp(self):
        self.P = PdfFit()
        self.P.read_struct(datafile("Ni.stru"))

    def tearDown(self):
        del self.P

    def test_unassignedError(self):
        """raise pdffit2.unassignedError when no space has been allocated"""
        self.assertRaises(pdffit2.unassignedError, self.P.calc)
开发者ID:cfarrow,项目名称:diffpy.pdffit2,代码行数:12,代码来源:ExceptionsTest.py

示例4: setdataExceptions

class setdataExceptions(unittest.TestCase):

    def setUp(self):
        self.P = PdfFit()

    def tearDown(self):
        del self.P

    def test_unassignedError(self):
        """raise pdffit2.unassignedError when data set does not exist"""
        self.P.read_struct(datafile("Ni.stru"))
        self.P.read_data(datafile("Ni.dat"), 'X', 25.0, 0.0)
        self.assertRaises(pdffit2.unassignedError, self.P.setdata, 2)
开发者ID:cfarrow,项目名称:diffpy.pdffit2,代码行数:13,代码来源:ExceptionsTest.py

示例5: bangExceptions

class bangExceptions(unittest.TestCase):

    def setUp(self):
        self.P = PdfFit()
        self.a1 = 1
        self.a2 = 2
        self.a3 = 3

    def tearDown(self):
        del self.P

    def test_unassignedError(self):
        """raise pdffit2.unassignedError when phase does not exist"""
        self.assertRaises(pdffit2.unassignedError, self.P.bang, self.a1,
                self.a2, self.a3)

    def test_ValueError1(self):
        """raise ValueError when selected atom(s) does not exist"""
        self.P.read_struct(datafile('Ni.stru'))
        self.P.read_data(datafile("Ni.dat"), 'X', 25.0, 0.0)
        self.assertRaises(ValueError, self.P.bang, 0,
                self.a2, self.a3)

    def test_ValueError2(self):
        """raise ValueError when selected atom(s) does not exist"""
        self.P.read_struct(datafile('Ni.stru'))
        self.assertRaises(ValueError, self.P.bang, self.a1,
                -1, self.a3)

    def test_ValueError3(self):
        """raise ValueError when selected atom(s) does not exist"""
        self.P.read_struct(datafile('Ni.stru'))
        self.assertRaises(ValueError, self.P.bang, self.a1,
                self.a2, 6)
开发者ID:cfarrow,项目名称:diffpy.pdffit2,代码行数:34,代码来源:ExceptionsTest.py

示例6: setUp

 def setUp(self):
     self.P = PdfFit()
     self.qmax = 25
     self.qdamp = 0.5
     self.rmin = 4.0
     self.rmax = 10.0
     self.bin = 100
开发者ID:cfarrow,项目名称:diffpy.pdffit2,代码行数:7,代码来源:ExceptionsTest.py

示例7: setUp

 def setUp(self):
     self.P = PdfFit()
     self.P.read_struct(datafile('Ni.stru'))
     self.P.read_struct(datafile('PbScW25TiO3.stru'))
     self.P.alloc('X', 0.0, 0.05, 0.1, 10, 200)
     self.P.alloc('N', 0.0, 0.05, 0.1, 10, 200)
     return
开发者ID:cfarrow,项目名称:diffpy.pdffit2,代码行数:7,代码来源:TestPhaseFractions.py

示例8: getparExceptions

class getparExceptions(unittest.TestCase):

    def setUp(self):
        self.P = PdfFit()

    def tearDown(self):
        del self.P

    def test_unassignedError1(self):
        """raise pdffit2.unassignedError when parameter does not exist"""
        self.assertRaises(pdffit2.unassignedError, self.P.getpar, 1)

    def test_unassignedError2(self):
        """raise pdffit2.unassignedError when parameter does not exist"""
        self.P.read_struct(datafile("Ni.stru"))
        self.P.constrain(self.P.lat(1), 2)
        self.assertRaises(pdffit2.unassignedError, self.P.getpar, 1)
开发者ID:cfarrow,项目名称:diffpy.pdffit2,代码行数:17,代码来源:ExceptionsTest.py

示例9: getvarExceptions

class getvarExceptions(unittest.TestCase):

    def setUp(self):
        self.P = PdfFit()

    def tearDown(self):
        del self.P

    def test_unassignedError(self):
        """raise pdffit2.unassignedError when variable is undefined"""
        self.assertRaises(pdffit2.unassignedError, self.P.getvar,
                self.P.pscale())

    def test_ValueError(self):
        """raise ValueError when a variable index does not exist"""
        self.P.read_struct(datafile("Ni.stru"))
        self.assertRaises(ValueError, self.P.getvar, self.P.lat(7))
开发者ID:cfarrow,项目名称:diffpy.pdffit2,代码行数:17,代码来源:ExceptionsTest.py

示例10: pdeselExceptions

class pdeselExceptions(unittest.TestCase):

    def setUp(self):
        self.P = PdfFit()
        self.ip = 1

    def tearDown(self):
        del self.P

    def test_unassignedError1(self):
        """raise pdffit2.unassignedError when phase does not exist"""
        self.assertRaises(pdffit2.unassignedError, self.P.pdesel, self.ip)

    def test_unassignedError2(self):
        """raise pdffit2.unassignedError when phase does not exist"""
        self.P.read_struct(datafile("Ni.stru"))
        self.assertRaises(pdffit2.unassignedError, self.P.pdesel, self.ip)
开发者ID:cfarrow,项目名称:diffpy.pdffit2,代码行数:17,代码来源:ExceptionsTest.py

示例11: save_structExceptions

class save_structExceptions(unittest.TestCase):
    #Same code as show_struct

    def setUp(self):
        self.P = PdfFit()
        self.strufile = "temp.stru"

    def tearDown(self):
        del self.P

    def test_IOError(self):
        """raise IOError when structure cannot be saved"""
        self.P.read_struct(datafile("Ni.stru"))
        self.assertRaises(IOError, self.P.save_struct, 1,
                "nodir183160/"+self.strufile)

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

示例12: selectNoneExceptions

class selectNoneExceptions(unittest.TestCase):

    def setUp(self):
        self.P = PdfFit()
        self.iset = 1
        self.i = 1

    def tearDown(self):
        del self.P

    def test_unassignedError1(self):
        """raise pdffit2.unassignedError when set does not exist"""
        self.assertRaises(pdffit2.unassignedError, self.P.selectNone,
                self.iset, 'i')

    def test_unassignedError2(self):
        """raise pdffit2.unassignedError when set does not exist"""
        self.P.read_struct(datafile("Ni.stru"))
        # fail when there is no dataset
        self.assertRaises(pdffit2.unassignedError, self.P.selectNone,
                self.iset, 'i')
        # pass with dataset
        self.P.read_data(datafile("Ni.dat"), 'X', 25.0, 0.0)
        self.P.selectNone(self.iset, 'i')
        self.P.selectNone(self.iset, 'j')
        # fail for phase 2
        self.assertRaises(pdffit2.unassignedError, self.P.selectNone, 2, 'i')
        self.assertRaises(pdffit2.unassignedError, self.P.selectNone, 2, 'j')
开发者ID:cfarrow,项目名称:diffpy.pdffit2,代码行数:28,代码来源:ExceptionsTest.py

示例13: blenExceptions

class blenExceptions(unittest.TestCase):

    def setUp(self):
        self.P = PdfFit()
        self.a1 = 1
        self.a2 = 2

    def tearDown(self):
        del self.P

    def test_unassignedError(self):
        """raise pdffit2.unassignedError when no data exists"""
        self.assertRaises(pdffit2.unassignedError, self.P.blen, self.a1,
                self.a2)

    def test_ValueError1(self):
        """raise ValueError when selected atom(s) does not exist"""
        self.P.read_struct(datafile('Ni.stru'))
        self.assertRaises(ValueError, self.P.blen, 0, self.a2)

    def test_ValueError2(self):
        """raise ValueError when selected atom(s) does not exist"""
        self.P.read_struct(datafile('Ni.stru'))
        self.assertRaises(ValueError, self.P.blen, self.a1, 6)

    def test_ValueError3(self):
        """raise ValueError when selected atom(s) does not exist"""
        self.P.read_struct(datafile('Ni.stru'))
        self.assertRaises(ValueError, self.P.blen, 0, 6)
开发者ID:cfarrow,项目名称:diffpy.pdffit2,代码行数:29,代码来源:ExceptionsTest.py

示例14: save_difExceptions

class save_difExceptions(unittest.TestCase):

    def setUp(self):
        self.P = PdfFit()
        self.strufile = "temp.dif"

    def tearDown(self):
        del self.P

    def test_IOError(self):
        """raise IOError when dif cannot be saved"""
        self.P.read_struct(datafile("Ni.stru"))
        self.P.alloc('X', 30.0, 0.05, 2, 10, 100)
        self.P.calc()
        self.P.read_data(datafile("Ni.dat"), 'X', 25.0, 0.5)
        self.assertRaises(IOError, self.P.save_dif, 1,
                "nodir183160/"+self.strufile)

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

示例15: TestPhaseFractions

class TestPhaseFractions(unittest.TestCase):

    places = 4

    def setUp(self):
        self.P = PdfFit()
        self.P.read_struct(datafile('Ni.stru'))
        self.P.read_struct(datafile('PbScW25TiO3.stru'))
        self.P.alloc('X', 0.0, 0.05, 0.1, 10, 200)
        self.P.alloc('N', 0.0, 0.05, 0.1, 10, 200)
        return

    def tearDown(self):
        del self.P
        return

    def test_xray_fractions(self):
        """test_xray_fractions -- check phase fractions in x-ray dataset.
        """
        self.P.setdata(1)
        ph = self.P.phase_fractions()
        bb1 = 28**2
        bb2 = ((8*82 + 24*8 + 4*21 + 2*74 + 2*22) / 40.0)**2
        self.assertAlmostEqual(1.0, sum(ph['atom']), self.places)
        self.assertAlmostEqual(1.0, sum(ph['cell']), self.places)
        self.assertAlmostEqual(1.0, sum(ph['mass']), self.places)
        self.assertAlmostEqual(bb2/bb1,
                ph['atom'][0]/ph['atom'][1], self.places)
        self.assertAlmostEqual(bb2/bb1 * 40.0/4.0,
                ph['cell'][0]/ph['cell'][1], self.places)
        mavg1 = 58.69
        mavg2 = (8*207.19 + 24*15.994 + 4*44.956 + 2*183.85 + 2*47.90)/40.0
        self.assertAlmostEqual(bb2/bb1 * mavg1/mavg2,
                ph['mass'][0]/ph['mass'][1], self.places)
        self.assertEqual(0.0, sum(ph['stdatom']))
        self.assertEqual(0.0, sum(ph['stdcell']))
        self.assertEqual(0.0, sum(ph['stdmass']))
        self.P.setphase(1)
        self.P.setvar('pscale', 2.0)
        ph2 = self.P.phase_fractions()
        self.assertAlmostEqual(1.0, sum(ph2['atom']), self.places)
        self.assertAlmostEqual(1.0, sum(ph2['cell']), self.places)
        self.assertAlmostEqual(1.0, sum(ph2['mass']), self.places)
        self.assertAlmostEqual(2.0, ph2['atom'][0]/ph2['atom'][1] /
                (ph['atom'][0]/ph['atom'][1]), self.places)
        self.assertAlmostEqual(2.0, ph2['cell'][0]/ph2['cell'][1] /
                (ph['cell'][0]/ph['cell'][1]), self.places)
        self.assertAlmostEqual(2.0, ph2['mass'][0]/ph2['mass'][1] /
                (ph['mass'][0]/ph['mass'][1]), self.places)
        return

    def test_neutron_fractions(self):
        """test_neutron_fractions -- check phase fractions in neutron dataset.
        """
        self.P.setdata(2)
        ph = self.P.phase_fractions()
        bb1 = 10.31**2
        bPb = 9.4012
        bO = 5.8054
        bSc = 12.11
        bW = 4.75518
        bTi = -3.37013
        bb2 = ((8*bPb + 24*bO + 4*bSc + 2*bW + 2*bTi) / 40.0)**2
        self.assertAlmostEqual(1.0, sum(ph['atom']), self.places)
        self.assertAlmostEqual(1.0, sum(ph['cell']), self.places)
        self.assertAlmostEqual(1.0, sum(ph['mass']), self.places)
        self.assertAlmostEqual(bb2/bb1,
                ph['atom'][0]/ph['atom'][1], self.places)
        self.assertAlmostEqual(bb2/bb1 * 40.0/4.0,
                ph['cell'][0]/ph['cell'][1], self.places)
        mavg1 = 58.69
        mavg2 = (8*207.19 + 24*15.994 + 4*44.956 + 2*183.85 + 2*47.90)/40.0
        self.assertAlmostEqual(bb2/bb1 * mavg1/mavg2,
                ph['mass'][0]/ph['mass'][1], self.places)
        self.assertEqual(0.0, sum(ph['stdatom']))
        self.assertEqual(0.0, sum(ph['stdcell']))
        self.assertEqual(0.0, sum(ph['stdmass']))
        self.P.setphase(1)
        self.P.setvar('pscale', 2.0)
        ph2 = self.P.phase_fractions()
        self.assertAlmostEqual(1.0, sum(ph2['atom']), self.places)
        self.assertAlmostEqual(1.0, sum(ph2['cell']), self.places)
        self.assertAlmostEqual(1.0, sum(ph2['mass']), self.places)
        self.assertAlmostEqual(2.0, ph2['atom'][0]/ph2['atom'][1] /
                (ph['atom'][0]/ph['atom'][1]), self.places)
        self.assertAlmostEqual(2.0, ph2['cell'][0]/ph2['cell'][1] /
                (ph['cell'][0]/ph['cell'][1]), self.places)
        self.assertAlmostEqual(2.0, ph2['mass'][0]/ph2['mass'][1] /
                (ph['mass'][0]/ph['mass'][1]), self.places)
        return
开发者ID:cfarrow,项目名称:diffpy.pdffit2,代码行数:90,代码来源:TestPhaseFractions.py


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