Skip to content

Commit

Permalink
Merge pull request #386 from neutrons/bkg_remove
Browse files Browse the repository at this point in the history
finalize bkg removal
  • Loading branch information
Kvieta1990 authored Oct 12, 2022
2 parents a308364 + 871cc31 commit 5af9399
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions addie/post_process_m/event_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,25 @@ def load_mconfig(main_window):
for key in main_window._bankDict.keys():
if str(key) in mconfig_in.keys():
if 'Qmin' in mconfig_in[str(key)].keys():
main_window._bankDict[key]['Qmin'] = mconfig_in[str(key)]['Qmin']
qmin_tmp = mconfig_in[str(key)]['Qmin']
main_window._bankDict[key]['Qmin'] = qmin_tmp
if key == 1 and main_window.postprocessing_ui_m.comboBox_banks.currentText() == "1":
main_window.postprocessing_ui_m.doubleSpinBox_Qmin.setValue(float(qmin_tmp))
if 'Qmax' in mconfig_in[str(key)].keys():
main_window._bankDict[key]['Qmax'] = mconfig_in[str(key)]['Qmax']
qmax_tmp = mconfig_in[str(key)]['Qmax']
main_window._bankDict[key]['Qmax'] = qmax_tmp
if key == 1 and main_window.postprocessing_ui_m.comboBox_banks.currentText() == "1":
main_window.postprocessing_ui_m.doubleSpinBox_Qmax.setValue(float(qmax_tmp))
if 'Yoffset' in mconfig_in[str(key)].keys():
main_window._bankDict[key]['Yoffset'] = mconfig_in[str(key)]['Yoffset']
yoffset_tmp = mconfig_in[str(key)]['Yoffset']
main_window._bankDict[key]['Yoffset'] = yoffset_tmp
if key == 1 and main_window.postprocessing_ui_m.comboBox_banks.currentText() == "1":
main_window.postprocessing_ui_m.lineEdit_Yoffset.setText(yoffset_tmp)
if 'Yscale' in mconfig_in[str(key)].keys():
main_window._bankDict[key]['Yscale'] = mconfig_in[str(key)]['Yscale']
yscale_tmp = mconfig_in[str(key)]['Yscale']
main_window._bankDict[key]['Yscale'] = yscale_tmp
if key == 1 and main_window.postprocessing_ui_m.comboBox_banks.currentText() == "1":
main_window.postprocessing_ui_m.lineEdit_Yscale.setText(yscale_tmp)
if 'RemoveBkg' in mconfig_in.keys():
main_window.postprocessing_ui_m.checkBox_bkg_removal.setChecked(mconfig_in["RemoveBkg"])

Expand Down Expand Up @@ -443,12 +455,13 @@ def bkg_finder(all_data: list,
ws_real_bkg,
Output='ws_real_bkg_fitted')
c_err = mtd['ws_real_bkg_fitted_Parameters'].row(2)["Error"]
if c_err != 0.:
if c_err != 0. and c_err != float("inf") and c_err != float("-inf"):
break

a_init = mtd['ws_real_bkg_fitted_Parameters'].row(0)["Value"]
b_init = mtd['ws_real_bkg_fitted_Parameters'].row(1)["Value"]
c_init = mtd['ws_real_bkg_fitted_Parameters'].row(2)["Value"]

c_used = fudge_factor[bank] * c_init

y_bkg = [a_init - b_init * np.exp(-c_used * item**2.) for item in x_bank]
Expand Down Expand Up @@ -550,7 +563,7 @@ def merge_banks(main_window):
# updated to adapt to general way of grouping detectors into banks.
if len(main_window._bankDict) == 6:
qmax_bkg_est = [25., 25., 25., 25., 40., 0.]
fudge_factor = [1., 1., 0.1, 0.7, 0.7, 1.]
fudge_factor = [1., 1., 1., 0.7, 0.7, 1.]
elif len(main_window._bankDict) == 1:
qmax_bkg_est = [40.]
fudge_factor = [0.7]
Expand Down

1 comment on commit 5af9399

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GitLab pipeline for addie-dev has been submitted for this commit: "https://code.ornl.gov/sns-hfir-scse/deployments/addie-deploy/-/pipelines/290136"

Please sign in to comment.