q_grid = eu2quat(bungeAngs).T """ use sklearn KDTree for reduction of points for query (euclidean) """ qgrid_pos = np.copy(q_grid) qgrid_pos[qgrid_pos[:,0] < 0] *= -1 tree = KDTree(qgrid_pos) #rotation around path in space phi = np.linspace(0,2*np.pi,365) rad = np.sqrt( 2 * ( 1 - np.cos(0.5*theta) ) ) euc_rad = np.sqrt( 4 * np.sin(0.25*theta)**2 ) # q_path = calcFibre(hkls,xyz_pf,q_grid,phi,rad,tree,euc_rad) symOps = genSymOps('m-3m') symOps = np.unique(np.swapaxes(symOps,2,0),axis=0) """ sym ops """ proper = np.where( np.linalg.det(symOps) == 1 ) #proper orthogonal quatSymOps = quat.from_matrix(symOps[proper]) quatSymOps = np.tile(quatSymOps[:,:,np.newaxis],(1,1,len(phi))) quatSymOps = quatSymOps.transpose((0,2,1)) """ create small grid centered around [001] """ polar_stepN = 9 polar_step = np.deg2rad(5) / (polar_stepN-1) polar = np.arange(0,polar_stepN) * polar_step
testSym = symOri(test.as_matrix(), cs, ss) #try transpose testSym = testSym.transpose((0, 2, 1)) # convert to euler testSym_eu = om2eu(testSym) # pick fundamental zone fz = (testSym_eu[:, 0] <= 2 * np.pi) & (testSym_eu[:, 1] <= np.pi / 2) & ( testSym_eu[:, 2] <= np.pi / 2) fz_idx = np.nonzero(fz) g_fz = testSym[fz_idx[0], :, :] # generate crystal sym ops crysSymOps = genSymOps(cs) smplSymOps = genSymOps(ss) # create Nx3 array of grid points eu_grid = np.array( [od.phi1cen.flatten(), od.Phicen.flatten(), od.phi2cen.flatten()]).T g_grid = eu2om(eu_grid, out='mdarray_2') g_grid = g_grid.transpose((2, 0, 1)) trace = {} misori = {} mo_cell = [] for gi, g in enumerate(g_fz):
""" symmetry after """ fibre_e = {} fibre_q = {} weights = {} hkls = normalize(hkls) """ search for unique hkls to save time """ hkls_loop, uni_hkls_idx, hkls_loop_idx = np.unique(hkls, axis=0, return_inverse=True, return_index=True) symHKL_loop = symmetrise(crystalSym, hkls_loop) symHKL_loop = normalize(symHKL_loop) symOps = genSymOps(crystalSym) symOps = np.unique(np.swapaxes(symOps, 2, 0), axis=0) """ only use proper rotations """ """ complicated, simplify? """ proper = np.where(np.linalg.det(symOps) == 1) #proper orthogonal quatSymOps = quat.from_matrix(symOps[proper]) quatSymOps = np.tile(quatSymOps[:, :, np.newaxis], (1, 1, len(omega))) quatSymOps = quatSymOps.transpose((2, 0, 1)) """ gen quats from bunge grid """ bungeAngs = np.zeros((np.product(od.phi1cen.shape), 3)) for ii, i in enumerate(np.ndindex(od.phi1cen.shape)): bungeAngs[ii, :] = np.array((od.phi1cen[i], od.Phicen[i], od.phi2cen[i]))