Module: xrd.transforms_CAPI¶
19 Functions¶
- hexrd.xrd.transforms_CAPI.makeGVector(hkl, bMat)[source]¶
take a CRYSTAL RELATIVE B matrix onto a list of hkls to output unit reciprocal lattice vectors (a.k.a. lattice plane normals)
Required Arguments: hkls – (3, n) ndarray of n hstacked reciprocal lattice vector component
triplets- bMat – (3, 3) ndarray representing the matirix taking reciprocal lattice
- vectors to the crystal reference frame
Output: gVecs – (3, n) ndarray of n unit reciprocal lattice vectors
(a.k.a. lattice plane normals)To Do: * might benefit from some assert statements to catch improperly shaped
input.
- gvecToDetectorXY(gVec_c, rMat_d, rMat_s, rMat_c, tVec_d, tVec_s, tVec_c, beamVec=array([[-0.],
- [-0.],
- [-1.]]))
Takes a list of unit reciprocal lattice vectors in crystal frame to the specified detector-relative frame, subject to the conditions:
- the reciprocal lattice vector must be able to satisfy a bragg condition
- the associated diffracted beam must intersect the detector plane
Required Arguments: gVec_c – (n, 3) ndarray of n reciprocal lattice vectors in the CRYSTAL FRAME rMat_d – (3, 3) ndarray, the COB taking DETECTOR FRAME components to LAB FRAME rMat_s – (3, 3) ndarray, the COB taking SAMPLE FRAME components to LAB FRAME rMat_c – (3, 3) ndarray, the COB taking CRYSTAL FRAME components to SAMPLE FRAME tVec_d – (3, 1) ndarray, the translation vector connecting LAB to DETECTOR tVec_s – (3, 1) ndarray, the translation vector connecting LAB to SAMPLE tVec_c – (3, 1) ndarray, the translation vector connecting SAMPLE to CRYSTAL
Outputs: (m, 2) ndarray containing the intersections of m <= n diffracted beams associated with gVecs
- detectorXYToGvec(xy_det, rMat_d, rMat_s, tVec_d, tVec_s, tVec_c, beamVec=array([[-0.],
- [-0.],
- [-1.]]), etaVec=array([[ 1.],
- [ 0.],
- [ 0.]]))
Takes a list cartesian (x, y) pairs in the detector coordinates and calculates the associated reciprocal lattice (G) vectors and (bragg angle, azimuth) pairs with respect to the specified beam and azimth (eta) reference directions
Required Arguments: xy_det – (n, 2) ndarray or list-like input of n detector (x, y) points rMat_d – (3, 3) ndarray, the COB taking DETECTOR FRAME components to LAB FRAME rMat_s – (3, 3) ndarray, the COB taking SAMPLE FRAME components to LAB FRAME tVec_d – (3, 1) ndarray, the translation vector connecting LAB to DETECTOR tVec_s – (3, 1) ndarray, the translation vector connecting LAB to SAMPLE tVec_c – (3, 1) ndarray, the translation vector connecting SAMPLE to CRYSTAL
Optional Keyword Arguments: beamVec – (3, 1) mdarray containing the incident beam direction components in the LAB FRAME etaVec – (3, 1) mdarray containing the reference azimuth direction components in the LAB FRAME
Outputs: (n, 2) ndarray containing the (tTh, eta) pairs associated with each (x, y) (n, 3) ndarray containing the associated G vector directions in the LAB FRAME associated with gVecs
- oscillAnglesOfHKLs(hkls, chi, rMat_c, bMat, wavelength, vInv=None, beamVec=array([[-0.],
- [-0.],
- [-1.]]), etaVec=array([[ 1.],
- [ 0.],
- [ 0.]]))
Takes a list of unit reciprocal lattice vectors in crystal frame to the specified detector-relative frame, subject to the conditions:
- the reciprocal lattice vector must be able to satisfy a bragg condition
- the associated diffracted beam must intersect the detector plane
Required Arguments: hkls – (n, 3) ndarray of n reciprocal lattice vectors in the CRYSTAL FRAME chi – float representing the inclination angle of the oscillation axis (std coords) rMat_c – (3, 3) ndarray, the COB taking CRYSTAL FRAME components to SAMPLE FRAME bMat – (3, 3) ndarray, the COB taking RECIPROCAL LATTICE components to CRYSTAL FRAME wavelength – float representing the x-ray wavelength in Angstroms
Optional Keyword Arguments: beamVec – (3, 1) mdarray containing the incident beam direction components in the LAB FRAME etaVec – (3, 1) mdarray containing the reference azimuth direction components in the LAB FRAME
Outputs: ome0 – (n, 3) ndarray containing the feasible (tTh, eta, ome) triplets for each input hkl (first solution) ome1 – (n, 3) ndarray containing the feasible (tTh, eta, ome) triplets for each input hkl (second solution)
The reciprocal lattice vector, G, will satisfy the the Bragg condition when:
b.T * G / ||G|| = -sin(theta)where b is the incident beam direction (k_i) and theta is the Bragg angle consistent with G and the specified wavelength. The components of G in the lab frame in this case are obtained using the crystal orientation, Rc, and the single-parameter oscillation matrix, Rs(ome):
Rs(ome) * Rc * G / ||G||The equation above can be rearranged to yield an expression of the form:
a*sin(ome) + b*cos(ome) = cwhich is solved using the relation:
a*sin(x) + b*cos(x) = sqrt(a**2 + b**2) * sin(x + alpha)
—> sin(x + alpha) = c / sqrt(a**2 + b**2)
where:
alpha = atan2(b, a)The solutions are:
/ | arcsin(c / sqrt(a**2 + b**2)) - alpha- x = <
- pi - arcsin(c / sqrt(a**2 + b**2)) - alpha
There is a double root in the case the reflection is tangent to the Debye-Scherrer cone (c**2 = a**2 + b**2), and no solution if the Laue condition cannot be satisfied (filled with NaNs in the results array here)
- hexrd.xrd.transforms_CAPI.arccosSafe(temp)[source]¶
Protect against numbers slightly larger than 1 in magnitude due to round-off
- hexrd.xrd.transforms_CAPI.angularDifference(angList0, angList1, units='radians')[source]¶
Do the proper (acute) angular difference in the context of a branch cut.
*) Default angular range is [-pi, pi]
- hexrd.xrd.transforms_CAPI.mapAngle(ang, *args, **kwargs)[source]¶
Utility routine to map an angle into a specified period
- hexrd.xrd.transforms_CAPI.columnNorm(a)[source]¶
normalize array of column vectors (hstacked, axis = 0)
- hexrd.xrd.transforms_CAPI.makeDetectorRotMat(tiltAngles)[source]¶
Form the (3, 3) tilt rotations from the tilt angle list:
tiltAngles = [gamma_Xl, gamma_Yl, gamma_Zl] in radians
- hexrd.xrd.transforms_CAPI.makeRotMatOfExpMap(expMap)[source]¶
make a rotation matrix from an exponential map