Skip to content

Commit

Permalink
Re #5042 Improved stitcher/added choice of ref x-section
Browse files Browse the repository at this point in the history
  • Loading branch information
mdoucet committed Apr 17, 2012
1 parent fc886e1 commit ed71fb0
Show file tree
Hide file tree
Showing 3 changed files with 178 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,14 @@ def get_user_data(self, polarization=0):
return self._data[ReflData.OFF_OFF]

def get_skipped(self):
low = int(self._low_skip_ctrl.text())
high = int(self._high_skip_ctrl.text())
low_str = str(self._low_skip_ctrl.text())
low = 0
high = 0
if len(low_str.strip())>0:
low = int(low_str)
high_str = str(self._high_skip_ctrl.text())
if len(high_str.strip())>0:
high = int(high_str)
return low, high

def update_skipped(self):
Expand Down Expand Up @@ -217,6 +223,21 @@ def initialize_content(self):
self._content.max_q_unity_edit.setText("0.01")
self._content.max_q_unity_edit.setValidator(QtGui.QDoubleValidator(self._content.max_q_unity_edit))

if self._settings.instrument_name == "REFL":
self._content.ref_pol_label.hide()
self._content.off_off_radio.hide()
self._content.on_off_radio.hide()
self._content.off_on_radio.hide()
self._content.on_on_radio.hide()
else:
self.radio_group = QtGui.QButtonGroup()
self.radio_group.addButton(self._content.off_off_radio)
self.radio_group.addButton(self._content.off_on_radio)
self.radio_group.addButton(self._content.on_off_radio)
self.radio_group.addButton(self._content.on_on_radio)
self.radio_group.setExclusive(True)


def _add_entry(self, workspace):
entry = ReflData(workspace, parent_layout=self._content.angle_list_layout)
self._workspace_list.append(entry)
Expand All @@ -243,7 +264,12 @@ def _apply(self):
try:
self._scale_data_sets()
except:
mtd.sendLogMessage("Could not scale data\n%s" % sys.exc_value)
message = "Could not scale data\n %s" % sys.exc_value
if self._content.scale_to_one_chk.isChecked():
message += "\n\nCheck your Q range near the critical edge"
QtGui.QMessageBox.warning(self,
"Error scaling data",
message)

def _pick_specular_ridge(self):
from LargeScaleStructures import data_stitching
Expand Down Expand Up @@ -273,6 +299,16 @@ def _scale_data_sets(self):

s = Stitcher()
refID = 0

# Get reference cross-section
ref_pol = ReflData.OFF_OFF
if self._content.off_on_radio.isChecked():
ref_pol = ReflData.OFF_ON
elif self._content.on_off_radio.isChecked():
ref_pol = ReflData.ON_OFF
elif self._content.on_on_radio.isChecked():
ref_pol = ReflData.ON_ON

for i in range(len(self._workspace_list)):
item = self._workspace_list[i]
data = DataSet(item.name)
Expand All @@ -291,8 +327,13 @@ def _scale_data_sets(self):
data.set_scale(scale)
item.set_scale(scale)


s.append(data)
ref_data = item.get_user_data(ref_pol)
if ref_data is None:
QtGui.QMessageBox.warning(self,
"Invalid choice of reference cross-section",
"The selected cross-section is empty, please select another one")
return
s.append(ref_data)

if s.size()==0:
mtd.sendLogMessage("No data to scale")
Expand All @@ -302,7 +343,7 @@ def _scale_data_sets(self):
s.compute()

for item in self._workspace_list:
data = item.get_user_data()
data = item.get_user_data(ref_pol)
data.apply_scale()
scale = data.get_scale()
item.set_scale(scale)
Expand Down
95 changes: 95 additions & 0 deletions Code/Mantid/scripts/Interface/ui/reflectometer/refl_stitching.ui
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,101 @@ skip</string>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="ref_pol_label">
<property name="text">
<string>Reference cross-section:</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="off_off_radio">
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Off-Off</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="on_off_radio">
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>On-Off</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="off_on_radio">
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Off-On</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="on_on_radio">
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>On-On</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_7">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

