Index: DataLoader/data_info.py
===================================================================
--- DataLoader/data_info.py	(revision 0997158f0d11874fd896ee66b3bb468898c9bb2b)
+++ DataLoader/data_info.py	(revision a7a5886e7fa30dd75a5a77d68a58574c9246f27f)
@@ -33,5 +33,6 @@
     Data1D is a place holder for 1D plottables.
     """
-    # The presence of these should be mutually exclusive with the presence of Qdev (dx)
+    # The presence of these should be mutually
+    # exclusive with the presence of Qdev (dx)
     x = None
     y = None
@@ -49,17 +50,27 @@
     _yunit = ''
     
-    def __init__(self,x,y,dx=None,dy=None,dxl=None,dxw=None):
+    def __init__(self, x, y, dx=None, dy=None, dxl=None, dxw=None):
         self.x = numpy.asarray(x)
         self.y = numpy.asarray(y)
-        if dx is not None: self.dx = numpy.asarray(dx)
-        if dy is not None: self.dy = numpy.asarray(dy)
-        if dxl is not None: self.dxl = numpy.asarray(dxl)
-        if dxw is not None: self.dxw = numpy.asarray(dxw)
+        if dx is not None:
+             self.dx = numpy.asarray(dx)
+        if dy is not None: 
+            self.dy = numpy.asarray(dy)
+        if dxl is not None: 
+            self.dxl = numpy.asarray(dxl)
+        if dxw is not None: 
+            self.dxw = numpy.asarray(dxw)
 
     def xaxis(self, label, unit):
+        """
+        set the x axis label and unit
+        """
         self._xaxis = label
         self._xunit = unit
         
     def yaxis(self, label, unit):
+        """
+        set the y axis label and unit
+        """
         self._yaxis = label
         self._yunit = unit
@@ -90,5 +101,7 @@
     _zunit = ''
     
-    def __init__(self, data=None, err_data=None, qx_data=None, qy_data=None, q_data=None,mask=None, dqx_data=None, dqy_data=None):
+    def __init__(self, data=None, err_data=None, qx_data=None,
+                  qy_data=None, q_data=None, mask=None,
+                   dqx_data=None, dqy_data=None):
         self.data = numpy.asarray(data)
         self.qx_data = numpy.asarray(qx_data)
@@ -101,12 +114,21 @@
                
     def xaxis(self, label, unit):
+        """
+        set the x axis label and unit
+        """
         self._xaxis = label
         self._xunit = unit
         
     def yaxis(self, label, unit):
+        """
+        set the y axis label and unit
+        """
         self._yaxis = label
         self._yunit = unit
             
     def zaxis(self, label, unit):
+        """
+        set the z axis label and unit
+        """
         self._zaxis = label
         self._zunit = unit
@@ -139,5 +161,6 @@
         
     def __str__(self):
-        return "x = %s\ty = %s\tz = %s" % (str(self.x), str(self.y), str(self.z))
+        msg = "x = %s\ty = %s\tz = %s" % (str(self.x), str(self.y), str(self.z))
+        return msg
         
 
@@ -151,11 +174,14 @@
     distance = None
     distance_unit = 'mm'
-    ## Offset of this detector position in X, Y, (and Z if necessary) [Vector] [mm] 
+    ## Offset of this detector position in X, Y, 
+    #(and Z if necessary) [Vector] [mm] 
     offset = None
     offset_unit = 'm'
-    ## Orientation (rotation) of this detector in roll, pitch, and yaw [Vector] [degrees]
+    ## Orientation (rotation) of this detector in roll,
+    # pitch, and yaw [Vector] [degrees]
     orientation = None
     orientation_unit = 'degree'
-    ## Center of the beam on the detector in X and Y (and Z if necessary) [Vector] [mm]
+    ## Center of the beam on the detector in X and Y 
+    #(and Z if necessary) [Vector] [mm]
     beam_center = None
     beam_center_unit = 'mm'
@@ -352,5 +378,5 @@
     name = ''
     date = ''
-    description= ''
+    description = ''
     term = None
     notes = None
@@ -460,5 +486,11 @@
     # but should be implemented for each data class inherited from DataInfo
     # that holds actual data (ex.: Data1D)
-    def _perform_operation(self, other, operation): return NotImplemented
+    def _perform_operation(self, other, operation): 
+        """
+        Private method to perform operation. Not implemented for DataInfo,
+        but should be implemented for each data class inherited from DataInfo
+        that holds actual data (ex.: Data1D)
+        """
+        return NotImplemented
 
     def __add__(self, other):
@@ -470,5 +502,6 @@
         :raise ValueError: raised when two data sets are incompatible
         """
-        def operation(a, b): return a+b
+        def operation(a, b):
+            return a + b
         return self._perform_operation(other, operation)
         
@@ -484,5 +517,6 @@
         
         """
-        def operation(a, b): return b+a
+        def operation(a, b):
+            return b + a
         return self._perform_operation(other, operation)
         
@@ -498,5 +532,6 @@
         
         """
-        def operation(a, b): return a-b
+        def operation(a, b):
+            return a - b
         return self._perform_operation(other, operation)
         
@@ -512,5 +547,6 @@
         
         """
-        def operation(a, b): return b-a
+        def operation(a, b):
+            return b - a
         return self._perform_operation(other, operation)
         
@@ -526,5 +562,6 @@
         
         """
-        def operation(a, b): return a*b
+        def operation(a, b):
+            return a * b
         return self._perform_operation(other, operation)
         
@@ -539,5 +576,6 @@
         :raise ValueError: raised when two data sets are incompatible
         """
-        def operation(a, b): return b*a
+        def operation(a, b):
+            return b * a
         return self._perform_operation(other, operation)
         
@@ -553,5 +591,6 @@
         
         """
-        def operation(a, b): return a/b
+        def operation(a, b):
+            return a/b
         return self._perform_operation(other, operation)
         
@@ -567,5 +606,6 @@
         
         """
-        def operation(a, b): return b/a
+        def operation(a, b):
+            return b/a
         return self._perform_operation(other, operation)            
             
@@ -604,6 +644,6 @@
         """
         def _check(v):            
-            if (v.__class__==list or v.__class__==numpy.ndarray) \
-                and len(v)>0 and min(v)>0:
+            if (v.__class__ == list or v.__class__ == numpy.ndarray) \
+                and len(v) > 0 and min(v) > 0:
                 return True
             
@@ -664,20 +704,22 @@
             if len(self.x) != len(other.x) or \
                 len(self.y) != len(other.y):
-                raise ValueError, "Unable to perform operation: data length are not equal"
+                msg =  "Unable to perform operation: data length are not equal"
+                raise ValueError, msg
             
             # Here we could also extrapolate between data points
             for i in range(len(self.x)):
                 if self.x[i] != other.x[i]:
-                    raise ValueError, "Incompatible data sets: x-values do not match"
+                    msg = "Incompatible data sets: x-values do not match"
+                    raise ValueError, msg
             
             # Check that the other data set has errors, otherwise
             # create zero vector
             dy_other = other.dy
-            if other.dy==None or (len(other.dy) != len(other.y)):
+            if other.dy == None or (len(other.dy) != len(other.y)):
                 dy_other = numpy.zeros(len(other.y))
             
         # Check that we have errors, otherwise create zero vector
         dy = self.dy
-        if self.dy==None or (len(self.dy) != len(self.y)):
+        if self.dy == None or (len(self.dy) != len(self.y)):
             dy = numpy.zeros(len(self.y))            
             
@@ -693,5 +735,5 @@
         for i in range(len(self.x)):
             result.x[i] = self.x[i]
-            if self.dx is not None and len(self.x)==len(self.dx):
+            if self.dx is not None and len(self.x) == len(self.dx):
                 result.dx[i] = self.dx[i]
             
@@ -724,10 +766,13 @@
     
     
-    def __init__(self, data=None, err_data=None, qx_data=None, qy_data=None, q_data=None, mask=None, dqx_data=None, dqy_data=None):
+    def __init__(self, data=None, err_data=None, qx_data=None,
+                  qy_data=None, q_data=None, mask=None, 
+                  dqx_data=None, dqy_data=None):
         self.y_bins = []
         self.x_bins = []
         DataInfo.__init__(self)
-        plottable_2D.__init__(self, data, err_data, qx_data, qy_data, q_data,mask, dqx_data, dqy_data)
-        if len(self.detector)>0:
+        plottable_2D.__init__(self, data, err_data, qx_data,
+                              qy_data, q_data,mask, dqx_data, dqy_data)
+        if len(self.detector) > 0:
             raise RuntimeError, "Data2D: Detector bank already filled at init"
 
@@ -739,7 +784,7 @@
         _str += "   X- & Y-axis:  %s\t[%s]\n" % (self._yaxis, self._yunit)
         _str += "   Z-axis:       %s\t[%s]\n" % (self._zaxis, self._zunit)
-        leny = 0
-        if len(self.data)>0:
-            leny = len(self.data)
+        #leny = 0
+        #if len(self.data) > 0:
+        #    leny = len(self.data)
         _str += "   Length:       %g \n" % (len(self.data))
         
@@ -766,5 +811,6 @@
             dqx_data = None
             dqy_data = None
-            clone = Data2D(data, err_data, qx_data, qy_data, q_data,mask, dqx_data=dqx_data, dqy_data=dqy_data)
+            clone = Data2D(data, err_data, qx_data, qy_data,
+                            q_data,mask, dqx_data=dqx_data, dqy_data=dqy_data)
 
         clone.title       = self.title
@@ -802,5 +848,6 @@
             # Check that data lengths are the same
             if numpy.size(self.data) != numpy.size(other.data):
-                raise ValueError, "Unable to perform operation: data length are not equal"
+                msg = "Unable to perform operation: data length are not equal"
+                raise ValueError, msg
                
             # Check that the scales match
@@ -811,11 +858,15 @@
             #TODO: test this
             err_other = other.err_data
-            if other.err_data==None or (numpy.size(other.err_data) != numpy.size(other.data)):
-                err_other = numpy.zeros([numpy.size(other.data,0), numpy.size(other.data,1)])
+            if other.err_data == None or \
+                (numpy.size(other.err_data) != numpy.size(other.data)):
+                err_other = numpy.zeros([numpy.size(other.data, 0),
+                                          numpy.size(other.data, 1)])
             
         # Check that we have errors, otherwise create zero vector
         err = self.err_data
-        if self.err_data==None or (numpy.size(self.err_data) != numpy.size(self.data)):
-            err = numpy.zeros([numpy.size(self.data,0), numpy.size(self.data,1)])
+        if self.err_data == None or \
+            (numpy.size(self.err_data) != numpy.size(self.data)):
+            err = numpy.zeros([numpy.size(self.data, 0),
+                                numpy.size(self.data, 1)])
             
         return err, err_other
@@ -833,10 +884,12 @@
         dy, dy_other = self._validity_check(other)
     
-        result = self.clone_without_data([numpy.size(self.data,0), numpy.size(self.data,1)])
-        
-        for i in range(numpy.size(self.data,0)):
-            for j in range(numpy.size(self.data,1)):
+        result = self.clone_without_data([numpy.size(self.data, 0), 
+                                          numpy.size(self.data, 1)])
+        
+        for i in range(numpy.size(self.data, 0)):
+            for j in range(numpy.size(self.data, 1)):
                 result.data[i][j] = self.data[i][j]
-                if self.err_data is not None and numpy.size(self.data)==numpy.size(self.err_data):
+                if self.err_data is not None and \
+                    numpy.size(self.data) == numpy.size(self.err_data):
                     result.err_data[i][j] = self.err_data[i][j]
                 
Index: DataLoader/loader.py
===================================================================
--- DataLoader/loader.py	(revision f118fe2fda5d8c6e91732f24f6a1ce6daec96867)
+++ DataLoader/loader.py	(revision a7a5886e7fa30dd75a5a77d68a58574c9246f27f)
@@ -23,5 +23,4 @@
 """
 
-from data_util.registry import ExtensionRegistry
 import os 
 import sys
@@ -29,8 +28,9 @@
 import time
 from zipfile import ZipFile
-
+from data_util.registry import ExtensionRegistry
 # Default readers are defined in the readers sub-module
 import readers
-from readers import ascii_reader,cansas_reader
+from readers import ascii_reader
+from readers import cansas_reader
 
 class Registry(ExtensionRegistry):
@@ -55,5 +55,6 @@
         readers.read_associations(self)
         
-        #TODO: remove the following line when ready to switch to the new default readers
+        #TODO: remove the following line when ready to switch to 
+        #the new default readers
         #readers.register_readers(self._identify_plugin)
         
@@ -67,5 +68,6 @@
 
         :param path: file path
-        :param format: explicit extension, to force the use of a particular reader
+        :param format: explicit extension, to force the use 
+            of a particular reader
 
         Defaults to the ascii (multi-column) reader
@@ -83,4 +85,5 @@
                 cansas_loader = cansas_reader.Reader()
                 return cansas_loader.read(path)
+            
     def find_plugins(self, dir):
         """
@@ -112,6 +115,8 @@
                         if self._identify_plugin(module):
                             readers_found += 1
-                    except :
-                        logging.error("Loader: Error importing %s\n  %s" % (item, sys.exc_value))
+                    except:
+                        msg = "Loader: Error importing "
+                        msg += "%s\n  %s" % (item, sys.exc_value)
+                        logging.error(msg)
                             
                 # Process zip files
@@ -128,12 +133,17 @@
                                 fullname = mfile.replace('/', '.')
                                 fullname = os.path.splitext(fullname)[0]
-                                module = __import__(fullname, globals(), locals(), [""])
+                                module = __import__(fullname, globals(),
+                                                     locals(), [""])
                                 if self._identify_plugin(module):
                                     readers_found += 1
                             except:
-                                logging.error("Loader: Error importing %s\n  %s" % (mfile, sys.exc_value))
+                                msg = "Loader: Error importing"
+                                msg += " %s\n  %s" % (mfile, sys.exc_value)
+                                logging.error(msg)
                             
                     except:
-                        logging.error("Loader: Error importing %s\n  %s" % (item, sys.exc_value))
+                        msg = "Loader: Error importing "
+                        msg += " %s\n  %s" % (item, sys.exc_value)
+                        logging.error(msg)
                      
         return readers_found 
@@ -166,5 +176,6 @@
                     type_name = loader.type_name
                     
-                wcard = "%s files (*%s)|*%s" % (type_name, ext.lower(), ext.lower())
+                wcard = "%s files (*%s)|*%s" % (type_name, ext.lower(),
+                                                 ext.lower())
                 if wcard not in self.wildcards:
                     self.wildcards.append(wcard)
@@ -178,5 +189,7 @@
                         
             except:
-                logging.error("Loader: Error accessing Reader in %s\n  %s" % (module.__name__, sys.exc_value))
+                msg = "Loader: Error accessing"
+                msg += " Reader in %s\n  %s" % (module.__name__, sys.exc_value)
+                logging.error(msg)
         return reader_found
 
@@ -203,10 +216,13 @@
                 type_name = loader.type_name
                 
-                wcard = "%s files (*%s)|*%s" % (type_name, ext.lower(), ext.lower())
+                wcard = "%s files (*%s)|*%s" % (type_name, ext.lower(), 
+                                                ext.lower())
                 if wcard not in self.wildcards:
                     self.wildcards.append(wcard)
                  
         except:
