コード例 #1
0
ファイル: fitting.py プロジェクト: B-Rich/hexrd
def matchOmegas(xyo_det, hkls_idx, chi, rMat_c, bMat, wavelength, 
                vInv=vInv_ref, beamVec=bVec_ref, etaVec=eta_ref, 
                omePeriod=None):
    """
    For a given list of (x, y, ome) points, outputs the index into the results from
    oscillAnglesOfHKLs, including the calculated omega values.
    """
    # get omegas for rMat_s calculation
    if omePeriod is not None:
        meas_omes = xf.mapAngle(xyo_det[:, 2], omePeriod)
    else:
        meas_omes = xyo_det[:, 2]
    
    oangs0, oangs1 = xf.oscillAnglesOfHKLs(hkls_idx, chi, rMat_c, bMat, wavelength, 
                                           vInv=vInv, 
                                           beamVec=beamVec, 
                                           etaVec=etaVec)

    if omePeriod is not None:
        calc_omes  = np.vstack( [xf.mapAngle(oangs0[2, :], omePeriod), 
                                 xf.mapAngle(oangs1[2, :], omePeriod) ] )
    else:
        calc_omes  = np.vstack( [xf.mapAngle(oangs0[2, :]), 
                                 xf.mapAngle(oangs1[2, :]) ] )
        
    match_omes = np.argsort(abs(np.tile(meas_omes, (2, 1)) - calc_omes), axis=0) == 0
    calc_omes  = calc_omes.T.flatten()[match_omes.T.flatten()]

    return match_omes, calc_omes
コード例 #2
0
rMat_c = xf.makeRotMatOfExpMap(np.array( [ [ 0.66931818],
                                           [-0.98578066],
                                           [ 0.73593251] ] ) )

vInv_s = np.c_[ -2.10434927e-04,  -9.51655879e-05,   5.21695993e-05,
                -7.69921049e-05,  -7.75926245e-05,  -2.49452890e-04].T
# vInv_s = np.c_[1., 1., 1., 0., 0., 0.].T

# ######################################################################

# oscillation angle arrays
n=22
start1 = time.clock()                      # time this
for i in range(n):
    oangs01, oangs11 = xf.oscillAnglesOfHKLs(hklsT, chi, rMat_c, bMat, wavelength, 
                                             vInv=vInv_s, beamVec=bVec_ref, etaVec=eta_ref)
elapsed1 = (time.clock() - start1)
print "Time for Python oscillAnglesOfHKLs: %f"%elapsed1

start2 = time.clock()                      # time this
for i in range(n):
    oangs02, oangs12 = xfcapi.oscillAnglesOfHKLs(hkls, chi, rMat_c, bMat, wavelength, 
                                                 vInv=vInv_s, beamVec=bVec_ref, etaVec=eta_ref)
elapsed2 = (time.clock() - start2)
print "Time for CAPI oscillAnglesOfHKLs:   %f"%elapsed2
#print oangs01.shape, oangs11.shape
#print oangs02.shape, oangs12.shape
#print np.linalg.norm(oangs01[:,0]),np.linalg.norm(oangs01[:,1]),np.linalg.norm(oangs01[:,2])
#print np.linalg.norm(oangs11[:,0]),np.linalg.norm(oangs11[:,1]),np.linalg.norm(oangs11[:,2])
print "Maximum Relative Differences: %f, %f"%(np.linalg.norm(oangs01-oangs02.T)/np.linalg.norm(oangs01),np.linalg.norm(oangs11-oangs12.T)/np.linalg.norm(oangs11))
コード例 #3
0
    np.array([[0.66931818], [-0.98578066], [0.73593251]]))

vInv_s = np.c_[-2.10434927e-04, -9.51655879e-05, 5.21695993e-05,
               -7.69921049e-05, -7.75926245e-05, -2.49452890e-04].T
# vInv_s = np.c_[1., 1., 1., 0., 0., 0.].T

# ######################################################################

# oscillation angle arrays
n = 22
start1 = time.clock()  # time this
for i in range(n):
    oangs01, oangs11 = xf.oscillAnglesOfHKLs(hklsT,
                                             chi,
                                             rMat_c,
                                             bMat,
                                             wavelength,
                                             vInv=vInv_s,
                                             beamVec=bVec_ref,
                                             etaVec=eta_ref)
elapsed1 = (time.clock() - start1)
print "Time for Python oscillAnglesOfHKLs: %f" % elapsed1

start2 = time.clock()  # time this
for i in range(n):
    oangs02, oangs12 = xfcapi.oscillAnglesOfHKLs(hkls,
                                                 chi,
                                                 rMat_c,
                                                 bMat,
                                                 wavelength,
                                                 vInv=vInv_s,
                                                 beamVec=bVec_ref,