From d9fcffe42e499449733f78f7765670205b025b8a Mon Sep 17 00:00:00 2001 From: Ivan Usov Date: Tue, 31 Mar 2020 14:07:13 +0200 Subject: [PATCH] Add ang2hkl function This function is based on angtohkl, but doesn't include prints --- pyzebra/xtal.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/pyzebra/xtal.py b/pyzebra/xtal.py index 99aa538..50ef0b9 100644 --- a/pyzebra/xtal.py +++ b/pyzebra/xtal.py @@ -327,7 +327,15 @@ def angtohkl(wave,ddist,gammad,om,ch,ph,nud,x,y): print('Bisecting angles to put reflection into the detector center: ga=', ga, ', om=', om, ', ch=', ch, ', ph=', ph, ', nu=', nu) +def ang2hkl(wave, ddist, gammad, om, ch, ph, nud, ub, x, y): + """Calculate hkl-indices of a reflection from its position (x,y,angles) at the 2d-detector + """ + ga, nu = det2pol(ddist, gammad, nud, x, y) + z1 = z1frmd(wave, ga, om, ch, ph, nu) + ubinv = np.linalg.inv(ub) + + h = ubinv[0, 0] * z1[0] + ubinv[0, 1] * z1[1] + ubinv[0, 2] * z1[2] + k = ubinv[1, 0] * z1[0] + ubinv[1, 1] * z1[1] + ubinv[1, 2] * z1[2] + l = ubinv[2, 0] * z1[0] + ubinv[2, 1] * z1[1] + ubinv[2, 2] * z1[2] - - - \ No newline at end of file + return h, k, l