Skip to content

Commit

Permalink
Re #4303 Minor tweaks to ref_l ui
Browse files Browse the repository at this point in the history
  • Loading branch information
mdoucet committed Jan 20, 2012
1 parent be72ff6 commit 590cebf
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 48 deletions.
34 changes: 21 additions & 13 deletions Code/Mantid/Framework/PythonAPI/PythonAlgorithms/RefLReduction.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ def PyInit(self):
self.declareListProperty("RunNumbers", [0], Validator=ArrayBoundedValidator(Lower=0))
self.declareProperty("NormalizationRunNumber", 0, Description="")
self.declareListProperty("SignalPeakPixelRange", [126, 134], Validator=ArrayBoundedValidator(Lower=0))
self.declareProperty("SubtractSignalBackground", True)
self.declareListProperty("SignalBackgroundPixelRange", [123, 137], Validator=ArrayBoundedValidator(Lower=0))
self.declareListProperty("NormPeakPixelRange", [127, 133], Validator=ArrayBoundedValidator(Lower=0))
self.declareProperty("SubtractNormBackground", True)
self.declareListProperty("NormBackgroundPixelRange", [123, 137], Validator=ArrayBoundedValidator(Lower=0))
self.declareListProperty("LowResAxisPixelRange", [115, 210], Validator=ArrayBoundedValidator(Lower=0))
self.declareListProperty("TOFRange", [9000., 23600.], Validator=ArrayBoundedValidator(Lower=0))
Expand Down Expand Up @@ -69,6 +71,9 @@ def PyExec(self):
from_peak = norm_peak[0]
to_peak = norm_peak[1]

subtract_data_bck = self.getProperty("SubtractSignalBackground")
subtract_norm_bck = self.getProperty("SubtractNormBackground")

