本文整理匯總了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()