Skip to content

Commit

Permalink
Re #10859 add error weighting option to HFIR UI
Browse files Browse the repository at this point in the history
  • Loading branch information
mdoucet committed Jan 8, 2015
1 parent 4de8be7 commit 7f5b9df
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 15 deletions.
Expand Up @@ -39,6 +39,7 @@ class ReductionOptions(BaseScriptElement):
n_sub_pix = 1
log_binning = False
align_log_with_decades = True
error_weighting = False

# Wedges
n_wedges = 2
Expand Down Expand Up @@ -123,6 +124,7 @@ def to_script(self):
# Q binning
script += "AzimuthalAverage(n_bins=%g, n_subpix=%g, log_binning=%s" % (self.n_q_bins, self.n_sub_pix, str(self.log_binning))
if self.align_log_with_decades: script += ", align_log_with_decades=%s" % str(self.align_log_with_decades)
if self.error_weighting: script += ", error_weighting=%s" % str(self.error_weighting)
script += ")\n"

# If we align we decades, use more points for I(qx,qy)
Expand Down Expand Up @@ -191,6 +193,7 @@ def to_xml(self):
xml += " <n_sub_pix>%g</n_sub_pix>\n" % self.n_sub_pix
xml += " <log_binning>%s</log_binning>\n" % str(self.log_binning)
xml += " <align_log_with_decades>%s</align_log_with_decades>\n" % str(self.align_log_with_decades)
xml += " <error_weighting>%s</error_weighting>\n" % str(self.error_weighting)

xml += " <n_wedges>%g</n_wedges>\n" % self.n_wedges
xml += " <wedge_angle>%g</wedge_angle>\n" % self.wedge_angle
Expand Down Expand Up @@ -283,6 +286,8 @@ def from_xml(self, xml_str):
default = ReductionOptions.log_binning)
self.align_log_with_decades = BaseScriptElement.getBoolElement(instrument_dom, "align_log_with_decades",
default = ReductionOptions.align_log_with_decades)
self.error_weighting = BaseScriptElement.getBoolElement(instrument_dom, "error_weighting",
default = ReductionOptions.error_weighting)

self.n_wedges = BaseScriptElement.getIntElement(instrument_dom, "n_wedges",
default=ReductionOptions.n_wedges)
Expand Down Expand Up @@ -369,6 +374,7 @@ def from_setup_info(self, xml_str):
self.n_sub_pix = BaseScriptElement.getPropertyValue(alg, "NumberOfSubpixels", default=ReductionOptions.n_sub_pix)
self.log_binning = BaseScriptElement.getPropertyValue(alg, "IQLogBinning", default = ReductionOptions.log_binning)
self.align_log_with_decades = BaseScriptElement.getPropertyValue(alg, "IQAlignLogWithDecades", default = ReductionOptions.align_log_with_decades)
self.error_weighting = BaseScriptElement.getPropertyValue(alg, "ErrorWeighting", default = ReductionOptions.error_weighting)

self.n_wedges = BaseScriptElement.getPropertyValue(alg, "NumberOfWedges", default=ReductionOptions.n_wedges)
self.wedge_angle = BaseScriptElement.getPropertyValue(alg, "WedgeAngle", default=ReductionOptions.wedge_angle)
Expand Down Expand Up @@ -445,6 +451,7 @@ def reset(self):
self.n_sub_pix = ReductionOptions.n_sub_pix
self.log_binning = ReductionOptions.log_binning
self.align_log_with_decades = ReductionOptions.align_log_with_decades
self.error_weighting = ReductionOptions.error_weighting

self.n_wedges = ReductionOptions.n_wedges
self.wedge_angle = ReductionOptions.wedge_angle
Expand Down
Expand Up @@ -348,6 +348,7 @@ def set_state(self, state):
self._summary.log_binning_radio.setChecked(state.log_binning)
self._summary.align_check.setEnabled(state.log_binning)
self._summary.align_check.setChecked(state.align_log_with_decades)
self._summary.error_weighting_check.setChecked(state.error_weighting)

self._summary.n_wedges_edit.setText(str(state.n_wedges))
self._summary.wedge_angle_edit.setText(str(state.wedge_angle))
Expand Down Expand Up @@ -426,6 +427,7 @@ def get_state(self):
m.n_sub_pix = util._check_and_get_int_line_edit(self._summary.n_sub_pix_edit)
m.log_binning = self._summary.log_binning_radio.isChecked()
m.align_log_with_decades = self._summary.align_check.isChecked()
m.error_weighting = self._summary.error_weighting_check.isChecked()