########################################################################
# Find full path to event NeXus data file
f = FileFinder.findRuns("REF_L%d" %run_numbers[0])
Expand Down Expand Up @@ -174,12 +179,14 @@ def PyExec(self):
OutputWorkspace='TransposedID')
ConvertToHistogram(InputWorkspace='TransposedID',
OutputWorkspace='TransposedID')
FlatBackground(InputWorkspace='TransposedID',
OutputWorkspace='TransposedFlatID',
StartX=BackfromYpixel,
Mode='Mean',
EndX=data_peak[0])
Transpose(InputWorkspace='TransposedFlatID',

if subtract_data_bck:
FlatBackground(InputWorkspace='TransposedID',
OutputWorkspace='TransposedID',
StartX=BackfromYpixel,
Mode='Mean',
EndX=data_peak[0])
Transpose(InputWorkspace='TransposedID',
OutputWorkspace='DataWks')


Expand Down Expand Up @@ -235,13 +242,14 @@ def PyExec(self):
ConvertToHistogram(InputWorkspace='TransposedID',
OutputWorkspace='TransposedID')

FlatBackground(InputWorkspace='TransposedID',
OutputWorkspace='TransposedFlatID',
StartX=BackfromYpixel,
Mode='Mean',
EndX=norm_peak[0])

Transpose(InputWorkspace='TransposedFlatID',
if subtract_norm_bck:
FlatBackground(InputWorkspace='TransposedID',
OutputWorkspace='TransposedID',
StartX=BackfromYpixel,
Mode='Mean',
EndX=norm_peak[0])

Transpose(InputWorkspace='TransposedID',
OutputWorkspace='NormWks')

#perform the integration myself
Expand Down
9 changes: 8 additions & 1 deletion Code/Mantid/scripts/Interface/reduction_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,14 @@ def open_file(self, file_path=None):
file_path = unicode(action.data().toString())

# Check whether the file describes the current instrument
found_instrument = self._interface.scripter.verify_instrument(file_path)
try:
found_instrument = self._interface.scripter.verify_instrument(file_path)
except:
msg = "The file you attempted to load doesn't have a recognized format.\n\n"
msg += "Please make sure it has been produced by this application."
QtGui.QMessageBox.warning(self, "Error loading reduction parameter file", msg)
return

if not found_instrument == self._instrument:
self._instrument = found_instrument
self.setup_layout()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ def to_script(self):
script = "RefLReduction(RunNumbers=%s,\n" % ','.join([str(i) for i in self.data_files])
script += " NormalizationRunNumber=%d,\n" % self.norm_file
script += " SignalPeakPixelRange=%s,\n" % str(self.DataPeakPixels)
script += " SubtractSignalBackground=%s,\n" % str(self.DataBackgroundFlag)
script += " SignalBackgroundPixelRange=%s,\n" % str(self.DataBackgroundRoi[:2])
script += " NormPeakPixelRange=%s,\n" % str(self.NormPeakPixels)
script += " NormBackgroundPixelRange=%s,\n" % str(self.NormBackgroundRoi)
script += " SubtractNormBackground=%s,\n" % str(self.NormBackgroundFlag)
script += " LowResAxisPixelRange=%s,\n" % str(self.x_range)
script += " TOFRange=%s,\n" % str(self.DataTofRange)
script += " Binning=[0,200,200000],\n"
Expand Down Expand Up @@ -115,7 +117,7 @@ def from_xml_element(self, instrument_dom):
BaseScriptElement.getIntElement(instrument_dom, "x_max_pixel")]

#discrete selection string
self.DataBackgroundFlag = BaseScriptElement.getStringElement(instrument_dom, "peak_discrete_selection")
self.DataPeakDiscreteSelection = BaseScriptElement.getStringElement(instrument_dom, "peak_discrete_selection")

#background flag
self.DataBackgroundFlag = BaseScriptElement.getBoolElement(instrument_dom, "background_flag")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,22 @@ def initialize_content(self):
self._summary.data_to_tof.setValidator(QtGui.QDoubleValidator(self._summary.data_to_tof))

# Event connections
self.connect(self._summary.norm_background_switch, QtCore.SIGNAL("clicked(bool)"), self._norm_background_clicked)
self.connect(self._summary.data_background_switch, QtCore.SIGNAL("clicked(bool)"), self._data_background_clicked)
self.connect(self._summary.plot_count_vs_y_btn, QtCore.SIGNAL("clicked()"), self._plot_count_vs_y)
self.connect(self._summary.plot_tof_btn, QtCore.SIGNAL("clicked()"), self._plot_tof)
self.connect(self._summary.add_dataset_btn, QtCore.SIGNAL("clicked()"), self._add_data)
self.connect(self._summary.angle_list, QtCore.SIGNAL("itemSelectionChanged()"), self._angle_changed)

def is_running(self, is_running):
"""
Enable/disable controls depending on whether a reduction is running or not
@param is_running: True if a reduction is running
"""
super(DataReflWidget, self).is_running(is_running)
self._summary.plot_count_vs_y_btn.setEnabled(not is_running)
self._summary.plot_tof_btn.setEnabled(not is_running)

def _data_background_clicked(self, is_checked):
"""
This is reached when the user clicks the Background switch and will enabled or not
Expand All @@ -75,6 +85,16 @@ def _data_background_clicked(self, is_checked):
self._summary.data_background_to_pixel1.setEnabled(is_checked)
self._summary.data_background_to_pixel1_label.setEnabled(is_checked)

def _norm_background_clicked(self, is_checked):
"""
This is reached when the user clicks the Background switch and will enabled or not
the widgets that follow that button
"""
self._summary.norm_background_from_pixel1.setEnabled(is_checked)
self._summary.norm_background_from_pixel1_label.setEnabled(is_checked)
self._summary.norm_background_to_pixel1.setEnabled(is_checked)
self._summary.norm_background_to_pixel1_label.setEnabled(is_checked)

def _plot_count_vs_y(self):
f = FileFinder.findRuns("REF_L%s" % str(self._summary.data_run_number_edit.text()))
if len(f)>0 and os.path.isfile(f[0]):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@
</palette>
</property>
<property name="text">
<string>*</string>
<string/>
</property>
</widget>
</item>
Expand Down Expand Up @@ -667,7 +667,7 @@
</palette>
</property>
<property name="text">
<string>*</string>
<string/>
</property>
</widget>
</item>
Expand Down Expand Up @@ -1064,7 +1064,7 @@
</widget>
</item>
<item>
<widget class="QLabel" name="data_peak_from_pixel_missing_2">
<widget class="QLabel" name="norm_peak_from_pixel_missing">
<property name="minimumSize">
<size>
<width>10</width>
Expand Down Expand Up @@ -1493,7 +1493,7 @@
</palette>
</property>
<property name="text">
<string>*</string>
<string/>
</property>
</widget>
</item>
Expand Down Expand Up @@ -1543,7 +1543,7 @@
</widget>
</item>
<item>
<widget class="QLabel" name="data_peak_to_pixel_missing_2">
<widget class="QLabel" name="norm_peak_to_pixel_missing">
<property name="palette">
<palette>
<active>
Expand Down Expand Up @@ -1582,7 +1582,7 @@
</palette>
</property>
<property name="text">
<string>*</string>
<string/>
</property>
</widget>
</item>
Expand Down Expand Up @@ -1626,7 +1626,7 @@
</widget>
</item>
<item>
<widget class="QLabel" name="data_background_from_pixel1_label_2">
<widget class="QLabel" name="norm_background_from_pixel1_label">
<property name="enabled">
<bool>false</bool>
</property>
Expand Down Expand Up @@ -1739,7 +1739,7 @@
</spacer>
</item>
<item>
<widget class="QLabel" name="data_background_to_pixel1_label_2">
<widget class="QLabel" name="norm_background_to_pixel1_label">
<property name="enabled">
<bool>false</bool>
</property>
Expand Down

0 comments on commit 590cebf

Please sign in to comment.