-            logging.error("Loader: Error accessing Reader in %s\n  %s" % (module.__name__, sys.exc_value))
+            msg = "Loader: Error accessing Reader "
+            msg += "in %s\n  %s" % (module.__name__, sys.exc_value)
+            logging.error(msg)
         return reader_found
 
@@ -229,7 +245,7 @@
                     if ext not in self.loaders:
                         self.loaders[ext] = []
-                    # When finding a reader at run time, treat this reader as the new 
-                    # default
-                    self.loaders[ext].insert(0,loader.read)
+                    # When finding a reader at run time,
+                    # treat this reader as the new default
+                    self.loaders[ext].insert(0, loader.read)
 
                     reader_found = True
@@ -239,5 +255,6 @@
                     if hasattr(loader, 'type_name'):
                         type_name = loader.type_name
-                    wcard = "%s files (*%s)|*%s" % (type_name, ext.lower(), ext.lower())
+                    wcard = "%s files (*%s)|*%s" % (type_name, ext.lower(),
+                                                     ext.lower())
                     if wcard not in self.wildcards:
                     	self.wildcards.append(wcard)
@@ -251,5 +268,7 @@
                         
             except:
-                logging.error("Loader: Error accessing Reader in %s\n  %s" % (module.__name__, sys.exc_value))
+                msg = "Loader: Error accessing Reader"
+                msg += " in %s\n  %s" % (module.__name__, sys.exc_value)
+                logging.error(msg)
         return reader_found
 
@@ -263,5 +282,5 @@
         extlist = [ext for ext in self.extensions() if path.endswith(ext)]
         # Sort matching extensions by decreasing order of length
-        extlist.sort(lambda a,b: len(a)<len(b))
+        extlist.sort(lambda a, b: len(a) < len(b))
         # Combine loaders for matching extensions into one big list
         writers = []
@@ -276,5 +295,5 @@
         # Raise an error if there are no matching extensions
         if len(writers) == 0:
-            raise ValueError, "Unknown file type for "+path
+            raise ValueError, "Unknown file type for " + path
         # All done
         return writers
@@ -372,6 +391,6 @@
                         filemode='w')
     l = Loader()
-    data = l.load('test/cansas1d.xml')
-    l.save('test_file.xml', data, '.xml')
+    test_data = l.load('test/cansas1d.xml')
+    l.save('test_file.xml', test_data, '.xml')
     
     print l.get_wildcards()
Index: DataLoader/manipulations.py
===================================================================
--- DataLoader/manipulations.py	(revision 0997158f0d11874fd896ee66b3bb468898c9bb2b)
+++ DataLoader/manipulations.py	(revision a7a5886e7fa30dd75a5a77d68a58574c9246f27f)
@@ -9,15 +9,15 @@
 
 """
-    Data manipulations for 2D data sets.
-    Using the meta data information, various types of averaging
-    are performed in Q-space 
+Data manipulations for 2D data sets.
+Using the meta data information, various types of averaging
+are performed in Q-space 
 """
-
-
 #TODO: copy the meta data from the 2D object to the resulting 1D object
-
-from data_info import plottable_2D, Data1D
 import math
 import numpy
+
+#from data_info import plottable_2D
+from data_info import Data1D
+
 
 def get_q(dx, dy, det_dist, wavelength):
@@ -31,26 +31,26 @@
     plane_dist = math.sqrt(dx*dx + dy*dy)
     # Half of the scattering angle
-    theta      = 0.5*math.atan(plane_dist/det_dist)
-    return (4.0*math.pi/wavelength)*math.sin(theta)
-
-def get_q_compo(dx, dy, det_dist, wavelength,compo=None):
+    theta = 0.5 * math.atan(plane_dist/det_dist)
+    return (4.0 * math.pi/wavelength) * math.sin(theta)
+
+def get_q_compo(dx, dy, det_dist, wavelength, compo=None):
     """
     This reduces tiny error at very large q.
     Implementation of this func is not started yet.<--ToDo
     """
-    if dy==0:
-        if dx>=0:
-            angle_xy=0
+    if dy == 0:
+        if dx >= 0:
+            angle_xy = 0
         else:
-            angle_xy=math.pi
+            angle_xy = math.pi
     else:
-        angle_xy=math.atan(dx/dy)
-        
-    if compo=="x":
-        out=get_q(dx, dy, det_dist, wavelength)*cos(angle_xy)
-    elif compo=="y":
-        out=get_q(dx, dy, det_dist, wavelength)*sin(angle_xy)
+        angle_xy = math.atan(dx/dy)
+        
+    if compo == "x":
+        out = get_q(dx, dy, det_dist, wavelength) * math.cos(angle_xy)
+    elif compo == "y":
+        out = get_q(dx, dy, det_dist, wavelength) * math.sin(angle_xy)
     else:
-        out=get_q(dx, dy, det_dist, wavelength)
+        out = get_q(dx, dy, det_dist, wavelength)
     return out
 
@@ -63,7 +63,7 @@
     Pi = math.pi
     if phi < 0:
-        phi_out = phi  + 2*Pi
-    elif phi > 2*Pi:
-        phi_out = phi  - 2*Pi
+        phi_out = phi  + (2 * Pi)
+    elif phi > (2 * Pi):
+        phi_out = phi  - (2 * Pi)
     else:
         phi_out = phi 
@@ -72,5 +72,6 @@
 def reader2D_converter(data2d=None):
     """
-    convert old 2d format opened by IhorReader or danse_reader to new Data2D format
+    convert old 2d format opened by IhorReader or danse_reader
+    to new Data2D format
     
     :param data2d: 2d array of Data2D object
@@ -79,22 +80,22 @@
     
     """
-    if data2d.data==None or data2d.x_bins==None or data2d.y_bins==None:
-        raise ValueError,"Can't convert this data: data=None..."
+    if data2d.data == None or data2d.x_bins == None or data2d.y_bins == None:
+        raise ValueError, "Can't convert this data: data=None..."
     
     from DataLoader.data_info import Data2D
 
-    new_x = numpy.tile(data2d.x_bins, (len(data2d.y_bins),1))
-    new_y = numpy.tile(data2d.y_bins, (len(data2d.x_bins),1))
-    new_y = new_y.swapaxes(0,1)
+    new_x = numpy.tile(data2d.x_bins, (len(data2d.y_bins), 1))
+    new_y = numpy.tile(data2d.y_bins, (len(data2d.x_bins), 1))
+    new_y = new_y.swapaxes(0, 1)
 
     new_data = data2d.data.flatten()
     qx_data = new_x.flatten()
     qy_data = new_y.flatten()
-    q_data = numpy.sqrt(qx_data*qx_data+qy_data*qy_data)
-    if data2d.err_data == None or numpy.any(data2d.err_data<=0): 
+    q_data = numpy.sqrt(qx_data*qx_data + qy_data*qy_data)
+    if data2d.err_data == None or numpy.any(data2d.err_data <= 0): 
         new_err_data = numpy.sqrt(numpy.abs(new_data))
     else:
         new_err_data = data2d.err_data.flatten()
-    mask    = numpy.ones(len(new_data), dtype = bool)
+    mask    = numpy.ones(len(new_data), dtype=bool)
 
     output = Data2D()
@@ -113,5 +114,6 @@
     Compute average I(Q) for a region of interest
     """
-    def __init__(self, x_min=0.0, x_max=0.0, y_min=0.0, y_max=0.0, bin_width=0.001):
+    def __init__(self, x_min=0.0, x_max=0.0, y_min=0.0,
+                 y_max=0.0, bin_width=0.001):
         # Minimum Qx value [A-1]
         self.x_min = x_min
@@ -124,8 +126,10 @@
         # Bin width (step size) [A-1]
         self.bin_width = bin_width
-        # If True, I(|Q|) will be return, otherwise, negative q-values are allowed
+        # If True, I(|Q|) will be return, otherwise,
+        # negative q-values are allowed
         self.fold = False
         
-    def __call__(self, data2D): return NotImplemented
+    def __call__(self, data2D):
+        return NotImplemented
         
     def _avg(self, data2D, maj):
@@ -141,5 +145,7 @@
         """
         if len(data2D.detector) != 1:
-            raise RuntimeError, "_Slab._avg: invalid number of detectors: %g" % len(data2D.detector)
+            msg = "_Slab._avg: invalid number of "
+            msg += " detectors: %g" % len(data2D.detector)
+            raise RuntimeError, msg
         
         # Get data 
@@ -151,14 +157,15 @@
              
         # Build array of Q intervals
-        if maj=='x':
-            if self.fold: x_min = 0     
+        if maj == 'x':
+            if self.fold:
+                x_min = 0     
             else:  x_min = self.x_min
-            nbins = int(math.ceil((self.x_max-x_min)/self.bin_width))
-            qbins = self.bin_width*numpy.arange(nbins)+ x_min
-        elif maj=='y':
+            nbins = int(math.ceil((self.x_max - x_min)/self.bin_width))
+            qbins = self.bin_width * numpy.arange(nbins) + x_min
+        elif maj == 'y':
             if self.fold: y_min = 0     
             else:  y_min = self.y_min
-            nbins = int(math.ceil((self.y_max-y_min)/self.bin_width))
-            qbins = self.bin_width*numpy.arange(nbins)+ y_min          
+            nbins = int(math.ceil((self.y_max - y_min)/self.bin_width))
+            qbins = self.bin_width * numpy.arange(nbins) + y_min          
         else:
             raise RuntimeError, "_Slab._avg: unrecognized axis %s" % str(maj)
@@ -179,23 +186,23 @@
             if self.y_min <= qy_data[npts] and self.y_max > qy_data[npts]:
                 frac_y = 1
-            
             frac = frac_x * frac_y
             
-            if frac == 0: continue
-
+            if frac == 0:
+                continue
             # binning: find axis of q
-            if maj=='x': 
+            if maj == 'x': 
                 q_value = qx_data[npts]
                 min = x_min 
-            if maj=='y': 
+            if maj == 'y': 
                 q_value = qy_data[npts] 
                 min = y_min 
-            if self.fold and q_value<0: q_value = -q_value   
-            
+            if self.fold and q_value < 0:
+                q_value = -q_value   
             # bin
-            i_q = int(math.ceil((q_value-min)/self.bin_width)) - 1
+            i_q = int(math.ceil((q_value - min)/self.bin_width)) - 1
             
             # skip outside of max bins
-            if i_q<0 or i_q>=nbins: continue
+            if i_q < 0 or i_q >= nbins:
+                continue
             
             # give it full weight
@@ -203,9 +210,9 @@
             
             #TODO: find better definition of x[i_q] based on q_data
-            x[i_q]         = min +(i_q+1)*self.bin_width/2.0
-            y[i_q]         += frac * data[npts]
-            
-            if err_data == None or err_data[npts]==0.0:
-                if data[npts] <0: data[npts] = -data[npts]
+            x[i_q] = min + (i_q + 1) * self.bin_width / 2.0
+            y[i_q] += frac * data[npts]
+            
+            if err_data == None or err_data[npts] == 0.0:
+                if data[npts] < 0: data[npts] = -data[npts]
                 err_y[i_q] += frac * frac * data[npts]
             else:
@@ -217,13 +224,15 @@
             err_y[n] = math.sqrt(err_y[n])
           
-        err_y = err_y/y_counts
-        y    = y/y_counts
-        
-        idx = (numpy.isfinite(y)& numpy.isfinite(x)) 
+        err_y = err_y / y_counts
+        y    = y / y_counts
+        
+        idx = (numpy.isfinite(y) & numpy.isfinite(x)) 
         
         if not idx.any(): 
-            raise ValueError, "Average Error: No points inside ROI to average..." 
-        elif len(y[idx])!= nbins:
-            print "resulted",nbins- len(y[idx]),"empty bin(s) due to tight binning..."
+            msg = "Average Error: No points inside ROI to average..." 
+            raise ValueError, msg
+        #elif len(y[idx])!= nbins:
+        #    msg = "empty bin(s) due to tight binning..."
+        #    print "resulted",nbins- len(y[idx]), msg
         return Data1D(x=x[idx], y=y[idx], dy=err_y[idx])
         
@@ -283,6 +292,6 @@
         
         # Average the sums
-        counts = 0 if y_counts==0 else y
-        error  = 0 if y_counts==0 else math.sqrt(err_y)
+        counts = 0 if y_counts == 0 else y
+        error  = 0 if y_counts == 0 else math.sqrt(err_y)
         
         return counts, error
@@ -294,10 +303,12 @@
         :param data2D: Data2D object
         
-        :return: number of counts, error on number of counts, number of entries summed
+        :return: number of counts, 
+            error on number of counts, number of entries summed
         
         """
         if len(data2D.detector) != 1:
-            raise RuntimeError, "Circular averaging: invalid number of detectors: %g" % len(data2D.detector)
-        
+            msg = "Circular averaging: invalid number "
+            msg += "of detectors: %g" % len(data2D.detector)
+            raise RuntimeError, msg
         # Get data 
         data = data2D.data[numpy.isfinite(data2D.data)]
@@ -326,17 +337,16 @@
             if self.y_min <= qy and self.y_max > qy:
                 frac_y = 1
-                
             #Find the fraction along each directions            
             frac = frac_x * frac_y
-            if frac == 0: continue
-
+            if frac == 0:
+                continue
             y += frac * data[npts]
-            if err_data == None or err_data[npts]==0.0:
-                if data[npts] <0: data[npts] = -data[npts]
+            if err_data == None or err_data[npts] == 0.0:
+                if data[npts] < 0:
+                    data[npts] = -data[npts]
                 err_y += frac * frac * data[npts]
             else:
                 err_y += frac * frac * err_data[npts] * err_data[npts]
-            y_counts += frac
-               
+            y_counts += frac     
         return y, err_y, y_counts
 
@@ -348,5 +358,6 @@
     """
     def __init__(self, x_min=0.0, x_max=0.0, y_min=0.0, y_max=0.0):
-        super(Boxavg, self).__init__(x_min=x_min, x_max=x_max, y_min=y_min, y_max=y_max)
+        super(Boxavg, self).__init__(x_min=x_min, x_max=x_max,
+                                      y_min=y_min, y_max=y_max)
 
     def __call__(self, data2D):
@@ -362,6 +373,6 @@
         
         # Average the sums
-        counts = 0 if y_counts==0 else y/y_counts
-        error  = 0 if y_counts==0 else math.sqrt(err_y)/y_counts
+        counts = 0 if y_counts == 0 else y/y_counts
+        error  = 0 if y_counts == 0 else math.sqrt(err_y)/y_counts
         
         return counts, error
