From bc66c593f33ede86c2477011a1ab9b2b68ffb836 Mon Sep 17 00:00:00 2001 From: Ivan Usov Date: Mon, 6 Feb 2023 15:32:32 +0100 Subject: [PATCH] Minor simplifications --- pyzebra/app/panel_plot_data.py | 8 +++--- pyzebra/app/plot_hkl.py | 47 ++++++++++++++-------------------- 2 files changed, 23 insertions(+), 32 deletions(-) diff --git a/pyzebra/app/panel_plot_data.py b/pyzebra/app/panel_plot_data.py index 7f1c70b..97fd2f5 100644 --- a/pyzebra/app/panel_plot_data.py +++ b/pyzebra/app/panel_plot_data.py @@ -119,7 +119,7 @@ def create(): ) # Convert all hkls to cartesian - hkl = [[h[:, :, :], k[:, :, :], l[:, :, :]]] + hkl = [[h, k, l]] hkl = np.transpose(hkl) hkl_c = np.matmul(M, hkl) @@ -153,9 +153,9 @@ def create(): y = np.transpose(y) # Get slices: - x_slice = x[ind[0], ind[1], ind[2]] - y_slice = y[ind[0], ind[1], ind[2]] - I_slice = I_matrix[ind[0], ind[1], ind[2]] + x_slice = x[ind] + y_slice = y[ind] + I_slice = I_matrix[ind] # Meshgrid limits for plotting if auto_range_cb.active: diff --git a/pyzebra/app/plot_hkl.py b/pyzebra/app/plot_hkl.py index 1792d99..6d2cba1 100644 --- a/pyzebra/app/plot_hkl.py +++ b/pyzebra/app/plot_hkl.py @@ -51,11 +51,6 @@ class PlotHKL: k = np.array(k_vectors.value.split()).astype(float).reshape(-1, 3) tol_k = tol_k_ni.value - # Plotting options - grid_flag = 1 - grid_minor_flag = 1 - grid_div = 2 # Number of minor division lines per unit - # different symbols based on file number file_flag = 0 in disting_opt_cb.active # scale marker size according to intensity @@ -144,9 +139,7 @@ class PlotHKL: # Calculate resolution in degrees expr = np.tan(gammad / 2 * np.pi / 180) - res = ( - np.sqrt(0.4639 * expr**2 - 0.4452 * expr + 0.1506) * res_mult - ) # res in deg + res = np.sqrt(0.4639 * expr**2 - 0.4452 * expr + 0.1506) * res_mult # convert to resolution in hkl along scan line ang2hkl_1d = pyzebra.ang2hkl_1d @@ -196,29 +189,27 @@ class PlotHKL: # Plot grid lines xs, ys = [], [] xs_minor, ys_minor = [], [] - if grid_flag: - for yy in np.arange(min_grid_y, max_grid_y, 1): - hkl1 = M @ [0, yy, 0] - xs.append([min_grid_y, max_grid_y]) - ys.append([hkl1[1], hkl1[1]]) + for yy in np.arange(min_grid_y, max_grid_y, 1): + hkl1 = M @ [0, yy, 0] + xs.append([min_grid_y, max_grid_y]) + ys.append([hkl1[1], hkl1[1]]) - for xx in np.arange(min_grid_x, max_grid_x, 1): - hkl1 = M @ [xx, min_grid_x, 0] - hkl2 = M @ [xx, max_grid_x, 0] - xs.append([hkl1[0], hkl2[0]]) - ys.append([hkl1[1], hkl2[1]]) + for xx in np.arange(min_grid_x, max_grid_x, 1): + hkl1 = M @ [xx, min_grid_x, 0] + hkl2 = M @ [xx, max_grid_x, 0] + xs.append([hkl1[0], hkl2[0]]) + ys.append([hkl1[1], hkl2[1]]) - if grid_minor_flag: - for yy in np.arange(min_grid_y, max_grid_y, 1 / grid_div): - hkl1 = M @ [0, yy, 0] - xs_minor.append([min_grid_y, max_grid_y]) - ys_minor.append([hkl1[1], hkl1[1]]) + for yy in np.arange(min_grid_y, max_grid_y, 0.5): + hkl1 = M @ [0, yy, 0] + xs_minor.append([min_grid_y, max_grid_y]) + ys_minor.append([hkl1[1], hkl1[1]]) - for xx in np.arange(min_grid_x, max_grid_x, 1 / grid_div): - hkl1 = M @ [xx, min_grid_x, 0] - hkl2 = M @ [xx, max_grid_x, 0] - xs_minor.append([hkl1[0], hkl2[0]]) - ys_minor.append([hkl1[1], hkl2[1]]) + for xx in np.arange(min_grid_x, max_grid_x, 0.5): + hkl1 = M @ [xx, min_grid_x, 0] + hkl2 = M @ [xx, max_grid_x, 0] + xs_minor.append([hkl1[0], hkl2[0]]) + ys_minor.append([hkl1[1], hkl2[1]]) grid_source.data.update(xs=xs, ys=ys) minor_grid_source.data.update(xs=xs_minor, ys=ys_minor)