def convertRotMatToRisoeU(rMats, U0, symTag='Oh'): """ Makes GrainSpotter gff ouput U11 U12 U13 U21 U22 U23 U13 U23 U33 and takes it into the LLNL/APS frame of reference Urows comes from grainspotter's gff output U0 comes from XRD.crystallography.latticeVectors.U0 """ R = hexrd.XRD.Rotations # formerly import numU = num.shape(num.atleast_3d(rMats))[0] Rsamp = num.dot( R.rotMatOfExpMap(piby2*Zl), R.rotMatOfExpMap(piby2*Yl) ) qin = R.quatOfRotMat(num.atleast_3d(rMats)) print "quaternions in (LLNL convention):" print qin.T qout = num.dot( R.quatProductMatrix( R.quatOfRotMat(Rsamp.T), mult='left' ), \ num.dot( R.quatProductMatrix( R.quatOfRotMat(U0), mult='right'), \ qin ).squeeze() ).squeeze() if qout.ndim == 1: qout = toFundamentalRegion(qout.reshape(4, 1), crysSym=symTag, sampSym=None) else: qout = toFundamentalRegion(qout, crysSym=symTag, sampSym=None) print "quaternions out (Risoe convention, symmetrically reduced)" print qout.T Uout = R.rotMatOfQuat(qout) return Uout
def convertUToRotMat(Urows, U0, symTag='Oh'): """ Takes GrainSpotter gff ouput U11 U12 U13 U21 U22 U23 U13 U23 U33 and takes it into the LLNL/APS frame of reference Urows comes from grainspotter's gff output U0 comes from XRD.crystallography.latticeVectors.U0 """ R = hexrd.XRD.Rotations numU, testDim = Urows.shape assert testDim == 9, "Your input must have 9 columns; yours has %d" % (testDim) Rsamp = num.dot( R.rotMatOfExpMap(piby2*Zl), R.rotMatOfExpMap(piby2*Yl) ) qin = R.quatOfRotMat(Urows.reshape(numU, 3, 3)) print "quaternions in (Risoe convention):" print qin.T qout = num.dot( R.quatProductMatrix( R.quatOfRotMat(Rsamp), mult='left' ), \ num.dot( R.quatProductMatrix( R.quatOfRotMat(U0.T), mult='right'), \ qin ).squeeze() ).squeeze() if qout.ndim == 1: qout = toFundamentalRegion(qout.reshape(4, 1), crysSym=symTag, sampSym=None) else: qout = toFundamentalRegion(qout, crysSym=symTag, sampSym=None) print "quaternions out (LLNL convention, symmetrically reduced)" print qout.T Uout = R.rotMatOfQuat(qout) return Uout