Skip to content

Commit 6213ab6

Browse files
authored
Merge pull request #727 from HEXRD/pinhole-correction-fix
Fix pinhole offset corrections
2 parents 8c669ab + d96f41f commit 6213ab6

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

hexrd/xrdutil/phutil.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -392,8 +392,12 @@ def calc_phi_x(bvec, eHat_l):
392392
"""
393393
bv = np.array(bvec)
394394
bv[2] = 0.
395-
bv = bv/np.linalg.norm(bv)
396-
return np.arccos(np.dot(bv, -eHat_l)).item()
395+
bv_norm = np.linalg.norm(bv)
396+
if np.isclose(bv_norm, 0):
397+
return 0.
398+
else:
399+
bv = bv / bv_norm
400+
return np.arccos(np.dot(bv, -eHat_l)).item()
397401

398402

399403
def azimuth(vv, v0, v1):
@@ -449,7 +453,7 @@ def _infer_eHat_l(panel):
449453

450454
eHat_l_dict = {
451455
'TARDIS': -ct.lab_x.reshape((3, 1)),
452-
'PXRDIP': ct.lab_y.reshape((3, 1))
456+
'PXRDIP': -ct.lab_x.reshape((3, 1))
453457
}
454458

455459
return eHat_l_dict[instr_type]
@@ -460,7 +464,7 @@ def _infer_eta_shift(panel):
460464

461465
eta_shift_dict = {
462466
'TARDIS': -np.radians(180),
463-
'PXRDIP': -np.radians(90),
467+
'PXRDIP': -np.radians(180),
464468
}
465469

466470
return eta_shift_dict[instr_type]
@@ -525,8 +529,8 @@ def calc_tth_rygg_pinhole(panels, absorption_length, tth, eta,
525529

526530
v0 = np.array([0, 0, 1])
527531
v1 = np.squeeze(eHat_l)
528-
phi_d = azimuth(dvectors, v0, v1).reshape(tth.shape)
529-
beta = np.arccos(np.dot(dvectors, [0, 0, -1])).reshape(tth.shape)
532+
phi_d = azimuth(dvectors, -v0, v1).reshape(tth.shape)
533+
beta = np.arccos(-dvectors[:, 2]).reshape(tth.shape)
530534

531535
# Compute r_d
532536
# We will first convert to Cartesian, then clip to the panel, add the

0 commit comments

Comments
 (0)