From 90c3b3170d4300ebd521bb4b623fc647f5d6e577 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Fri, 13 May 2022 09:53:44 +0200 Subject: [PATCH] propagate 'normalize' option --- python/damask/_orientation.py | 6 ++++-- python/damask/_result.py | 20 +++++++++++++------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/python/damask/_orientation.py b/python/damask/_orientation.py index 0c995110c..dcc139b7c 100644 --- a/python/damask/_orientation.py +++ b/python/damask/_orientation.py @@ -796,7 +796,8 @@ class Orientation(Rotation,Crystal): uvw|hkl : numpy.ndarray, shape (...,3) Miller indices of crystallographic direction or plane normal. 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 Calculate all N symmetrically equivalent vectors. Defaults to False. @@ -807,7 +808,8 @@ class Orientation(Rotation,Crystal): Returns ------- 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) diff --git a/python/damask/_result.py b/python/damask/_result.py index 253881731..7a58a1621 100644 --- a/python/damask/_result.py +++ b/python/damask/_result.py @@ -1023,26 +1023,26 @@ class Result: @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 brackets = ['[]','()','⟨⟩','{}'][(uvw is None)*1+with_symmetry*2] label = 'p^' + '{}{} {} {}{}'.format(brackets[0], *(uvw if uvw else hkl), 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 { - 'data': pole, + 'data': ori.to_pole(uvw=uvw,hkl=hkl,with_symmetry=with_symmetry,normalize=normalize), 'label': label, 'meta' : { 'unit': '1', - 'description': 'lab frame vector along lattice ' \ - + ('direction' if uvw else 'plane') \ + 'description': f'{"normalized " if normalize else ""}lab frame vector along lattice ' \ + + ('direction' if uvw is not None else 'plane') \ + ('s' if with_symmetry else ''), '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). @@ -1055,9 +1055,15 @@ class Result: Miller indices of crystallographic direction or plane normal. with_symmetry : bool, optional 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