本文整理汇总了Python中diffpy.srreal.pdfcalculator.PDFCalculator.maskAllPairs方法的典型用法代码示例。如果您正苦于以下问题:Python PDFCalculator.maskAllPairs方法的具体用法?Python PDFCalculator.maskAllPairs怎么用?Python PDFCalculator.maskAllPairs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类diffpy.srreal.pdfcalculator.PDFCalculator
的用法示例。
在下文中一共展示了PDFCalculator.maskAllPairs方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestPDFCalculator
# 需要导入模块: from diffpy.srreal.pdfcalculator import PDFCalculator [as 别名]
# 或者: from diffpy.srreal.pdfcalculator.PDFCalculator import maskAllPairs [as 别名]
#.........这里部分代码省略.........
"""
frutile = datafile('TiO2_rutile-fit.fgr')
gpf2 = numpy.loadtxt(frutile, usecols=(1,))
# configure calculator according to testdata/TiO2_ruitile-fit.fgr
self.pdfcalc.qmax = 26
self.pdfcalc.qdamp = 0.0665649
dscale = 0.655857
self.pdfcalc.rmin = 1
self.pdfcalc.rmax = 30.0001
# apply data scale
self.pdfcalc(self.tio2rutile)
self.pdfcalc.scale *= dscale
gcalc = self.pdfcalc.pdf
# termination at rmin is poorly cut in PDFfit2
mxnd = _maxNormDiff(gpf2, gcalc)
self.failUnless(mxnd < 0.057)
# more accurate from 1.5
mxnd1 = _maxNormDiff(gpf2[:500], gcalc[:500])
mxnd2 = _maxNormDiff(gpf2[500:], gcalc[500:])
self.failUnless(mxnd1 < 0.056)
self.failUnless(mxnd2 < 0.020)
return
def test_partial_pdfs(self):
"""Check calculation of partial PDFs.
"""
pdfc = self.pdfcalc
pdfc.rstep = 0.1
rutile = self.tio2rutile
atomtypes = [a.element for a in rutile]
r0, g0 = pdfc(rutile)
rdf0 = pdfc.rdf
# Ti-Ti
pdfc.maskAllPairs(False)
pdfc.setTypeMask("Ti", "Ti", True)
r1, g1 = pdfc(rutile)
rdf1 = pdfc.rdf
self.failUnless(numpy.array_equal(r0, r1))
pdfc.invertMask()
r1i, g1i = pdfc(rutile)
rdf1i = pdfc.rdf
self.failUnless(numpy.array_equal(r0, r1i))
self.failUnless(numpy.allclose(g0, g1 + g1i))
self.failUnless(numpy.allclose(rdf0, rdf1 + rdf1i))
# Ti-O
pdfc.maskAllPairs(True)
pdfc.setPairMask(range(2), range(2), False)
pdfc.setPairMask(range(2, 6), range(2, 6), False)
r2, g2 = pdfc(rutile)
rdf2 = pdfc.rdf
self.failUnless(numpy.array_equal(r0, r2))
pdfc.invertMask()
r2i, g2i = pdfc(rutile)
rdf2i = pdfc.rdf
self.failUnless(numpy.allclose(g0, g2 + g2i))
self.failUnless(numpy.allclose(rdf0, rdf2 + rdf2i))
# Ti-O using type mask
pdfc.maskAllPairs(True)
pdfc.setTypeMask("Ti", "Ti", False)
pdfc.setTypeMask("O", "O", False)
r2t, g2t = pdfc(rutile)
rdf2t = pdfc.rdf
self.failUnless(numpy.array_equal(r0, r2t))
self.failUnless(numpy.array_equal(g2, g2t))
self.failUnless(numpy.array_equal(rdf2, rdf2t))
pdfc.invertMask()