From e88182b0072ce7ba8461556f92d50b5a2f4049f5 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 24 Feb 2019 14:39:34 +0100 Subject: [PATCH] improved converte, now with test still needs to figure out how +P is handled --- PRIVATE | 2 +- processing/pre/geom_fromDREAM3D.py | 4 ++-- python/damask/orientation.py | 6 +++++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/PRIVATE b/PRIVATE index 8deb37dd4..144e72981 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit 8deb37dd4526fb5e1425fe1d2360508d01b6ac3e +Subproject commit 144e729811024fd5f99225fa10b6d8fa40e7d492 diff --git a/processing/pre/geom_fromDREAM3D.py b/processing/pre/geom_fromDREAM3D.py index 6c2830372..f75694ef6 100755 --- a/processing/pre/geom_fromDREAM3D.py +++ b/processing/pre/geom_fromDREAM3D.py @@ -95,7 +95,7 @@ for name in filenames: except: errors.append('Pointwise orientation data ({}) not found'.format(dataset)) - texture = [damask.Rotation.fromQuaternion(q,P=+1) for q in quats] + texture = [damask.Rotation.fromQuaternion(q,True,P=+1) for q in quats] dataset = os.path.join(group_pointwise,options.phase) try: @@ -118,7 +118,7 @@ for name in filenames: dataset = os.path.join(group_average,options.quaternion) try: - texture = [damask.Rotation.fromQuaternion(q,P=+1) for q in inFile[dataset][...][1:]] # skip first entry (unindexed) + texture = [damask.Rotation.fromQuaternion(q,True,P=+1) for q in inFile[dataset][...][1:]] # skip first entry (unindexed) except: errors.append('Average orientation data ({}) not found'.format(dataset)) diff --git a/python/damask/orientation.py b/python/damask/orientation.py index e11613020..ad9877835 100644 --- a/python/damask/orientation.py +++ b/python/damask/orientation.py @@ -301,12 +301,16 @@ class Rotation: @classmethod def fromQuaternion(cls, quaternion, + acceptHomomorph = False, P = -1): qu = quaternion if isinstance(quaternion, np.ndarray) else np.array(quaternion) if P > 0: qu[1:4] *= -1 # convert from P=1 to P=-1 if qu[0] < 0.0: - raise ValueError('Quaternion has negative first component.\n{}'.format(qu[0])) + if acceptHomomorph: + qu *= -1. + else: + raise ValueError('Quaternion has negative first component.\n{}'.format(qu[0])) if not np.isclose(np.linalg.norm(qu), 1.0): raise ValueError('Quaternion is not of unit length.\n{} {} {} {}'.format(*qu))