Commit c209c8c0 authored by Tobias WEBER's avatar Tobias WEBER
Browse files

calculated distance to plane

parent e506c106
......@@ -172,6 +172,8 @@ editKf = qtw.QLineEdit(Qpanel)
editQAbs = qtw.QLineEdit(Qpanel)
editQAbs.setReadOnly(True)
tasstatus = qtw.QLabel(taspanel)
separatorTas = qtw.QFrame(Qpanel)
separatorTas.setFrameStyle(qtw.QFrame.HLine)
......@@ -254,12 +256,17 @@ def QChanged():
try:
orient_up_rlu = tas.cross(orient_rlu, orient2_rlu, B) # up vector in rlu
[a3, a4] = tas.get_a3a4(ki, kf, Q_rlu, orient_rlu, orient_up_rlu, B)
[a3, a4, dist_Q_plane] = tas.get_a3a4(ki, kf, Q_rlu, orient_rlu, orient_up_rlu, B)
Qlen = tas.get_Q(ki, kf, a4)
Q_in_plane = np.abs(dist_Q_plane) < 1e-4
editA3.setText("%.6g" % (a3 / np.pi * 180.))
editA4.setText("%.6g" % (a4 / np.pi * 180.))
editQAbs.setText("%.6g" % Qlen)
if Q_in_plane:
tasstatus.setText("")
else:
tasstatus.setText(u"WARNING: Q is out of the plane by %.4g / \u212b!" % dist_Q_plane)
except (ArithmeticError, la.LinAlgError) as err:
editA3.setText("invalid")
editA4.setText("invalid")
......@@ -341,6 +348,7 @@ taslayout.addWidget(qtw.QLabel("Mono., Ana. d (A):", taspanel), 10,0, 1,1)
taslayout.addWidget(editDm, 10,1, 1,1)
taslayout.addWidget(editDa, 10,2, 1,1)
taslayout.addItem(qtw.QSpacerItem(16,16, qtw.QSizePolicy.Minimum, qtw.QSizePolicy.Expanding), 11,0, 1,3)
taslayout.addWidget(tasstatus, 12,0, 1,3)
tabs.addTab(taspanel, "TAS")
# -----------------------------------------------------------------------------
......
......@@ -13,9 +13,9 @@ use_scipy = False
# -----------------------------------------------------------------------------
# choose an a3 convention
#a3_offs = 0. # for sics
#a3_offs = 0. # for sics: a3 is angle between ki and orient1
#a3_offs = np.pi/2. # for takin: Q along orient1 => a3:=a4/2
a3_offs = np.pi # for nomad: ki along orient1 => a3:=0
a3_offs = np.pi # for nomad: a3 is angle between ki and orient1 + 180 deg
def set_a3_offs(offs):
global a3_offs
......@@ -151,8 +151,13 @@ def get_a3a4(ki, kf, Q_rlu, orient_rlu, orient_up_rlu, B):
if dot(cross(orient_rlu, Q_rlu, B), orient_up_rlu, metric) < 0.:
xi = -xi
# length of Q
Qlen = np.sqrt(dot(Q_rlu, Q_rlu, metric))
# distance to plane
up_len = np.sqrt(dot(orient_up_rlu, orient_up_rlu, metric))
dist_Q_plane = dot(Q_rlu, orient_up_rlu, metric) / up_len
# angle psi enclosed by ki and Q
psi = get_psi(ki, kf, Qlen)
......@@ -160,7 +165,7 @@ def get_a3a4(ki, kf, Q_rlu, orient_rlu, orient_up_rlu, B):
a4 = get_a4(ki, kf, Qlen)
#print("xi = " + str(xi/np.pi*180.) + ", psi = " + str(psi/np.pi*180.))
return [a3, a4]
return [a3, a4, dist_Q_plane]
def get_hkl(ki, kf, a3, Qlen, orient_rlu, orient_up_rlu, B):
......
......@@ -43,7 +43,7 @@ if __name__ == "__main__":
ki = tas.get_ki(kf, E)
[a1, a2] = tas.get_a1a2(ki, dmono)
[a5, a6] = tas.get_a1a2(kf, dana)
[a3, a4] = tas.get_a3a4(ki, kf, Q_rlu, orient_rlu, orient_up_rlu, B)
[a3, a4, dist_Q_plane] = tas.get_a3a4(ki, kf, Q_rlu, orient_rlu, orient_up_rlu, B)
# --------------------------------------------------------------------------
# --------------------------------------------------------------------------
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment