Ejemplo n.º 1
0
def make_grain_params(quat, tVec_c=np.zeros(3), vInv=vInv_ref, filename=None):
    phi = 2 * np.arccos(quat[0])
    n = unitVector(quat[1:, :])
    expMap_c = phi * n
    if filename is not None:
        if isinstance(filename, file):
            fid = filename
        elif isinstance(filename, str) or isinstance(filename, unicode):
            fid = open(filename, "w")
        print >> fid, "%1.7e\t# expMap_c[0]\n" % (expMap_c[0]) + "%1.7e\t# expMap_c[1]\n" % (
            expMap_c[1]
        ) + "%1.7e\t# expMap_c[2]\n" % (expMap_c[2]) + "%1.7e\t# tVec_c[0]  \n" % (
            tVec_c[0]
        ) + "%1.7e\t# tVec_c[1]  \n" % (
            tVec_c[1]
        ) + "%1.7e\t# tVec_c[2]  \n" % (
            tVec_c[2]
        ) + "%1.7e\t# vInv_s[0]  \n" % (
            vInv[0]
        ) + "%1.7e\t# vInv_s[1]  \n" % (
            vInv[1]
        ) + "%1.7e\t# vInv_s[2]  \n" % (
            vInv[2]
        ) + "%1.7e\t# vInv_s[3]  \n" % (
            vInv[3]
        ) + "%1.7e\t# vInv_s[4]  \n" % (
            vInv[4]
        ) + "%1.7e\t# vInv_s[5]  \n" % (
            vInv[5]
        )
        fid.close()
    return np.hstack([expMap_c.flatten(), tVec_c.flatten(), vInv.flatten()])
Ejemplo n.º 2
0
def make_grain_params(quat, tVec_c=np.zeros(3), vInv=vInv_ref, filename=None):
    phi      = 2*np.arccos(quat[0])
    n        = unitVector(quat[1:, :])
    expMap_c = phi*n
    if filename is not None:
        if isinstance(filename, file):
            fid = filename
        elif isinstance(filename, str) or isinstance(filename, unicode):
            fid = open(filename, 'w')
        print >> fid, \
            "%1.7e\t# expMap_c[0]\n" % (expMap_c[0]) + \
            "%1.7e\t# expMap_c[1]\n" % (expMap_c[1]) + \
            "%1.7e\t# expMap_c[2]\n" % (expMap_c[2]) + \
            "%1.7e\t# tVec_c[0]  \n" % (tVec_c[0])   + \
            "%1.7e\t# tVec_c[1]  \n" % (tVec_c[1])   + \
            "%1.7e\t# tVec_c[2]  \n" % (tVec_c[2])   + \
            "%1.7e\t# vInv_s[0]  \n" % (vInv[0])     + \
            "%1.7e\t# vInv_s[1]  \n" % (vInv[1])     + \
            "%1.7e\t# vInv_s[2]  \n" % (vInv[2])     + \
            "%1.7e\t# vInv_s[3]  \n" % (vInv[3])     + \
            "%1.7e\t# vInv_s[4]  \n" % (vInv[4])     + \
            "%1.7e\t# vInv_s[5]  \n" % (vInv[5])
        fid.close()
    return np.hstack([expMap_c.flatten(), tVec_c.flatten(), vInv.flatten()])
Ejemplo n.º 3
0
import sys, os, time, random
import numpy as np

from hexrd.xrd import transforms as xf
from hexrd.xrd import transforms_CAPI as xfcapi

epsf = 2.2e-16

vec = np.array([[random.uniform(-np.pi,np.pi),random.uniform(-np.pi,np.pi),random.uniform(-np.pi,np.pi)]])
vHat1 = xf.unitVector(vec.T)
vHat2 = xfcapi.unitRowVector(vec)
print "unitVector results match:             ",np.linalg.norm(vHat1.T-vHat2)/np.linalg.norm(vHat1) < epsf

tAng = np.array([0.0011546340766314521,-0.0040527538387122993,-0.0026221336905160211])
rMat1 = xf.makeDetectorRotMat(tAng)
rMat2 = xfcapi.makeDetectorRotMat(tAng)
print "makeDetectorRotMat results match:     ",np.linalg.norm(rMat1-rMat2)/np.linalg.norm(rMat1) < epsf

oAng = np.array([-0.0011591608938627839,0.0011546340766314521])
rMat1 = xf.makeOscillRotMat(oAng)
rMat2 = xfcapi.makeOscillRotMat(oAng)
print "makeOscillRotMat results match:       ",np.linalg.norm(rMat1-rMat2)/np.linalg.norm(rMat1) < epsf

eMap = np.array([ 0.66931818,-0.98578066,0.73593251])
rMat1 = xf.makeRotMatOfExpMap(eMap)
rMat2 = xfcapi.makeRotMatOfExpMap(eMap)
print "makeRotMatOfExpMap results match:     ",np.linalg.norm(rMat1-rMat2)/np.linalg.norm(rMat1) < epsf

axis = np.array([ 0.66931818,-0.98578066,0.73593251])
rMat1 = xf.makeBinaryRotMat(axis)
rMat2 = xfcapi.makeBinaryRotMat(axis)
Ejemplo n.º 4
0
import sys, os, time, random
import numpy as np

from hexrd.xrd import transforms as xf
from hexrd.xrd import transforms_CAPI as xfcapi

epsf = 2.2e-16

vec = np.array([[
    random.uniform(-np.pi, np.pi),
    random.uniform(-np.pi, np.pi),
    random.uniform(-np.pi, np.pi)
]])
vHat1 = xf.unitVector(vec.T)
vHat2 = xfcapi.unitRowVector(vec)
print "unitVector results match:             ", np.linalg.norm(
    vHat1.T - vHat2) / np.linalg.norm(vHat1) < epsf

tAng = np.array(
    [0.0011546340766314521, -0.0040527538387122993, -0.0026221336905160211])
rMat1 = xf.makeDetectorRotMat(tAng)
rMat2 = xfcapi.makeDetectorRotMat(tAng)
print "makeDetectorRotMat results match:     ", np.linalg.norm(
    rMat1 - rMat2) / np.linalg.norm(rMat1) < epsf

oAng = np.array([-0.0011591608938627839, 0.0011546340766314521])
rMat1 = xf.makeOscillRotMat(oAng)
rMat2 = xfcapi.makeOscillRotMat(oAng)
print "makeOscillRotMat results match:       ", np.linalg.norm(
    rMat1 - rMat2) / np.linalg.norm(rMat1) < epsf