# Form implementation generated from reading ui file 'ui/reflectometer/refl_stitching.ui'
#
# Created: Tue Apr 10 13:22:26 2012
# by: PyQt4 UI code generator 4.7.2
# Created: Tue Apr 17 12:56:48 2012
# by: PyQt4 UI code generator 4.7.4
#
# WARNING! All changes made in this file will be lost!

Expand Down Expand Up @@ -148,8 +148,35 @@ def setupUi(self, Frame):
self.save_btn.setObjectName("save_btn")
self.horizontalLayout_2.addWidget(self.save_btn)
self.verticalLayout_3.addLayout(self.horizontalLayout_2)
spacerItem5 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
self.verticalLayout_3.addItem(spacerItem5)
self.horizontalLayout_5 = QtGui.QHBoxLayout()
self.horizontalLayout_5.setObjectName("horizontalLayout_5")
spacerItem5 = QtGui.QSpacerItem(20, 20, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Minimum)
self.horizontalLayout_5.addItem(spacerItem5)
self.ref_pol_label = QtGui.QLabel(self.scrollAreaWidgetContents)
self.ref_pol_label.setObjectName("ref_pol_label")
self.horizontalLayout_5.addWidget(self.ref_pol_label)
self.off_off_radio = QtGui.QRadioButton(self.scrollAreaWidgetContents)
self.off_off_radio.setMinimumSize(QtCore.QSize(100, 0))
self.off_off_radio.setChecked(True)
self.off_off_radio.setObjectName("off_off_radio")
self.horizontalLayout_5.addWidget(self.off_off_radio)
self.on_off_radio = QtGui.QRadioButton(self.scrollAreaWidgetContents)
self.on_off_radio.setMinimumSize(QtCore.QSize(100, 0))
self.on_off_radio.setObjectName("on_off_radio")
self.horizontalLayout_5.addWidget(self.on_off_radio)
self.off_on_radio = QtGui.QRadioButton(self.scrollAreaWidgetContents)
self.off_on_radio.setMinimumSize(QtCore.QSize(100, 0))
self.off_on_radio.setObjectName("off_on_radio")
self.horizontalLayout_5.addWidget(self.off_on_radio)
self.on_on_radio = QtGui.QRadioButton(self.scrollAreaWidgetContents)
self.on_on_radio.setMinimumSize(QtCore.QSize(100, 0))
self.on_on_radio.setObjectName("on_on_radio")
self.horizontalLayout_5.addWidget(self.on_on_radio)
spacerItem6 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.horizontalLayout_5.addItem(spacerItem6)
self.verticalLayout_3.addLayout(self.horizontalLayout_5)
spacerItem7 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
self.verticalLayout_3.addItem(spacerItem7)
self.horizontalLayout_6.addLayout(self.verticalLayout_3)
self.verticalLayout_2.addLayout(self.horizontalLayout_6)
self.scrollArea.setWidget(self.scrollAreaWidgetContents)
Expand Down Expand Up @@ -188,4 +215,9 @@ def retranslateUi(self, Frame):
self.pick_unity_range_btn.setText(QtGui.QApplication.translate("Frame", "Pick range", None, QtGui.QApplication.UnicodeUTF8))
self.auto_scale_btn.setText(QtGui.QApplication.translate("Frame", "Auto scale", None, QtGui.QApplication.UnicodeUTF8))
self.save_btn.setText(QtGui.QApplication.translate("Frame", "Save", None, QtGui.QApplication.UnicodeUTF8))
self.ref_pol_label.setText(QtGui.QApplication.translate("Frame", "Reference cross-section:", None, QtGui.QApplication.UnicodeUTF8))
self.off_off_radio.setText(QtGui.QApplication.translate("Frame", "Off-Off", None, QtGui.QApplication.UnicodeUTF8))
self.on_off_radio.setText(QtGui.QApplication.translate("Frame", "On-Off", None, QtGui.QApplication.UnicodeUTF8))
self.off_on_radio.setText(QtGui.QApplication.translate("Frame", "Off-On", None, QtGui.QApplication.UnicodeUTF8))
self.on_on_radio.setText(QtGui.QApplication.translate("Frame", "On-On", None, QtGui.QApplication.UnicodeUTF8))

0 comments on commit ed71fb0

Please sign in to comment.