Index: sansdataloader/src/sans/dataloader/readers/IgorReader.py
===================================================================
--- sansdataloader/src/sans/dataloader/readers/IgorReader.py	(revision ad8034f2bbcd87293b219fc00bc095a3f8df9fb6)
+++ sansdataloader/src/sans/dataloader/readers/IgorReader.py	(revision 7d6351ed3bb9d1bb801111e3d9813fff5b5cf091)
@@ -1,3 +1,5 @@
-
+"""
+    IGOR 2D reduced file reader
+"""
 ############################################################################
 #This software was developed by the University of Tennessee as part of the
@@ -10,11 +12,5 @@
 #copyright 2008, University of Tennessee
 #############################################################################
-
-"""
-    IGOR 2D reduced file reader
-"""
-
 import os
-#import sys
 import numpy
 import math
@@ -31,8 +27,9 @@
     has_converter = False
 
+
 class Reader:
     """ Simple data reader for Igor data files """
     ## File type
-    type_name = "IGOR 2D"   
+    type_name = "IGOR 2D"
     ## Wildcards
     type = ["IGOR 2D files (*.ASC)|*.ASC"]
@@ -40,5 +37,5 @@
     ext=['.ASC', '.asc']
 
-    def read(self,filename=None):
+    def read(self, filename=None):
         """ Read file """
         if not os.path.isfile(filename):
@@ -47,5 +44,5 @@
         
         # Read file
-        f = open(filename,'r')
+        f = open(filename, 'r')
         buf = f.read()
         
@@ -54,10 +51,10 @@
         output.filename = os.path.basename(filename)
         detector = Detector()
-        if len(output.detector)>0: print str(output.detector[0])
+        if len(output.detector) > 0:
+            print str(output.detector[0])
         output.detector.append(detector)
                 
         # Get content
         dataStarted = False
-        
         
         lines = buf.split('\n')
@@ -91,5 +88,5 @@
             data_conv_i = Converter('1/cm')
             # Test it
-            data_conv_i(1.0, output.I_unit)            
+            data_conv_i(1.0, output.I_unit)
          
         for line in lines:
@@ -117,10 +114,10 @@
                 
             i_tot_row += 1
-        i_tot_row=math.ceil(math.sqrt(i_tot_row))-1 
+        i_tot_row = math.ceil(math.sqrt(i_tot_row)) - 1
         #print "i_tot", i_tot_row
-        size_x = i_tot_row#192#128
-        size_y = i_tot_row#192#128
-        output.data = numpy.zeros([size_x,size_y])
-        output.err_data = numpy.zeros([size_x,size_y])
+        size_x = i_tot_row  # 192#128
+        size_y = i_tot_row  # 192#128
+        output.data = numpy.zeros([size_x, size_y])
+        output.err_data = numpy.zeros([size_x, size_y])
      
         #Read Header and 2D data
@@ -151,21 +148,20 @@
                     raise ValueError, msg
                                             
-            if line.count("LAMBDA")>0:
+            if line.count("LAMBDA") > 0:
                 isInfo = True
                 
             # Find center info line
             if isCenter:
-                isCenter = False                
+                isCenter = False
                 line_toks = line.split()
                 
-                # Center in bin number: Must substrate 1 because 
+                # 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
-
-            if line.count("BCENT")>0:
+                center_x = float(line_toks[0]) - 1
+                center_y = float(line_toks[1]) - 1
+
+            if line.count("BCENT") > 0:
                 isCenter = True
                 
-        
             # Find data start
             if line.count("***")>0:
@@ -188,5 +184,5 @@
                 
                 # Get bin number
-                if math.fmod(itot, i_tot_row)==0:
+                if math.fmod(itot, i_tot_row) == 0:
                     i_x = 0
                     i_y += 1
@@ -195,10 +191,10 @@
                     
                 output.data[i_y][i_x] = value
-                ncounts += 1 
+                ncounts += 1
                 
                 # Det 640 x 640 mm
                 # Q = 4pi/lambda sin(theta/2)
                 # Bin size is 0.5 cm 
-                #REmoved +1 from theta = (i_x-center_x+1)*0.5 / distance 
+                #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 /
@@ -206,24 +202,24 @@
                 #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)
+                theta = (i_x - center_x) * 0.5 / distance / 100.0
+                qx = 4.0 * math.pi / wavelength * math.sin(theta/2.0)
 
                 if has_converter == True and output.Q_unit != '1/A':
                     qx = data_conv_q(qx, units=output.Q_unit)
 
-                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
                 
-                theta = (i_y-center_y)*0.5 / distance / 100.0
-                qy = 4.0*math.pi/wavelength * math.sin(theta/2.0)
+                theta = (i_y - center_y) * 0.5 / distance / 100.0
+                qy = 4.0 * math.pi / wavelength * math.sin(theta / 2.0)
 
                 if has_converter == True and output.Q_unit != '1/A':
                     qy = data_conv_q(qy, units=output.Q_unit)
                 
-                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
                 
@@ -237,12 +233,12 @@
                   
         theta = 0.25 / distance / 100.0
-        xstep = 4.0*math.pi/wavelength * math.sin(theta/2.0)
+        xstep = 4.0 * math.pi / wavelength * math.sin(theta / 2.0)
         
         theta = 0.25 / distance / 100.0
-        ystep = 4.0*math.pi/wavelength * math.sin(theta/2.0)
+        ystep = 4.0 * math.pi/ wavelength * math.sin(theta / 2.0)
         
         # 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)
@@ -250,5 +246,5 @@
 
         # 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)
@@ -260,5 +256,5 @@
         # Store pixel size
         pixel = 5.0
-        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)
@@ -267,13 +263,12 @@
   
         # Store beam center in distance units
-        detector.beam_center.x = center_x*pixel
-        detector.beam_center.y = center_y*pixel
-  
+        detector.beam_center.x = center_x * pixel
+        detector.beam_center.y = center_y * pixel
         
         # Store limits of the image (2D array)
-        xmin    =xmin-xstep/2.0
-        xmax    =xmax+xstep/2.0
-        ymin    =ymin-ystep/2.0
-        ymax    =ymax+ystep/2.0
+        xmin = xmin - xstep / 2.0
+        xmax = xmax + xstep / 2.0
+        ymin = ymin - ystep / 2.0
+        ymax = ymax + ystep / 2.0
         if has_converter == True and output.Q_unit != '1/A':
             xmin = data_conv_q(xmin, units=output.Q_unit)
@@ -287,6 +282,6 @@
         
         # Store x and y axis bin centers
-        output.x_bins     = x
-        output.y_bins     = y
+        output.x_bins = x
+        output.y_bins = y
         
         # Units
@@ -301,5 +296,5 @@
             output.zaxis("\\rm{Intensity}", output.I_unit)
         else:
-            output.zaxis("\\rm{Intensity}","cm^{-1}")
+            output.zaxis("\\rm{Intensity}", "cm^{-1}")
     
         # Store loading process information
@@ -308,7 +303,2 @@
 
         return output
-    
-if __name__ == "__main__": 
-    reader = Reader()
-    print reader.read("../test/MAR07232_rest.ASC") 
-    
Index: sansdataloader/src/sans/dataloader/readers/abs_reader.py
===================================================================
--- sansdataloader/src/sans/dataloader/readers/abs_reader.py	(revision aac129aac2f0d1c7ec50e8be93a0690708a6549d)
+++ sansdataloader/src/sans/dataloader/readers/abs_reader.py	(revision 7d6351ed3bb9d1bb801111e3d9813fff5b5cf091)
@@ -4,5 +4,5 @@
 #This software was developed by the University of Tennessee as part of the
 #Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-#project funded by the US National Science Foundation. 
+#project funded by the US National Science Foundation.
 #See the license text in license.txt
 #copyright 2008, University of Tennessee
@@ -20,4 +20,5 @@
     has_converter = False
     
+    
 class Reader:
     """
@@ -25,9 +26,9 @@
     """
     ## File type
-    type_name = "IGOR 1D"   
+    type_name = "IGOR 1D"
     ## Wildcards
     type = ["IGOR 1D files (*.abs)|*.abs"]
     ## List of allowed extensions
-    ext = ['.abs', '.ABS']  
+    ext = ['.abs', '.ABS']
     
     def read(self, path):
