propagate 'normalize' option

This commit is contained in:
Martin Diehl 2022-05-13 09:53:44 +02:00
parent b080e414ae
commit 90c3b3170d
2 changed files with 17 additions and 9 deletions

View File

@ -796,7 +796,8 @@ 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 of 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. Defaults to False.
@ -807,7 +808,8 @@ class Orientation(Rotation,Crystal):
Returns Returns
------- -------
vector : numpy.ndarray, shape (...,3) or (...,N,3) vector : numpy.ndarray, shape (...,3) or (...,N,3)
Lab frame vector (or vectors if with_symmetry) along [uvw] direction or (hkl) plane normal. Lab frame vector (or vectors if with_symmetry) along
[uvw] direction or (hkl) plane normal.
""" """
v = self.to_frame(uvw=uvw,hkl=hkl) v = self.to_frame(uvw=uvw,hkl=hkl)

View File

@ -1023,26 +1023,26 @@ class Result:
@staticmethod @staticmethod
def _add_pole(q,uvw,hkl,with_symmetry): def _add_pole(q,uvw,hkl,with_symmetry,normalize):
c = q['meta']['c/a'] if 'c/a' in q['meta'] else 1 c = q['meta']['c/a'] if 'c/a' in q['meta'] else 1
brackets = ['[]','()','⟨⟩','{}'][(uvw is None)*1+with_symmetry*2] brackets = ['[]','()','⟨⟩','{}'][(uvw is None)*1+with_symmetry*2]
label = 'p^' + '{}{} {} {}{}'.format(brackets[0], label = 'p^' + '{}{} {} {}{}'.format(brackets[0],
*(uvw if uvw else hkl), *(uvw if uvw else hkl),
brackets[-1],) brackets[-1],)
pole = Orientation(q['data'],lattice=q['meta']['lattice'],a=1,c=c).to_pole(uvw=uvw,hkl=hkl,with_symmetry=with_symmetry) ori = Orientation(q['data'],lattice=q['meta']['lattice'],a=1,c=c)
return { return {
'data': pole, 'data': ori.to_pole(uvw=uvw,hkl=hkl,with_symmetry=with_symmetry,normalize=normalize),
'label': label, 'label': label,
'meta' : { 'meta' : {
'unit': '1', 'unit': '1',
'description': 'lab frame vector along lattice ' \ 'description': f'{"normalized " if normalize else ""}lab frame vector along lattice ' \
+ ('direction' if uvw else 'plane') \ + ('direction' if uvw is not None else 'plane') \
+ ('s' if with_symmetry else ''), + ('s' if with_symmetry else ''),
'creator': 'add_pole' 'creator': 'add_pole'
} }
} }
def add_pole(self,q='O',*,uvw=None,hkl=None,with_symmetry=False): def add_pole(self,q='O',*,uvw=None,hkl=None,with_symmetry=False,normalize=True):
""" """
Add lab frame vector along lattice direction [uvw] or plane normal (hkl). Add lab frame vector along lattice direction [uvw] or plane normal (hkl).
@ -1055,9 +1055,15 @@ class Result:
Miller indices of crystallographic direction or plane normal. Miller indices of crystallographic direction or plane normal.
with_symmetry : bool, optional with_symmetry : bool, optional
Calculate all N symmetrically equivalent vectors. Calculate all N symmetrically equivalent vectors.
Defaults to True.
normalize : bool, optional
Normalize output vector.
Defaults to True.
""" """
self._add_generic_pointwise(self._add_pole,{'q':q},{'uvw':uvw,'hkl':hkl,'with_symmetry':with_symmetry}) self._add_generic_pointwise(self._add_pole,
{'q':q},
{'uvw':uvw,'hkl':hkl,'with_symmetry':with_symmetry,'normalize':normalize})
@staticmethod @staticmethod