Enable fit range selection
This commit is contained in:
parent
3291a67e7d
commit
fe68b1de7e
@ -311,8 +311,8 @@ def create():
|
|||||||
merge_button = Button(label="Merge scans", width=145)
|
merge_button = Button(label="Merge scans", width=145)
|
||||||
merge_button.on_click(merge_button_callback)
|
merge_button.on_click(merge_button_callback)
|
||||||
|
|
||||||
integ_from = Spinner(title="Integrate from:", default_size=145, disabled=True)
|
fit_from_spinner = Spinner(title="Fit from:", default_size=145)
|
||||||
integ_to = Spinner(title="to:", default_size=145, disabled=True)
|
fit_to_spinner = Spinner(title="to:", default_size=145)
|
||||||
|
|
||||||
def fitparams_add_dropdown_callback(click):
|
def fitparams_add_dropdown_callback(click):
|
||||||
# bokeh requires (str, str) for MultiSelect options
|
# bokeh requires (str, str) for MultiSelect options
|
||||||
@ -416,7 +416,9 @@ def create():
|
|||||||
|
|
||||||
def fit_all_button_callback():
|
def fit_all_button_callback():
|
||||||
for scan in det_data:
|
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_plot(_get_selected_scan())
|
||||||
_update_table()
|
_update_table()
|
||||||
@ -426,7 +428,9 @@ def create():
|
|||||||
|
|
||||||
def fit_button_callback():
|
def fit_button_callback():
|
||||||
scan = _get_selected_scan()
|
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_plot(scan)
|
||||||
_update_table()
|
_update_table()
|
||||||
@ -514,7 +518,7 @@ def create():
|
|||||||
fitparams_table,
|
fitparams_table,
|
||||||
Spacer(width=20),
|
Spacer(width=20),
|
||||||
column(
|
column(
|
||||||
row(integ_from, integ_to),
|
row(fit_from_spinner, fit_to_spinner),
|
||||||
row(bin_size_spinner, column(Spacer(height=19), lorentz_toggle)),
|
row(bin_size_spinner, column(Spacer(height=19), lorentz_toggle)),
|
||||||
row(area_method_radiobutton),
|
row(area_method_radiobutton),
|
||||||
row(fit_button, fit_all_button),
|
row(fit_button, fit_all_button),
|
||||||
|
@ -414,8 +414,8 @@ def create():
|
|||||||
)
|
)
|
||||||
param_select.on_change("value", param_select_callback)
|
param_select.on_change("value", param_select_callback)
|
||||||
|
|
||||||
integ_from = Spinner(title="Integrate from:", default_size=145, disabled=True)
|
fit_from_spinner = Spinner(title="Fit from:", default_size=145)
|
||||||
integ_to = Spinner(title="to:", default_size=145, disabled=True)
|
fit_to_spinner = Spinner(title="to:", default_size=145)
|
||||||
|
|
||||||
def fitparams_add_dropdown_callback(click):
|
def fitparams_add_dropdown_callback(click):
|
||||||
# bokeh requires (str, str) for MultiSelect options
|
# bokeh requires (str, str) for MultiSelect options
|
||||||
@ -518,7 +518,9 @@ def create():
|
|||||||
|
|
||||||
def fit_all_button_callback():
|
def fit_all_button_callback():
|
||||||
for scan in det_data:
|
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_plot()
|
||||||
_update_table()
|
_update_table()
|
||||||
@ -528,7 +530,9 @@ def create():
|
|||||||
|
|
||||||
def fit_button_callback():
|
def fit_button_callback():
|
||||||
scan = _get_selected_scan()
|
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_plot()
|
||||||
_update_table()
|
_update_table()
|
||||||
@ -610,7 +614,7 @@ def create():
|
|||||||
fitparams_table,
|
fitparams_table,
|
||||||
Spacer(width=20),
|
Spacer(width=20),
|
||||||
column(
|
column(
|
||||||
row(integ_from, integ_to),
|
row(fit_from_spinner, fit_to_spinner),
|
||||||
row(bin_size_spinner, column(Spacer(height=19), lorentz_toggle)),
|
row(bin_size_spinner, column(Spacer(height=19), lorentz_toggle)),
|
||||||
row(area_method_radiobutton),
|
row(area_method_radiobutton),
|
||||||
row(fit_button, fit_all_button),
|
row(fit_button, fit_all_button),
|
||||||
|
@ -87,10 +87,20 @@ def merge_scans(scan1, scan2):
|
|||||||
print(f'Merging scans: {scan1["idx"]} ({fname1}) <-- {scan2["idx"]} ({fname2})')
|
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"]
|
y_fit = scan["Counts"]
|
||||||
x_fit = scan[scan["scan_motor"]]
|
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
|
model = None
|
||||||
for model_index, (model_name, model_param) in enumerate(model_dict.items()):
|
for model_index, (model_name, model_param) in enumerate(model_dict.items()):
|
||||||
model_name, _ = model_name.split("-")
|
model_name, _ = model_name.split("-")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user