@@ -43,10 +44,10 @@
         """
         if os.path.isfile(path):
-            basename  = os.path.basename(path)
+            basename = os.path.basename(path)
             root, extension = os.path.splitext(basename)
             if extension.lower() in self.ext:
                 try:
-                    input_f =  open(path,'r')
-                except :
+                    input_f = open(path,'r')
+                except:
                     raise  RuntimeError, "abs_reader: cannot open %s" % path
                 buff = input_f.read()
@@ -91,5 +92,5 @@
                                 output.source.wavelength_unit != 'A':
                                 conv = Converter('A')
-                                output.source.wavelength = conv(value, 
+                                output.source.wavelength = conv(value,
                                         units=output.source.wavelength_unit)
                             else:
@@ -99,6 +100,4 @@
                             msg = "abs_reader: cannot open %s" % path
                             raise  RuntimeError, msg
-                            #raise ValueError,"IgorReader: can't read this file,
-                            # missing wavelength"
                         
                         # Distance in meters
@@ -108,5 +107,5 @@
                                 detector.distance_unit != 'm':
                                 conv = Converter('m')
-                                detector.distance = conv(value, 
+                                detector.distance = conv(value,
                                                 units=detector.distance_unit)
                             else:
@@ -116,5 +115,5 @@
                             msg = "abs_reader: cannot open %s" % path
                             raise  RuntimeError, msg
-                        # Transmission 
+                        # Transmission
                         try:
                             output.sample.transmission = float(line_toks[4])
@@ -129,5 +128,5 @@
                                 output.sample.thickness_unit != 'cm':
                                 conv = Converter('cm')
-                                output.sample.thickness = conv(value, 
+                                output.sample.thickness = conv(value,
                                             units=output.sample.thickness_unit)
                             else:
@@ -144,5 +143,5 @@
                     # Find center info line
                     if is_center == True:
-                        is_center = False                
+                        is_center = False
                         line_toks = line.split()
                         # Center in bin number
@@ -154,5 +153,5 @@
                             detector.pixel_size_unit != 'mm':
                             conv = Converter('mm')
-                            detector.pixel_size.x = conv(5.0, 
+                            detector.pixel_size.x = conv(5.0,
                                                 units=detector.pixel_size_unit)
                             detector.pixel_size.y = conv(5.0,
@@ -164,10 +163,10 @@
                         # Store beam center in distance units
                         # Det 640 x 640 mm
-                        if has_converter==True and \
+                        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, 
+                            detector.beam_center.y = conv(center_y * 5.0,
                                             units=detector.beam_center_unit)
                         else:
@@ -182,6 +181,6 @@
                             pass
                     
-                    #BCENT(X,Y)   A1(mm)   A2(mm)   A1A2DIST(m)   DL/L 
-                    #  BSTOP(mm)   DET_TYP 
+                    #BCENT(X,Y)   A1(mm)   A2(mm)   A1A2DIST(m)   DL/L
+                    #  BSTOP(mm)   DET_TYP
                     if line.count("BCENT") > 0:
                         is_center = True
@@ -191,7 +190,7 @@
                         toks = line.split()
 
-                        try:  
+                        try:
                             _x  = float(toks[0])
-                            _y  = float(toks[1]) 
+                            _y  = float(toks[1])
                             _dy = float(toks[2])
                             _dx = float(toks[3])
@@ -205,8 +204,8 @@
                                 _dy = data_conv_i(_dy, units=output.y_unit)
                            
-                            x  = numpy.append(x,   _x) 
-                            y  = numpy.append(y,   _y)
+                            x = numpy.append(x, _x)
+                            y = numpy.append(y, _y)
                             dy = numpy.append(dy, _dy)
-                            dx  = numpy.append(dx, _dx)
+                            dx = numpy.append(dx, _dx)
                             
                         except:
@@ -218,5 +217,5 @@
                     #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:
+                    if line.count("The 6 columns") > 0:
                         is_data_started = True
             
@@ -230,8 +229,8 @@
                     raise ValueError, "ascii_reader: could not load file"
                 
-                output.x = x[x!=0]
-                output.y = y[x!=0]
-                output.dy = dy[x!=0]
-                output.dx = dx[x!=0]
+                output.x = x[x != 0]
+                output.y = y[x != 0]
+                output.dy = dy[x != 0]
+                output.dx = dx[x != 0]
                 if data_conv_q is not None:
                     output.xaxis("\\rm{Q}", output.x_unit)
@@ -241,17 +240,10 @@
                     output.yaxis("\\rm{Intensity}", output.y_unit)
                 else:
-                    output.yaxis("\\rm{Intensity}","cm^{-1}")
+                    output.yaxis("\\rm{Intensity}", "cm^{-1}")
                     
                 # Store loading process information
-                output.meta_data['loader'] = self.type_name                       
+                output.meta_data['loader'] = self.type_name
                 return output
         else:
             raise RuntimeError, "%s is not a file" % path
         return None
-    
-if __name__ == "__main__": 
-    reader = Reader()
-    print reader.read("../test/jan08002.ABS")
-    
-    
-            
Index: sansdataloader/src/sans/dataloader/readers/ascii_reader.py
===================================================================
--- sansdataloader/src/sans/dataloader/readers/ascii_reader.py	(revision 9cd0baa894ca115b41e3859315a38cd618515165)
+++ sansdataloader/src/sans/dataloader/readers/ascii_reader.py	(revision 7d6351ed3bb9d1bb801111e3d9813fff5b5cf091)
@@ -1,12 +1,13 @@
-
-
+"""
+    ASCII reader
+"""
 ############################################################################
 #This software was developed by the University of Tennessee as part of the
 #Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
 #project funded by the US National Science Foundation. 
-#If you use DANSE applications to do scientific research that leads to 
-#publication, we ask that you acknowledge the use of the software with the 
+#If you use DANSE applications to do scientific research that leads to
+#publication, we ask that you acknowledge the use of the software with the
 #following sentence:
-#This work benefited from DANSE software developed under NSF award DMR-0520547. 
+#This work benefited from DANSE software developed under NSF award DMR-0520547.
 #copyright 2008, University of Tennessee
 #############################################################################
@@ -24,4 +25,5 @@
     has_converter = False
 _ZERO = 1e-16
+
 
 class Reader:
@@ -38,5 +40,5 @@
             "CSV files (*.csv)|*.csv"]
     ## List of allowed extensions
-    ext = ['.txt', '.TXT', '.dat', '.DAT', '.abs', '.ABS', 'csv', 'CSV']  
+    ext = ['.txt', '.TXT', '.dat', '.DAT', '.abs', '.ABS', 'csv', 'CSV']
     
     ## Flag to bypass extension check
@@ -44,5 +46,5 @@
     
     def read(self, path):
-        """ 
+        """
         Load data file
         
@@ -55,5 +57,5 @@
         """
         if os.path.isfile(path):
-            basename  = os.path.basename(path)
+            basename = os.path.basename(path)
             _, extension = os.path.splitext(basename)
             if self.allow_all or extension.lower() in self.ext:
@@ -61,15 +63,15 @@
                     # Read in binary mode since GRASP frequently has no-ascii
                     # characters that brakes the open operation
-                    input_f =  open(path,'rb')
-                except :
+                    input_f = open(path,'rb')
+                except:
                     raise  RuntimeError, "ascii_reader: cannot open %s" % path
                 buff = input_f.read()
                 lines = buff.split('\n')
                 
-                #Jae could not find python universal line spliter: 
+                #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 : 
+                if len(lines) < 2 :
                     lines = buff.split('\r')
                  
@@ -101,5 +103,4 @@
                     data_conv_i(1.0, output.y_unit)
            
-                
                 # The first good line of data will define whether
                 # we have 2-column or 3-column ascii
@@ -108,18 +109,18 @@
                 
                 #Initialize counters for data lines and header lines.
-                is_data = False #Has more than 5 lines
+                is_data = False  # Has more than 5 lines
                 # More than "5" lines of data is considered as actual
                 # data unless that is the only data
-                mum_data_lines = 5 
+                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          
+                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            
+                # Helps to count # of header lines
                 j1 = -1
-                #minimum required number of columns of data; ( <= 4).           
-                lentoks = 2     
+                #minimum required number of columns of data; ( <= 4).
+                lentoks = 2
                 for line in lines:
                     toks = line.split(',')
@@ -146,5 +147,5 @@
                             
                         if data_conv_i is not None:
-                            _y = data_conv_i(_y, units=output.y_unit)                        
+                            _y = data_conv_i(_y, units=output.y_unit)
                         
                         # If we have an extra token, check
@@ -186,14 +187,14 @@
                             has_error_dx = False if _dx == None else True
                         
-                        #After talked with PB, we decided to take care of only 
+                        #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 
+                        #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 lentoks != new_lentoks :
+                        #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:
                                 break
@@ -203,5 +204,4 @@
                                 j = -1
                                 j1 = -1
-                            
                             
                         #Delete the previously stored lines of data candidates
@@ -215,6 +215,6 @@
                                 pass
                             
-                        x  = numpy.append(x,   _x) 
-                        y  = numpy.append(y,   _y)
+                        x = numpy.append(x, _x) 
+                        y = numpy.append(y, _y)
                         
                         if has_error_dy == True:
@@ -224,7 +224,7 @@
                                 is_data == False:
                                 try:
-                                    dy = numpy.zeros(0)  
+                                    dy = numpy.zeros(0)
                                 except:
-                                    pass                                                               
+                                    pass
                             dy = numpy.append(dy, _dy)
                             
@@ -235,7 +235,7 @@
                                 is_data == False:
                                 try:
-                                    dx = numpy.zeros(0)                            
+                                    dx = numpy.zeros(0)
                                 except:
-                                    pass                                                               
+                                    pass
                             dx = numpy.append(dx, _dx)
                             
@@ -249,8 +249,8 @@
                                 ty = numpy.zeros(0)
                             except:
-                                pass                                                           
-
-                        tx  = numpy.append(tx,   _x) 
-                        ty  = numpy.append(ty,   _y)
+                                pass
+
+                        tx = numpy.append(tx, _x)
+                        ty = numpy.append(ty, _y)
                         
                         if has_error_dy == True:
@@ -262,5 +262,5 @@
                                     tdy = numpy.zeros(0)
                                 except:
-                                    pass                                                                                                                
+                                    pass
                             tdy = numpy.append(tdy, _dy)
                         if has_error_dx == True:
@@ -272,5 +272,5 @@
                                     tdx = numpy.zeros(0)
                                 except:
-                                    pass                                                                                                          
+                                    pass
                             tdx = numpy.append(tdx, _dx)
 
@@ -278,13 +278,13 @@
                         if lentoks < new_lentoks:
                             if is_data == False:
-                                i1 = -1                            
+                                i1 = -1
                         #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    
+                        #Reset # of header lines and counts #
+                        # of data candidate lines
                         if j == 0 and j1 == 0:
