Skip to content

Commit

Permalink
Re #4303 fix error catching code
Browse files Browse the repository at this point in the history
  • Loading branch information
mdoucet committed Feb 2, 2012
1 parent 4883e6f commit d20a433
Show file tree
Hide file tree
Showing 6 changed files with 772 additions and 705 deletions.
1,022 changes: 511 additions & 511 deletions Code/Mantid/instrument/Grouping/REFL_Detector_Grouping_Sum_X.xml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def __init__(self):
super(DataSets, self).__init__()
self.reset()

def to_script(self):
def to_script(self, for_automated_reduction=False):
"""
Generate reduction script
@param execute: if true, the script will be executed
Expand All @@ -58,7 +58,10 @@ def to_script(self):
script += " TOFRange=%s,\n" % str(self.DataTofRange)
script += " QMin=%s,\n" % str(self.q_min)
script += " QStep=%s,\n" % str(self.q_step)
script += " OutputWorkspace='reflectivity_%s')" % str(self.data_files[0])
if for_automated_reduction:
script += " OutputWorkspace='reflectivity_'+%s)" % str(self.data_files[0])
else:
script += " OutputWorkspace='reflectivity_%s')" % str(self.data_files[0])
script += "\n"

return script
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,10 @@ def _create_auto_reduce_template(self):
content = "# Script automatically generated by Mantid on %s\n" % time.ctime()
content += "import sys\n"
content += "import os\n"
content += "sys.path.append('/opt/Mantid/bin')\n"
content += "from MantidFramework import *\n"
content += "if (os.environ.has_key(\"MANTIDPATH\")):\n"
content += " del os.environ[\"MANTIDPATH\"]\n"
content += "sys.path.insert(0,'/opt/mantidnightly/bin')\n"
content += "from MantidFramework import mtd\n"
content += "mtd.initialize()\n"
content += "from mantidsimple import *\n\n"

Expand All @@ -114,7 +116,7 @@ def _create_auto_reduce_template(self):
content += "file_name = 'reflectivity_'+runNumber+'.txt'\n"
content += "file_path = os.path.join(outputDir,file_name)\n"
content += "SaveAscii(Filename=file_path,\n"
content += " InputWorkspace='reflectivity_runNumber',\n"
content += " InputWorkspace='reflectivity_'+runNumber,\n"
content += " Separator='Tab',\n"
content += " CommentIndicator='# ')"

Expand Down Expand Up @@ -259,6 +261,11 @@ def set_state(self, state):
if len(state.data_sets)>0:
self.set_editing_state(state.data_sets[0])
self._summary.angle_list.setCurrentRow(0)

# Common Q binning
self._summary.q_min_edit.setText(str(state.data_sets[0].q_min))
self._summary.log_scale_chk.setChecked(state.data_sets[0].q_step<0)
self._summary.q_step_edit.setText(str(math.fabs(state.data_sets[0].q_step)))

def set_editing_state(self, state):

Expand Down Expand Up @@ -298,9 +305,9 @@ def set_editing_state(self, state):
self._summary.norm_background_to_pixel1.setText(str(state.NormBackgroundRoi[1]))

# Q binning
self._summary.q_min_edit.setText(str(state.q_min))
self._summary.log_scale_chk.setChecked(state.q_step<0)
self._summary.q_step_edit.setText(str(math.fabs(state.q_step)))
#self._summary.q_min_edit.setText(str(state.q_min))
#self._summary.log_scale_chk.setChecked(state.q_step<0)
#self._summary.q_step_edit.setText(str(math.fabs(state.q_step)))

def get_state(self):
"""
Expand All @@ -309,8 +316,19 @@ def get_state(self):
m = self.get_editing_state()
state = DataSeries()
state_list = []

# Common Q binning
q_min = float(self._summary.q_min_edit.text())
q_step = float(self._summary.q_step_edit.text())
if self._summary.log_scale_chk.isChecked():
q_step = -q_step

for i in range(self._summary.angle_list.count()):
data = self._summary.angle_list.item(i).data(QtCore.Qt.UserRole).toPyObject()
# Over-write Q binning with common binning
data.q_min = q_min
data.q_step = q_step

state_list.append(data)
state.data_sets = state_list
return state
Expand Down Expand Up @@ -357,9 +375,9 @@ def get_editing_state(self):
roi1_to = int(self._summary.norm_background_to_pixel1.text())
m.NormBackgroundRoi = [roi1_from, roi1_to]

m.q_min = float(self._summary.q_min_edit.text())
m.q_step = float(self._summary.q_step_edit.text())
if self._summary.log_scale_chk.isChecked():
m.q_step = -m.q_step
#m.q_min = float(self._summary.q_min_edit.text())
#m.q_step = float(self._summary.q_step_edit.text())
#if self._summary.log_scale_chk.isChecked():
# m.q_step = -m.q_step

return m

0 comments on commit d20a433

Please sign in to comment.