@@ -384,8 +395,8 @@
     
     """
-    if x<=xmin:
+    if x <= xmin:
         return 0.0
-    if x>xmin and x<xmax:
-        return (x-xmin)/(xmax-xmin)
+    if x > xmin and x < xmax:
+        return (x - xmin) / (xmax - xmin)
     else:
         return 1.0
@@ -423,9 +434,10 @@
 
         if len(data2D.q_data) == None:
-            raise RuntimeError, "Circular averaging: invalid q_data: %g" % data2D.q_data
+            msg = "Circular averaging: invalid q_data: %g" % data2D.q_data
+            raise RuntimeError, msg
 
         # Build array of Q intervals
-        nbins = int(math.ceil((self.r_max-self.r_min)/self.bin_width))
-        qbins = self.bin_width*numpy.arange(nbins)+self.r_min
+        nbins = int(math.ceil((self.r_max - self.r_min) / self.bin_width))
+        qbins = self.bin_width * numpy.arange(nbins) + self.r_min
 
         x  = numpy.zeros(nbins)
@@ -438,26 +450,25 @@
             
             # q-value at the pixel (j,i)
-            q_value = q_data[npt]
-                
+            q_value = q_data[npt] 
             data_n = data[npt]                
             
             ## No need to calculate the frac when all data are within range
             if self.r_min >= self.r_max:
-                raise ValueError, "Limit Error: min > max ???" 
-            
-            if self.r_min <= q_value and q_value <= self.r_max: frac = 1                       
-
-            if frac == 0: continue
-                       
-            i_q = int(math.floor((q_value-self.r_min)/self.bin_width))    
+                raise ValueError, "Limit Error: min > max" 
+            
+            if self.r_min <= q_value and q_value <= self.r_max:
+                frac = 1                       
+            if frac == 0:
+                continue 
+            i_q = int(math.floor((q_value - self.r_min) / self.bin_width))    
 
             # Take care of the edge case at phi = 2pi. 
             if i_q == nbins:  
-                i_q = nbins -1 
-                                    
+                i_q = nbins -1              
             y[i_q] += frac * data_n
 
-            if err_data == None or err_data[npt]==0.0:
-                if data_n <0: data_n = -data_n
+            if err_data == None or err_data[npt] == 0.0:
+                if data_n < 0:
+                    data_n = -data_n
                 err_y[i_q] += frac * frac * data_n
             else:
@@ -466,20 +477,21 @@
         
         ## x should be the center value of each bins        
-        x = qbins+self.bin_width/2  
+        x = qbins + self.bin_width / 2  
         
         # Average the sums       
         for n in range(nbins):
-            if err_y[n] <0: err_y[n] = -err_y[n]
+            if err_y[n] < 0: err_y[n] = -err_y[n]
             err_y[n] = math.sqrt(err_y[n])
                       
-        err_y = err_y/y_counts
-        y    = y/y_counts
-        idx = (numpy.isfinite(y))&(numpy.isfinite(x)) 
+        err_y = err_y / y_counts
+        y    = y / y_counts
+        idx = (numpy.isfinite(y)) & (numpy.isfinite(x)) 
         
         if not idx.any(): 
-            raise ValueError, "Average Error: No points inside ROI to average..." 
-        elif len(y[idx])!= nbins:
-            print "resulted",nbins- len(y[idx]),"empty bin(s) due to tight binning..."
-        
+            msg = "Average Error: No points inside ROI to average..." 
+            raise ValueError, msg
+        #elif len(y[idx])!= nbins:
+        #    print "resulted",nbins- len(y[idx])
+        #,"empty bin(s) due to tight binning..."
         return Data1D(x=x[idx], y=y[idx], dy=err_y[idx])
     
@@ -498,5 +510,5 @@
     """
     #Todo: remove center.
-    def __init__(self, r_min=0, r_max=0, center_x=0, center_y=0,nbins=20 ):
+    def __init__(self, r_min=0, r_max=0, center_x=0, center_y=0, nbins=20):
         # Minimum radius
         self.r_min = r_min
@@ -541,31 +553,29 @@
         for npt in range(len(data)):          
             frac = 0
-            
             # q-value at the point (npt)
             q_value = q_data[npt]
-                
             data_n = data[npt]    
                         
             # phi-value at the point (npt)
-            phi_value=math.atan2(qy_data[npt],qx_data[npt])+Pi
-            
-            if self.r_min <= q_value and q_value <= self.r_max: frac = 1                       
-
-            if frac == 0: continue
-            
+            phi_value = math.atan2(qy_data[npt], qx_data[npt]) + Pi
+            
+            if self.r_min <= q_value and q_value <= self.r_max:
+                frac = 1                       
+            if frac == 0:
+                continue
             # binning           
-            i_phi = int(math.floor((self.nbins_phi)*phi_value/(2*Pi)))
+            i_phi = int(math.floor((self.nbins_phi) * phi_value / (2 * Pi)))
             
             # Take care of the edge case at phi = 2pi. 
             if i_phi == self.nbins_phi:  
-                i_phi =  self.nbins_phi -1 
-                                             
+                i_phi =  self.nbins_phi - 1                            
             phi_bins[i_phi] += frac * data[npt]
             
-            if err_data == None or err_data[npt] ==0.0:
-                if data_n <0: data_n = -data_n
+            if err_data == None or err_data[npt] == 0.0:
+                if data_n < 0:
+                    data_n = -data_n
                 phi_err[i_phi] += frac * frac * math.fabs(data_n)
             else:
-                phi_err[i_phi] += frac * frac *err_data[npt]*err_data[npt]
+                phi_err[i_phi] += frac * frac * err_data[npt] * err_data[npt]
             phi_counts[i_phi] += frac
                           
@@ -573,12 +583,14 @@
             phi_bins[i] = phi_bins[i] / phi_counts[i]
             phi_err[i] = math.sqrt(phi_err[i]) / phi_counts[i]
-            phi_values[i] = 2.0*math.pi/self.nbins_phi*(1.0*i + 0.5)
+            phi_values[i] = 2.0 * math.pi / self.nbins_phi * (1.0 * i + 0.5)
             
         idx = (numpy.isfinite(phi_bins)) 
 
-        if not idx.any(): 
-            raise ValueError, "Average Error: No points inside ROI to average..." 
-        elif len(phi_bins[idx])!= self.nbins_phi:
-            print "resulted",self.nbins_phi- len(phi_bins[idx]),"empty bin(s) due to tight binning..."
+        if not idx.any():
+            msg = "Average Error: No points inside ROI to average..." 
+            raise ValueError, msg
+        #elif len(phi_bins[idx])!= self.nbins_phi:
+        #    print "resulted",self.nbins_phi- len(phi_bins[idx])
+        #,"empty bin(s) due to tight binning..."
         return Data1D(x=phi_values[idx], y=phi_bins[idx], dy=phi_err[idx])
     
@@ -600,5 +612,4 @@
     
     """
-    
     # y side for x = minx
     x_0 = get_intercept(qmax, q_00, q_01)
@@ -615,37 +626,32 @@
     
     if x_0 and x_1:
-        frac_max = (x_0+x_1)/2.0
-    
+        frac_max = (x_0 + x_1) / 2.0
     elif y_0 and y_1:
-        frac_max = (y_0+y_1)/2.0
-    
+        frac_max = (y_0 + y_1) / 2.0
     elif x_0 and y_0:
         if q_00 < q_10:
-            frac_max = x_0*y_0/2.0
+            frac_max = x_0 * y_0 / 2.0
         else:
-            frac_max = 1.0-x_0*y_0/2.0
-    
+            frac_max = 1.0 - x_0 * y_0 / 2.0
     elif x_0 and y_1:
         if q_00 < q_10:
-            frac_max = x_0*y_1/2.0
+            frac_max = x_0 * y_1 / 2.0
         else:
-            frac_max = 1.0-x_0*y_1/2.0
-    
+            frac_max = 1.0 - x_0 * y_1 / 2.0
     elif x_1 and y_0:
         if q_00 > q_10:
-            frac_max = x_1*y_0/2.0
+            frac_max = x_1 * y_0 / 2.0
         else:
-            frac_max = 1.0-x_1*y_0/2.0
-    
+            frac_max = 1.0 - x_1 * y_0 / 2.0
     elif x_1 and y_1:
         if q_00 < q_10:
-            frac_max = 1.0 - (1.0-x_1)*(1.0-y_1)/2.0
+            frac_max = 1.0 - (1.0 - x_1) * (1.0 - y_1) / 2.0
         else:
-            frac_max = (1.0-x_1)*(1.0-y_1)/2.0
+            frac_max = (1.0 - x_1) * (1.0 - y_1) / 2.0
             
     # If we make it here, there is no intercept between
     # this pixel and the constant-q ring. We only need
     # to know if we have to include it or exclude it.
-    elif (q_00+q_01+q_10+q_11)/4.0 < qmax:
+    elif (q_00 + q_01 + q_10 + q_11)/4.0 < qmax:
         frac_max = 1.0
 
@@ -671,8 +677,8 @@
     if q_1 > q_0:
         if (q > q_0 and q <= q_1):
-            return (q-q_0)/(q_1 - q_0)    
+            return (q - q_0)/(q_1 - q_0)    
     else:
         if (q > q_1 and q <= q_0):
-            return (q-q_1)/(q_0 - q_1)
+            return (q - q_1)/(q_0 - q_1)
     return None
      
@@ -682,10 +688,12 @@
     The sector is defined by r_min, r_max, phi_min, phi_max,
     and the position of the center of the ring 
-    where phi_min and phi_max are defined by the right and left lines wrt central line
+    where phi_min and phi_max are defined by the right
+    and left lines wrt central line
     and phi_max could be less than phi_min. 
    
-    Phi is defined between 0 and 2*pi in anti-clockwise starting from the x- axis on the left-hand side
-    """
-    def __init__(self, r_min, r_max, phi_min=0, phi_max=2*math.pi,nbins=20):
+    Phi is defined between 0 and 2*pi in anti-clockwise 
+    starting from the x- axis on the left-hand side
+    """
+    def __init__(self, r_min, r_max, phi_min=0, phi_max=2*math.pi, nbins=20):
         self.r_min = r_min
         self.r_max = r_max
@@ -728,66 +736,73 @@
                       
         for n in range(len(data)):     
-                frac = 0
+            frac = 0
+            
+            # q-value at the pixel (j,i)
+            q_value = q_data[n]
+            data_n = data[n]
+            
+            # Is pixel within range?
+            is_in = False
+            
+            # phi-value of the pixel (j,i)
+            phi_value = math.atan2(qy_data[n], qx_data[n]) + Pi 
+            
+            ## No need to calculate the frac when all data are within range
+            if self.r_min <= q_value and q_value <= self.r_max:
+                frac = 1                       
+            if frac == 0:
+                continue
+            #In case of two ROIs (symmetric major and minor regions)(for 'q2')
+            if run.lower()=='q2':
+                ## For minor sector wing 
+                # Calculate the minor wing phis
+                phi_min_minor = flip_phi(phi_min - Pi)
+                phi_max_minor = flip_phi(phi_max - Pi)
+                # Check if phis of the minor ring is within 0 to 2pi
+                if phi_min_minor > phi_max_minor:
+                    is_in = (phi_value > phi_min_minor or \
+                              phi_value < phi_max_minor)
+                else:
+                    is_in = (phi_value > phi_min_minor and \
+                              phi_value < phi_max_minor)
+
+            #For all cases(i.e.,for 'q', 'q2', and 'phi') 
+            #Find pixels within ROI  
+            if phi_min > phi_max: 
+                is_in = is_in or (phi_value > phi_min or \
+                                   phi_value < phi_max)         
+            else:
+                is_in = is_in or (phi_value >= phi_min  and \
+                                    phi_value < phi_max)
+            
+            if not is_in:
+                frac = 0                                                        
+            if frac == 0:
+                continue
+            # Check which type of averaging we need
+            if run.lower() == 'phi': 
+                temp_x = (self.nbins) * (phi_value - self.phi_min)
+                temp_y = (self.phi_max - self.phi_min)
+                i_bin = int(math.floor(temp_x / temp_y))
+            else:
+                temp_x = (self.nbins) * (q_value - self.r_min)
+                tem_y = (self.r_max - self.r_min)
+                i_bin = int(math.floor(temp_x / temp_y))
+
+            # Take care of the edge case at phi = 2pi. 
+            if i_bin == self.nbins:  
+                i_bin =  self.nbins - 1
                 
-                # q-value at the pixel (j,i)
-                q_value = q_data[n]
-                
-    
-                data_n = data[n]
-                
-                # Is pixel within range?
-                is_in = False
-                
-                # phi-value of the pixel (j,i)
-                phi_value=math.atan2(qy_data[n],qx_data[n])+Pi 
-                
-                ## No need to calculate the frac when all data are within range
-                if self.r_min <= q_value and q_value <= self.r_max: frac = 1                       
-
-                if frac == 0: continue
-  
-                #In case of two ROIs (symmetric major and minor regions)(for 'q2')
-                if run.lower()=='q2':
-                    ## For minor sector wing 
-                    # Calculate the minor wing phis
-                    phi_min_minor = flip_phi(phi_min-Pi)
-                    phi_max_minor = flip_phi(phi_max-Pi)
-                    # Check if phis of the minor ring is within 0 to 2pi
-                    if phi_min_minor > phi_max_minor:
-                        is_in = (phi_value > phi_min_minor or phi_value < phi_max_minor)
-                    else:
-                        is_in = (phi_value > phi_min_minor and phi_value < phi_max_minor)
-
-                #For all cases(i.e.,for 'q', 'q2', and 'phi') 
-                #Find pixels within ROI  
-                if phi_min > phi_max: 
-                    is_in = is_in or (phi_value > phi_min or phi_value < phi_max)         
-                else:
-                    is_in = is_in or (phi_value>= phi_min  and  phi_value <phi_max)
-                
-                if not is_in: frac = 0                                                        
-                if frac == 0: continue
-                
-                # Check which type of averaging we need
-                if run.lower()=='phi': 
-                    i_bin    = int(math.floor((self.nbins)*(phi_value-self.phi_min)\
-                                              /(self.phi_max-self.phi_min)))
-                else:
-                    i_bin = int(math.floor((self.nbins)*(q_value-self.r_min)/(self.r_max-self.r_min)))
-
-                # Take care of the edge case at phi = 2pi. 
-                if i_bin == self.nbins:  
-                    i_bin =  self.nbins -1
-                    
-                ## Get the total y          
-                y[i_bin] += frac * data_n
-
-                if err_data == None or err_data[n] ==0.0:
-                    if data_n<0: data_n= -data_n
-                    y_err[i_bin] += frac * frac * data_n
-                else:
-                    y_err[i_bin] += frac * frac * err_data[n]*err_data[n]
-                y_counts[i_bin] += frac
-       
+            ## Get the total y          
+            y[i_bin] += frac * data_n
+
+            if err_data == None or err_data[n] == 0.0:
+                if data_n < 0:
+                    data_n = -data_n
+                y_err[i_bin] += frac * frac * data_n
+            else:
+                y_err[i_bin] += frac * frac * err_data[n] * err_data[n]
+            y_counts[i_bin] += frac
+   
         # Organize the results
         for i in range(self.nbins):
@@ -797,15 +812,19 @@
             # The type of averaging: phi,q2, or q
             # Calculate x[i]should be at the center of the bin
-            if run.lower()=='phi':               
-                x[i] = (self.phi_max-self.phi_min)/self.nbins*(1.0*i + 0.5)+self.phi_min
+            if run.lower() == 'phi': 
+                temp = self.nbins * (1.0 * i + 0.5) + self.phi_min              
+                x[i] = (self.phi_max - self.phi_min) / temp
             else:
-                x[i] = (self.r_max-self.r_min)/self.nbins*(1.0*i + 0.5)+self.r_min
+                temp = self.nbins * (1.0 * i + 0.5) + self.r_min
+                x[i] = (self.r_max - self.r_min) / temp
                 
-        idx = (numpy.isfinite(y)& numpy.isfinite(y_err))
-        
-        if not idx.any(): 
-            raise ValueError, "Average Error: No points inside sector of ROI to average..." 
-        elif len(y[idx])!= self.nbins:
-            print "resulted",self.nbins- len(y[idx]),"empty bin(s) due to tight binning..."
+        idx = (numpy.isfinite(y) & numpy.isfinite(y_err))
+        
+        if not idx.any():
+            msg = "Average Error: No points inside sector of ROI to average..." 
+            raise ValueError, msg
+        #elif len(y[idx])!= self.nbins:
+        #    print "resulted",self.nbins- len(y[idx]),
+        #"empty bin(s) due to tight binning..."
         return Data1D(x=x[idx], y=y[idx], dy=y_err[idx])
                 
@@ -885,5 +904,5 @@
         qy_data = data2D.qy_data
         mask = data2D.mask
-        q_data = numpy.sqrt(qx_data*qx_data+qy_data*qy_data)
+        q_data = numpy.sqrt(qx_data * qx_data + qy_data * qy_data)
         #q_data_max = numpy.max(q_data)
 
@@ -946,10 +965,11 @@
     Defines a sector (major + minor) region on a 2D data set.
     The sector is defined by phi_min, phi_max,
-    where phi_min and phi_max are defined by the right and left lines wrt central line. 
+    where phi_min and phi_max are defined by the right 
+    and left lines wrt central line. 
    
     Phi_min and phi_max are given in units of radian 
     and (phi_max-phi_min) should not be larger than pi
     """