-                            i1 = i + 1                            
+                            i1 = i + 1
                         i += 1
                     except:
@@ -292,19 +292,19 @@
                         # It is data and meet non - number, then stop reading
                         if is_data == True:
-                            break    
+                            break
                         lentoks = 2
-                        #Counting # of header lines                    
+                        #Counting # of header lines
                         j += 1
                         if j == j1 + 1:
-                            j1 = j                            
-                        else:                            
+                            j1 = j
+                        else:
                             j = -1
                         #Reset # of lines of data candidates
                         i = -1
                         
-                        # Couldn't parse this line, skip it 
+                        # Couldn't parse this line, skip it
                         pass
                     
-                input_f.close()     
+                input_f.close()
                 # Sanity check
                 if has_error_dy == True and not len(y) == len(dy):
@@ -329,14 +329,16 @@
                     if has_error_dx == True:
                         dx[i] = tdx[ind[i]]
-                # Zeros in dx, dy 
+                # Zeros in dx, dy
                 if has_error_dx:
-                    dx[dx==0] = _ZERO
+                    dx[dx == 0] = _ZERO
                 if has_error_dy:
-                    dy[dy==0] = _ZERO
-                #Data    
-                output.x = x[x!=0]
-                output.y = y[x!=0]
-                output.dy = dy[x!=0] if has_error_dy == True else numpy.zeros(len(output.y))
-                output.dx = dx[x!=0] if has_error_dx == True else numpy.zeros(len(output.x))
+                    dy[dy == 0] = _ZERO
+                #Data
+                output.x = x[x != 0]
+                output.y = y[x != 0]
+                output.dy = dy[x != 0] if has_error_dy == True\
+                    else numpy.zeros(len(output.y))
+                output.dx = dx[x != 0] if has_error_dx == True\
+                    else numpy.zeros(len(output.x))
                                 
                 if data_conv_q is not None:
@@ -347,8 +349,8 @@
                     output.yaxis("\\rm{Intensity}", output.y_unit)
                 else:
-                    output.yaxis("\\rm{Intensity}","cm^{-1}")
+                    output.yaxis("\\rm{Intensity}", "cm^{-1}")
                     
                 # Store loading process information
-                output.meta_data['loader'] = self.type_name    
+                output.meta_data['loader'] = self.type_name
                     
                 return output
@@ -357,10 +359,2 @@
             raise RuntimeError, "%s is not a file" % path
         return None
-    
-if __name__ == "__main__": 
-    reader = Reader()
-    #print reader.read("../test/test_3_columns.txt")
-    print reader.read("../test/empty.txt")
-    
-    
-                        
Index: sansdataloader/src/sans/dataloader/readers/associations.py
===================================================================
--- sansdataloader/src/sans/dataloader/readers/associations.py	(revision f576de0923f0a817d8a605ccb8a055ba709b7fe9)
+++ sansdataloader/src/sans/dataloader/readers/associations.py	(revision 7d6351ed3bb9d1bb801111e3d9813fff5b5cf091)
@@ -1,16 +1,2 @@
-
-
-############################################################################
-#This software was developed by the University of Tennessee as part of the
-#Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-#project funded by the US National Science Foundation. 
-#If you use DANSE applications to do scientific research that leads to 
-#publication, we ask that you acknowledge the use of the software with the 
-#following sentence:
-#This work benefited from DANSE software developed under NSF award DMR-0520547. 
-#copyright 2009, University of Tennessee
-#############################################################################
-
-
 """
 Module to associate default readers to file extensions.
@@ -18,14 +4,24 @@
 The readers are tried in order they appear when reading a file.
 """
-
+############################################################################
+#This software was developed by the University of Tennessee as part of the
+#Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
+#project funded by the US National Science Foundation.
+#If you use DANSE applications to do scientific research that leads to
+#publication, we ask that you acknowledge the use of the software with the
+#following sentence:
+#This work benefited from DANSE software developed under NSF award DMR-0520547.
+#copyright 2009, University of Tennessee
+#############################################################################
 import os
 import sys
 import logging
-from lxml import etree 
+from lxml import etree
 # Py2exe compatibility: import _elementpath to ensure that py2exe finds it
-from lxml import _elementpath  
+from lxml import _elementpath
 
 ## Format version for the XML settings file
 VERSION = 'sansloader/1.0'
+
 
 def read_associations(loader, settings='defaults.xml'):
@@ -54,5 +50,5 @@
         
         # 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()
         
@@ -64,9 +60,9 @@
         for entry in entry_list:
             reader = entry.get('reader')
-            ext    = entry.get('extension')
+            ext = entry.get('extension')
             
             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 
+                # TODO: Modify the Register code to be case-insensitive
                 # and remove the extra line below.
                 try:
@@ -114,18 +110,3 @@
     registry_function(tiff_reader)
     
-    return True            
-
-
-if __name__ == "__main__": 
-    logging.basicConfig(level=logging.INFO,
-                        format='%(asctime)s %(levelname)s %(message)s',
-                        filename='logger.log',
-                        filemode='w')
-    from sans.dataloader.loader import Loader
-    l = Loader()
-    read_associations(l)
-    
-    
-    print l.get_wildcards()
-    
-    
+    return True
Index: sansdataloader/src/sans/dataloader/readers/cansas_reader.py
===================================================================
--- sansdataloader/src/sans/dataloader/readers/cansas_reader.py	(revision 5a0dac1f93f85b9a8cdb2a1579f25daf2e370676)
+++ sansdataloader/src/sans/dataloader/readers/cansas_reader.py	(revision 7d6351ed3bb9d1bb801111e3d9813fff5b5cf091)
@@ -1,4 +1,5 @@
-
-
+"""
+    CanSAS data reader
+"""
 ############################################################################
 #This software was developed by the University of Tennessee as part of the
@@ -25,5 +26,4 @@
 #      Process notes have the same problem.
 #TODO: Unit conversion is not complete (temperature units are missing)
-
 
 import logging
@@ -47,4 +47,5 @@
 CANSAS_NS = "cansas1d/1.0"
 ALLOW_ALL = True
+
 
 def write_node(doc, parent, name, value, attr={}):
@@ -67,4 +68,5 @@
     return False
 
+
 def get_content(location, node):
     """
@@ -78,12 +80,13 @@
     nodes = node.xpath(location, namespaces={'ns': CANSAS_NS})
     
-    if len(nodes)>0:
+    if len(nodes) > 0:
         return nodes[0]
     else:
         return None
 
+
 def get_float(location, node):
     """
-    Get the content of a node as a float 
+    Get the content of a node as a float
     
     :param location: xpath location
@@ -96,5 +99,5 @@
     if len(nodes) > 0:
         try:
-            value = float(nodes[0].text)   
+            value = float(nodes[0].text)
         except:
             # Could not pass, skip and return None
@@ -124,5 +127,5 @@
 
     ## List of allowed extensions
-    ext = ['.xml', '.XML', '.avex', '.AVEx', '.absx', 'ABSx']  
+    ext = ['.xml', '.XML', '.avex', '.AVEx', '.absx', 'ABSx']
     
     def __init__(self):
@@ -131,5 +134,5 @@
     
     def read(self, path):
-        """ 
+        """
         Load data file
         
@@ -145,5 +148,5 @@
         output = []
         if os.path.isfile(path):
-            basename  = os.path.basename(path)
+            basename = os.path.basename(path)
             root, extension = os.path.splitext(basename)
             if ALLOW_ALL or extension.lower() in self.ext:
@@ -152,5 +155,5 @@
                     # Check the format version number
                     # Specifying the namespace will take care of the file
-                    # format version 
+                    # format version
                     root = tree.getroot()
                     
@@ -173,5 +176,5 @@
         # Return output consistent with the loader's api
         if len(output) == 0:
-            #cannot return none when it cannot read 
+            #cannot return none when it cannot read
             #return None
             raise RuntimeError, "%s cannot be read \n" % path
@@ -179,5 +182,5 @@
             return output[0]
         else:
-            return output                
+            return output
                 
     def _parse_entry(self, dom):
@@ -194,10 +197,10 @@
         data_info = Data1D(x, y)
         
-        # Look up title      
+        # Look up title
         self._store_content('ns:Title', dom, 'title', data_info)
         
-        # Look up run number   
+        # Look up run number
         nodes = dom.xpath('ns:Run', namespaces={'ns': CANSAS_NS})
-        for item in nodes:    
+        for item in nodes:
             if item.text is not None:
                 value = item.text.strip()
@@ -207,5 +210,5 @@
                         data_info.run_name[value] = item.get('name')
                            
-        # Look up instrument name              
+        # Look up instrument name
         self._store_content('ns:SASinstrument/ns:name', dom, 'instrument',
                              data_info)
@@ -230,14 +233,14 @@
             data_info.sample.name = entry.get('name')
             
-        self._store_content('ns:SASsample/ns:ID', 
-                     dom, 'ID', data_info.sample)                    
-        self._store_float('ns:SASsample/ns:thickness', 
+        self._store_content('ns:SASsample/ns:ID',
+                     dom, 'ID', data_info.sample)
+        self._store_float('ns:SASsample/ns:thickness',
                      dom, 'thickness', data_info.sample)
-        self._store_float('ns:SASsample/ns:transmission', 
+        self._store_float('ns:SASsample/ns:transmission',
                      dom, 'transmission', data_info.sample)
-        self._store_float('ns:SASsample/ns:temperature', 
+        self._store_float('ns:SASsample/ns:temperature',
                      dom, 'temperature', data_info.sample)
         
-        nodes = dom.xpath('ns:SASsample/ns:details', 
+        nodes = dom.xpath('ns:SASsample/ns:details',
                           namespaces={'ns': CANSAS_NS})
         for item in nodes:
@@ -254,18 +257,18 @@
         
         # Position (as a vector)
-        self._store_float('ns:SASsample/ns:position/ns:x', 
-                     dom, 'position.x', data_info.sample)          
-        self._store_float('ns:SASsample/ns:position/ns:y', 
-                     dom, 'position.y', data_info.sample)          
-        self._store_float('ns:SASsample/ns:position/ns:z', 
-                     dom, 'position.z', data_info.sample)          
+        self._store_float('ns:SASsample/ns:position/ns:x',
+                     dom, 'position.x', data_info.sample)
+        self._store_float('ns:SASsample/ns:position/ns:y',
+                     dom, 'position.y', data_info.sample)
+        self._store_float('ns:SASsample/ns:position/ns:z',
+                     dom, 'position.z', data_info.sample)
         
         # Orientation (as a vector)
-        self._store_float('ns:SASsample/ns:orientation/ns:roll', 
-                     dom, 'orientation.x', data_info.sample)          
-        self._store_float('ns:SASsample/ns:orientation/ns:pitch', 
-                     dom, 'orientation.y', data_info.sample)          
-        self._store_float('ns:SASsample/ns:orientation/ns:yaw', 
-                     dom, 'orientation.z', data_info.sample)          
+        self._store_float('ns:SASsample/ns:orientation/ns:roll',
+                     dom, 'orientation.x', data_info.sample)
+        self._store_float('ns:SASsample/ns:orientation/ns:pitch',
+                     dom, 'orientation.y', data_info.sample)
+        self._store_float('ns:SASsample/ns:orientation/ns:yaw',
+                     dom, 'orientation.z', data_info.sample)
        
         # Source info ###################
@@ -274,16 +277,16 @@
             data_info.source.name = entry.get('name')
         
-        self._store_content('ns:SASinstrument/ns:SASsource/ns:radiation', 
-                     dom, 'radiation', data_info.source)                    
-        self._store_content('ns:SASinstrument/ns:SASsource/ns:beam_shape', 
-                     dom, 'beam_shape', data_info.source)                    
-        self._store_float('ns:SASinstrument/ns:SASsource/ns:wavelength', 
-                     dom, 'wavelength', data_info.source)          
-        self._store_float('ns:SASinstrument/ns:SASsource/ns:wavelength_min', 
-                     dom, 'wavelength_min', data_info.source)          
-        self._store_float('ns:SASinstrument/ns:SASsource/ns:wavelength_max', 
-                     dom, 'wavelength_max', data_info.source)          
-        self._store_float('ns:SASinstrument/ns:SASsource/ns:wavelength_spread', 
-                     dom, 'wavelength_spread', data_info.source)    
+        self._store_content('ns:SASinstrument/ns:SASsource/ns:radiation',
+                     dom, 'radiation', data_info.source)
+        self._store_content('ns:SASinstrument/ns:SASsource/ns:beam_shape',
+                     dom, 'beam_shape', data_info.source)
+        self._store_float('ns:SASinstrument/ns:SASsource/ns:wavelength',
+                     dom, 'wavelength', data_info.source)
+        self._store_float('ns:SASinstrument/ns:SASsource/ns:wavelength_min',
+                     dom, 'wavelength_min', data_info.source)
+        self._store_float('ns:SASinstrument/ns:SASsource/ns:wavelength_max',
+                     dom, 'wavelength_max', data_info.source)
+        self._store_float('ns:SASinstrument/ns:SASsource/ns:wavelength_spread',
+                     dom, 'wavelength_spread', data_info.source)
         
         # Beam size (as a vector)   
@@ -292,13 +295,13 @@
             data_info.source.beam_size_name = entry.get('name')
             
-        self._store_float('ns:SASinstrument/ns:SASsource/ns:beam_size/ns:x', 
-                     dom, 'beam_size.x', data_info.source)    
-        self._store_float('ns:SASinstrument/ns:SASsource/ns:beam_size/ns:y', 
-                     dom, 'beam_size.y', data_info.source)    
-        self._store_float('ns:SASinstrument/ns:SASsource/ns:beam_size/ns:z', 
-                     dom, 'beam_size.z', data_info.source)    
+        self._store_float('ns:SASinstrument/ns:SASsource/ns:beam_size/ns:x',
+                     dom, 'beam_size.x', data_info.source)
+        self._store_float('ns:SASinstrument/ns:SASsource/ns:beam_size/ns:y',
+                     dom, 'beam_size.y', data_info.source)
+        self._store_float('ns:SASinstrument/ns:SASsource/ns:beam_size/ns:z',
+                     dom, 'beam_size.z', data_info.source)
         
         # Collimation info ###################
-        nodes = dom.xpath('ns:SASinstrument/ns:SAScollimation', 
+        nodes = dom.xpath('ns:SASinstrument/ns:SAScollimation',
                           namespaces={'ns': CANSAS_NS})
         for item in nodes:
@@ -306,10 +309,10 @@
             if item.get('name') is not None:
                 collim.name = item.get('name')
-            self._store_float('ns:length', item, 'length', collim)  
+            self._store_float('ns:length', item, 'length', collim)
             
             # Look for apertures
             apert_list = item.xpath('ns:aperture', namespaces={'ns': CANSAS_NS})
             for apert in apert_list:
-                aperture =  Aperture()
+                aperture = Aperture()
                 
                 # Get the name and type of the aperture
@@ -317,5 +320,5 @@
                 aperture.type = apert.get('type')
                     
-                self._store_float('ns:distance', apert, 'distance', aperture)    
+                self._store_float('ns:distance', apert, 'distance', aperture)
                 
                 entry = get_content('ns:size', apert)
@@ -323,6 +326,6 @@
                     aperture.size_name = entry.get('name')
                 
-                self._store_float('ns:size/ns:x', apert, 'size.x', aperture)    
-                self._store_float('ns:size/ns:y', apert, 'size.y', aperture)    
+                self._store_float('ns:size/ns:x', apert, 'size.x', aperture)
+                self._store_float('ns:size/ns:y', apert, 'size.y', aperture)
                 self._store_float('ns:size/ns:z', apert, 'size.z', aperture)
                 
@@ -339,38 +342,38 @@
             
             self._store_content('ns:name', item, 'name', detector)
-            self._store_float('ns:SDD', item, 'distance', detector)    
+            self._store_float('ns:SDD', item, 'distance', detector)
             
             # Detector offset (as a vector)
-            self._store_float('ns:offset/ns:x', item, 'offset.x', detector)    
-            self._store_float('ns:offset/ns:y', item, 'offset.y', detector)    
-            self._store_float('ns:offset/ns:z', item, 'offset.z', detector)    
+            self._store_float('ns:offset/ns:x', item, 'offset.x', detector)
+            self._store_float('ns:offset/ns:y', item, 'offset.y', detector)
+            self._store_float('ns:offset/ns:z', item, 'offset.z', detector)
             
             # Detector orientation (as a vector)
-            self._store_float('ns:orientation/ns:roll',  item, 'orientation.x',
-                               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)    
+                               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)    
+                               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)    
+                               detector)
             
             # Pixel size (as a vector)
             self._store_float('ns:pixel_size/ns:x', item, 'pixel_size.x',
-                               detector)    
+                               detector)
             self._store_float('ns:pixel_size/ns:y', item, 'pixel_size.y',
-                               detector)    
+                               detector)
             self._store_float('ns:pixel_size/ns:z', item, 'pixel_size.z',
-                               detector)    
+                               detector)
             
             self._store_float('ns:slit_length', item, 'slit_length', detector)
             
-            data_info.detector.append(detector)    
+            data_info.detector.append(detector)
 
         # Processes info ######################
@@ -397,5 +400,5 @@
                     logging.error(err_mess)
             
-            note_list = item.xpath('ns:SASprocessnote', 
+            note_list = item.xpath('ns:SASprocessnote',
                                    namespaces={'ns': CANSAS_NS})
             for note in note_list:
@@ -404,5 +407,4 @@
             
             data_info.process.append(process)
-            
             
         # Data info ######################
@@ -415,6 +417,6 @@
         nodes = dom.xpath('ns:SASdata/ns:Idata', namespaces={'ns': CANSAS_NS})
 
-        x  = numpy.zeros(0)
-        y  = numpy.zeros(0)
+        x = numpy.zeros(0)
+        y = numpy.zeros(0)
         dx = numpy.zeros(0)
         dy = numpy.zeros(0)
@@ -434,5 +436,5 @@
                 _dxw = 0.0
                 
-            if attr.has_key('unit') and \
+            if 'unit' in attr and \
                 attr['unit'].lower() != data_info.x_unit.lower():
                 if HAS_CONVERTER == True:
@@ -441,7 +443,7 @@
                         _x = data_conv_q(_x, units=data_info.x_unit)
                     except:
-                        msg =  "CanSAS reader: could not convert "
+                        msg = "CanSAS reader: could not convert "
                         msg += "Q unit [%s]; " % attr['unit'],
-                        msg += "expecting [%s]\n  %s" % (data_info.x_unit, 
+                        msg += "expecting [%s]\n  %s" % (data_info.x_unit,
                                                          sys.exc_value)
                         raise ValueError, msg
@@ -454,5 +456,5 @@
                         
             # Error in Q
-            if attr_d.has_key('unit') and \
+            if 'unit' in attr_d and \
                 attr_d['unit'].lower() != data_info.x_unit.lower():
                 if HAS_CONVERTER == True:
@@ -463,5 +465,5 @@
                         msg = "CanSAS reader: could not convert dQ unit [%s]; "\
                         % attr['unit']
-                        msg += " expecting " 
+                        msg += " expecting "
                         msg += "[%s]\n  %s" % (data_info.x_unit, sys.exc_value)
                         raise ValueError, msg
@@ -471,8 +473,8 @@
                     % attr['unit']
                     msg += "expecting [%s]" % data_info.x_unit
-                    raise ValueError,  msg
+                    raise ValueError, msg
                         
             # Slit length
-            if attr_l.has_key('unit') and \
+            if 'unit' in attr_l and \
                 attr_l['unit'].lower() != data_info.x_unit.lower():
                 if HAS_CONVERTER == True:
@@ -483,8 +485,7 @@
                         msg = "CanSAS reader: could not convert dQl unit [%s];"\
                         % attr['unit']
-                        msg += " expecting [%s]\n  %s" % (data_info.x_unit, 
+                        msg += " expecting [%s]\n  %s" % (data_info.x_unit,
                                                           sys.exc_value)
-                        raise ValueError, msg
-                        
+                        raise ValueError, msg 
                 else:
                     msg = "CanSAS reader: unrecognized dQl unit [%s];"\
@@ -494,5 +495,5 @@
                         
             # Slit width
-            if attr_w.has_key('unit') and \
+            if 'unit' in attr_w and \
             attr_w['unit'].lower() != data_info.x_unit.lower():
                 if HAS_CONVERTER == True:
@@ -503,5 +504,5 @@
                         msg = "CanSAS reader: could not convert dQw unit [%s];"\
                         % attr['unit']
-                        msg += " expecting [%s]\n  %s" % (data_info.x_unit, 
+                        msg += " expecting [%s]\n  %s" % (data_info.x_unit,
                                                           sys.exc_value)
                         raise ValueError, msg
@@ -511,10 +512,10 @@
                     % attr['unit']
                     msg += " expecting [%s]" % data_info.x_unit
-                    raise ValueError, msg   
+                    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 \
+            if 'unit' in attr and \
             attr['unit'].lower() != data_info.y_unit.lower():
                 if HAS_CONVERTER == True:
@@ -537,5 +538,5 @@
                     raise ValueError, msg 
                         
-            if attr_d.has_key('unit') and \
+            if 'unit' in attr_d and \
             attr_d['unit'].lower() != data_info.y_unit.lower():
                 if HAS_CONVERTER == True:
@@ -545,8 +546,8 @@
                     except:
                         if attr_d['unit'].lower() == 'count':
-                            pass 
+                            pass
                         else:
                             msg = "CanSAS reader: could not convert dI(q) unit "
-                            msg += "[%s]; expecting [%s]\n  %s"  % (attr_d['unit'],
+                            msg += "[%s]; expecting [%s]\n  %s" % (attr_d['unit'],
                                                  data_info.y_unit, sys.exc_value)
                             raise ValueError, msg
@@ -558,23 +559,23 @@
                 
             if _x is not None and _y is not None:
-                x  = numpy.append(x, _x)
-                y  = numpy.append(y, _y)
+                x = numpy.append(x, _x)
+                y = numpy.append(y, _y)
                 dx = numpy.append(dx, _dx)
                 dy = numpy.append(dy, _dy)
                 dxl = numpy.append(dxl, _dxl)
                 dxw = numpy.append(dxw, _dxw)
-        # Zeros in dx, dy 
-        if not numpy.all(dx==0):
-            dx[dx==0] = _ZERO
-        if not numpy.all(dy==0):
-            dy[dy==0] = _ZERO
+        # Zeros in dx, dy
+        if not numpy.all(dx == 0):
+            dx[dx == 0] = _ZERO
+        if not numpy.all(dy == 0):
+            dy[dy == 0] = _ZERO
        
-        data_info.x = x[x!=0]
-        data_info.y = y[x!=0]
-        data_info.dx = dx[x!=0]
-        
-        data_info.dy = dy[x!=0]
-        data_info.dxl = dxl[x!=0]
-        data_info.dxw = dxw[x!=0]
+        data_info.x = x[x != 0]
+        data_info.y = y[x != 0]
+        data_info.dx = dx[x != 0]
+        
+        data_info.dy = dy[x != 0]
+        data_info.dxl = dxl[x != 0]
+        data_info.dxw = dxw[x != 0]
         
         data_conv_q = None
@@ -589,5 +590,5 @@
             data_conv_i = Converter('1/cm')
             # Test it
-            data_conv_i(1.0, output.I_unit)                    
+            data_conv_i(1.0, output.I_unit)
                 
         if data_conv_q is not None:
@@ -598,5 +599,5 @@
             data_info.yaxis("\\rm{Intensity}", data_info.y_unit)
         else:
-            data_info.yaxis("\\rm{Intensity}","cm^{-1}")
+            data_info.yaxis("\\rm{Intensity}", "cm^{-1}")
 
         return data_info
@@ -629,7 +630,7 @@
         for item in datainfo.run:
             runname = {}
-            if datainfo.run_name.has_key(item) and \
-            len(str(datainfo.run_name[item]))>1:
-                runname = {'name': datainfo.run_name[item] }
+            if item in datainfo.run_name and \
+            len(str(datainfo.run_name[item])) > 1:
+                runname = {'name': datainfo.run_name[item]}
             write_node(doc, entry_node, "Run", item, runname)
         
@@ -641,22 +642,21 @@
             pt = doc.createElement("Idata")
             node.appendChild(pt)
-            write_node(doc, pt, "Q", datainfo.x[i], {'unit':datainfo.x_unit})
-            if len(datainfo.y)>=i:
+            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})
+                            {'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})
+                            {'unit': datainfo.x_unit})
             if datainfo.dxl != None and len(datainfo.dxl) >= i:
                 write_node(doc, pt, "dQl", datainfo.dxl[i],
-                            {'unit':datainfo.x_unit})    
+                            {'unit': datainfo.x_unit})
             if datainfo.dxw != None and len(datainfo.dxw) >= i:
                 write_node(doc, pt, "dQw", datainfo.dxw[i],
-                            {'unit':datainfo.x_unit})              
+                            {'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})
-
-        
+                            {'unit': datainfo.y_unit})
+
         # Sample info
         sample = doc.createElement("SASsample")
@@ -666,8 +666,8 @@
         write_node(doc, sample, "ID", str(datainfo.sample.ID))
         write_node(doc, sample, "thickness", datainfo.sample.thickness,
-                   {"unit":datainfo.sample.thickness_unit})
+                   {"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})
+                   {"unit": datainfo.sample.temperature_unit})
         
         for item in datainfo.sample.details:
@@ -676,11 +676,11 @@
         pos = doc.createElement("position")
         written = write_node(doc, pos, "x", datainfo.sample.position.x,
-                             {"unit":datainfo.sample.position_unit})
+                             {"unit": datainfo.sample.position_unit})
         written = written | write_node(doc, pos, "y",
                                        datainfo.sample.position.y,
-                                       {"unit":datainfo.sample.position_unit})
+                                       {"unit": datainfo.sample.position_unit})
         written = written | write_node(doc, pos, "z",
                                        datainfo.sample.position.z,
-                                       {"unit":datainfo.sample.position_unit})
+                                       {"unit": datainfo.sample.position_unit})
         if written == True:
             sample.appendChild(pos)
@@ -689,11 +689,11 @@
         written = write_node(doc, ori, "roll",
                              datainfo.sample.orientation.x,
-                             {"unit":datainfo.sample.orientation_unit})
+                             {"unit": datainfo.sample.orientation_unit})
         written = written | write_node(doc, ori, "pitch",
                                        datainfo.sample.orientation.y,
-                                    {"unit":datainfo.sample.orientation_unit})
+                                    {"unit": datainfo.sample.orientation_unit})
         written = written | write_node(doc, ori, "yaw",
                                        datainfo.sample.orientation.z,
-                                    {"unit":datainfo.sample.orientation_unit})
+                                    {"unit": datainfo.sample.orientation_unit})
         if written == True:
             sample.appendChild(ori)
@@ -717,11 +717,11 @@
             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})
+                             {"unit": datainfo.source.beam_size_unit})
         written = written | write_node(doc, size, "y",
                                        datainfo.source.beam_size.y,
-                                       {"unit":datainfo.source.beam_size_unit})
+                                       {"unit": datainfo.source.beam_size_unit})
         written = written | write_node(doc, size, "z",
                                        datainfo.source.beam_size.z,
-                                       {"unit":datainfo.source.beam_size_unit})
+                                       {"unit": datainfo.source.beam_size_unit})
         if written == True:
             source.appendChild(size)
@@ -729,14 +729,14 @@
         write_node(doc, source, "wavelength",
                    datainfo.source.wavelength,
-                   {"unit":datainfo.source.wavelength_unit})
+                   {"unit": datainfo.source.wavelength_unit})
         write_node(doc, source, "wavelength_min",
                    datainfo.source.wavelength_min,
-                   {"unit":datainfo.source.wavelength_min_unit})
+                   {"unit": datainfo.source.wavelength_min_unit})
         write_node(doc, source, "wavelength_max",
                    datainfo.source.wavelength_max,
-                   {"unit":datainfo.source.wavelength_max_unit})
+                   {"unit": datainfo.source.wavelength_max_unit})
         write_node(doc, source, "wavelength_spread",
                    datainfo.source.wavelength_spread,
-                   {"unit":datainfo.source.wavelength_spread_unit})
+                   {"unit": datainfo.source.wavelength_spread_unit})
         
         #   Collimation
