コード例 #1
0
ファイル: test_strain.py プロジェクト: matthewjpeel/edxrd
 def test_q0_fit(self):
     q0 = 2.685
     ex,ey,exy = 0.002,-0.002,-0.002
 
     #the azimuthal angle in radians
     phi = np.linspace(-np.pi/2,np.pi/2,23) #23 detectors over 180 deg
     
     #create some fake peak positions
     q = q0 - q0*(ex*np.cos(phi)**2 + ey*np.sin(phi)**2 + exy*np.sin(2*phi))
     #add some noise
     q += np.random.uniform(-0.00002,0.00002,q.size)
     #data/error in uncertainties.unumpy array (poisson statistics)
     q = unumpy.uarray((q,np.sqrt(q)))
     
     result = strain.strain_from_q(q,phi)
     #check the results
     self.assertAlmostEqual(q0,result['q0'].nominal_value,4)
コード例 #2
0
ファイル: helpers.py プロジェクト: matthewjpeel/edxrd
def calcstrain(source,phi,Q0=None,allow_shear=True):

    if len(phi) > 2:
        take = np.ones(len(phi)).astype(bool)
        take[5] = take[8] = False
    else:
        take=np.ones(2).astype(bool)

    for fit,result,info in source:

        info['azimuth'] = phi[take]
        for key,subresult in result.iteritems():
            if Q0 is not None: q0=Q0[key]
            else: q0=None
            s = strain.strain_from_q(subresult['centre'][take],phi[take],q0,allow_shear)
            subresult.update(s)
            subresult.update(info) #
        yield fit,result,info
コード例 #3
0
ファイル: test_strain.py プロジェクト: matthewjpeel/edxrd
 def test_qstrain_2calc(self):  
     #create some fake strains
     d0=2.34
     e1=0.002
     e2=-0.0012
     e12=0.000
     #convert to q
     q0 = 2*np.pi/d0
     #the azimuthal angle
     phi = np.array([0,np.pi/2])
     edata = q0 - q0*(e1*np.cos(phi)**2 + e2*np.sin(phi)**2 + e12*np.sin(2*phi))
     edata += np.random.uniform(-0.00002,0.00002,edata.size)
     edata = unumpy.uarray((edata,np.sqrt(edata)))
     #fit
     result = strain.strain_from_q(edata,phi,q0)
     #check the results
     self.assertAlmostEqual(e1,result['strain_x'].nominal_value,4)
     self.assertAlmostEqual(e2,result['strain_y'].nominal_value,4)
     self.assertAlmostEqual(0,result['strain_xy'].nominal_value,4)
     
     #check this fails if too many phi
     badphi = np.array([0.1,np.pi/3])
     self.assertRaises(ValueError,strain.strain_from_q,edata,badphi,d0)