From cb79f0eb29d465ebc40b612d6a0909a8565e811d Mon Sep 17 00:00:00 2001 From: smribet Date: Thu, 5 Dec 2024 05:56:04 -0800 Subject: [PATCH] rotation bug --- py4DSTEM/tomography/tomography.py | 40 ++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/py4DSTEM/tomography/tomography.py b/py4DSTEM/tomography/tomography.py index a739224c4..5a8e62d13 100644 --- a/py4DSTEM/tomography/tomography.py +++ b/py4DSTEM/tomography/tomography.py @@ -448,6 +448,24 @@ def _prepare_datacube( ) ) + from pdb import set_trace + + set_trace() + + if self._force_q_to_r_rotation_deg is not None: + for a0 in range(datacube.shape[0]): + for a1 in range(datacube.shape[1]): + datacube.data[a0, a1] = np.clip( + rotate( + datacube.data[a0, a1], + -self._force_q_to_r_rotation_deg, + reshape=False, + order=0, + ), + 0, + np.inf, + ) + # resize diffraction space if diffraction_intensities_shape is not None: Q = datacube.shape[-1] @@ -785,17 +803,17 @@ def _make_diffraction_masks(self, q_max_inv_A): ind_diffraction_rotate_transpose = ( ind_diffraction_rotate_transpose.swapaxes(-1, -2) ) - if self._force_q_to_r_rotation_deg is not None: - ind_diffraction_rotate_transpose = np.clip( - rotate( - ind_diffraction_rotate_transpose, - -self._force_q_to_r_rotation_deg, # negative makes this rotation consistant with phase contrast module rotation - reshape=False, - order=0, - ), - 0, - np.max(ind_diffraction), - ) + # if self._force_q_to_r_rotation_deg is not None: + # ind_diffraction_rotate_transpose = np.clip( + # rotate( + # ind_diffraction_rotate_transpose, + # -self._force_q_to_r_rotation_deg, # negative makes this rotation consistant with phase contrast module rotation + # reshape=False, + # order=0, + # ), + # 0, + # np.max(ind_diffraction), + # ) self._ind_diffraction = ind_diffraction self._ind_diffraction_ravel = ind_diffraction.ravel()