From 3d10266fbc759da1c54b8c15996e2f5d837714c2 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 12 Apr 2020 01:29:11 +0200 Subject: [PATCH] similar style as for other conversions --- python/damask/_Lambert.py | 4 ---- python/damask/_rotation.py | 7 +++++++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/python/damask/_Lambert.py b/python/damask/_Lambert.py index 59abe7f64..a823764e9 100644 --- a/python/damask/_Lambert.py +++ b/python/damask/_Lambert.py @@ -52,8 +52,6 @@ def cube_to_ball(cube): """ cube_ = np.clip(cube,None,np.pi**(2./3.) * 0.5) if np.isclose(np.abs(np.max(cube)),np.pi**(2./3.) * 0.5,atol=1e-6) else cube - if np.abs(np.max(cube_))>np.pi**(2./3.) * 0.5: - raise ValueError('Coordinate outside of the cube: {} {} {}.'.format(*cube)) # transform to the sphere grid via the curved square, and intercept the zero point if np.allclose(cube_,0.0,rtol=0.0,atol=1.0e-16): @@ -105,8 +103,6 @@ def ball_to_cube(ball): """ ball_ = ball/np.linalg.norm(ball)*R1 if np.isclose(np.linalg.norm(ball),R1,atol=1e-6) else ball rs = np.linalg.norm(ball_) - if rs > R1+1.e-9: - raise ValueError('Coordinate outside of the sphere: {} {} {}.'.format(*ball)) if np.allclose(ball_,0.0,rtol=0.0,atol=1.0e-16): cube = np.zeros(3) diff --git a/python/damask/_rotation.py b/python/damask/_rotation.py index b68ce4d8e..dcd61822f 100644 --- a/python/damask/_rotation.py +++ b/python/damask/_rotation.py @@ -350,6 +350,9 @@ class Rotation: else np.array(homochoric,dtype=float) if P > 0: ho *= -1 # convert from P=1 to P=-1 + if np.linalg.norm(ho) > (3.*np.pi/4.)**(1./3.)+1e-9: + raise ValueError('Coordinate outside of the sphere: {} {} {}.'.format(ho)) + return Rotation(Rotation.ho2qu(ho)) @staticmethod @@ -358,6 +361,10 @@ class Rotation: cu = cubochoric if isinstance(cubochoric, np.ndarray) and cubochoric.dtype == np.dtype(float) \ else np.array(cubochoric,dtype=float) + + if np.abs(np.max(cu))>np.pi**(2./3.) * 0.5+1e-9: + raise ValueError('Coordinate outside of the cube: {} {} {}.'.format(*cu)) + ho = Rotation.cu2ho(cu) if P > 0: ho *= -1 # convert from P=1 to P=-1