-    def __init__(self,phi_min=0, phi_max=math.pi):
+    def __init__(self, phi_min=0, phi_max=math.pi):
         self.phi_min = phi_min
         self.phi_max = phi_max
@@ -991,6 +1011,6 @@
         
         # Get the min and max into the region: -pi <= phi < Pi
-        phi_min_major = flip_phi(self.phi_min+Pi)-Pi
-        phi_max_major = flip_phi(self.phi_max+Pi)-Pi  
+        phi_min_major = flip_phi(self.phi_min + Pi) - Pi
+        phi_max_major = flip_phi(self.phi_max + Pi) - Pi  
         # check for major sector
         if phi_min_major > phi_max_major:
@@ -1001,12 +1021,14 @@
         # minor sector
         # Get the min and max into the region: -pi <= phi < Pi
-        phi_min_minor = flip_phi(self.phi_min)-Pi
-        phi_max_minor = flip_phi(self.phi_max)-Pi
+        phi_min_minor = flip_phi(self.phi_min) - Pi
+        phi_max_minor = flip_phi(self.phi_max) - Pi
               
         # check for minor sector
         if phi_min_minor > phi_max_minor:
-            out_minor= (phi_min_minor <= phi_data) + (phi_max_minor>= phi_data) 
+            out_minor = (phi_min_minor <= phi_data) + \
+                            (phi_max_minor >= phi_data) 
         else:
-            out_minor = (phi_min_minor <= phi_data) & (phi_max_minor >= phi_data) 
+            out_minor = (phi_min_minor <= phi_data) & \
+                            (phi_max_minor >= phi_data) 
         out = out_major + out_minor
         
Index: DataLoader/qsmearing.py
===================================================================
--- DataLoader/qsmearing.py	(revision 023c8e2681880c4cf42fd1240e018e99e28e1dd5)
+++ DataLoader/qsmearing.py	(revision a7a5886e7fa30dd75a5a77d68a58574c9246f27f)
@@ -7,9 +7,9 @@
 #copyright 2008, University of Tennessee
 ######################################################################
-
+import numpy
+#import math
+import logging
+import sys
 import DataLoader.extensions.smearer as smearer
-import numpy
-import math
-import logging, sys
 from DataLoader.smearing_2d import Smearer2D
 
@@ -40,13 +40,14 @@
         return Smearer2D(data1D)
     
-    if  not hasattr(data1D, "dx") and not hasattr(data1D, "dxl") and not hasattr(data1D, "dxw"):
+    if  not hasattr(data1D, "dx") and not hasattr(data1D, "dxl")\
+         and not hasattr(data1D, "dxw"):
         return None
     
     # Look for resolution smearing data
     _found_resolution = False
-    if data1D.dx is not None and len(data1D.dx)==len(data1D.x):
+    if data1D.dx is not None and len(data1D.dx) == len(data1D.x):
         
         # Check that we have non-zero data
-        if data1D.dx[0]>0.0:
+        if data1D.dx[0] > 0.0:
             _found_resolution = True
             #print "_found_resolution",_found_resolution
@@ -58,9 +59,9 @@
     # Look for slit smearing data
     _found_slit = False
-    if data1D.dxl is not None and len(data1D.dxl)==len(data1D.x) \
-        and data1D.dxw is not None and len(data1D.dxw)==len(data1D.x):
+    if data1D.dxl is not None and len(data1D.dxl) == len(data1D.x) \
+        and data1D.dxw is not None and len(data1D.dxw) == len(data1D.x):
         
         # Check that we have non-zero data
-        if data1D.dxl[0]>0.0 or data1D.dxw[0]>0.0:
+        if data1D.dxl[0] > 0.0 or data1D.dxw[0] > 0.0:
             _found_slit = True
         
@@ -78,5 +79,4 @@
     if _found_slit == True:
         return SlitSmearer(data1D)
-    
     return None
             
@@ -101,6 +101,8 @@
         return result
 
-        
-    def _compute_matrix(self): return NotImplemented
+    def _compute_matrix(self):
+        """
+        """
+        return NotImplemented
 
     def get_bin_range(self, q_min=None, q_max=None):
@@ -115,17 +117,14 @@
         if not self._init_complete:
             self._initialize_smearer()
-            
         if q_min == None:
             q_min = self.min
-        
         if q_max == None:
             q_max = self.max
-        
-        _qmin_unsmeared, _qmax_unsmeared = self.get_unsmeared_range(q_min, q_max)
-        
+        _qmin_unsmeared, _qmax_unsmeared = self.get_unsmeared_range(q_min,
+                                                                     q_max)
         _first_bin = None
         _last_bin  = None
 
-        step = (self.max-self.min)/(self.nbins-1.0)
+        step = (self.max - self.min) / (self.nbins - 1.0)
         try:
             for i in range(self.nbins):
@@ -138,5 +137,7 @@
                         _last_bin  = i
         except:
-            raise RuntimeError, "_BaseSmearer.get_bin_range: error getting range\n  %s" % sys.exc_value
+            msg = "_BaseSmearer.get_bin_range: "
+            msg += " error getting range\n  %s" % sys.exc_value
+            raise RuntimeError, msg
                
         return _first_bin, _last_bin
@@ -152,20 +153,29 @@
              
         # Get the max value for the last bin
-        if last_bin is None or last_bin>=len(iq_in):
-            last_bin = len(iq_in)-1
+        if last_bin is None or last_bin >= len(iq_in):
+            last_bin = len(iq_in) - 1
         # Check that the first bin is positive
-        if first_bin<0:
+        if first_bin < 0:
             first_bin = 0
             
         # Sanity check
         if len(iq_in) != self.nbins:
-            raise RuntimeError, "Invalid I(q) vector: inconsistent array length %d != %s" % (len(iq_in), str(self.nbins))
+            msg = "Invalid I(q) vector: inconsistent array "
+            msg += " length %d != %s" % (len(iq_in), str(self.nbins))
+            raise RuntimeError, msg
              
         # Storage for smeared I(q)   
         iq_out = numpy.zeros(self.nbins)
-        smear_output = smearer.smear(self._smearer, iq_in, iq_out, first_bin, last_bin)
+        smear_output = smearer.smear(self._smearer, iq_in, iq_out,
+                                      first_bin, last_bin)
         if smear_output < 0:
-            raise RuntimeError, "_BaseSmearer: could not smear, code = %g" % smear_output
+            msg = "_BaseSmearer: could not smear, code = %g" % smear_output
+            raise RuntimeError, msg
         return iq_out
+    
+    def _initialize_smearer(self):
+        """
+        """
+        return NotImplemented
     
 class _SlitSmearer(_BaseSmearer):
@@ -207,6 +217,8 @@
         This method HAS to be called before smearing
         """
-        #self._smearer = smearer.new_slit_smearer(self.width, self.height, self.min, self.max, self.nbins)
-        self._smearer = smearer.new_slit_smearer_with_q(self.width, self.height, self.qvalues)
+        #self._smearer = smearer.new_slit_smearer(self.width,
+        # self.height, self.min, self.max, self.nbins)
+        self._smearer = smearer.new_slit_smearer_with_q(self.width, 
+                                                    self.height, self.qvalues)
         self._init_complete = True
 
@@ -241,19 +253,22 @@
         ## Slit width
         self.width = 0
-        if data1D.dxw is not None and len(data1D.dxw)==len(data1D.x):
+        if data1D.dxw is not None and len(data1D.dxw) == len(data1D.x):
             self.width = data1D.dxw[0]
             # Sanity check
             for value in data1D.dxw:
                 if value != self.width:
-                    raise RuntimeError, "Slit smearing parameters must be the same for all data"
-                
+                    msg = "Slit smearing parameters must "
+                    msg += " be the same for all data"
+                    raise RuntimeError, msg
         ## Slit height
         self.height = 0
-        if data1D.dxl is not None and len(data1D.dxl)==len(data1D.x):
+        if data1D.dxl is not None and len(data1D.dxl) == len(data1D.x):
             self.height = data1D.dxl[0]
             # Sanity check
             for value in data1D.dxl:
                 if value != self.height:
-                    raise RuntimeError, "Slit smearing parameters must be the same for all data"
+                    msg = "Slit smearing parameters must be"
+                    msg += " the same for all data"
+                    raise RuntimeError, msg
         
         ## Number of Q bins
@@ -283,11 +298,11 @@
         _BaseSmearer.__init__(self)
         ## Standard deviation in Q [A-1]
-        self.width  = width
+        self.width = width
         ## Q_min (Min Q-value for I(q))
-        self.min    = min
+        self.min = min
         ## Q_max (Max Q_value for I(q))
-        self.max    = max
+        self.max = max
         ## Number of Q bins 
-        self.nbins  = nbins
+        self.nbins = nbins
         ## Smearing matrix
         self._weights = None
@@ -299,6 +314,8 @@
         This method HAS to be called before smearing
         """
-        #self._smearer = smearer.new_q_smearer(numpy.asarray(self.width), self.min, self.max, self.nbins)
-        self._smearer = smearer.new_q_smearer_with_q(numpy.asarray(self.width), self.qvalues)
+        #self._smearer = smearer.new_q_smearer(numpy.asarray(self.width),
+        # self.min, self.max, self.nbins)
+        self._smearer = smearer.new_q_smearer_with_q(numpy.asarray(self.width),
+                                                      self.qvalues)
         self._init_complete = True
         
@@ -313,7 +330,7 @@
         _qmax_unsmeared = q_max 
         try:
-            offset = 3.0*max(self.width)
-            _qmin_unsmeared = max([self.min, q_min-offset])
-            _qmax_unsmeared = min([self.max, q_max+offset])
+            offset = 3.0 * max(self.width)
+            _qmin_unsmeared = max([self.min, q_min - offset])
+            _qmax_unsmeared = min([self.max, q_max + offset])
         except:
             logging.error("_QSmearer.get_bin_range: %s" % sys.exc_value)
@@ -336,5 +353,5 @@
         ## Resolution
         self.width = numpy.zeros(len(data1D.x))
-        if data1D.dx is not None and len(data1D.dx)==len(data1D.x):
+        if data1D.dx is not None and len(data1D.dx) == len(data1D.x):
             self.width = data1D.dx
         
@@ -350,11 +367,9 @@
 
 if __name__ == '__main__':
-    x = 0.001*numpy.arange(1,11)
-    y = 12.0-numpy.arange(1,11)
+    x = 0.001 * numpy.arange(1, 11)
+    y = 12.0 - numpy.arange(1, 11)
     print x
     #for i in range(10): print i, 0.001 + i*0.008/9.0 
     #for i in range(100): print i, int(math.floor( (i/ (100/9.0)) )) 
-
-    
     s = _SlitSmearer(nbins=10, width=0.0, height=0.005, min=0.001, max=0.010)
     #s = _QSmearer(nbins=10, width=0.001, min=0.001, max=0.010)
@@ -366,5 +381,5 @@
     if True:
         for i in range(10):
-            print x[i],y[i], sy[i]
+            print x[i], y[i], sy[i]
             #print q, ' : ', s.weight(q), s._compute_iq(q) 
             #print q, ' : ', s(q), s._compute_iq(q) 
