Skip to content

Commit

Permalink
Merge pull request #117 from neutrons/add_deadtime
Browse files Browse the repository at this point in the history
Add dead time option
  • Loading branch information
mdoucet authored Mar 26, 2024
2 parents ee64971 + 8417686 commit 53f5257
Show file tree
Hide file tree
Showing 12 changed files with 40 additions and 483 deletions.
4 changes: 4 additions & 0 deletions RefRed/configuration/export_xml_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@ def main_part(self):
)

str_array.append(' <slits_width_flag>True</slits_width_flag>\n')

# Dead time correction
dead_time = o_general_settings.dead_time
str_array.append(' <dead_time_correction>' + str(dead_time) + '</dead_time_correction>\n')
str_array.append(' </RefLData>\n')

str_array.append(' </DataSeries>\n')
Expand Down
3 changes: 3 additions & 0 deletions RefRed/configuration/loading_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,9 @@ def populate_main_gui_general_settings(self):
o_scaling_factor_widget.checkbox(status=scaling_factor_flag)
o_scaling_factor_widget.set_enabled(status=scaling_factor_flag)

use_dead_time = str2bool(self.getNodeValue(node_0, 'dead_time_correction'))
self.parent.ui.deadtime_checkbox.setChecked(use_dead_time)

def getMetadataObject(self, node) -> LConfigDataset:
r"""Populate an instance of type LConfigDataset using the information contained in one of the
'RefLData XML blocks within a configuration file."""
Expand Down
2 changes: 1 addition & 1 deletion RefRed/gui_handling/gui_utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def init_widgets_value(self):
_gui_metadata = self.parent.gui_metadata

# event tof bins
_tof_bin = _gui_metadata['tof_bin']
_tof_bin = int(_gui_metadata['tof_bin'])
self.parent.ui.eventTofBins.setValue(_tof_bin)

# q bin
Expand Down
4 changes: 2 additions & 2 deletions RefRed/initialization/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ def set_gui_size(self):
self.parent.setGeometry(
50,
50,
self.gui_size_coeff * screen.width(),
self.gui_size_coeff * screen.height(),
int(self.gui_size_coeff * screen.width()),
int(self.gui_size_coeff * screen.height()),
)

def set_statusbar(self):
Expand Down
6 changes: 0 additions & 6 deletions RefRed/interfaces/mplwidgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import os
import tempfile
from qtpy import QtCore, QtGui, QtWidgets
import matplotlib.cm
import matplotlib.colors
from matplotlib.colors import LogNorm, Normalize
from RefRed.config import plotting
Expand All @@ -17,11 +16,6 @@ def _set_default_rc():

_set_default_rc()

cmap = matplotlib.colors.LinearSegmentedColormap.from_list(
"default", ["#0000ff", "#00ff00", "#ffff00", "#ff0000", "#bd7efc", "#000000"], N=256
)
matplotlib.cm.register_cmap("default", cmap=cmap)


# set the default backend to be compatible with Qt in case someone uses pylab from IPython console
def set_matplotlib_backend():
Expand Down
484 changes: 19 additions & 465 deletions RefRed/interfaces/refred_main_interface.ui

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions RefRed/reduction/global_reduction_settings_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def retrieve(self):
self.angle_offset_error = self.get_angle_offset_error()
self.tof_steps = self.get_tof_steps()
self.apply_normalization = self.parent.ui.useNormalizationFlag.isChecked()
self.dead_time = self.parent.ui.deadtime_checkbox.isChecked()

def to_dict(self):
"""
Expand All @@ -40,6 +41,7 @@ def to_dict(self):
"angle_offset_error",
"tof_steps",
"apply_normalization",
"dead_time",
]
return {k: getattr(self, k) for k in keys}

Expand Down
1 change: 0 additions & 1 deletion RefRed/reduction/live_reduction_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ def run(self):
template_data,
info=True,
normalize=reduction_pars['apply_normalization'],
functional_background=reduction_pars['two_backgrounds'],
)
self.save_reduction(row_index, refl=[q, r, dr], info=info)
except:
Expand Down
2 changes: 1 addition & 1 deletion RefRed/sf_calculator/sf_calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def runSequenceLineEditEvent(self):

def updateProgressBar(self, progress):
self.event_progressbar.setVisible(True)
self.event_progressbar.setValue(progress * 100)
self.event_progressbar.setValue(int(progress * 100))
self.event_progressbar.update()
if progress == 1:
time.sleep(2)
Expand Down
12 changes: 6 additions & 6 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
name: refred
channels:
- mantid/label/main
- mantid/label/nightly
- conda-forge
- defaults
dependencies:
- python=3.8
- mantid=6.7.0
- qt>=5.12.9,<6
- pyqt>=5.12.3
- python=3.10
- mantid>6.9.20240318
- qt==5.15.8
- pyqt>=5.15,<6
- qtpy>=1.9.0
- configobj
- matplotlib
- pip
- pip:
- git+https://github.com/neutrons/[email protected].18#egg=lr_reduction
- git+https://github.com/neutrons/[email protected].21#egg=lr_reduction
# documentation
- sphinx
- sphinx_rtd_theme
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ numpy
PyQt5
qtpy
setuptools
lr_reduction@git+https://github.com/neutrons/[email protected].18#egg=lr_reduction
lr_reduction@git+https://github.com/neutrons/[email protected].21#egg=lr_reduction

Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def test_populate_main_gui_general_settings(self):
'scaling_factor_file': 'scaling_factor_file',
'incident_medium_index_selected': 5.005,
'scaling_factor_flag': 6.006,
'dead_time_correction': False,
}

def side_effect(node, arg):
Expand Down

1 comment on commit 53f5257

@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 refred-dev has been submitted for this commit: "https://code.ornl.gov/sns-hfir-scse/deployments/conda-legacy-deploy/-/pipelines/544412"

Please sign in to comment.