From 18d5bec8429ff08a2effd34d3a9113523a680851 Mon Sep 17 00:00:00 2001 From: Ivan Usov Date: Fri, 20 Jan 2023 18:12:28 +0100 Subject: [PATCH] Improve intensity estimation for marker sizes --- pyzebra/app/panel_ccl_prepare.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/pyzebra/app/panel_ccl_prepare.py b/pyzebra/app/panel_ccl_prepare.py index 64c445f..7cf88aa 100644 --- a/pyzebra/app/panel_ccl_prepare.py +++ b/pyzebra/app/panel_ccl_prepare.py @@ -29,6 +29,7 @@ from bokeh.models import ( ) from bokeh.palettes import Dark2 from bokeh.plotting import figure +from scipy.integrate import simpson, trapezoid import pyzebra from pyzebra import app @@ -401,6 +402,8 @@ def create(): print(f"Error loading {md_fname}") return + pyzebra.normalize_dataset(file_data) + # Loop throguh all data for scan in file_data: om = scan["omega"] @@ -410,7 +413,6 @@ def create(): nud = 0 # 1d detector ub = scan["ub"] counts = scan["counts"] - mon = scan["monitor"] wave = scan["wavelength"] # Calculate resolution in degrees @@ -436,14 +438,9 @@ def create(): hkl_m = ang2hkl_1d(wave, gammad, om[np.argmax(counts)], chi, phi, nud, ub) # Estimate intensity for marker size scaling - y1 = counts[0] - y2 = counts[-1] - x1 = om[0] - x2 = om[-1] - a = (y1 - y2) / (x1 - x2) - b = y1 - a * x1 - intensity_exp = np.sum(counts - (a * om + b)) - c = int(intensity_exp / mon * 10000) + y_bkg = [counts[0], counts[-1]] + x_bkg = [om[0], om[-1]] + c = int(simpson(counts, x=om) - trapezoid(y_bkg, x=x_bkg)) # Recognize k_flag_vec reduced_hkl_m = np.minimum(1 - hkl_m % 1, hkl_m % 1)