Index: DataLoader/readers/IgorReader.py
===================================================================
--- DataLoader/readers/IgorReader.py	(revision 0997158f0d11874fd896ee66b3bb468898c9bb2b)
+++ DataLoader/readers/IgorReader.py	(revision a7a5886e7fa30dd75a5a77d68a58574c9246f27f)
@@ -15,8 +15,11 @@
 """
 
-import os, sys
+import os
+#import sys
 import numpy
-import math, logging
-from DataLoader.data_info import Data2D, Detector
+import math
+#import logging
+from DataLoader.data_info import Data2D
+from DataLoader.data_info import Detector
 from DataLoader.manipulations import reader2D_converter
 
@@ -100,5 +103,6 @@
                     wavelength = float(line_toks[1])
                 except:
-                    raise ValueError,"IgorReader: can't read this file, missing wavelength"
+                    msg = "IgorReader: can't read this file, missing wavelength"
+                    raise ValueError, msg
                 
             #Find # of bins in a row assuming the detector is square.
@@ -130,10 +134,12 @@
                     wavelength = float(line_toks[1])
                 except:
-                    raise ValueError,"IgorReader: can't read this file, missing wavelength"
+                    msg = "IgorReader: can't read this file, missing wavelength"
+                    raise ValueError, msg
                 # Distance in meters
                 try:
                     distance = float(line_toks[3])
                 except:
-                    raise ValueError,"IgorReader: can't read this file, missing distance"
+                    msg = "IgorReader: can't read this file, missing distance"
+                    raise ValueError, msg
                 
                 # Distance in meters
@@ -141,5 +147,7 @@
                     transmission = float(line_toks[4])
                 except:
-                    raise ValueError,"IgorReader: can't read this file, missing transmission"
+                    msg = "IgorReader: can't read this file, "
+                    msg += "missing transmission"
+                    raise ValueError, msg
                                             
             if line.count("LAMBDA")>0:
@@ -151,5 +159,6 @@
                 line_toks = line.split()
                 
-                # Center in bin number: Must substrate 1 because the index starts from 1
+                # Center in bin number: Must substrate 1 because 
+                #the index starts from 1
                 center_x = float(line_toks[0])-1
                 center_y = float(line_toks[1])-1
@@ -168,5 +177,6 @@
                     or center_x == None \
                     or center_y == None:
-                    raise ValueError, "IgorReader:Missing information in data file"
+                    msg = "IgorReader:Missing information in data file"
+                    raise ValueError, msg
                 
             if dataStarted == True:
@@ -190,7 +200,10 @@
                 # Q = 4pi/lambda sin(theta/2)
                 # Bin size is 0.5 cm 
-                #REmoved +1 from theta = (i_x-center_x+1)*0.5 / distance / 100.0 and 
-                #REmoved +1 from theta = (i_y-center_y+1)*0.5 / distance / 100.0
-                #ToDo: Need  complete check if the following covert process is consistent with fitting.py.
+                #REmoved +1 from theta = (i_x-center_x+1)*0.5 / distance 
+                # / 100.0 and 
+                #REmoved +1 from theta = (i_y-center_y+1)*0.5 /
+                # distance / 100.0
+                #ToDo: Need  complete check if the following
+                # covert process is consistent with fitting.py.
                 theta = (i_x-center_x)*0.5 / distance / 100.0
                 qx = 4.0*math.pi/wavelength * math.sin(theta/2.0)
Index: DataLoader/readers/abs_reader.py
===================================================================
--- DataLoader/readers/abs_reader.py	(revision 0997158f0d11874fd896ee66b3bb468898c9bb2b)
+++ DataLoader/readers/abs_reader.py	(revision a7a5886e7fa30dd75a5a77d68a58574c9246f27f)
@@ -1,2 +1,4 @@
+"""
+"""
 #####################################################################
 #This software was developed by the University of Tennessee as part of the
@@ -9,5 +11,6 @@
 import numpy
 import os
-from DataLoader.data_info import Data1D, Detector
+from DataLoader.data_info import Data1D
+from DataLoader.data_info import Detector
 
 has_converter = True
@@ -26,5 +29,5 @@
     type = ["IGOR 1D files (*.abs)|*.abs"]
     ## List of allowed extensions
-    ext=['.abs', '.ABS']  
+    ext = ['.abs', '.ABS']  
     
     def read(self, path):
@@ -78,5 +81,5 @@
                     
                     # Information line 1
-                    if is_info==True:
+                    if is_info == True:
                         is_info = False
                         line_toks = line.split()
@@ -85,26 +88,32 @@
                         try:
                             value = float(line_toks[1])
-                            if has_converter==True and output.source.wavelength_unit != 'A':
+                            if has_converter == True and \
+                                output.source.wavelength_unit != 'A':
                                 conv = Converter('A')
-                                output.source.wavelength = conv(value, units=output.source.wavelength_unit)
+                                output.source.wavelength = conv(value, 
+                                        units=output.source.wavelength_unit)
                             else:
                                 output.source.wavelength = value
                         except:
                             #goes to ASC reader
-                            raise  RuntimeError, "abs_reader: cannot open %s" % path
-                            #raise ValueError,"IgorReader: can't read this file, missing wavelength"
+                            msg = "abs_reader: cannot open %s" % path
+                            raise  RuntimeError, msg
+                            #raise ValueError,"IgorReader: can't read this file,
+                            # missing wavelength"
                         
                         # Distance in meters
                         try:
                             value = float(line_toks[3])
-                            if has_converter==True and detector.distance_unit != 'm':
+                            if has_converter == True and \
+                                detector.distance_unit != 'm':
                                 conv = Converter('m')
-                                detector.distance = conv(value, units=detector.distance_unit)
+                                detector.distance = conv(value, 
+                                                units=detector.distance_unit)
                             else:
                                 detector.distance = value
                         except:
                             #goes to ASC reader
-                            raise  RuntimeError, "abs_reader: cannot open %s" % path
-                        
+                            msg = "abs_reader: cannot open %s" % path
+                            raise  RuntimeError, msg
                         # Transmission 
                         try:
@@ -117,7 +126,9 @@
                         try:
                             value = float(line_toks[5])
-                            if has_converter==True and output.sample.thickness_unit != 'cm':
+                            if has_converter == True and \
+                                output.sample.thickness_unit != 'cm':
                                 conv = Converter('cm')
-                                output.sample.thickness = conv(value, units=output.sample.thickness_unit)
+                                output.sample.thickness = conv(value, 
+                                            units=output.sample.thickness_unit)
                             else:
                                 output.sample.thickness = value
@@ -126,10 +137,11 @@
                             pass
                     
-                    #MON CNT   LAMBDA   DET ANG   DET DIST   TRANS   THICK   AVE   STEP
-                    if line.count("LAMBDA")>0:
+                    #MON CNT   LAMBDA   DET ANG   DET DIST   TRANS   THICK 
+                    #  AVE   STEP
+                    if line.count("LAMBDA") > 0:
                         is_info = True
                         
                     # Find center info line
-                    if is_center==True:
+                    if is_center == True:
                         is_center = False                
                         line_toks = line.split()
@@ -139,8 +151,11 @@
                         
                         # Bin size
-                        if has_converter==True and detector.pixel_size_unit != 'mm':
+                        if has_converter == True and \
+                            detector.pixel_size_unit != 'mm':
                             conv = Converter('mm')
-                            detector.pixel_size.x = conv(5.0, units=detector.pixel_size_unit)
-                            detector.pixel_size.y = conv(5.0, units=detector.pixel_size_unit)
+                            detector.pixel_size.x = conv(5.0, 
+                                                units=detector.pixel_size_unit)
+                            detector.pixel_size.y = conv(5.0,
+                                                units=detector.pixel_size_unit)
                         else:
                             detector.pixel_size.x = 5.0
@@ -149,11 +164,14 @@
                         # Store beam center in distance units
                         # Det 640 x 640 mm
-                        if has_converter==True and detector.beam_center_unit != 'mm':
+                        if has_converter==True and \
+                            detector.beam_center_unit != 'mm':
                             conv = Converter('mm')
-                            detector.beam_center.x = conv(center_x*5.0, units=detector.beam_center_unit)
-                            detector.beam_center.y = conv(center_y*5.0, units=detector.beam_center_unit)
+                            detector.beam_center.x = conv(center_x * 5.0,
+                                             units=detector.beam_center_unit)
+                            detector.beam_center.y = conv(center_y * 5.0, 
+                                            units=detector.beam_center_unit)
                         else:
-                            detector.beam_center.x = center_x*5.0
-                            detector.beam_center.y = center_y*5.0
+                            detector.beam_center.x = center_x * 5.0
+                            detector.beam_center.y = center_y * 5.0
                         
                         # Detector type
@@ -164,10 +182,11 @@
                             pass
                     
-                    #BCENT(X,Y)   A1(mm)   A2(mm)   A1A2DIST(m)   DL/L   BSTOP(mm)   DET_TYP 
-                    if line.count("BCENT")>0:
+                    #BCENT(X,Y)   A1(mm)   A2(mm)   A1A2DIST(m)   DL/L 
+                    #  BSTOP(mm)   DET_TYP 
+                    if line.count("BCENT") > 0:
                         is_center = True
                         
                     # Parse the data
-                    if is_data_started==True:
+                    if is_data_started == True:
                         toks = line.split()
 
@@ -197,5 +216,6 @@
                             pass
                             
-                    #The 6 columns are | Q (1/A) | I(Q) (1/cm) | std. dev. I(Q) (1/cm) | sigmaQ | meanQ | ShadowFactor|
+                    #The 6 columns are | Q (1/A) | I(Q) (1/cm) | std. dev.
+                    # I(Q) (1/cm) | sigmaQ | meanQ | ShadowFactor|
                     if line.count("The 6 columns")>0:
                         is_data_started = True
@@ -203,11 +223,10 @@
                 # Sanity check
                 if not len(y) == len(dy):
-                    raise ValueError, "abs_reader: y and dy have different length"
-
+                    msg = "abs_reader: y and dy have different length"
+                    raise ValueError, msg
                 # If the data length is zero, consider this as
                 # though we were not able to read the file.
-                if len(x)==0:
+                if len(x) == 0:
                     raise ValueError, "ascii_reader: could not load file"
-               
                 output.x = x
                 output.y = y
Index: DataLoader/readers/ascii_reader.py
===================================================================
--- DataLoader/readers/ascii_reader.py	(revision fca90f826e46e090353be593a04ab978b84efae5)
+++ DataLoader/readers/ascii_reader.py	(revision a7a5886e7fa30dd75a5a77d68a58574c9246f27f)
@@ -36,5 +36,5 @@
             "ASCII files (*.abs)|*.abs"]
     ## List of allowed extensions
-    ext=['.txt', '.TXT', '.dat', '.DAT', '.abs', '.ABS']  
+    ext = ['.txt', '.TXT', '.dat', '.DAT', '.abs', '.ABS']  
     
     ## Flag to bypass extension check
@@ -54,5 +54,5 @@
         if os.path.isfile(path):
             basename  = os.path.basename(path)
-            root, extension = os.path.splitext(basename)
+            _, extension = os.path.splitext(basename)
             if self.allow_all or extension.lower() in self.ext:
                 try:
@@ -63,6 +63,8 @@
                 lines = buff.split('\n')
                 
-                #Jae could not find python universal line spliter: keep the below for now
-                # some ascii data has \r line separator, try it when the data is on only one long line
+                #Jae could not find python universal line spliter: 
+                #keep the below for now
+                # some ascii data has \r line separator,
+                # try it when the data is on only one long line
                 if len(lines) < 2 : 
                     lines = buff.split('\r')
@@ -103,15 +105,19 @@
                 #Initialize counters for data lines and header lines.
                 is_data = False #Has more than 5 lines
-                mum_data_lines = 5 # More than "5" lines of data is considered as actual data unless that is the only data
-
-                i=-1            # To count # of current data candidate lines
-                i1=-1           # To count total # of previous data candidate lines
-                j=-1            # To count # of header lines
-                j1=-1           # Helps to count # of header lines
-                lentoks = 2     # minimum required number of columns of data; ( <= 4).
-                
+                # More than "5" lines of data is considered as actual
+                # data unless that is the only data
+                mum_data_lines = 5 
+                # To count # of current data candidate lines
+                i = -1  
+                # To count total # of previous data candidate lines          
+                i1 = -1 
+                # To count # of header lines          
+                j = -1
+                # Helps to count # of header lines            
+                j1 = -1
+                #minimum required number of columns of data; ( <= 4).           
+                lentoks = 2     
                 for line in lines:
                     toks = line.split()
-                    
                     try:
                         #Make sure that all columns are numbers.
@@ -140,5 +146,5 @@
                         # third column.
                         _dy = None
-                        if len(toks)>2:
+                        if len(toks) > 2:
                             try:
                                 _dy = float(toks[2])
@@ -158,5 +164,5 @@
                         #Check for dx
                         _dx = None
-                        if len(toks)>3:
+                        if len(toks) > 3:
                             try:
                                 _dx = float(toks[3])
@@ -174,10 +180,13 @@
                             has_error_dx = False if _dx == None else True
                         
-                        #After talked with PB, we decided to take care of only 4 columns of data for now.
+                        #After talked with PB, we decided to take care of only 
+                        # 4 columns of data for now.
                         #number of columns in the current line
-                        #To remember the # of columns in the current line of data
+                        #To remember the # of columns in the current 
+                        #line of data
                         new_lentoks = len(toks)
                         
-                        #If the previous columns not equal to the current, mark the previous as non-data and reset the dependents.  
+                        #If the previous columns not equal to the current, 
+                        #mark the previous as non-data and reset the dependents.  
                         if lentoks != new_lentoks :
                             if is_data == True:
@@ -190,10 +199,11 @@
                             
                             
-                        #Delete the previously stored lines of data candidates if is not data.
-                        if i < 0 and -1< i1 < mum_data_lines and is_data == False:
+                        #Delete the previously stored lines of data candidates
+                        # if is not data.
+                        if i < 0 and -1 < i1 < mum_data_lines and \
+                            is_data == False:
                             try:
-                                x= numpy.zeros(0)
-                                y= numpy.zeros(0)
-                                
+                                x = numpy.zeros(0)
+                                y = numpy.zeros(0)
                             except:
                                 pass
@@ -203,6 +213,8 @@
                         
                         if has_error_dy == True:
-                            #Delete the previously stored lines of data candidates if is not data.
-                            if i < 0 and -1< i1 < mum_data_lines and is_data== False:
+                            #Delete the previously stored lines of
+                            # data candidates if is not data.
+                            if i < 0 and -1 < i1 < mum_data_lines and \
+                                is_data == False:
                                 try:
                                     dy = numpy.zeros(0)  
@@ -212,6 +224,8 @@
                             
                         if has_error_dx == True:
-                            #Delete the previously stored lines of data candidates if is not data.
-                            if i < 0 and -1< i1 < mum_data_lines and is_data== False:
+                            #Delete the previously stored lines of
+                            # data candidates if is not data.
+                            if i < 0 and -1 < i1 < mum_data_lines and \
+                                is_data == False:
                                 try:
                                     dx = numpy.zeros(0)                            
@@ -221,11 +235,13 @@
                             
                         #Same for temp.
-                        #Delete the previously stored lines of data candidates if is not data.
-                        if i < 0 and -1< i1 < mum_data_lines and is_data== False:
+                        #Delete the previously stored lines of data candidates
+                        # if is not data.
+                        if i < 0 and -1 < i1 < mum_data_lines and\
+                            is_data == False:
                             try:
                                 tx = numpy.zeros(0)
                                 ty = numpy.zeros(0)
                             except:
-                                pass                                                               
+                                pass                                                           
 
                         tx  = numpy.append(tx,   _x) 
@@ -233,6 +249,8 @@
                         
                         if has_error_dy == True:
-                            #Delete the previously stored lines of data candidates if is not data.
-                            if i < 0 and -1<i1 < mum_data_lines and is_data== False:
+                            #Delete the previously stored lines of
+                            # data candidates if is not data.
+                            if i < 0 and -1 < i1 < mum_data_lines and \
+                                is_data == False:
                                 try:
                                     tdy = numpy.zeros(0)
@@ -241,24 +259,27 @@
                             tdy = numpy.append(tdy, _dy)
                         if has_error_dx == True:
-                            #Delete the previously stored lines of data candidates if is not data.
-                            if i < 0 and -1< i1 < mum_data_lines and is_data== False:
+                            #Delete the previously stored lines of
+                            # data candidates if is not data.
+                            if i < 0 and -1 < i1 < mum_data_lines and \
+                                is_data == False:
                                 try:
                                     tdx = numpy.zeros(0)
                                 except:
-                                    pass                                                                                                             
+                                    pass                                                                                                          
                             tdx = numpy.append(tdx, _dx)
 
                         #reset i1 and flag lentoks for the next
-                        if lentoks < new_lentoks :
+                        if lentoks < new_lentoks:
                             if is_data == False:
                                 i1 = -1                            
-                        #To remember the # of columns on the current line for the next line of data
+                        #To remember the # of columns on the current line
+                        # for the next line of data
                         lentoks = len(toks)
                         
-                        #Reset # of header lines and counts # of data candidate lines    
-                        if j == 0 and j1 ==0:
+                        #Reset # of header lines and counts # 
+                        # of data candidate lines    
+                        if j == 0 and j1 == 0:
                             i1 = i + 1                            
-                        i+=1
-                        
+                        i += 1
                     except:
 
@@ -268,6 +289,6 @@
                         lentoks = 2
                         #Counting # of header lines                    
-                        j+=1
-                        if j == j1+1:
+                        j += 1
+                        if j == j1 + 1:
                             j1 = j                            
                         else:                            
@@ -279,19 +300,20 @@
                         pass
                     
-    
                 input_f.close()     
                 # Sanity check
                 if has_error_dy == True and not len(y) == len(dy):
-                    raise RuntimeError, "ascii_reader: y and dy have different length"
+                    msg = "ascii_reader: y and dy have different length"
+                    raise RuntimeError, msg
                 if has_error_dx == True and not len(x) == len(dx):
-                    raise RuntimeError, "ascii_reader: y and dy have different length"
-
+                    msg = "ascii_reader: y and dy have different length"
+                    raise RuntimeError, msg
                 # If the data length is zero, consider this as
                 # though we were not able to read the file.
-                if len(x)==0:
+                if len(x) == 0:
                     raise RuntimeError, "ascii_reader: could not load file"
                 
-                #Let's re-order the data to make cal. curve look better some cases
-                ind = numpy.lexsort((ty,tx))
+                #Let's re-order the data to make cal.
+                # curve look better some cases
+                ind = numpy.lexsort((ty, tx))
                 for i in ind:
                     x[i] = tx[ind[i]]
@@ -301,6 +323,4 @@
                     if has_error_dx == True:
                         dx[i] = tdx[ind[i]]
-                
-                
                 #Data    
                 output.x = x
Index: DataLoader/readers/associations.py
===================================================================
--- DataLoader/readers/associations.py	(revision 0997158f0d11874fd896ee66b3bb468898c9bb2b)
+++ DataLoader/readers/associations.py	(revision a7a5886e7fa30dd75a5a77d68a58574c9246f27f)
@@ -19,5 +19,6 @@
 """
 
