use symmetry-aware Miller brackets in Result.add_pole
This commit is contained in:
parent
675e9c911d
commit
c9f344758a
|
@ -1025,17 +1025,21 @@ class Result:
|
|||
@staticmethod
|
||||
def _add_pole(q,uvw,hkl,with_symmetry):
|
||||
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)
|
||||
|
||||
return {
|
||||
'data': pole,
|
||||
'label': 'p^[{} {} {}]'.format(*uvw) if uvw else 'p^({} {} {})'.format(*hkl),
|
||||
'label': label,
|
||||
'meta' : {
|
||||
'unit': '1',
|
||||
'description': 'lab frame vector along lattice ' \
|
||||
+ ('direction' if uvw else 'plane') \
|
||||
+ ('s' if with_symmetry else ''),
|
||||
'creator': 'add_pole'
|
||||
'unit': '1',
|
||||
'description': 'lab frame vector along lattice ' \
|
||||
+ ('direction' if uvw else 'plane') \
|
||||
+ ('s' if with_symmetry else ''),
|
||||
'creator': 'add_pole'
|
||||
}
|
||||
}
|
||||
def add_pole(self,q='O',*,uvw=None,hkl=None,with_symmetry=False):
|
||||
|
@ -1047,7 +1051,7 @@ class Result:
|
|||
q : str
|
||||
Name of the dataset containing the crystallographic orientation as quaternions.
|
||||
Defaults to 'O'.
|
||||
uvw|hkl : numpy.ndarray of shape (...,3)
|
||||
uvw|hkl : numpy.ndarray of shape (3)
|
||||
Miller indices of crystallographic direction or plane normal.
|
||||
with_symmetry : bool, optional
|
||||
Calculate all N symmetrically equivalent vectors.
|
||||
|
|
|
@ -24,8 +24,7 @@ def default(tmp_path,ref_path):
|
|||
"""Small Result file in temp location for modification."""
|
||||
fname = '12grains6x7x8_tensionY.hdf5'
|
||||
shutil.copy(ref_path/fname,tmp_path)
|
||||
f = Result(tmp_path/fname)
|
||||
return f.view(times=20.0)
|
||||
return Result(tmp_path/fname).view(times=20.0)
|
||||
|
||||
@pytest.fixture
|
||||
def single_phase(tmp_path,ref_path):
|
||||
|
@ -226,15 +225,19 @@ class TestResult:
|
|||
assert np.allclose(in_memory,in_file)
|
||||
|
||||
@pytest.mark.parametrize('options',[{'uvw':[1,0,0],'with_symmetry':False},
|
||||
{'hkl':[0,1,1],'with_symmetry':True}])
|
||||
{'uvw':[1,1,0],'with_symmetry':True},
|
||||
{'hkl':[0,1,1],'with_symmetry':True},
|
||||
{'hkl':[1,1,1],'with_symmetry':False},
|
||||
])
|
||||
def test_add_pole(self,default,options):
|
||||
default.add_pole(**options)
|
||||
rot = default.place('O')
|
||||
in_memory = Orientation(rot,lattice=rot.dtype.metadata['lattice']).to_pole(**options)
|
||||
brackets = ['[[]','[]]'] if 'uvw' in options.keys() else ['(',')'] # escape fnmatch
|
||||
label = '{}{} {} {}{}'.format(brackets[0],*(list(options.values())[0]),brackets[1])
|
||||
in_file = default.place(f'p^{label}')
|
||||
print(in_file - in_memory)
|
||||
brackets = [['[[]','[]]'],'()','〈〉','{}'][('hkl' in options)*1+(options['with_symmetry'])*2] # escape fnmatch
|
||||
label = 'p^{}{} {} {}{}'.format(brackets[0],
|
||||
*(list(options.values())[0]),
|
||||
brackets[-1])
|
||||
in_file = default.place(label)
|
||||
assert np.allclose(in_memory,in_file)
|
||||
|
||||
def test_add_rotation(self,default):
|
||||
|
|
Loading…
Reference in New Issue