Skip to content

Commit

Permalink
Merge pull request #727 from HEXRD/pinhole-correction-fix
Browse files Browse the repository at this point in the history
Fix pinhole offset corrections
  • Loading branch information
saransh13 authored Nov 13, 2024
2 parents 8c669ab + d96f41f commit 6213ab6
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions hexrd/xrdutil/phutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,12 @@ 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()
bv_norm = np.linalg.norm(bv)
if np.isclose(bv_norm, 0):
return 0.
else:
bv = bv / bv_norm
return np.arccos(np.dot(bv, -eHat_l)).item()


def azimuth(vv, v0, v1):
Expand Down Expand Up @@ -449,7 +453,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]
Expand All @@ -460,7 +464,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]
Expand Down Expand Up @@ -525,8 +529,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
Expand Down

0 comments on commit 6213ab6

Please sign in to comment.