-import os, sys
+import os
+import sys
 import logging
 from lxml import etree 
@@ -52,5 +53,6 @@
         
         # Read in the file extension associations
-        entry_list = root.xpath('/ns:SansLoader/ns:FileType', namespaces={'ns': VERSION})
+        entry_list = root.xpath('/ns:SansLoader/ns:FileType',
+                                 namespaces={'ns': VERSION})
 
         # For each FileType entry, get the associated reader and extension
@@ -61,12 +63,16 @@
             if reader is not None and ext is not None:
                 # Associate the extension with a particular reader
-                # TODO: Modify the Register code to be case-insensitive and remove the
-                #       extra line below.
+                # TODO: Modify the Register code to be case-insensitive 
+                # and remove the extra line below.
                 try:
                     exec "import %s" % reader
-                    exec "loader.associate_file_type('%s', %s)" % (ext.lower(), reader)
-                    exec "loader.associate_file_type('%s', %s)" % (ext.upper(), reader)
+                    exec "loader.associate_file_type('%s', %s)" % (ext.lower(),
+                                                                    reader)
+                    exec "loader.associate_file_type('%s', %s)" % (ext.upper(),
+                                                                    reader)
                 except:
-                    logging.error("read_associations: skipping association for %s\n  %s" % (attr['extension'], sys.exc_value))
+                    msg = "read_associations: skipping association"
+                    msg += " for %s\n  %s" % (attr['extension'], sys.exc_value)
+                    logging.error(msg)
          
          
Index: DataLoader/readers/cansas_reader.py
===================================================================
--- DataLoader/readers/cansas_reader.py	(revision 74060405338e1db07021b0c80bf9186fef5846d6)
+++ DataLoader/readers/cansas_reader.py	(revision a7a5886e7fa30dd75a5a77d68a58574c9246f27f)
@@ -15,9 +15,12 @@
 # within a single SASentry. Will raise a runtime error.
 
-#TODO: check that all vectors are written only if they have at least one non-empty value
-#TODO: Writing only allows one SASentry per file. Would be best to allow multiple entries.
+#TODO: check that all vectors are written only if they have at 
+#    least one non-empty value
+#TODO: Writing only allows one SASentry per file.
+#     Would be best to allow multiple entries.
 #TODO: Store error list
 #TODO: Allow for additional meta data for each section
-#TODO: Notes need to be implemented. They can be any XML structure in version 1.0
+#TODO: Notes need to be implemented. They can be any XML 
+#    structure in version 1.0
 #      Process notes have the same problem.
 #TODO: Unit conversion is not complete (temperature units are missing)
@@ -26,6 +29,11 @@
 import logging
 import numpy
-import os, sys
-from DataLoader.data_info import Data1D, Collimation, Detector, Process, Aperture
+import os
+import sys
+from DataLoader.data_info import Data1D
+from DataLoader.data_info import Collimation
+from DataLoader.data_info import Detector
+from DataLoader.data_info import Process
+from DataLoader.data_info import Aperture
 from lxml import etree
 import xml.dom.minidom
@@ -85,19 +93,17 @@
     value = None
     attr = {}
-    
-    if len(nodes)>0:
+    if len(nodes) > 0:
         try:
             value = float(nodes[0].text)   
         except:
             # Could not pass, skip and return None
-            logging.error("cansas_reader.get_float: could not convert '%s' to float" % nodes[0].text)
-        
+            msg = "cansas_reader.get_float: could not "
+            msg += " convert '%s' to float" % nodes[0].text
+            logging.error(msg)
         if nodes[0].get('unit') is not None:
             attr['unit'] = nodes[0].get('unit')
-            
     return value, attr
 
             
