normalize to_pole output by default
This commit is contained in:
parent
302f020f63
commit
b080e414ae
|
@ -786,7 +786,8 @@ class Orientation(Rotation,Crystal):
|
||||||
def to_pole(self, *,
|
def to_pole(self, *,
|
||||||
uvw: FloatSequence = None,
|
uvw: FloatSequence = None,
|
||||||
hkl: FloatSequence = None,
|
hkl: FloatSequence = None,
|
||||||
with_symmetry: bool = False) -> np.ndarray:
|
with_symmetry: bool = False,
|
||||||
|
normalize: bool = True) -> np.ndarray:
|
||||||
"""
|
"""
|
||||||
Calculate lab frame vector along lattice direction [uvw] or plane normal (hkl).
|
Calculate lab frame vector along lattice direction [uvw] or plane normal (hkl).
|
||||||
|
|
||||||
|
@ -795,9 +796,13 @@ class Orientation(Rotation,Crystal):
|
||||||
uvw|hkl : numpy.ndarray, shape (...,3)
|
uvw|hkl : numpy.ndarray, shape (...,3)
|
||||||
Miller indices of crystallographic direction or plane normal.
|
Miller indices of crystallographic direction or plane normal.
|
||||||
Shape of vector blends with shape of own rotation array.
|
Shape of vector blends with shape of own rotation array.
|
||||||
For example, a rotation array, shape (3,2) and a vector array of shape (2,4) result in (3,2,4) outputs.
|
For example, a rotation array of shape (3,2) and a vector array of shape (2,4) result in (3,2,4) outputs.
|
||||||
with_symmetry : bool, optional
|
with_symmetry : bool, optional
|
||||||
Calculate all N symmetrically equivalent vectors.
|
Calculate all N symmetrically equivalent vectors.
|
||||||
|
Defaults to False.
|
||||||
|
normalize : bool, optional
|
||||||
|
Normalize output vector.
|
||||||
|
Defaults to True.
|
||||||
|
|
||||||
Returns
|
Returns
|
||||||
-------
|
-------
|
||||||
|
@ -807,6 +812,8 @@ class Orientation(Rotation,Crystal):
|
||||||
"""
|
"""
|
||||||
v = self.to_frame(uvw=uvw,hkl=hkl)
|
v = self.to_frame(uvw=uvw,hkl=hkl)
|
||||||
blend = util.shapeblender(self.shape,v.shape[:-1])
|
blend = util.shapeblender(self.shape,v.shape[:-1])
|
||||||
|
if normalize:
|
||||||
|
v /= np.linalg.norm(v,axis=-1,keepdims=len(v.shape)>1)
|
||||||
if with_symmetry:
|
if with_symmetry:
|
||||||
sym_ops = self.symmetry_operations
|
sym_ops = self.symmetry_operations
|
||||||
shape = v.shape[:-1]+sym_ops.shape
|
shape = v.shape[:-1]+sym_ops.shape
|
||||||
|
|
|
@ -173,8 +173,8 @@ class TestOrientation:
|
||||||
o = Orientation.from_directions(uvw=a,hkl=c,**kwargs)
|
o = Orientation.from_directions(uvw=a,hkl=c,**kwargs)
|
||||||
x = o.to_pole(uvw=a)
|
x = o.to_pole(uvw=a)
|
||||||
z = o.to_pole(hkl=c)
|
z = o.to_pole(hkl=c)
|
||||||
assert np.isclose(np.dot(x/np.linalg.norm(x),np.array([1,0,0])),1) \
|
assert np.isclose(np.dot(x,np.array([1,0,0])),1) \
|
||||||
and np.isclose(np.dot(z/np.linalg.norm(z),np.array([0,0,1])),1)
|
and np.isclose(np.dot(z,np.array([0,0,1])),1)
|
||||||
|
|
||||||
@pytest.mark.parametrize('function',[Orientation.from_random,
|
@pytest.mark.parametrize('function',[Orientation.from_random,
|
||||||
Orientation.from_quaternion,
|
Orientation.from_quaternion,
|
||||||
|
|
Loading…
Reference in New Issue