コード例 #1
0
 def test_ticker_override(self):
     """check method override for PeakProfile.ticker in a derived class.
     """
     pkf = MySawTooth()
     self.assertEqual(0, pkf.tcnt)
     et0 = pkf.ticker()
     self.assertEqual(1, pkf.tcnt)
     et1 = PeakProfile.ticker(pkf)
     self.assertEqual(1, pkf.tcnt)
     self.assertEqual(et0, et1)
     et0.click()
     self.assertEqual(et0, et1)
     # check that implicit ticker call from PDFCalculator is
     # handled by the Python ticker override.
     pc = PDFCalculator()
     pc.peakprofile = pkf
     pc.ticker()
     self.assertEqual(2, pkf.tcnt)
     return
コード例 #2
0
 def test_ticker_override(self):
     """check method override for PeakProfile.ticker in a derived class.
     """
     pkf = MySawTooth()
     self.assertEqual(0, pkf.tcnt)
     et0 = pkf.ticker()
     self.assertEqual(1, pkf.tcnt)
     et1 = PeakProfile.ticker(pkf)
     self.assertEqual(1, pkf.tcnt)
     self.assertEqual(et0, et1)
     et0.click()
     self.assertEqual(et0, et1)
     # check that implicit ticker call from PDFCalculator is
     # handled by the Python ticker override.
     pc = PDFCalculator()
     pc.peakprofile = pkf
     pc.ticker()
     self.assertEqual(2, pkf.tcnt)
     return
コード例 #3
0
ファイル: nirectpdf.py プロジェクト: DanOlds/diffpy_examples
# -*- coding: utf-8 -*-

from __future__ import print_function
import matplotlib.pyplot as plt
from diffpy.Structure import loadStructure
from diffpy.srreal.pdfcalculator import PDFCalculator
from rectangleprofile import RectangleProfile

ni = loadStructure('ni.cif')
# The CIF file had no displacement data so we supply them here:
ni.Uisoequiv = 0.005

# Calculate PDF with default profile function
pc1 = PDFCalculator()
r1, g1 = pc1(ni)
print("standard peakprofile:\n    " + repr(pc1.peakprofile))

# Create new calculator that uses the custom profile function
pc2 = PDFCalculator()
pc2.peakprofile = RectangleProfile()
# Note:  pc2.peakprofile = 'rectangleprofile'
# would do the same, because RectangleProfile class was registered
# under its 'rectangleprofile' identifier.
print("custom peakprofile:\n    " + repr(pc1.peakprofile))
r2, g2 = pc2(ni)

# compare both simulated curves
plt.plot(r1, g1, r2, g2)
plt.draw()
plt.show()
コード例 #4
0
ファイル: nirectpdf.py プロジェクト: ahmedpsi/cmi_exchange
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from matplotlib.pyplot import *
from diffpy.Structure import loadStructure
from diffpy.srreal.pdfcalculator import PDFCalculator
from rectangleprofile import RectangleProfile

ni = loadStructure('ni.cif')
# The CIF file had no displacement data so we supply them here:
ni.Uisoequiv = 0.005

# Calculate PDF with default profile function
pc1 = PDFCalculator()
r1, g1 = pc1(ni)
print "standard peakprofile:\n    " + repr(pc1.peakprofile)

# Create new calculator that uses the custom profile function
pc2 = PDFCalculator()
pc2.peakprofile = RectangleProfile()
# Note:  pc2.peakprofile = 'rectangleprofile'
# would do the same, because RectangleProfile class was registered
# under its 'rectangleprofile' identifier.
print "custom peakprofile:\n    " + repr(pc1.peakprofile)
r2, g2 = pc2(ni)

# compare both simulated curves
plot(r1, g1, r2, g2)
draw()
show()