-
 class Reader:
     """
@@ -117,5 +123,5 @@
 
     ## List of allowed extensions
-    ext=['.xml', '.XML','.avex', '.AVEx', '.absx', 'ABSx']  
+    ext = ['.xml', '.XML','.avex', '.AVEx', '.absx', 'ABSx']  
     
     def __init__(self):
@@ -144,8 +150,10 @@
                 tree = etree.parse(path, parser=etree.ETCompatXMLParser())
                 # Check the format version number
-                # Specifying the namespace will take care of the file format version 
+                # Specifying the namespace will take care of the file
+                # format version 
                 root = tree.getroot()
                 
-                entry_list = root.xpath('/ns:SASroot/ns:SASentry', namespaces={'ns': CANSAS_NS})
+                entry_list = root.xpath('/ns:SASroot/ns:SASentry',
+                                         namespaces={'ns': CANSAS_NS})
                 
                 for entry in entry_list:
@@ -196,5 +204,6 @@
                            
         # Look up instrument name              
-        self._store_content('ns:SASinstrument/ns:name', dom, 'instrument', data_info)
+        self._store_content('ns:SASinstrument/ns:name', dom, 'instrument',
+                             data_info)
 
         # Notes
@@ -207,5 +216,6 @@
                         data_info.notes.append(note_value)
             except:
-                err_mess = "cansas_reader.read: error processing entry notes\n  %s" % sys.exc_value
+                err_mess = "cansas_reader.read: error processing"
+                err_mess += " entry notes\n  %s" % sys.exc_value
                 self.errors.append(err_mess)
                 logging.error(err_mess)
@@ -225,5 +235,6 @@
                      dom, 'temperature', data_info.sample)
         
-        nodes = dom.xpath('ns:SASsample/ns:details', namespaces={'ns': CANSAS_NS})
+        nodes = dom.xpath('ns:SASsample/ns:details', 
+                          namespaces={'ns': CANSAS_NS})
         for item in nodes:
             try:
@@ -233,5 +244,6 @@
                         data_info.sample.details.append(detail_value)
             except:
-                err_mess = "cansas_reader.read: error processing sample details\n  %s" % sys.exc_value
+                err_mess = "cansas_reader.read: error processing "
+                err_mess += " sample details\n  %s" % sys.exc_value
                 self.errors.append(err_mess)
                 logging.error(err_mess)
@@ -284,5 +296,6 @@
         
         # Collimation info ###################
-        nodes = dom.xpath('ns:SASinstrument/ns:SAScollimation', namespaces={'ns': CANSAS_NS})
+        nodes = dom.xpath('ns:SASinstrument/ns:SAScollimation', 
+                          namespaces={'ns': CANSAS_NS})
         for item in nodes:
             collim = Collimation()
@@ -315,5 +328,6 @@
         
         # Detector info ######################
-        nodes = dom.xpath('ns:SASinstrument/ns:SASdetector', namespaces={'ns': CANSAS_NS})
+        nodes = dom.xpath('ns:SASinstrument/ns:SASdetector',
+                           namespaces={'ns': CANSAS_NS})
         for item in nodes:
             
@@ -329,17 +343,26 @@
             
             # Detector orientation (as a vector)
-            self._store_float('ns:orientation/ns:roll',  item, 'orientation.x', detector)    
-            self._store_float('ns:orientation/ns:pitch', item, 'orientation.y', detector)    
-            self._store_float('ns:orientation/ns:yaw',   item, 'orientation.z', detector)    
+            self._store_float('ns:orientation/ns:roll',  item, 'orientation.x',
+                               detector)    
+            self._store_float('ns:orientation/ns:pitch', item, 'orientation.y',
+                               detector)    
+            self._store_float('ns:orientation/ns:yaw',   item, 'orientation.z',
+                               detector)    
             
             # Beam center (as a vector)
-            self._store_float('ns:beam_center/ns:x', item, 'beam_center.x', detector)    
-            self._store_float('ns:beam_center/ns:y', item, 'beam_center.y', detector)    
-            self._store_float('ns:beam_center/ns:z', item, 'beam_center.z', detector)    
+            self._store_float('ns:beam_center/ns:x', item, 'beam_center.x',
+                               detector)    
+            self._store_float('ns:beam_center/ns:y', item, 'beam_center.y', 
+                              detector)    
+            self._store_float('ns:beam_center/ns:z', item, 'beam_center.z',
+                               detector)    
             
             # Pixel size (as a vector)
-            self._store_float('ns:pixel_size/ns:x', item, 'pixel_size.x', detector)    
-            self._store_float('ns:pixel_size/ns:y', item, 'pixel_size.y', detector)    
-            self._store_float('ns:pixel_size/ns:z', item, 'pixel_size.z', detector)    
+            self._store_float('ns:pixel_size/ns:x', item, 'pixel_size.x',
+                               detector)    
+            self._store_float('ns:pixel_size/ns:y', item, 'pixel_size.y',
+                               detector)    
+            self._store_float('ns:pixel_size/ns:z', item, 'pixel_size.z',
+                               detector)    
             
             self._store_float('ns:slit_length', item, 'slit_length', detector)
@@ -365,9 +388,11 @@
                         process.term.append(term_attr)
                 except:
-                    err_mess = "cansas_reader.read: error processing process term\n  %s" % sys.exc_value
+                    err_mess = "cansas_reader.read: error processing "
+                    err_mess += " process term\n  %s" % sys.exc_value
                     self.errors.append(err_mess)
                     logging.error(err_mess)
             
-            note_list = item.xpath('ns:SASprocessnote', namespaces={'ns': CANSAS_NS})
+            note_list = item.xpath('ns:SASprocessnote', 
+                                   namespaces={'ns': CANSAS_NS})
             for note in note_list:
                 if note.text is not None:
@@ -379,6 +404,8 @@
         # Data info ######################
         nodes = dom.xpath('ns:SASdata', namespaces={'ns': CANSAS_NS})
-        if len(nodes)>1:
-            raise RuntimeError, "CanSAS reader is not compatible with multiple SASdata entries"
+        if len(nodes) > 1:
+            msg = "CanSAS reader is not compatible with multiple"
+            msg += " SASdata entries"
+            raise RuntimeError, msg
         
         nodes = dom.xpath('ns:SASdata/ns:Idata', namespaces={'ns': CANSAS_NS})
@@ -403,5 +430,6 @@
                 _dxw = 0.0
                 
-            if attr.has_key('unit') and attr['unit'].lower() != data_info.x_unit.lower():
+            if attr.has_key('unit') and \
+                attr['unit'].lower() != data_info.x_unit.lower():
                 if has_converter==True:
                     try:
@@ -409,11 +437,18 @@
                         _x = data_conv_q(_x, units=data_info.x_unit)
                     except:
-                        raise ValueError, "CanSAS reader: could not convert Q unit [%s]; expecting [%s]\n  %s" \
-                        % (attr['unit'], data_info.x_unit, sys.exc_value)
+                        msg =  "CanSAS reader: could not convert "
+                        msg += "Q unit [%s]; " 
+                        msg += "expecting [%s]\n  %s" % (attr['unit'], 
+                                  data_info.x_unit, sys.exc_value)
+                        raise ValueError, msg
+                        
                 else:
-                    raise ValueError, "CanSAS reader: unrecognized Q unit [%s]; expecting [%s]" \
-                        % (attr['unit'], data_info.x_unit)
+                    msg = "CanSAS reader: unrecognized Q unit [%s]; "
+                    msg += "expecting [%s]" % (attr['unit'], data_info.x_unit)
+                    raise ValueError, msg
+                        
             # Error in Q
-            if attr_d.has_key('unit') and attr_d['unit'].lower() != data_info.x_unit.lower():
+            if attr_d.has_key('unit') and \
+                attr_d['unit'].lower() != data_info.x_unit.lower():
                 if has_converter==True:
                     try:
@@ -421,39 +456,56 @@
                         _dx = data_conv_q(_dx, units=data_info.x_unit)
                     except:
-                        raise ValueError, "CanSAS reader: could not convert dQ unit [%s]; expecting [%s]\n  %s" \
-                        % (attr['unit'], data_info.x_unit, sys.exc_value)
+                        msg = "CanSAS reader: could not convert dQ unit [%s];"
+                        msg += " expecting " 
+                        msg += "[%s]\n  %s" % (attr['unit'],
+                                                data_info.x_unit, sys.exc_value)
+                        raise ValueError, msg
+                        
                 else:
-                    raise ValueError, "CanSAS reader: unrecognized dQ unit [%s]; expecting [%s]" \
-                        % (attr['unit'], data_info.x_unit)
+                    msg = "CanSAS reader: unrecognized dQ unit [%s]; "
+                    msg += "expecting [%s]" % (attr['unit'], data_info.x_unit)
+                    raise ValueError,  msg
+                        
             # Slit length
-            if attr_l.has_key('unit') and attr_l['unit'].lower() != data_info.x_unit.lower():
-                if has_converter==True:
+            if attr_l.has_key('unit') and \
+                attr_l['unit'].lower() != data_info.x_unit.lower():
+                if has_converter == True:
                     try:
                         data_conv_q = Converter(attr_l['unit'])
                         _dxl = data_conv_q(_dxl, units=data_info.x_unit)
                     except:
-                        raise ValueError, "CanSAS reader: could not convert dQl unit [%s]; expecting [%s]\n  %s" \
-                        % (attr['unit'], data_info.x_unit, sys.exc_value)
+                        msg = "CanSAS reader: could not convert dQl unit [%s];"
+                        msg += " expecting [%s]\n  %s" % (attr['unit'],
+                                             data_info.x_unit, sys.exc_value)
+                        raise ValueError, msg
+                        
                 else:
-                    raise ValueError, "CanSAS reader: unrecognized dQl unit [%s]; expecting [%s]" \
-                        % (attr['unit'], data_info.x_unit)
+                    msg = "CanSAS reader: unrecognized dQl unit [%s];"
+                    msg += " expecting [%s]" % (attr['unit'], data_info.x_unit)
+                    raise ValueError, msg
+                        
             # Slit width
-            if attr_w.has_key('unit') and attr_w['unit'].lower() != data_info.x_unit.lower():
-                if has_converter==True:
+            if attr_w.has_key('unit') and \
+            attr_w['unit'].lower() != data_info.x_unit.lower():
+                if has_converter == True:
                     try:
                         data_conv_q = Converter(attr_w['unit'])
                         _dxw = data_conv_q(_dxw, units=data_info.x_unit)
                     except:
-                        raise ValueError, "CanSAS reader: could not convert dQw unit [%s]; expecting [%s]\n  %s" \
-                        % (attr['unit'], data_info.x_unit, sys.exc_value)
+                        msg = "CanSAS reader: could not convert dQw unit [%s];"
+                        msg += " expecting [%s]\n  %s" % (attr['unit'], 
+                                                data_info.x_unit, sys.exc_value)
+                        raise ValueError, msg
+                        
                 else:
-                    raise ValueError, "CanSAS reader: unrecognized dQw unit [%s]; expecting [%s]" \
-                        % (attr['unit'], data_info.x_unit)
-                    
+                    msg = "CanSAS reader: unrecognized dQw unit [%s];"
+                    msg += " expecting [%s]" % (attr['unit'], data_info.x_unit)
+                    raise ValueError, msg   
             _y, attr = get_float('ns:I', item)
             _dy, attr_d = get_float('ns:Idev', item)
             if _dy == None:
                 _dy = 0.0
-            if attr.has_key('unit') and attr['unit'].lower() != data_info.y_unit.lower():
+            if attr.has_key('unit') and \
+            attr['unit'].lower() != data_info.y_unit.lower():
                 if has_converter==True:
                     try:
@@ -461,10 +513,15 @@
                         _y = data_conv_i(_y, units=data_info.y_unit)
                     except:
-                        raise ValueError, "CanSAS reader: could not convert I(q) unit [%s]; expecting [%s]\n  %s" \
-                        % (attr['unit'], data_info.y_unit, sys.exc_value)
+                        msg = "CanSAS reader: could not convert I(q) unit [%s];"
+                        msg += " expecting [%s]\n  %s" % (attr['unit'], 
+                                            data_info.y_unit, sys.exc_value)
+                        raise ValueError, msg
                 else:
-                    raise ValueError, "CanSAS reader: unrecognized I(q) unit [%s]; expecting [%s]" \
-                        % (attr['unit'], data_info.y_unit)
-            if attr_d.has_key('unit') and attr_d['unit'].lower() != data_info.y_unit.lower():
+                    msg = "CanSAS reader: unrecognized I(q) unit [%s];"
+                    msg += " expecting [%s]" % (attr['unit'], data_info.y_unit)
+                    raise ValueError, msg 
+                        
+            if attr_d.has_key('unit') and \
+            attr_d['unit'].lower() != data_info.y_unit.lower():
                 if has_converter==True:
                     try:
@@ -472,9 +529,12 @@
                         _dy = data_conv_i(_dy, units=data_info.y_unit)
                     except:
-                        raise ValueError, "CanSAS reader: could not convert dI(q) unit [%s]; expecting [%s]\n  %s" \
-                        % (attr_d['unit'], data_info.y_unit, sys.exc_value)
+                        msg = "CanSAS reader: could not convert dI(q) unit "
+                        msg += "[%s]; expecting [%s]\n  %s"  % (attr_d['unit'],
+                                             data_info.y_unit, sys.exc_value)
+                        raise ValueError, msg
                 else:
-                    raise ValueError, "CanSAS reader: unrecognized dI(q) unit [%s]; expecting [%s]" \
-                        % (attr_d['unit'], data_info.y_unit)
+                    msg = "CanSAS reader: unrecognized dI(q) unit [%s]; "
+                    msg += "expecting [%s]" % (attr_d['unit'], data_info.y_unit)
+                    raise ValueError, msg
                 
             if _x is not None and _y is not None:
@@ -486,5 +546,4 @@
                 dxw = numpy.append(dxw, _dxw)
                 
-            
         data_info.x = x
         data_info.y = y
@@ -532,6 +591,8 @@
         main_node.setAttribute("version", self.version)
         main_node.setAttribute("xmlns", "cansas1d/%s" % self.version)
-        main_node.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance")
-        main_node.setAttribute("xsi:schemaLocation", "cansas1d/%s http://svn.smallangles.net/svn/canSAS/1dwg/trunk/cansas1d.xsd" % self.version)
+        main_node.setAttribute("xmlns:xsi",
+                               "http://www.w3.org/2001/XMLSchema-instance")
+        main_node.setAttribute("xsi:schemaLocation",
+                               "cansas1d/%s http://svn.smallangles.net/svn/canSAS/1dwg/trunk/cansas1d.xsd" % self.version)
         
         doc.appendChild(main_node)
@@ -543,5 +604,6 @@
         for item in datainfo.run:
             runname = {}
-            if datainfo.run_name.has_key(item) and len(str(datainfo.run_name[item]))>1:
+            if datainfo.run_name.has_key(item) and \
+            len(str(datainfo.run_name[item]))>1:
                 runname = {'name': datainfo.run_name[item] }
             write_node(doc, entry_node, "Run", item, runname)
@@ -556,9 +618,12 @@
             write_node(doc, pt, "Q", datainfo.x[i], {'unit':datainfo.x_unit})
             if len(datainfo.y)>=i:
-                write_node(doc, pt, "I", datainfo.y[i], {'unit':datainfo.y_unit})
+                write_node(doc, pt, "I", datainfo.y[i],
+                            {'unit':datainfo.y_unit})
             if datainfo.dx !=None and len(datainfo.dx)>=i:
-                write_node(doc, pt, "Qdev", datainfo.dx[i], {'unit':datainfo.x_unit})
+                write_node(doc, pt, "Qdev", datainfo.dx[i],
+                            {'unit':datainfo.x_unit})
             if datainfo.dy !=None and len(datainfo.dy)>=i:
-                write_node(doc, pt, "Idev", datainfo.dy[i], {'unit':datainfo.y_unit})
+                write_node(doc, pt, "Idev", datainfo.dy[i],
+                            {'unit':datainfo.y_unit})
 
         
@@ -569,7 +634,9 @@
         entry_node.appendChild(sample)
         write_node(doc, sample, "ID", str(datainfo.sample.ID))
-        write_node(doc, sample, "thickness", datainfo.sample.thickness, {"unit":datainfo.sample.thickness_unit})
+        write_node(doc, sample, "thickness", datainfo.sample.thickness,
+                   {"unit":datainfo.sample.thickness_unit})
         write_node(doc, sample, "transmission", datainfo.sample.transmission)
-        write_node(doc, sample, "temperature", datainfo.sample.temperature, {"unit":datainfo.sample.temperature_unit})
+        write_node(doc, sample, "temperature", datainfo.sample.temperature,
+                   {"unit":datainfo.sample.temperature_unit})
         
         for item in datainfo.sample.details:
@@ -577,14 +644,25 @@
         
         pos = doc.createElement("position")
-        written = write_node(doc, pos, "x", datainfo.sample.position.x, {"unit":datainfo.sample.position_unit})
-        written = written | write_node(doc, pos, "y", datainfo.sample.position.y, {"unit":datainfo.sample.position_unit})
-        written = written | write_node(doc, pos, "z", datainfo.sample.position.z, {"unit":datainfo.sample.position_unit})
+        written = write_node(doc, pos, "x", datainfo.sample.position.x,
+                             {"unit":datainfo.sample.position_unit})
+        written = written | write_node(doc, pos, "y",
+                                       datainfo.sample.position.y,
+                                       {"unit":datainfo.sample.position_unit})
+        written = written | write_node(doc, pos, "z",
+                                       datainfo.sample.position.z,
+                                       {"unit":datainfo.sample.position_unit})
         if written == True:
             sample.appendChild(pos)
         
         ori = doc.createElement("orientation")
-        written = write_node(doc, ori, "roll",  datainfo.sample.orientation.x, {"unit":datainfo.sample.orientation_unit})
-        written = written | write_node(doc, ori, "pitch", datainfo.sample.orientation.y, {"unit":datainfo.sample.orientation_unit})
-        written = written | write_node(doc, ori, "yaw",   datainfo.sample.orientation.z, {"unit":datainfo.sample.orientation_unit})
+        written = write_node(doc, ori, "roll",
+                             datainfo.sample.orientation.x,
+                             {"unit":datainfo.sample.orientation_unit})
+        written = written | write_node(doc, ori, "pitch",
+                                       datainfo.sample.orientation.y,
+                                    {"unit":datainfo.sample.orientation_unit})
+        written = written | write_node(doc, ori, "yaw",
+                                       datainfo.sample.orientation.z,
+                                    {"unit":datainfo.sample.orientation_unit})
         if written == True:
             sample.appendChild(ori)
@@ -607,14 +685,27 @@
         if datainfo.source.beam_size_name is not None:
             size.setAttribute("name", str(datainfo.source.beam_size_name))
-        written = write_node(doc, size, "x", datainfo.source.beam_size.x, {"unit":datainfo.source.beam_size_unit})
-        written = written | write_node(doc, size, "y", datainfo.source.beam_size.y, {"unit":datainfo.source.beam_size_unit})
-        written = written | write_node(doc, size, "z", datainfo.source.beam_size.z, {"unit":datainfo.source.beam_size_unit})
+        written = write_node(doc, size, "x", datainfo.source.beam_size.x,
+                             {"unit":datainfo.source.beam_size_unit})
+        written = written | write_node(doc, size, "y",
+                                       datainfo.source.beam_size.y,
+                                       {"unit":datainfo.source.beam_size_unit})
+        written = written | write_node(doc, size, "z",
+                                       datainfo.source.beam_size.z,
+                                       {"unit":datainfo.source.beam_size_unit})
         if written == True:
             source.appendChild(size)
             
-        write_node(doc, source, "wavelength", datainfo.source.wavelength, {"unit":datainfo.source.wavelength_unit})
-        write_node(doc, source, "wavelength_min", datainfo.source.wavelength_min, {"unit":datainfo.source.wavelength_min_unit})
-        write_node(doc, source, "wavelength_max", datainfo.source.wavelength_max, {"unit":datainfo.source.wavelength_max_unit})
-        write_node(doc, source, "wavelength_spread", datainfo.source.wavelength_spread, {"unit":datainfo.source.wavelength_spread_unit})
+        write_node(doc, source, "wavelength",
+                   datainfo.source.wavelength,
+                   {"unit":datainfo.source.wavelength_unit})
+        write_node(doc, source, "wavelength_min",
+                   datainfo.source.wavelength_min,
+                   {"unit":datainfo.source.wavelength_min_unit})
+        write_node(doc, source, "wavelength_max",
+                   datainfo.source.wavelength_max,
+                   {"unit":datainfo.source.wavelength_max_unit})
+        write_node(doc, source, "wavelength_spread",
+                   datainfo.source.wavelength_spread,
+                   {"unit":datainfo.source.wavelength_spread_unit})
         
         #   Collimation
@@ -625,5 +716,6 @@
             instr.appendChild(coll)
             
-            write_node(doc, coll, "length", item.length, {"unit":item.length_unit})
+            write_node(doc, coll, "length", item.length,
+                       {"unit":item.length_unit})
             
             for apert in item.aperture:
@@ -635,12 +727,16 @@
                 coll.appendChild(ap)
                 
-                write_node(doc, ap, "distance", apert.distance, {"unit":apert.distance_unit})
+                write_node(doc, ap, "distance", apert.distance,
+                           {"unit":apert.distance_unit})
                 
                 size = doc.createElement("size")
                 if apert.size_name is not None:
                     size.setAttribute("name", str(apert.size_name))
-                written = write_node(doc, size, "x", apert.size.x, {"unit":apert.size_unit})
-                written = written | write_node(doc, size, "y", apert.size.y, {"unit":apert.size_unit})
-                written = written | write_node(doc, size, "z", apert.size.z, {"unit":apert.size_unit})
+                written = write_node(doc, size, "x", apert.size.x,
+                                     {"unit":apert.size_unit})
+                written = written | write_node(doc, size, "y", apert.size.y,
+                                               {"unit":apert.size_unit})
+                written = written | write_node(doc, size, "z", apert.size.z,
+                                               {"unit":apert.size_unit})
                 if written == True:
                     ap.appendChild(size)
@@ -650,34 +746,53 @@
             det = doc.createElement("SASdetector")
             written = write_node(doc, det, "name", item.name)
-            written = written | write_node(doc, det, "SDD", item.distance, {"unit":item.distance_unit})
-            written = written | write_node(doc, det, "slit_length", item.slit_length, {"unit":item.slit_length_unit})
+            written = written | write_node(doc, det, "SDD", item.distance,
+                                           {"unit":item.distance_unit})
+            written = written | write_node(doc, det, "slit_length",
+                                           item.slit_length,
+                                           {"unit":item.slit_length_unit})
             if written == True:
                 instr.appendChild(det)
             
             off = doc.createElement("offset")
-            written = write_node(doc, off, "x", item.offset.x, {"unit":item.offset_unit})
-            written = written | write_node(doc, off, "y", item.offset.y, {"unit":item.offset_unit})
-            written = written | write_node(doc, off, "z", item.offset.z, {"unit":item.offset_unit})
+            written = write_node(doc, off, "x", item.offset.x,
+                                 {"unit":item.offset_unit})
+            written = written | write_node(doc, off, "y", item.offset.y,
+                                           {"unit":item.offset_unit})
+            written = written | write_node(doc, off, "z", item.offset.z,
+                                           {"unit":item.offset_unit})
             if written == True:
                 det.appendChild(off)
             
             center = doc.createElement("beam_center")
-            written = write_node(doc, center, "x", item.beam_center.x, {"unit":item.beam_center_unit})
-            written = written | write_node(doc, center, "y", item.beam_center.y, {"unit":item.beam_center_unit})
-            written = written | write_node(doc, center, "z", item.beam_center.z, {"unit":item.beam_center_unit})
+            written = write_node(doc, center, "x", item.beam_center.x,
+                                 {"unit":item.beam_center_unit})
+            written = written | write_node(doc, center, "y",
+                                           item.beam_center.y,
+                                           {"unit":item.beam_center_unit})
+            written = written | write_node(doc, center, "z",
+                                           item.beam_center.z,
+                                           {"unit":item.beam_center_unit})
             if written == True:
                 det.appendChild(center)
                 
             pix = doc.createElement("pixel_size")
-            written = write_node(doc, pix, "x", item.pixel_size.x, {"unit":item.pixel_size_unit})
-            written = written | write_node(doc, pix, "y", item.pixel_size.y, {"unit":item.pixel_size_unit})
-            written = written | write_node(doc, pix, "z", item.pixel_size.z, {"unit":item.pixel_size_unit})
+            written = write_node(doc, pix, "x", item.pixel_size.x,
+                                 {"unit":item.pixel_size_unit})
+            written = written | write_node(doc, pix, "y", item.pixel_size.y,
+                                           {"unit":item.pixel_size_unit})
+            written = written | write_node(doc, pix, "z", item.pixel_size.z,
+                                           {"unit":item.pixel_size_unit})
             if written == True:
                 det.appendChild(pix)
                 
             ori = doc.createElement("orientation")
-            written = write_node(doc, ori, "roll",  item.orientation.x, {"unit":item.orientation_unit})
-            written = written | write_node(doc, ori, "pitch", item.orientation.y, {"unit":item.orientation_unit})
-            written = written | write_node(doc, ori, "yaw",   item.orientation.z, {"unit":item.orientation_unit})
+            written = write_node(doc, ori, "roll",  item.orientation.x,
+                                 {"unit":item.orientation_unit})
+            written = written | write_node(doc, ori, "pitch",
+                                           item.orientation.y,
+                                           {"unit":item.orientation_unit})
+            written = written | write_node(doc, ori, "yaw",
+                                           item.orientation.z,
+                                           {"unit":item.orientation_unit})
             if written == True:
                 det.appendChild(ori)
@@ -731,5 +846,6 @@
         :param variable: name of the data member to store it in [string]
         :param storage: data object that has the 'variable' data member
-        :param optional: if True, no exception will be raised if unit conversion can't be done
+        :param optional: if True, no exception will be raised 
+            if unit conversion can't be done
 
         :raise ValueError: raised when the units are not recognized
@@ -752,7 +868,9 @@
                         try:
                             conv = Converter(units)
-                            exec "storage.%s = %g" % (variable, conv(value, units=local_unit))
+                            exec "storage.%s = %g" % (variable,
+                                            conv(value, units=local_unit))
                         except:
-                            err_mess = "CanSAS reader: could not convert %s unit [%s]; expecting [%s]\n  %s" \
+                            err_mess = "CanSAS reader: could not convert"
+                            err_mess += " %s unit [%s]; expecting [%s]\n  %s" \
                                 % (variable, units, local_unit, sys.exc_value)
                             self.errors.append(err_mess)
@@ -762,6 +880,7 @@
                                 raise ValueError, err_mess 
                     else:
-                        err_mess = "CanSAS reader: unrecognized %s unit [%s]; expecting [%s]" \
-                            % (variable, units, local_unit)
+                        err_mess = "CanSAS reader: unrecognized %s unit [%s];"
+                        err_mess += " expecting [%s]" % (variable, 
+                                                         units, local_unit)
                         self.errors.append(err_mess)
                         if optional:
Index: DataLoader/readers/danse_reader.py
===================================================================
--- DataLoader/readers/danse_reader.py	(revision 0997158f0d11874fd896ee66b3bb468898c9bb2b)
+++ DataLoader/readers/danse_reader.py	(revision a7a5886e7fa30dd75a5a77d68a58574c9246f27f)
@@ -18,5 +18,5 @@
 import math
 import os
-import copy
+#import copy
 import numpy
 import logging
@@ -50,14 +50,13 @@
         read_it = False
         for item in self.ext:
-            if filename.lower().find(item)>=0:
+            if filename.lower().find(item) >= 0:
                 read_it = True
                 
         if read_it:
             try:
-                 datafile = open(filename, 'r')
+                datafile = open(filename, 'r')
             except :
-                raise  RuntimeError,"danse_reader cannot open %s"%(filename)
-            
-            
+                raise  RuntimeError,"danse_reader cannot open %s" % (filename)
+        
             # defaults
             # wavelength in Angstrom
@@ -84,5 +83,5 @@
             
             output.data = numpy.zeros([size_x,size_y])
-            output.err_data = numpy.zeros([size_x,size_y])
+            output.err_data = numpy.zeros([size_x, size_y])
             
             data_conv_q = None
@@ -102,23 +101,23 @@
             while read_on:
                 line = datafile.readline()
-                if line.find("DATA:")>=0:
+                if line.find("DATA:") >= 0:
                     read_on = False
                     break
                 toks = line.split(':')
-                if toks[0]=="FORMATVERSION":
+                if toks[0] == "FORMATVERSION":
                     fversion = float(toks[1])
-                if toks[0]=="WAVELENGTH":    
+                if toks[0] == "WAVELENGTH":    
                     wavelength = float(toks[1])                
-                elif toks[0]=="DISTANCE":
+                elif toks[0] == "DISTANCE":
                     distance = float(toks[1])
-                elif toks[0]=="CENTER_X":
+                elif toks[0] == "CENTER_X":
                     center_x = float(toks[1])
-                elif toks[0]=="CENTER_Y":
+                elif toks[0] == "CENTER_Y":
                     center_y = float(toks[1])
-                elif toks[0]=="PIXELSIZE":
+                elif toks[0] == "PIXELSIZE":
                     pixel = float(toks[1])
-                elif toks[0]=="SIZE_X":
+                elif toks[0] == "SIZE_X":
                     size_x = int(toks[1])
-                elif toks[0]=="SIZE_Y":
+                elif toks[0] == "SIZE_Y":
                     size_y = int(toks[1])
             
@@ -126,5 +125,5 @@
             data = []
             error = []
-            if fversion==1.0:
+            if fversion == 1.0:
                 data_str = datafile.readline()
                 data = data_str.split(' ')
@@ -133,5 +132,5 @@
                 while read_on:
                     data_str = datafile.readline()
-                    if len(data_str)==0:
+                    if len(data_str) == 0:
                         read_on = False
                     else:
@@ -146,5 +145,6 @@
                             error.append(err)
                         except:
-                            logging.info("Skipping line:%s,%s" %( data_str,sys.exc_value))
+                            logging.info("Skipping line:%s,%s" %( data_str,
+                                                                sys.exc_value))
             
             # Initialize 
@@ -158,8 +158,8 @@
             # Qx and Qy vectors
             theta = pixel / distance / 100.0
-            stepq = 4.0*math.pi/wavelength * math.sin(theta/2.0) 
+            stepq = 4.0 * math.pi/wavelength * math.sin(theta/2.0) 
             for i_x in range(size_x):
-                theta = (i_x-center_x+1)*pixel / distance / 100.0
-                qx = 4.0*math.pi/wavelength * math.sin(theta/2.0)
+                theta = (i_x - center_x + 1) * pixel / distance / 100.0
+                qx = 4.0 * math.pi / wavelength * math.sin(theta/2.0)
                 
                 if has_converter == True and output.Q_unit != '1/A':
@@ -167,7 +167,7 @@
                 
                 x_vals.append(qx)
-                if xmin==None or qx<xmin:
+                if xmin == None or qx < xmin:
                     xmin = qx
-                if xmax==None or qx>xmax:
+                if xmax == None or qx > xmax:
                     xmax = qx
             
@@ -175,6 +175,6 @@
             ymax = None
             for i_y in range(size_y):
-                theta = (i_y-center_y+1)*pixel / distance / 100.0
-                qy = 4.0*math.pi/wavelength * math.sin(theta/2.0)
+                theta = (i_y - center_y + 1) * pixel / distance / 100.0
+                qy = 4.0 * math.pi/wavelength * math.sin(theta/2.0)
                 
                 if has_converter == True and output.Q_unit != '1/A':
@@ -182,7 +182,7 @@
                 
                 y_vals.append(qy)
-                if ymin==None or qy<ymin:
+                if ymin == None or qy < ymin:
                     ymin = qy
-                if ymax==None or qy>ymax:
+                if ymax == None or qy > ymax:
                     ymax = qy
             
@@ -198,8 +198,10 @@
                     # For version 1.0, the data were still
                     # stored as strings at this point.
-                    logging.info("Skipping entry (v1.0):%s,%s" %(str(data[i_pt]), sys.exc_value))
+                    msg = "Skipping entry (v1.0):%s,%s" %(str(data[i_pt]),
+                                                           sys.exc_value)
+                    logging.info(msg)
                 
                 # Get bin number
-                if math.fmod(i_pt, size_x)==0:
+                if math.fmod(i_pt, size_x) == 0:
                     i_x = 0
                     i_y += 1
@@ -213,14 +215,15 @@
                     #output.err_data[size_y-1-i_y][i_x] = error[i_pt]
                 
-                
+
             # Store all data 
             # Store wavelength
-            if has_converter==True and output.source.wavelength_unit != 'A':
+            if has_converter == True and output.source.wavelength_unit != 'A':
                 conv = Converter('A')
-                wavelength = conv(wavelength, units=output.source.wavelength_unit)
+                wavelength = conv(wavelength,
+                                  units=output.source.wavelength_unit)
             output.source.wavelength = wavelength
                 
             # Store distance
-            if has_converter==True and detector.distance_unit != 'm':
+            if has_converter == True and detector.distance_unit != 'm':
                 conv = Converter('m')
                 distance = conv(distance, units=detector.distance_unit)
@@ -228,5 +231,5 @@
             
             # Store pixel size
-            if has_converter==True and detector.pixel_size_unit != 'mm':
+            if has_converter == True and detector.pixel_size_unit != 'mm':
                 conv = Converter('mm')
                 pixel = conv(pixel, units=detector.pixel_size_unit)
@@ -239,8 +242,8 @@
             
             # Store limits of the image (2D array)
-            xmin    =xmin-stepq/2.0
-            xmax    =xmax+stepq/2.0
-            ymin    =ymin-stepq/2.0
-            ymax    =ymax+stepq/2.0
+            xmin = xmin - stepq / 2.0
+            xmax = xmax + stepq / 2.0
+            ymin = ymin - stepq  /2.0
+            ymax = ymax + stepq / 2.0
             
             if has_converter == True and output.Q_unit != '1/A':
@@ -271,8 +274,9 @@
                 output.zaxis("\\rm{Intensity}","cm^{-1}")
            
-            if not fversion>=1.0:
-                raise ValueError,"Danse_reader can't read this file %s"%filename
-            else:
-                logging.info("Danse_reader Reading %s \n"%filename)
+            if not fversion >= 1.0:
+                msg = "Danse_reader can't read this file %s" % filename
+                raise ValueError, msg
+            else:
+                logging.info("Danse_reader Reading %s \n" % filename)
             
             # Store loading process information
Index: DataLoader/readers/hfir1d_reader.py
===================================================================
--- DataLoader/readers/hfir1d_reader.py	(revision 0997158f0d11874fd896ee66b3bb468898c9bb2b)
+++ DataLoader/readers/hfir1d_reader.py	(revision a7a5886e7fa30dd75a5a77d68a58574c9246f27f)
@@ -28,5 +28,5 @@
     type = ["HFIR 1D files (*.d1d)|*.d1d"]
     ## List of allowed extensions
-    ext=['.d1d']  
+    ext = ['.d1d']  
     
     def read(self, path):
@@ -87,5 +87,4 @@
                             _dy = data_conv_i(_dy, units=output.y_unit)                        
                                                     
-
                         x   = numpy.append(x, _x) 
                         y   = numpy.append(y, _y)
@@ -99,11 +98,13 @@
                 # Sanity check
                 if not len(y) == len(dy):
-                    raise RuntimeError, "hfir1d_reader: y and dy have different length"
+                    msg = "hfir1d_reader: y and dy have different length"
+                    raise RuntimeError, msg
                 if not len(x) == len(dx):
-                    raise RuntimeError, "hfir1d_reader: x and dx have different length"
+                    msg = "hfir1d_reader: x and dx have different length"
+                    raise RuntimeError, msg
 
                 # If the data length is zero, consider this as
                 # though we were not able to read the file.
-                if len(x)==0:
+                if len(x) == 0:
                     raise RuntimeError, "hfir1d_reader: could not load file"
                
Index: DataLoader/readers/red2d_reader.py
===================================================================
--- DataLoader/readers/red2d_reader.py	(revision d2539aa3818bfa10dd3c581e64ec1a07be708f63)
+++ DataLoader/readers/red2d_reader.py	(revision a7a5886e7fa30dd75a5a77d68a58574c9246f27f)
@@ -13,7 +13,9 @@
 
 
-import os, sys
+import os
+#import sys
 import numpy
-import math, logging
+import math
+#import logging
 from DataLoader.data_info import Data2D, Detector
 
@@ -121,7 +123,9 @@
                     wavelength = float(line_toks[1])
                     # Units
-                    if has_converter==True and output.source.wavelength_unit != 'A':
+                    if has_converter == True and \
+                    output.source.wavelength_unit != 'A':
                         conv = Converter('A')
-                        wavelength = conv(wavelength, units=output.source.wavelength_unit)
+                        wavelength = conv(wavelength,
+                                          units=output.source.wavelength_unit)
                 except:
                     #Not required
@@ -131,5 +135,5 @@
                     distance = float(line_toks[3])
                     # Units
-                    if has_converter==True and detector.distance_unit != 'm':
+                    if has_converter == True and detector.distance_unit != 'm':
                         conv = Converter('m')
                         distance = conv(distance, units=detector.distance_unit)
@@ -145,5 +149,5 @@
                     pass
                                             
-            if line.count("LAMBDA")>0:
+            if line.count("LAMBDA") > 0:
                 isInfo = True
                 
@@ -156,9 +160,9 @@
                 center_y = float(line_toks[1])
 
-            if line.count("BCENT")>0:
+            if line.count("BCENT") > 0:
                 isCenter = True
                        
             # Find data start
-            if line.count("Data columns") or line.count("ASCII data")>0:
+            if line.count("Data columns") or line.count("ASCII data") > 0:
                 dataStarted = True
                 continue
@@ -173,6 +177,4 @@
                 col_num = len(line_toks)
                 break
-
-        
         # Make numpy array to remove header lines using index
         lines_array = numpy.array(lines)
@@ -182,5 +184,5 @@
         
         # get the data lines
-        data_lines = lines_array[lines_index>=(line_num-1)]
+        data_lines = lines_array[lines_index >= (line_num - 1)]
         # Now we get the total number of rows (i.e., # of data points)
         row_num = len(data_lines)
@@ -190,6 +192,8 @@
         data_list = data_list.split()
  
-        # Check if the size is consistent with data, otherwise try the tab(\t) separator
-        # (this may be removed once get the confidence the former working all cases).
+        # Check if the size is consistent with data, otherwise 
+        #try the tab(\t) separator
+        # (this may be removed once get the confidence 
+        #the former working all cases).
         if len(data_list) != (len(data_lines)) * col_num:
             data_list = "\t".join(data_lines.tolist())
@@ -202,9 +206,11 @@
         # numpy array form
         data_array = numpy.array(data_list1)
-        # Redimesion based on the row_num and col_num, otherwise raise an error.
+        # Redimesion based on the row_num and col_num, 
+        #otherwise raise an error.
         try:
-            data_point = data_array.reshape(row_num,col_num).transpose()
+            data_point = data_array.reshape(row_num, col_num).transpose()
         except:
-            raise ValueError, "red2d_reader: Can't read this file: Not a proper file format"
+            msg = "red2d_reader: Can't read this file: Not a proper file format"
+            raise ValueError, msg
         
         ## Get the all data: Let's HARDcoding; Todo find better way
@@ -218,8 +224,8 @@
         qy_data = data_point[1]
         data = data_point[2]
-        if col_num >3: qz_data = data_point[3]
-        if col_num >4: dqx_data = data_point[4]
-        if col_num >5: dqy_data = data_point[5]
-        if col_num >6: mask[data_point[6]<1] = False
+        if col_num > 3: qz_data = data_point[3]
+        if col_num > 4: dqx_data = data_point[4]
+        if col_num > 5: dqy_data = data_point[5]
+        if col_num > 6: mask[data_point[6] < 1] = False
         q_data = numpy.sqrt(qx_data*qx_data+qy_data*qy_data+qz_data*qz_data)
            
@@ -291,5 +297,6 @@
         # optional data: if all of dq data == 0, do not pass to output
         if len(dqx_data) == len(qx_data) and dqx_data.any()!=0: 
-            # if no dqx_data, do not pass dqy_data.(1 axis dq is not supported yet).
+            # if no dqx_data, do not pass dqy_data.
+            #(1 axis dq is not supported yet).
             if len(dqy_data) == len(qy_data) and dqy_data.any()!=0:
                 output.dqx_data = dqx_data
Index: DataLoader/readers/tiff_reader.py
===================================================================
--- DataLoader/readers/tiff_reader.py	(revision 0997158f0d11874fd896ee66b3bb468898c9bb2b)
+++ DataLoader/readers/tiff_reader.py	(revision a7a5886e7fa30dd75a5a77d68a58574c9246f27f)
@@ -41,5 +41,6 @@
             import Image
         except:
-            raise RuntimeError, "tiff_reader: could not load file. Missing Image module."
+            msg = "tiff_reader: could not load file. Missing Image module."
+            raise RuntimeError, msg
         
         # Instantiate data object