@@ -748,5 +748,5 @@
             
             write_node(doc, coll, "length", item.length,
-                       {"unit":item.length_unit})
+                       {"unit": item.length_unit})
             
             for apert in item.aperture:
@@ -759,5 +759,5 @@
                 
                 write_node(doc, ap, "distance", apert.distance,
-                           {"unit":apert.distance_unit})
+                           {"unit": apert.distance_unit})
                 
                 size = doc.createElement("size")
@@ -765,9 +765,9 @@
                     size.setAttribute("name", str(apert.size_name))
                 written = write_node(doc, size, "x", apert.size.x,
-                                     {"unit":apert.size_unit})
+                                     {"unit": apert.size_unit})
                 written = written | write_node(doc, size, "y", apert.size.y,
-                                               {"unit":apert.size_unit})
+                                               {"unit": apert.size_unit})
                 written = written | write_node(doc, size, "z", apert.size.z,
-                                               {"unit":apert.size_unit})
+                                               {"unit": apert.size_unit})
                 if written == True:
                     ap.appendChild(size)
@@ -778,8 +778,8 @@
             written = write_node(doc, det, "name", item.name)
             written = written | write_node(doc, det, "SDD", item.distance,
-                                           {"unit":item.distance_unit})
+                                           {"unit": item.distance_unit})
             written = written | write_node(doc, det, "slit_length",
                                            item.slit_length,
-                                           {"unit":item.slit_length_unit})
+                                           {"unit": item.slit_length_unit})
             if written == True:
                 instr.appendChild(det)
@@ -787,9 +787,9 @@
             off = doc.createElement("offset")
             written = write_node(doc, off, "x", item.offset.x,
-                                 {"unit":item.offset_unit})
+                                 {"unit": item.offset_unit})
             written = written | write_node(doc, off, "y", item.offset.y,
-                                           {"unit":item.offset_unit})
+                                           {"unit": item.offset_unit})
             written = written | write_node(doc, off, "z", item.offset.z,
-                                           {"unit":item.offset_unit})
+                                           {"unit": item.offset_unit})
             if written == True:
                 det.appendChild(off)
@@ -797,11 +797,11 @@
             center = doc.createElement("beam_center")
             written = write_node(doc, center, "x", item.beam_center.x,
-                                 {"unit":item.beam_center_unit})
+                                 {"unit": item.beam_center_unit})
             written = written | write_node(doc, center, "y",
                                            item.beam_center.y,
-                                           {"unit":item.beam_center_unit})
+                                           {"unit": item.beam_center_unit})
             written = written | write_node(doc, center, "z",
                                            item.beam_center.z,
-                                           {"unit":item.beam_center_unit})
+                                           {"unit": item.beam_center_unit})
             if written == True:
                 det.appendChild(center)
@@ -809,25 +809,24 @@
             pix = doc.createElement("pixel_size")
             written = write_node(doc, pix, "x", item.pixel_size.x,
-                                 {"unit":item.pixel_size_unit})
+                                 {"unit": item.pixel_size_unit})
             written = written | write_node(doc, pix, "y", item.pixel_size.y,
-                                           {"unit":item.pixel_size_unit})
+                                           {"unit": item.pixel_size_unit})
             written = written | write_node(doc, pix, "z", item.pixel_size.z,
-                                           {"unit":item.pixel_size_unit})
+                                           {"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 = 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})
+                                           {"unit": item.orientation_unit})
             written = written | write_node(doc, ori, "yaw",
                                            item.orientation.z,
-                                           {"unit":item.orientation_unit})
+                                           {"unit": item.orientation_unit})
             if written == True:
                 det.appendChild(ori)
                 
-        
         # Processes info
         for item in datainfo.process:
@@ -857,5 +856,5 @@
         """
         # Create XML document
-        doc, sasentry = self._to_xml_doc(datainfo)
+        doc, _ = self._to_xml_doc(datainfo)
         # Write the file
         fd = open(filename, 'w')
@@ -877,5 +876,5 @@
         :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 
+        :param optional: if True, no exception will be raised
             if unit conversion can't be done
 
@@ -895,5 +894,5 @@
                 toks = variable.split('.')
                 exec "local_unit = storage.%s_unit" % toks[0]
-                if units.lower()!=local_unit.lower():
+                if units.lower() != local_unit.lower():
                     if HAS_CONVERTER == True:
                         try:
@@ -909,5 +908,5 @@
                                 logging.info(err_mess)
                             else:
-                                raise ValueError, err_mess 
+                                raise ValueError, err_mess
                     else:
                         err_mess = "CanSAS reader: unrecognized %s unit [%s];"\
@@ -942,16 +941,2 @@
         if entry is not None and entry.text is not None:
             exec "storage.%s = entry.text.strip()" % variable
-
-            
-            
-if __name__ == "__main__": 
-    logging.basicConfig(level=logging.ERROR,
-                        format='%(asctime)s %(levelname)s %(message)s',
-                        filename='cansas_reader.log',
-                        filemode='w')
-    reader = Reader()
-    print reader.read("../test/cansas1d.xml")
-    #print reader.read("../test/latex_smeared.xml")
-    
-    
-                        
Index: sansdataloader/src/sans/dataloader/readers/danse_reader.py
===================================================================
--- sansdataloader/src/sans/dataloader/readers/danse_reader.py	(revision ad8034f2bbcd87293b219fc00bc095a3f8df9fb6)
+++ sansdataloader/src/sans/dataloader/readers/danse_reader.py	(revision 7d6351ed3bb9d1bb801111e3d9813fff5b5cf091)
@@ -1,19 +1,15 @@
-
-
+"""
+    DANSE/SANS file reader
+"""
 ############################################################################
 #This software was developed by the University of Tennessee as part of the
 #Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
 #project funded by the US National Science Foundation. 
-#If you use DANSE applications to do scientific research that leads to 
-#publication, we ask that you acknowledge the use of the software with the 
+#If you use DANSE applications to do scientific research that leads to
+#publication, we ask that you acknowledge the use of the software with the
 #following sentence:
-#This work benefited from DANSE software developed under NSF award DMR-0520547. 
+#This work benefited from DANSE software developed under NSF award DMR-0520547.
 #copyright 2008, University of Tennessee
 #############################################################################
-
-"""
-    DANSE/SANS file reader
-"""
-
 import math
 import os
@@ -31,4 +27,5 @@
     has_converter = False
 
+
 class Reader:
     """
@@ -36,9 +33,9 @@
     """
     ## File type
-    type_name = "DANSE"   
+    type_name = "DANSE"
     ## Wildcards
     type = ["DANSE files (*.sans)|*.sans"]
     ## Extension
-    ext  = ['.sans', '.SANS']    
+    ext  = ['.sans', '.SANS']
         
     def read(self, filename=None):
@@ -56,5 +53,5 @@
             try:
                 datafile = open(filename, 'r')
-            except :
+            except:
                 raise  RuntimeError,"danse_reader cannot open %s" % (filename)
         
@@ -96,5 +93,5 @@
                 data_conv_i = Converter('1/cm')
                 # Test it
-                data_conv_i(1.0, output.I_unit)            
+                data_conv_i(1.0, output.I_unit)
         
             read_on = True
@@ -107,6 +104,6 @@
                 if toks[0] == "FORMATVERSION":
                     fversion = float(toks[1])
-                if toks[0] == "WAVELENGTH":    
-                    wavelength = float(toks[1])                
+                if toks[0] == "WAVELENGTH":
+                    wavelength = float(toks[1])
                 elif toks[0] == "DISTANCE":
                     distance = float(toks[1])
@@ -145,10 +142,10 @@
                             error.append(err)
                         except:
-                            logging.info("Skipping line:%s,%s" %( data_str,
+                            logging.info("Skipping line:%s,%s" %(data_str,
                                                                 sys.exc_value))
             
-            # Initialize 
+            # Initialize
             x_vals = []
-            y_vals = [] 
+            y_vals = []
             ymin = None
             ymax = None
@@ -158,8 +155,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)
+                qx = 4.0 * math.pi / wavelength * math.sin(theta / 2.0)
                 
                 if has_converter == True and output.Q_unit != '1/A':
@@ -176,5 +173,5 @@
             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)
+                qy = 4.0 * math.pi / wavelength * math.sin(theta/2.0)
                 
                 if has_converter == True and output.Q_unit != '1/A':
@@ -188,7 +185,6 @@
             
             # Store the data in the 2D array
-            itot = 0
-            i_x  = 0
-            i_y  = -1
+            i_x = 0
+            i_y = -1
             
             for i_pt in range(len(data)):
@@ -198,5 +194,5 @@
                     # For version 1.0, the data were still
                     # stored as strings at this point.
-                    msg = "Skipping entry (v1.0):%s,%s" %(str(data[i_pt]),
+                    msg = "Skipping entry (v1.0):%s,%s" % (str(data[i_pt]),
                                                            sys.exc_value)
                     logging.info(msg)
@@ -209,12 +205,9 @@
                     i_x += 1
                     
-                output.data[i_y][i_x] = value       
-                #output.data[size_y-1-i_y][i_x] = value
+                output.data[i_y][i_x] = value
                 if fversion>1.0:
                     output.err_data[i_y][i_x] = error[i_pt]
-                    #output.err_data[size_y-1-i_y][i_x] = error[i_pt]
-                
-
-            # Store all data 
+                
+            # Store all data
             # Store wavelength
             if has_converter == True and output.source.wavelength_unit != 'A':
@@ -238,11 +231,11 @@
 
             # Store beam center in distance units
-            detector.beam_center.x = center_x*pixel
-            detector.beam_center.y = center_y*pixel
+            detector.beam_center.x = center_x * pixel
+            detector.beam_center.y = center_y * pixel
             
             # Store limits of the image (2D array)
             xmin = xmin - stepq / 2.0
             xmax = xmax + stepq / 2.0
-            ymin = ymin - stepq  /2.0
+            ymin = ymin - stepq /2.0
             ymax = ymax + stepq / 2.0
             
@@ -258,6 +251,6 @@
             
             # Store x and y axis bin centers
-            output.x_bins     = x_vals
-            output.y_bins     = y_vals
+            output.x_bins = x_vals
+            output.y_bins = y_vals
            
             # Units
@@ -272,5 +265,5 @@
                 output.zaxis("\\rm{Intensity}", output.I_unit)
             else:
-                output.zaxis("\\rm{Intensity}","cm^{-1}")
+                output.zaxis("\\rm{Intensity}", "cm^{-1}")
            
             if not fversion >= 1.0:
@@ -281,12 +274,7 @@
             
             # Store loading process information
-            output.meta_data['loader'] = self.type_name    
+            output.meta_data['loader'] = self.type_name
             output = reader2D_converter(output)
             return output
         
         return None
-
-if __name__ == "__main__": 
-    reader = Reader()
-    print reader.read("../test/MP_New.sans")
-    
Index: sansdataloader/src/sans/dataloader/readers/hfir1d_reader.py
===================================================================
--- sansdataloader/src/sans/dataloader/readers/hfir1d_reader.py	(revision ad8034f2bbcd87293b219fc00bc095a3f8df9fb6)
+++ sansdataloader/src/sans/dataloader/readers/hfir1d_reader.py	(revision 7d6351ed3bb9d1bb801111e3d9813fff5b5cf091)
@@ -1,11 +1,12 @@
-
+"""
+    HFIR 1D 4-column data reader
+"""
 #####################################################################
 #This software was developed by the University of Tennessee as part of the
 #Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-#project funded by the US National Science Foundation. 
+#project funded by the US National Science Foundation.
 #See the license text in license.txt
 #copyright 2008, University of Tennessee
 ######################################################################
-
 import numpy
 import os
@@ -24,9 +25,9 @@
     """
     ## File type