m.n_wedges = util._check_and_get_int_line_edit(self._summary.n_wedges_edit)
m.wedge_angle = util._check_and_get_float_line_edit(self._summary.wedge_angle_edit)
Expand Down
21 changes: 14 additions & 7 deletions Code/Mantid/scripts/Interface/ui/sans/hfir_instrument.ui
Expand Up @@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>1026</width>
<width>1053</width>
<height>1152</height>
</rect>
</property>
Expand Down Expand Up @@ -60,7 +60,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>1026</width>
<width>1053</width>
<height>1152</height>
</rect>
</property>
Expand Down Expand Up @@ -788,23 +788,30 @@ in each direction and will create 9 sub-pixels.</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="error_weighting_check">
<property name="text">
<string>Error weighting</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="log_binning_radio">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>120</width>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>120</width>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
Expand All @@ -822,14 +829,14 @@ in each direction and will create 9 sub-pixels.</string>
<item>
<widget class="QCheckBox" name="align_check">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>160</width>
<width>0</width>
<height>0</height>
</size>
</property>
Expand Down
20 changes: 12 additions & 8 deletions Code/Mantid/scripts/Interface/ui/sans/ui_hfir_instrument.py
Expand Up @@ -2,7 +2,7 @@

# Form implementation generated from reading ui file 'ui/sans/hfir_instrument.ui'
#
# Created: Wed Nov 19 14:25:58 2014
# Created: Thu Jan 8 09:09:45 2015
# by: PyQt4 UI code generator 4.7.4
#
# WARNING! All changes made in this file will be lost!
Expand All @@ -12,7 +12,7 @@
class Ui_Frame(object):
def setupUi(self, Frame):
Frame.setObjectName("Frame")
Frame.resize(1026, 1152)
Frame.resize(1053, 1152)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
Expand All @@ -36,7 +36,7 @@ def setupUi(self, Frame):
self.scrollArea.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop)
self.scrollArea.setObjectName("scrollArea")
self.scrollAreaWidgetContents = QtGui.QWidget(self.scrollArea)
self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 1026, 1152))
self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 1053, 1152))
self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents")
self.verticalLayout_4 = QtGui.QVBoxLayout(self.scrollAreaWidgetContents)
self.verticalLayout_4.setObjectName("verticalLayout_4")
Expand Down Expand Up @@ -299,24 +299,27 @@ def setupUi(self, Frame):
self.n_sub_pix_edit.setMaximumSize(QtCore.QSize(80, 16777215))
self.n_sub_pix_edit.setObjectName("n_sub_pix_edit")
self.horizontalLayout_9.addWidget(self.n_sub_pix_edit)
self.error_weighting_check = QtGui.QCheckBox(self.reduction_options_group)
self.error_weighting_check.setObjectName("error_weighting_check")
self.horizontalLayout_9.addWidget(self.error_weighting_check)
self.log_binning_radio = QtGui.QCheckBox(self.reduction_options_group)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.log_binning_radio.sizePolicy().hasHeightForWidth())
self.log_binning_radio.setSizePolicy(sizePolicy)
self.log_binning_radio.setMinimumSize(QtCore.QSize(120, 0))
self.log_binning_radio.setMaximumSize(QtCore.QSize(120, 16777215))
self.log_binning_radio.setMinimumSize(QtCore.QSize(0, 0))
self.log_binning_radio.setMaximumSize(QtCore.QSize(16777215, 16777215))
self.log_binning_radio.setLayoutDirection(QtCore.Qt.LeftToRight)
self.log_binning_radio.setObjectName("log_binning_radio")
self.horizontalLayout_9.addWidget(self.log_binning_radio)
self.align_check = QtGui.QCheckBox(self.reduction_options_group)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.align_check.sizePolicy().hasHeightForWidth())
self.align_check.setSizePolicy(sizePolicy)
self.align_check.setMinimumSize(QtCore.QSize(160, 0))
self.align_check.setMinimumSize(QtCore.QSize(0, 0))
self.align_check.setObjectName("align_check")
self.horizontalLayout_9.addWidget(self.align_check)
spacerItem8 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
Expand Down Expand Up @@ -572,6 +575,7 @@ def retranslateUi(self, Frame):
self.n_sub_pix_edit.setToolTip(QtGui.QApplication.translate("Frame", "Enter the number of sub-pixels in each direction of a detector pixel to use for the\n"
"radial averaging. For instance, entering 3 will sub-divide each detector pixel by 3\n"
"in each direction and will create 9 sub-pixels.", None, QtGui.QApplication.UnicodeUTF8))
self.error_weighting_check.setText(QtGui.QApplication.translate("Frame", "Error weighting", None, QtGui.QApplication.UnicodeUTF8))
self.log_binning_radio.setToolTip(QtGui.QApplication.translate("Frame", "Select to use logarithmic binning for I(Q).", None, QtGui.QApplication.UnicodeUTF8))
self.log_binning_radio.setText(QtGui.QApplication.translate("Frame", "Log binning", None, QtGui.QApplication.UnicodeUTF8))
self.align_check.setText(QtGui.QApplication.translate("Frame", "Align log to decades", None, QtGui.QApplication.UnicodeUTF8))
Expand Down

0 comments on commit 7f5b9df

Please sign in to comment.