From cb43d217af7409a2c2ca34b32ec2671bc70a02fb Mon Sep 17 00:00:00 2001
From: Jean Bilheux <bilheuxjm@ornl.gov>
Date: Mon, 13 Feb 2012 17:04:41 -0500
Subject: [PATCH] Implemented low res flag (works). This refs #4303

---
 .../PythonAlgorithms/RefLReduction.py         | 41 +++++++++----------
 .../reflectometer/refl_data_script.py         |  2 +
 .../widgets/reflectometer/refl_data_simple.py |  4 ++
 3 files changed, 26 insertions(+), 21 deletions(-)

diff --git a/Code/Mantid/Framework/PythonAPI/PythonAlgorithms/RefLReduction.py b/Code/Mantid/Framework/PythonAPI/PythonAlgorithms/RefLReduction.py
index 7523d1d080c..bede2ca8353 100644
--- a/Code/Mantid/Framework/PythonAPI/PythonAlgorithms/RefLReduction.py
+++ b/Code/Mantid/Framework/PythonAPI/PythonAlgorithms/RefLReduction.py
@@ -24,7 +24,9 @@ class RefLReduction(PythonAlgorithm):
         self.declareListProperty("NormPeakPixelRange", [127, 133], Validator=ArrayBoundedValidator(Lower=0))
         self.declareProperty("SubtractNormBackground", True)
         self.declareListProperty("NormBackgroundPixelRange", [123, 137], Validator=ArrayBoundedValidator(Lower=0))
+        self.declareProperty("LowResDataAxisPixelRangeFlag", True)
         self.declareListProperty("LowResDataAxisPixelRange", [115, 210], Validator=ArrayBoundedValidator(Lower=0))
+        self.declareProperty("LowResNormAxisPixelRangeFlag", True)
         self.declareListProperty("LowResNormAxisPixelRange", [115, 210], Validator=ArrayBoundedValidator(Lower=0))
         self.declareListProperty("TOFRange", [9000., 23600.], Validator=ArrayBoundedValidator(Lower=0))
         self.declareProperty("QMin", 0.001, Description="Minimum Q-value")
@@ -64,22 +66,28 @@ class RefLReduction(PythonAlgorithm):
         q_min = self.getProperty("QMin")
         q_step = self.getProperty("QStep")
                 
+        #dimension of the detector (256 by 304 pixels)
+        maxX = 304
+        maxY = 256
+                
         #Due to the frame effect, it's sometimes necessary to narrow the range
         #over which we add all the pixels along the low resolution
         #Parameter
-        Xrange = self.getProperty("LowResDataAxisPixelRange")
-        
-        print 'LowResDataAxisPixelRange'
-        print Xrange
-        print
+        DataXrangeFlag = self.getProperty("LowResDataAxisPixelRangeFlag")
+        if DataXrangeFlag:
+            Xrange = self.getProperty("LowResDataAxisPixelRange")
+        else:
+            Xrange = [0,maxX-1]
+
+        NormXrangeFlag = self.getProperty("LowResNormAxisPixelRangeFlag")
+        if NormXrangeFlag:
+            normXrange = self.getProperty("LowResNormAxisPixelRange")
+        else:
+            normXrange = [0,maxX-1]
                 
         h = 6.626e-34  #m^2 kg s^-1
         m = 1.675e-27     #kg
-        
-        #dimension of the detector (256 by 304 pixels)
-        maxX = 304
-        maxY = 256
-        
+                
         norm_back = self.getProperty("NormBackgroundPixelRange")
         BackfromYpixel = norm_back[0]
         BacktoYpixel = norm_back[1]
@@ -311,15 +319,6 @@ class RefLReduction(PythonAlgorithm):
     
             # Normalized by Current (proton charge)
             NormaliseByCurrent(InputWorkspace=ws_norm_histo_data, OutputWorkspace=ws_norm_histo_data)
-    
-            ##Background subtraction
-            Yrange = self.getProperty("LowResNormAxisPixelRange")
-            
-            print 'LowResDataAxisPixelRange'
-            print Yrange
-            print
-
-
 
             #Create a new event workspace of only the range of pixel of interest 
             #background range (along the y-axis) and of only the pixel
@@ -327,8 +326,8 @@ class RefLReduction(PythonAlgorithm):
             ws_integrated_data = "__IntegratedNormWks"
             wks_utility.createIntegratedWorkspace(mtd[ws_norm_histo_data], 
                                                   ws_integrated_data,
-                                                  fromXpixel=Yrange[0],
-                                                  toXpixel=Yrange[1],
+                                                  fromXpixel=normXrange[0],
+                                                  toXpixel=normXrange[1],
                                                   fromYpixel=BackfromYpixel,
                                                   toYpixel=BacktoYpixel,
                                                   maxX=maxX,
diff --git a/Code/Mantid/scripts/Interface/reduction_gui/reduction/reflectometer/refl_data_script.py b/Code/Mantid/scripts/Interface/reduction_gui/reduction/reflectometer/refl_data_script.py
index 0036064212d..11108833b0a 100644
--- a/Code/Mantid/scripts/Interface/reduction_gui/reduction/reflectometer/refl_data_script.py
+++ b/Code/Mantid/scripts/Interface/reduction_gui/reduction/reflectometer/refl_data_script.py
@@ -62,7 +62,9 @@ class DataSets(BaseScriptElement):
         script += "              NormPeakPixelRange=%s,\n" % str(self.NormPeakPixels)
         script += "              NormBackgroundPixelRange=%s,\n" % str(self.NormBackgroundRoi)
         script += "              SubtractNormBackground=%s,\n" % str(self.NormBackgroundFlag)
+        script += "              LowResDataAxisPixelRangeFlag=%s,\n" % str(self.data_x_range_flag)
         script += "              LowResDataAxisPixelRange=%s,\n" % str(self.data_x_range)
+        script += "              LowResNormAxisPixelRangeFlag=%s,\n" % str(self.norm_x_range_flag)
         script += "              LowResNormAxisPixelRange=%s,\n" % str(self.norm_x_range)
         script += "              TOFRange=%s,\n" % str(self.DataTofRange)
         script += "              QMin=%s,\n" % str(self.q_min)
diff --git a/Code/Mantid/scripts/Interface/reduction_gui/widgets/reflectometer/refl_data_simple.py b/Code/Mantid/scripts/Interface/reduction_gui/widgets/reflectometer/refl_data_simple.py
index b3412765b41..cb2564ffafc 100644
--- a/Code/Mantid/scripts/Interface/reduction_gui/widgets/reflectometer/refl_data_simple.py
+++ b/Code/Mantid/scripts/Interface/reduction_gui/widgets/reflectometer/refl_data_simple.py
@@ -412,9 +412,13 @@ class DataReflWidget(BaseWidget):
         self._summary.data_peak_from_pixel.setText(str(state.DataPeakPixels[0]))
         self._summary.data_peak_to_pixel.setText(str(state.DataPeakPixels[1]))
         
+        #data low resolution range
+        self._summary.data_low_res_range_switch.setChecked(state.data_x_range_flag)
         self._summary.x_min_edit.setText(str(state.data_x_range[0]))
         self._summary.x_max_edit.setText(str(state.data_x_range[1]))
         
+        #norm low resolution range
+        self._summary.norm_low_res_range_switch.setChecked(state.norm_x_range_flag)
         self._summary.norm_x_min_edit.setText(str(state.norm_x_range[0]))
         self._summary.norm_x_max_edit.setText(str(state.norm_x_range[1]))
         
-- 
GitLab