From e99edbaf729b2d679e91937614a916b3191681dc Mon Sep 17 00:00:00 2001 From: Ivan Usov Date: Tue, 11 May 2021 14:22:55 +0200 Subject: [PATCH] Add a temporary workaround for integral area --- pyzebra/app/panel_ccl_integrate.py | 3 +-- pyzebra/ccl_io.py | 9 +++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/pyzebra/app/panel_ccl_integrate.py b/pyzebra/app/panel_ccl_integrate.py index 3f13cf8..3e832d5 100644 --- a/pyzebra/app/panel_ccl_integrate.py +++ b/pyzebra/app/panel_ccl_integrate.py @@ -371,7 +371,6 @@ def create(): # ("Pseudo Voigt1", "pseudovoigt1"), ], width=145, - disabled=True, ) fitparams_add_dropdown.on_click(fitparams_add_dropdown_callback) @@ -406,7 +405,7 @@ def create(): fitparams_select.value = [] - fitparams_remove_button = Button(label="Remove fit function", width=145, disabled=True) + fitparams_remove_button = Button(label="Remove fit function", width=145) fitparams_remove_button.on_click(fitparams_remove_button_callback) def fitparams_factory(function): diff --git a/pyzebra/ccl_io.py b/pyzebra/ccl_io.py index 80e0e29..247a84f 100644 --- a/pyzebra/ccl_io.py +++ b/pyzebra/ccl_io.py @@ -3,6 +3,7 @@ import re from collections import defaultdict import numpy as np +from scipy.integrate import simpson, trapezoid META_VARS_STR = ( "instrument", @@ -277,8 +278,12 @@ def export_1D(data, path, area_method=AREA_METHODS[0], lorentz=False, hkl_precis break else: # no peak functions in a fit model - area_n = np.nan - area_s = np.nan + # assume this is a background fit, so do numeric integration + y_val = scan["Counts"] + x_val = scan[scan["scan_motor"]] + y_bkg = scan["fit"].eval(x=x_val) + area_n = simpson(y_val, x=x_val) - trapezoid(y_bkg, x=x_val) + area_s = np.sqrt(area_n) # apply lorentz correction to area if lorentz: