From b7d867c370c934508ab81664ed7672a867061865 Mon Sep 17 00:00:00 2001 From: Saransh Singh Date: Wed, 6 Nov 2024 16:15:38 -0800 Subject: [PATCH 1/3] fix pinhole corrections for edge cases. All variables for PXRDIP and TARDIS should be same now. No special treatment of PXRDIP data needed. --- hexrd/xrdutil/phutil.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/hexrd/xrdutil/phutil.py b/hexrd/xrdutil/phutil.py index 286c1243..54139104 100644 --- a/hexrd/xrdutil/phutil.py +++ b/hexrd/xrdutil/phutil.py @@ -392,8 +392,11 @@ def calc_phi_x(bvec, eHat_l): """ bv = np.array(bvec) bv[2] = 0. - bv = bv/np.linalg.norm(bv) - return np.arccos(np.dot(bv, -eHat_l)).item() + if np.linalg.norm(bv) == 0.: + return 0. + else: + bv = bv/np.linalg.norm(bv) + return np.arccos(np.dot(bv, -eHat_l)).item() def azimuth(vv, v0, v1): @@ -449,7 +452,7 @@ def _infer_eHat_l(panel): eHat_l_dict = { 'TARDIS': -ct.lab_x.reshape((3, 1)), - 'PXRDIP': ct.lab_y.reshape((3, 1)) + 'PXRDIP': -ct.lab_x.reshape((3, 1)) } return eHat_l_dict[instr_type] @@ -460,7 +463,7 @@ def _infer_eta_shift(panel): eta_shift_dict = { 'TARDIS': -np.radians(180), - 'PXRDIP': -np.radians(90), + 'PXRDIP': -np.radians(180), } return eta_shift_dict[instr_type] @@ -525,8 +528,8 @@ def calc_tth_rygg_pinhole(panels, absorption_length, tth, eta, v0 = np.array([0, 0, 1]) v1 = np.squeeze(eHat_l) - phi_d = azimuth(dvectors, v0, v1).reshape(tth.shape) - beta = np.arccos(np.dot(dvectors, [0, 0, -1])).reshape(tth.shape) + phi_d = azimuth(dvectors, -v0, v1).reshape(tth.shape) + beta = np.arccos(-dvectors[:, 2]).reshape(tth.shape) # Compute r_d # We will first convert to Cartesian, then clip to the panel, add the From f0939107b038016da3f1f3cacc0361f404fa358d Mon Sep 17 00:00:00 2001 From: Saransh Date: Wed, 13 Nov 2024 11:29:02 -0800 Subject: [PATCH 2/3] Update hexrd/xrdutil/phutil.py use `np.isclose` instead of `==` Co-authored-by: Patrick Avery --- hexrd/xrdutil/phutil.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hexrd/xrdutil/phutil.py b/hexrd/xrdutil/phutil.py index 54139104..1f847348 100644 --- a/hexrd/xrdutil/phutil.py +++ b/hexrd/xrdutil/phutil.py @@ -392,7 +392,8 @@ def calc_phi_x(bvec, eHat_l): """ bv = np.array(bvec) bv[2] = 0. - if np.linalg.norm(bv) == 0.: + bv_norm = np.linalg.norm(bv) + if np.isclose(bv_norm, 0): return 0. else: bv = bv/np.linalg.norm(bv) From d96f41fd06c8f20bfd14487043b6be1ceedb5966 Mon Sep 17 00:00:00 2001 From: Saransh Date: Wed, 13 Nov 2024 12:23:43 -0800 Subject: [PATCH 3/3] Update hexrd/xrdutil/phutil.py Co-authored-by: Patrick Avery --- hexrd/xrdutil/phutil.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hexrd/xrdutil/phutil.py b/hexrd/xrdutil/phutil.py index 1f847348..512c3399 100644 --- a/hexrd/xrdutil/phutil.py +++ b/hexrd/xrdutil/phutil.py @@ -396,7 +396,7 @@ def calc_phi_x(bvec, eHat_l): if np.isclose(bv_norm, 0): return 0. else: - bv = bv/np.linalg.norm(bv) + bv = bv / bv_norm return np.arccos(np.dot(bv, -eHat_l)).item()