示例#1
0
    def test_combine(self):
        x,y = self.edxdata['LaB6']
        unit_cell = [4.15695,4.15695,4.15695,90,90,90]
        space_group = 'pm-3m'            
        cal1 = search_match_fit(x,y,unit_cell,space_group,qmax=10,**self.searchkwargs)

        x,y = self.edxdata['CeO2']
        unit_cell = [5.411,5.411,5.411,90,90,90]
        space_group = 'fm-3m'            
        cal2 = search_match_fit(x,y,unit_cell,space_group,qmax=10,**self.searchkwargs)

        x,y = self.edxdata['Si']
        unit_cell = [5.4307,5.4307,5.4307,90,90,90]
        space_group = 'fd-3m'       
        cal3 = search_match_fit(x,y,unit_cell,space_group,qmax=10,**self.searchkwargs)
                
        cal = sum([cal1,cal2,cal3])
        f = createCalibrationPlot(cal)
        f.savefig('all_cal.png',dpi=400)

        self.assertLess(abs(cal.values[0]),1e-9)
        self.assertAlmostEqual(cal.values[1], 0.001942,5)
        self.assertLess(abs(cal.values[2]),0.005) 
        self.assertNotIn(cal,[cal1,cal2,cal3])
     
        col1 = Collection()
        col1['Detector1'] = cal1
        col1['Detector2'] = cal1

        col2 = Collection()
        col2['Detector1'] = cal2
        col2['Detector2'] = cal2

        col = sum([col1,col2])
        self.assertLess(abs(col['Detector1'].values[0]),1e-9)
        self.assertAlmostEqual(col['Detector1'].values[1], 0.001942,5)
        self.assertLess(abs(col['Detector1'].values[2]),0.005) 

        col3 = Collection()
        col3['Detector1'] = cal3
        col3['Detector2'] = cal3

        col = col1 + col2 + col3
        
        self.assertLess(abs(col['Detector1'].values[0]),1e-9)
        self.assertAlmostEqual(col['Detector1'].values[1], 0.001942,5)
        self.assertLess(abs(col['Detector1'].values[2]),0.005) 

        col2['Detector3'] = cal2
        self.assertRaises(TypeError,sum,[3,col2])
示例#2
0
    def test_calibrate_LaB6(self):
        x,y = self.edxdata['LaB6']
        unit_cell = [4.15691,4.15691,4.15691,90,90,90]
        space_group = 'pm-3m'            
        
        c = search_match_fit(x,y,unit_cell,space_group,qmin=2,qmax=10,**self.searchkwargs)
        f = createCalibrationPlot(c)
        f.savefig('lab6_cal.png',dpi=200)

        self.assertLess(abs(c.values[0]),1e-9)
        self.assertAlmostEqual(c.values[1], 0.001942,5)
        self.assertLess(abs(c.values[2]),0.005)
示例#3
0
    def test_calibrate_Si(self):
        x,y = self.edxdata['Si']
        unit_cell = [5.4307,5.4307,5.4307,90,90,90]
        space_group = 'fd-3m'       
    
        c = search_match_fit(x,y,unit_cell,space_group,qmax=10,**self.searchkwargs)
        
        f = createCalibrationPlot(c)
        f.savefig('si_cal.png',dpi=200)

        self.assertLess(abs(c.values[0]),1e-9)
        self.assertAlmostEqual(c.values[1], 0.001948,5)
        self.assertLess(abs(c.values[2]),0.005)
示例#4
0
import matplotlib.pyplot as plt

from edxrd import test
from edxrd import calibration

#get some data and prepare the constants we need
edx = test.getedxdata()
x,y = edx['LaB6']
unit_cell = [4.15695,4.15695,4.15695,90,90,90]
space_group = 'pm-3m' 

#test the search and peak fitting part
settings = test.test_search_settings()
cal = calibration.search_match_fit(x,y,unit_cell,space_group,**settings)

#the rest is all plotting
sob = cal.search[0] #calibration objects may have data from several spectra
f,axs = plt.subplots(2,sharex=True)
ax1,ax2 = axs
ax1.plot(sob.x,sob.y,'b')
ax1.plot(sob.x,sob.pfit,'r')
ax1.plot(sob.centres,sob.heights, 'ro',markerfacecolor='none')
ax1.set_yscale('log')

mob = cal.match[0] #calibration objects may have data from several spectra
ax2.plot(mob.candidates.filtered,mob.known.filtered,'ko')
ax2.plot(cal.xfit,cal.yfit,'r--')
ax2.set_xbound(0,mob.candidates.filtered.max())

#Now test the method without using peak search
#i.e. some candidates found by some other method preferred by the user