-    type_name = "HFIR 1D"   
+    type_name = "HFIR 1D"
     ## Wildcards
     type = ["HFIR 1D files (*.d1d)|*.d1d"]
     ## List of allowed extensions
-    ext = ['.d1d']  
+    ext = ['.d1d']
     
     def read(self, path):
@@ -42,15 +43,15 @@
         """
         if os.path.isfile(path):
-            basename  = os.path.basename(path)
+            basename = os.path.basename(path)
             root, extension = os.path.splitext(basename)
             if extension.lower() in self.ext:
                 try:
-                    input_f =  open(path,'r')
-                except :
+                    input_f = open(path,'r')
+                except:
                     raise  RuntimeError, "hfir1d_reader: cannot open %s" % path
                 buff = input_f.read()
                 lines = buff.split('\n')
-                x  = numpy.zeros(0)
-                y  = numpy.zeros(0)
+                x = numpy.zeros(0)
+                y = numpy.zeros(0)
                 dx = numpy.zeros(0)
                 dy = numpy.zeros(0)
@@ -84,16 +85,15 @@
                             
                         if data_conv_i is not None:
-                            _y = data_conv_i(_y, units=output.y_unit)                        
-                            _dy = data_conv_i(_dy, units=output.y_unit)                        
+                            _y = data_conv_i(_y, units=output.y_unit)
+                            _dy = data_conv_i(_dy, units=output.y_unit)
                                                     
-                        x   = numpy.append(x, _x) 
-                        y   = numpy.append(y, _y)
-                        dx  = numpy.append(dx, _dx)
-                        dy  = numpy.append(dy, _dy)                        
+                        x = numpy.append(x, _x)
+                        y = numpy.append(y, _y)
+                        dx = numpy.append(dx, _dx)
+                        dy = numpy.append(dy, _dy)
                     except:
                         # Couldn't parse this line, skip it 
                         pass
                          
-                     
                 # Sanity check
                 if not len(y) == len(dy):
@@ -120,17 +120,10 @@
                     output.yaxis("\\rm{Intensity}", output.y_unit)
                 else:
-                    output.yaxis("\\rm{Intensity}","cm^{-1}")
+                    output.yaxis("\\rm{Intensity}", "cm^{-1}")
                 
                 # Store loading process information
-                output.meta_data['loader'] = self.type_name   
+                output.meta_data['loader'] = self.type_name
                 return output
         else:
             raise RuntimeError, "%s is not a file" % path
         return None
-    
-if __name__ == "__main__": 
-    reader = Reader()
-    print reader.read("../test/S2-30dq.d1d")
-    
-    
-                        
Index: sansdataloader/src/sans/dataloader/readers/red2d_reader.py
===================================================================
--- sansdataloader/src/sans/dataloader/readers/red2d_reader.py	(revision ad8034f2bbcd87293b219fc00bc095a3f8df9fb6)
+++ sansdataloader/src/sans/dataloader/readers/red2d_reader.py	(revision 7d6351ed3bb9d1bb801111e3d9813fff5b5cf091)
@@ -1,3 +1,5 @@
-
+"""
+    TXT/IGOR 2D Q Map file reader
+"""
 #####################################################################
 #This software was developed by the University of Tennessee as part of the
@@ -7,15 +9,7 @@
 #copyright 2008, University of Tennessee
 ######################################################################
-
-"""
-    TXT/IGOR 2D Q Map file reader
-"""
-
-
 import os
-#import sys
 import numpy
 import math
-#import logging
 from sans.dataloader.data_info import Data2D, Detector
 
@@ -26,4 +20,5 @@
 except:
     has_converter = False
+    
     
 def check_point(x_point):
@@ -36,13 +31,14 @@
     except:
         return 0
+      
         
 class Reader:
     """ Simple data reader for Igor data files """
     ## File type
-    type_name = "IGOR/DAT 2D Q_map"   
+    type_name = "IGOR/DAT 2D Q_map"
     ## Wildcards
     type = ["IGOR/DAT 2D file in Q_map (*.dat)|*.DAT"]
     ## Extension
-    ext=['.DAT', '.dat']
+    ext = ['.DAT', '.dat']
     
     def write(self, filename, data):
@@ -51,8 +47,7 @@
         
         :param filename: file name to write
-        :param data: data2D 
+        :param data: data2D
         """
         import time
-        st = time.time()
         # Write the file
         fd = open(filename, 'w')
@@ -66,11 +61,11 @@
         # write qx qy I values
         for i in range(len(data.data)):
