diff --git a/pyzebra/app/panel_ccl_integrate.py b/pyzebra/app/panel_ccl_integrate.py index 45d3dc4..317785c 100644 --- a/pyzebra/app/panel_ccl_integrate.py +++ b/pyzebra/app/panel_ccl_integrate.py @@ -311,8 +311,8 @@ def create(): merge_button = Button(label="Merge scans", width=145) merge_button.on_click(merge_button_callback) - integ_from = Spinner(title="Integrate from:", default_size=145, disabled=True) - integ_to = Spinner(title="to:", default_size=145, disabled=True) + fit_from_spinner = Spinner(title="Fit from:", default_size=145) + fit_to_spinner = Spinner(title="to:", default_size=145) def fitparams_add_dropdown_callback(click): # bokeh requires (str, str) for MultiSelect options @@ -416,7 +416,9 @@ def create(): def fit_all_button_callback(): for scan in det_data: - pyzebra.fit_scan(scan, fit_params) + pyzebra.fit_scan( + scan, fit_params, fit_from=fit_from_spinner.value, fit_to=fit_to_spinner.value + ) _update_plot(_get_selected_scan()) _update_table() @@ -426,7 +428,9 @@ def create(): def fit_button_callback(): scan = _get_selected_scan() - pyzebra.fit_scan(scan, fit_params) + pyzebra.fit_scan( + scan, fit_params, fit_from=fit_from_spinner.value, fit_to=fit_to_spinner.value + ) _update_plot(scan) _update_table() @@ -514,7 +518,7 @@ def create(): fitparams_table, Spacer(width=20), column( - row(integ_from, integ_to), + row(fit_from_spinner, fit_to_spinner), row(bin_size_spinner, column(Spacer(height=19), lorentz_toggle)), row(area_method_radiobutton), row(fit_button, fit_all_button), diff --git a/pyzebra/app/panel_param_study.py b/pyzebra/app/panel_param_study.py index b96e5ff..d2d9f59 100644 --- a/pyzebra/app/panel_param_study.py +++ b/pyzebra/app/panel_param_study.py @@ -414,8 +414,8 @@ def create(): ) param_select.on_change("value", param_select_callback) - integ_from = Spinner(title="Integrate from:", default_size=145, disabled=True) - integ_to = Spinner(title="to:", default_size=145, disabled=True) + fit_from_spinner = Spinner(title="Fit from:", default_size=145) + fit_to_spinner = Spinner(title="to:", default_size=145) def fitparams_add_dropdown_callback(click): # bokeh requires (str, str) for MultiSelect options @@ -518,7 +518,9 @@ def create(): def fit_all_button_callback(): for scan in det_data: - pyzebra.fit_scan(scan, fit_params) + pyzebra.fit_scan( + scan, fit_params, fit_from=fit_from_spinner.value, fit_to=fit_to_spinner.value + ) _update_plot() _update_table() @@ -528,7 +530,9 @@ def create(): def fit_button_callback(): scan = _get_selected_scan() - pyzebra.fit_scan(scan, fit_params) + pyzebra.fit_scan( + scan, fit_params, fit_from=fit_from_spinner.value, fit_to=fit_to_spinner.value + ) _update_plot() _update_table() @@ -610,7 +614,7 @@ def create(): fitparams_table, Spacer(width=20), column( - row(integ_from, integ_to), + row(fit_from_spinner, fit_to_spinner), row(bin_size_spinner, column(Spacer(height=19), lorentz_toggle)), row(area_method_radiobutton), row(fit_button, fit_all_button), diff --git a/pyzebra/ccl_process.py b/pyzebra/ccl_process.py index 01a3bed..3ccd7e1 100644 --- a/pyzebra/ccl_process.py +++ b/pyzebra/ccl_process.py @@ -87,10 +87,20 @@ def merge_scans(scan1, scan2): print(f'Merging scans: {scan1["idx"]} ({fname1}) <-- {scan2["idx"]} ({fname2})') -def fit_scan(scan, model_dict): +def fit_scan(scan, model_dict, fit_from=None, fit_to=None): + if fit_from is None: + fit_from = -np.inf + if fit_to is None: + fit_to = np.inf + y_fit = scan["Counts"] x_fit = scan[scan["scan_motor"]] + # apply fitting range + fit_ind = (fit_from <= x_fit) & (x_fit <= fit_to) + y_fit = y_fit[fit_ind] + x_fit = x_fit[fit_ind] + model = None for model_index, (model_name, model_param) in enumerate(model_dict.items()): model_name, _ = model_name.split("-")