From 9f2585139bb6139777973982bae21cc44b97f196 Mon Sep 17 00:00:00 2001 From: Ivan Usov Date: Mon, 6 Feb 2023 16:55:20 +0100 Subject: [PATCH] Calculate and display y_dir --- pyzebra/app/panel_plot_data.py | 5 ++++- pyzebra/app/plot_hkl.py | 8 +++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/pyzebra/app/panel_plot_data.py b/pyzebra/app/panel_plot_data.py index b710c04..2e1b9bf 100644 --- a/pyzebra/app/panel_plot_data.py +++ b/pyzebra/app/panel_plot_data.py @@ -132,6 +132,7 @@ def create(): # Calculate y-direction in plot (orthogonal to x-direction and out-of-plane direction) y_c = np.cross(x_c, o_c) + hkl_in_plane_y.value = " ".join([f"{val:.1f}" for val in y_c]) # Calculate distance of all points to plane Q = np.array(o_c) * orth_cut @@ -211,6 +212,7 @@ def create(): hkl_cut = Spinner(title="cut", value=0, step=0.1, width=70) hkl_delta = NumericInput(title="delta", value=0.1, mode="float", width=70) hkl_in_plane_x = TextInput(title="in-plane X", value="1 0 0", width=70) + hkl_in_plane_y = TextInput(title="in-plane Y", value="", width=100, disabled=True) def redef_lattice_cb_callback(_attr, _old, new): if new: @@ -301,7 +303,8 @@ def create(): hkl_delta, Spacer(width=10), hkl_in_plane_x, - Spacer(width=50), + hkl_in_plane_y, + Spacer(width=10), cm_layout, ), row(column(Spacer(height=7), redef_lattice_cb), redef_lattice_ti), diff --git a/pyzebra/app/plot_hkl.py b/pyzebra/app/plot_hkl.py index 6d2cba1..901420c 100644 --- a/pyzebra/app/plot_hkl.py +++ b/pyzebra/app/plot_hkl.py @@ -46,7 +46,6 @@ class PlotHKL: cut_tol = hkl_delta.value cut_or = hkl_cut.value x_dir = list(map(float, hkl_in_plane_x.value.split())) - y_dir = list(map(float, hkl_in_plane_y.value.split())) k = np.array(k_vectors.value.split()).astype(float).reshape(-1, 3) tol_k = tol_k_ni.value @@ -98,9 +97,12 @@ class PlotHKL: # Calculate in-plane y-direction x_c = M @ x_dir - y_c = M @ y_dir o_c = M @ orth_dir + # Calculate y-direction in plot (orthogonal to x-direction and out-of-plane direction) + y_c = np.cross(x_c, o_c) + hkl_in_plane_y.value = " ".join([f"{val:.1f}" for val in y_c]) + # Normalize all directions y_c = y_c / np.linalg.norm(y_c) x_c = x_c / np.linalg.norm(x_c) @@ -349,7 +351,7 @@ class PlotHKL: hkl_cut = Spinner(title="cut", value=0, step=0.1, width=70) hkl_delta = NumericInput(title="delta", value=0.1, mode="float", width=70) hkl_in_plane_x = TextInput(title="in-plane X", value="1 0 0", width=70) - hkl_in_plane_y = TextInput(title="in-plane Y", value="0 1 0", width=70) + hkl_in_plane_y = TextInput(title="in-plane Y", value="", width=100, disabled=True) disting_opt_div = Div(text="Distinguish options:", margin=(5, 5, 0, 5)) disting_opt_cb = CheckboxGroup(