Optimize ang2hkl functions to accept inverted UB directly
This commit is contained in:
parent
dfef1eadd9
commit
dd262ab6cd
@ -975,7 +975,7 @@ def calculate_hkl(scan, index):
|
||||
gammad = scan["gamma"][index]
|
||||
om = scan["omega"][index]
|
||||
nud = scan["nu"]
|
||||
ub = scan["ub"]
|
||||
ub_inv = np.linalg.inv(scan["ub"])
|
||||
geometry = scan["zebra_mode"]
|
||||
|
||||
if geometry == "bi":
|
||||
@ -990,7 +990,7 @@ def calculate_hkl(scan, index):
|
||||
for xi in np.arange(IMAGE_W):
|
||||
for yi in np.arange(IMAGE_H):
|
||||
h[yi, xi], k[yi, xi], l[yi, xi] = pyzebra.ang2hkl(
|
||||
wave, ddist, gammad, om, chi, phi, nud, ub, xi, yi
|
||||
wave, ddist, gammad, om, chi, phi, nud, ub_inv, xi, yi
|
||||
)
|
||||
|
||||
return h, k, l
|
||||
|
@ -138,7 +138,7 @@ class PlotHKL:
|
||||
chi = scan["chi"]
|
||||
phi = scan["phi"]
|
||||
nud = 0 # 1d detector
|
||||
ub = scan["ub"]
|
||||
ub_inv = np.linalg.inv(scan["ub"])
|
||||
counts = scan["counts"]
|
||||
wave = scan["wavelength"]
|
||||
|
||||
@ -153,18 +153,18 @@ class PlotHKL:
|
||||
res_x = []
|
||||
res_y = []
|
||||
for _om in np.linspace(om[0], om[-1], num=res_N):
|
||||
expr1 = ang2hkl_1d(wave, gammad, _om + res / 2, chi, phi, nud, ub)
|
||||
expr2 = ang2hkl_1d(wave, gammad, _om - res / 2, chi, phi, nud, ub)
|
||||
expr1 = ang2hkl_1d(wave, gammad, _om + res / 2, chi, phi, nud, ub_inv)
|
||||
expr2 = ang2hkl_1d(wave, gammad, _om - res / 2, chi, phi, nud, ub_inv)
|
||||
hkl_temp = M @ (np.abs(expr1 - expr2) / 2)
|
||||
res_x.append(hkl_temp[0])
|
||||
res_y.append(hkl_temp[1])
|
||||
|
||||
# Get first and final hkl
|
||||
hkl1 = ang2hkl_1d(wave, gammad, om[0], chi, phi, nud, ub)
|
||||
hkl2 = ang2hkl_1d(wave, gammad, om[-1], chi, phi, nud, ub)
|
||||
hkl1 = ang2hkl_1d(wave, gammad, om[0], chi, phi, nud, ub_inv)
|
||||
hkl2 = ang2hkl_1d(wave, gammad, om[-1], chi, phi, nud, ub_inv)
|
||||
|
||||
# Get hkl at best intensity
|
||||
hkl_m = ang2hkl_1d(wave, gammad, om[np.argmax(counts)], chi, phi, nud, ub)
|
||||
hkl_m = ang2hkl_1d(wave, gammad, om[np.argmax(counts)], chi, phi, nud, ub_inv)
|
||||
|
||||
# Estimate intensity for marker size scaling
|
||||
y_bkg = [counts[0], counts[-1]]
|
||||
|
@ -361,21 +361,19 @@ def angtohkl(wave, ddist, gammad, om, ch, ph, nud, x, y):
|
||||
)
|
||||
|
||||
|
||||
def ang2hkl(wave, ddist, gammad, om, ch, ph, nud, ub, x, y):
|
||||
def ang2hkl(wave, ddist, gammad, om, ch, ph, nud, ub_inv, 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)
|
||||
hkl = ubinv @ z1
|
||||
hkl = ub_inv @ z1
|
||||
|
||||
return hkl
|
||||
|
||||
|
||||
def ang2hkl_1d(wave, ga, om, ch, ph, nu, ub):
|
||||
def ang2hkl_1d(wave, ga, om, ch, ph, nu, ub_inv):
|
||||
"""Calculate hkl-indices of a reflection from its position (angles) at the 1d-detector"""
|
||||
z1 = z1frmd(wave, ga, om, ch, ph, nu)
|
||||
ubinv = np.linalg.inv(ub)
|
||||
hkl = ubinv @ z1
|
||||
hkl = ub_inv @ z1
|
||||
|
||||
return hkl
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user