From b299f353902524612c50d6f121c07aa2dda21ec0 Mon Sep 17 00:00:00 2001 From: Rhys Thomas Date: Tue, 3 Dec 2024 12:26:15 +0000 Subject: [PATCH] Add option for both IPF triangle up and down --- defdap/plotting.py | 57 ++++++++++++++++++++++++++++++++-------------- defdap/quat.py | 35 ++++++++++++++++++++-------- 2 files changed, 66 insertions(+), 26 deletions(-) diff --git a/defdap/plotting.py b/defdap/plotting.py index c32730b..3f83d18 100644 --- a/defdap/plotting.py +++ b/defdap/plotting.py @@ -1011,23 +1011,46 @@ def add_axis(self): pad_y=0.005, va='bottom', ha='center', fontsize=12) elif self.plot_type == "IPF" and self.crystal_sym == "hexagonal": - # line between [0001] and [10-10] ([001] and [210]) - # converted to cubic axes - self.add_line([0, 0, 1], [np.sqrt(3), 1, 0], c='k', lw=2) - - # line between [0001] and [2-1-10] ([001] and [100]) - self.add_line([0, 0, 1], [1, 0, 0], c='k', lw=2) - - # line between [2-1-10] and [10-10] ([100] and [210]) - self.add_line([1, 0, 0], [np.sqrt(3), 1, 0], c='k', lw=2) - - # label poles - self.label_point([0, 0, 1], '0001', - pad_y=-0.012, va='top', ha='center', fontsize=12) - self.label_point([1, 0, 0], r'$2\bar{1}\bar{1}0$', - pad_y=-0.012, va='top', ha='center', fontsize=12) - self.label_point([np.sqrt(3), 1, 0], r'$10\bar{1}0$', - pad_y=0.009, va='bottom', ha='center', fontsize=12) + + triangle = 'aztec' + + if triangle == 'aztec': + # line between [0001] and [01-10] ([001] and [2-10]) + # converted to cubic axes + self.add_line([0, 0, 1], [np.sqrt(3), -1, 0], c='k', lw=2) + + # line between [0001] and [-12-10] ([001] and [100]) + self.add_line([0, 0, 1], [1, 0, 0], c='k', lw=2) + + # line between [-12-10] and [01-10] ([100] and [2-10]) + self.add_line([1, 0, 0], [np.sqrt(3), -1, 0], c='k', lw=2) + + # label poles + self.label_point([0, 0, 1], '0001', + pad_y=0.012, va='bottom', ha='center', fontsize=12) + self.label_point([1, 0, 0], r'$\bar{1}2\bar{1}0$', + pad_y=0.012, va='bottom', ha='center', fontsize=12) + self.label_point([np.sqrt(3), -1, 0], r'$01\bar{1}0$', + pad_y=-0.006, va='top', ha='center', fontsize=12) + + elif triangle == 'mtex': + # line between [0001] and [10-10] ([001] and [210]) + # converted to cubic axes + self.add_line([0, 0, 1], [np.sqrt(3), 1, 0], c='k', lw=2) + + # line between [0001] and [2-1-10] ([001] and [100]) + self.add_line([0, 0, 1], [1, 0, 0], c='k', lw=2) + + # line between [2-1-10] and [10-10] ([100] and [210]) + self.add_line([1, 0, 0], [np.sqrt(3), 1, 0], c='k', lw=2) + + # label poles + self.label_point([0, 0, 1], '0001', + pad_y=-0.012, va='top', ha='center', fontsize=12) + self.label_point([1, 0, 0], r'$2\bar{1}\bar{1}0$', + pad_y=-0.012, va='top', ha='center', fontsize=12) + self.label_point([np.sqrt(3), 1, 0], r'$10\bar{1}0$', + pad_y=0.009, va='bottom', ha='center', fontsize=12) else: raise NotImplementedError("Only works for cubic and hexagonal.") diff --git a/defdap/quat.py b/defdap/quat.py index 9fda81d..f159e2f 100755 --- a/defdap/quat.py +++ b/defdap/quat.py @@ -1052,15 +1052,32 @@ def calc_fund_dirs( alpha_fund = alpha[min_alpha_idx, np.arange(len(min_alpha_idx))] elif sym_group == "hexagonal": - # first beta should be between 0 and 30 deg leaving 1 - # symmetric equivalent per orientation - trial_poles = np.logical_and(beta >= 0, beta <= np.pi / 6) - # if less than 1 left need to expand search slightly to - # catch edge cases - if np.any(np.sum(trial_poles, axis=0) < 1): - delta_beta = 1e-8 - trial_poles = np.logical_and(beta >= -delta_beta, - beta <= np.pi / 6 + delta_beta) + + triangle = 'aztec' + + if triangle == 'aztec': + + # first beta should be between 0 and 30 deg leaving 1 + # symmetric equivalent per orientation + trial_poles = np.logical_and(beta <= 0, beta >= -np.pi / 6) + # if less than 1 left need to expand search slightly to + # catch edge cases + if np.any(np.sum(trial_poles, axis=0) < 1): + delta_beta = 1e-8 + trial_poles = np.logical_and(beta >= delta_beta, + beta <= - (np.pi / 6 + delta_beta)) + + if triangle == 'mtex': + + # first beta should be between -30 and 0 deg leaving 1 + # symmetric equivalent per orientation + trial_poles = np.logical_and(beta >= 0, beta <= np.pi / 6) + # if less than 1 left need to expand search slightly to + # catch edge cases + if np.any(np.sum(trial_poles, axis=0) < 1): + delta_beta = 1e-8 + trial_poles = np.logical_and(beta >= -delta_beta, + beta <= np.pi / 6 + delta_beta) # non-indexed points cause more than 1 symmetric equivalent, use this # to pick one and filter non-indexed points later