-            fd.write("%g  %g  %g\n" % (data.qx_data[i], 
+            fd.write("%g  %g  %g\n" % (data.qx_data[i],
                                         data.qy_data[i],
                                        data.data[i]))
         # close
-        fd.close()                 
-
-    def read(self,filename=None):
+        fd.close()
+
+    def read(self, filename=None):
         """ Read file """
         if not os.path.isfile(filename):
@@ -79,12 +74,13 @@
 
         # Read file
-        f = open(filename,'r')
+        f = open(filename, 'r')
         buf = f.read()
-        f.close()     
+        f.close()
         # Instantiate data object
         output = Data2D()
         output.filename = os.path.basename(filename)
         detector = Detector()
-        if len(output.detector)>0: print str(output.detector[0])
+        if len(output.detector) > 0:
+            print str(output.detector[0])
         output.detector.append(detector)
                 
@@ -92,14 +88,11 @@
         dataStarted = False
         
-        ## Defaults      
+        ## Defaults
         lines = buf.split('\n')
-        itot = 0
         x = []
         y = []
         
-        ncounts = 0
-        
-        wavelength   = None
-        distance     = None
+        wavelength = None
+        distance = None
         transmission = None
         
@@ -107,9 +100,5 @@
         pixel_y = None
         
-        i_x    = 0
-        i_y    = -1
-        pixels = 0
-        
-        isInfo   = False
+        isInfo = False
         isCenter = False
 
@@ -126,5 +115,5 @@
             data_conv_i = Converter('1/cm')
             # Test it
-            data_conv_i(1.0, output.I_unit)            
+            data_conv_i(1.0, output.I_unit)
         
               
@@ -132,6 +121,6 @@
         # to calculate the exact number of data points
         count = 0
-        while (len(lines[len(lines)-(count+1)].lstrip().rstrip()) < 1):
-            del lines[len(lines)-(count+1)]
+        while (len(lines[len(lines) - (count + 1)].lstrip().rstrip()) < 1):
+            del lines[len(lines) - (count + 1)]
             count = count + 1
 
@@ -140,5 +129,5 @@
         # Old version NIST files: 0
         ver = 0
-        for line in lines:      
+        for line in lines:
             line_num += 1
             ## Reading the header applies only to IGOR/NIST 2D q_map data files
@@ -182,5 +171,5 @@
             # Find center info line
             if isCenter:
-                isCenter = False                
+                isCenter = False
                 line_toks = line.split()
                 # Center in bin number
@@ -199,7 +188,7 @@
                 continue
 
-            ## Read and get data.   
+            ## Read and get data.
             if dataStarted == True:
-                line_toks = line.split()              
+                line_toks = line.split()
                 if len(line_toks) == 0:
                     #empty line
@@ -223,7 +212,7 @@
         data_list = data_list.split()
  
-        # Check if the size is consistent with data, otherwise 
+        # Check if the size is consistent with data, otherwise
         #try the tab(\t) separator
-        # (this may be removed once get the confidence 
+        # (this may be removed once get the confidence
         #the former working all cases).
         if len(data_list) != (len(data_lines)) * col_num:
@@ -233,9 +222,9 @@
         # Change it(string) into float
         #data_list = map(float,data_list)
-        data_list1 = map(check_point,data_list)
+        data_list1 = map(check_point, data_list)
 
         # numpy array form
         data_array = numpy.array(data_list1)
-        # Redimesion based on the row_num and col_num, 
+        # Redimesion based on the row_num and col_num,
         #otherwise raise an error.
         try:
@@ -250,5 +239,5 @@
         err_data = numpy.ones(row_num)
         qz_data = numpy.zeros(row_num)
-        mask = numpy.ones(row_num,dtype=bool)
+        mask = numpy.ones(row_num, dtype=bool)
         # Get from the array
         qx_data = data_point[0]
@@ -256,8 +245,12 @@
         data = data_point[2]
         if ver == 1:
-            if col_num > (2 + ver): err_data = data_point[(2 + ver)]
-        if col_num > (3 + ver): qz_data = data_point[(3 + ver)]
-        if col_num > (4 + ver): dqx_data = data_point[(4 + ver)]
-        if col_num > (5 + ver): dqy_data = data_point[(5 + ver)]
+            if col_num > (2 + ver):
+                err_data = data_point[(2 + ver)]
+        if col_num > (3 + ver):
+            qz_data = data_point[(3 + ver)]
+        if col_num > (4 + ver):
+            dqx_data = data_point[(4 + ver)]
+        if col_num > (5 + ver):
+            dqy_data = data_point[(5 + ver)]
         #if col_num > (6 + ver): mask[data_point[(6 + ver)] < 1] = False
         q_data = numpy.sqrt(qx_data*qx_data+qy_data*qy_data+qz_data*qz_data)
@@ -265,11 +258,12 @@
         # Extra protection(it is needed for some data files): 
         # If all mask elements are False, put all True
-        if not mask.any(): mask[mask==False] = True   
+        if not mask.any():
+            mask[mask == False] = True
   
         # Store limits of the image in q space
-        xmin    = numpy.min(qx_data)
-        xmax    = numpy.max(qx_data)
-        ymin    = numpy.min(qy_data)
-        ymax    = numpy.max(qy_data)
+        xmin = numpy.min(qx_data)
+        xmax = numpy.max(qx_data)
+        ymin = numpy.min(qy_data)
+        ymax = numpy.max(qy_data)
 
         # units
@@ -286,23 +280,23 @@
         # calculate the number of pixels in the each axes
         npix_y = math.floor(math.sqrt(len(data)))
-        npix_x = math.floor(len(data)/npix_y)
-        
-        # calculate the size of bins      
-        xstep = x_size/(npix_x-1)
-        ystep = y_size/(npix_y-1)
+        npix_x = math.floor(len(data) / npix_y)
+        
+        # calculate the size of bins
+        xstep = x_size / (npix_x - 1)
+        ystep = y_size / (npix_y - 1)
         
         # store x and y axis bin centers in q space
-        x_bins  = numpy.arange(xmin,xmax+xstep,xstep)
-        y_bins  = numpy.arange(ymin,ymax+ystep,ystep)
+        x_bins = numpy.arange(xmin, xmax + xstep, xstep)
+        y_bins = numpy.arange(ymin, ymax + ystep, ystep)
        
         # get the limits of q values
-        xmin = xmin - xstep/2
-        xmax = xmax + xstep/2
-        ymin = ymin - ystep/2
-        ymax = ymax + ystep/2
-        
-        #Store data in outputs  
-        #TODO: Check the lengths 
-        output.data     = data
+        xmin = xmin - xstep / 2
+        xmax = xmax + xstep / 2
+        ymin = ymin - ystep / 2
+        ymax = ymax + ystep / 2
+        
+        #Store data in outputs
+        #TODO: Check the lengths
+        output.data = data
         if (err_data == 1).all():
             output.err_data = numpy.sqrt(numpy.abs(data))
@@ -311,8 +305,8 @@
             output.err_data = err_data
             
-        output.qx_data  = qx_data
-        output.qy_data  = qy_data             
-        output.q_data   = q_data
-        output.mask     = mask 
+        output.qx_data = qx_data
+        output.qy_data = qy_data
+        output.q_data = q_data
+        output.mask = mask
         
         output.x_bins = x_bins
@@ -334,8 +328,8 @@
         
         # 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 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 len(dqy_data) == len(qy_data) and dqy_data.any()!=0:
+            if len(dqy_data) == len(qy_data) and dqy_data.any() != 0:
                 # Currently we do not support dq parr, perp.
                 # tranfer the comp. to cartesian coord. for newer version.
@@ -346,10 +340,10 @@
                     output.dqx_data = numpy.sqrt((dqx_data * cos_th) * \
                                                  (dqx_data * cos_th) \
-                                                 + ( dqy_data * sin_th) * \
-                                                  ( dqy_data * sin_th))
+                                                 + (dqy_data * sin_th) * \
+                                                  (dqy_data * sin_th))
                     output.dqy_data = numpy.sqrt((dqx_data * sin_th) * \
                                                  (dqx_data * sin_th) \
-                                                 + ( dqy_data * cos_th) * \
-                                                  ( dqy_data * cos_th))
+                                                 + (dqy_data * cos_th) * \
+                                                  (dqy_data * cos_th))
                 else:
                     output.dqx_data = dqx_data
@@ -362,9 +356,9 @@
         else:
             output.xaxis("\\rm{Q_{x}}", 'A^{-1}')
-            output.yaxis("\\rm{Q_{y}}", 'A^{-1}')            
+            output.yaxis("\\rm{Q_{y}}", 'A^{-1}')
         if data_conv_i is not None:
             output.zaxis("\\rm{Intensity}", output.I_unit)
         else:
-            output.zaxis("\\rm{Intensity}","cm^{-1}")
+            output.zaxis("\\rm{Intensity}", "cm^{-1}")
     
         # Store loading process information
@@ -372,8 +366,2 @@
 
         return output
-    
-if __name__ == "__main__": 
-    reader = Reader()
-    print reader.read("../test/exp18_14_igor_2dqxqy.dat") 
-        
-
Index: sansdataloader/src/sans/dataloader/readers/tiff_reader.py
===================================================================
--- sansdataloader/src/sans/dataloader/readers/tiff_reader.py	(revision ad8034f2bbcd87293b219fc00bc095a3f8df9fb6)
+++ sansdataloader/src/sans/dataloader/readers/tiff_reader.py	(revision 7d6351ed3bb9d1bb801111e3d9813fff5b5cf091)
@@ -1,4 +1,2 @@
-
-
 #####################################################################
 #This software was developed by the University of Tennessee as part of the
@@ -9,13 +7,13 @@
 ######################################################################
 """
-    Image reader. Untested. 
+    Image reader. Untested.
 """
-
-
 #TODO: load and check data and orientation of the image (needs rendering)
-
-import math, logging, os
+import math
+import logging
+import os
 import numpy
 from sans.dataloader.data_info import Data2D
+    
     
 class Reader:
@@ -24,5 +22,5 @@
     """
     ## File type
-    type_name = "TIF"   
+    type_name = "TIF"
     ## Wildcards
     type = ["TIF files (*.tif)|*.tif",
@@ -30,5 +28,5 @@
             ]
     ## Extension
-    ext  = ['.tif', '.tiff']    
+    ext = ['.tif', '.tiff']
         
     def read(self, filename=None):
@@ -51,15 +49,15 @@
         try:
             im = Image.open(filename)
-        except :
-            raise  RuntimeError,"cannot open %s"%(filename)
+        except:
+            raise  RuntimeError, "cannot open %s"%(filename)
         data = im.getdata()
 
         # Initiazed the output data object
-        output.data = numpy.zeros([im.size[0],im.size[1]])
-        output.err_data = numpy.zeros([im.size[0],im.size[1]])
+        output.data = numpy.zeros([im.size[0], im.size[1]])
+        output.err_data = numpy.zeros([im.size[0], im.size[1]])
         
-        # Initialize 
+        # Initialize
         x_vals = []
-        y_vals = [] 
+        y_vals = []
 
         # x and y vectors
@@ -79,5 +77,5 @@
             
             # Get bin number
-            if math.fmod(itot, im.size[0])==0:
+            if math.fmod(itot, im.size[0]) == 0:
                 i_x = 0
                 i_y += 1
@@ -85,25 +83,18 @@
                 i_x += 1
                 
-            output.data[im.size[1]-1-i_y][i_x] = value
+            output.data[im.size[1] - 1 - i_y][i_x] = value
             
             itot += 1
                 
-        output.xbins      = im.size[0]
-        output.ybins      = im.size[1]
-        output.x_bins     = x_vals
-        output.y_bins     = y_vals
-        output.xmin       = 0
-        output.xmax       = im.size[0]-1
-        output.ymin       = 0
-        output.ymax       = im.size[0]-1
+        output.xbins = im.size[0]
+        output.ybins = im.size[1]
+        output.x_bins = x_vals
+        output.y_bins = y_vals
+        output.xmin = 0
+        output.xmax = im.size[0] - 1
+        output.ymin = 0
+        output.ymax = im.size[0] - 1
         
         # Store loading process information
-        output.meta_data['loader'] = self.type_name 
+        output.meta_data['loader'] = self.type_name
         return output
-        
-
-if __name__ == "__main__": 
-    reader = Reader()
-    print reader.read("../test/MP_New.sans")
-    
-
