Index: sansview/perspectives/fitting/basepage.py
===================================================================
--- sansview/perspectives/fitting/basepage.py	(revision b324aa9324de278f19e7264b7f4942401a9f39f3)
+++ sansview/perspectives/fitting/basepage.py	(revision e575db9662930b83110efe94cb57f283c0833a4b)
@@ -54,4 +54,5 @@
         ## data
         self.data = None
+        self.mask = None
         self.state = PageState(parent=parent)
         ## dictionary containing list of models
Index: sansview/perspectives/fitting/fitpage.py
===================================================================
--- sansview/perspectives/fitting/fitpage.py	(revision b324aa9324de278f19e7264b7f4942401a9f39f3)
+++ sansview/perspectives/fitting/fitpage.py	(revision e575db9662930b83110efe94cb57f283c0833a4b)
@@ -916,9 +916,5 @@
         qmin,qmax = self.get_range()
         if self.data.__class__.__name__ =="Data2D":
-            for qx in self.data.x_bins:
-                for qy in self.data.y_bins:
-                   if math.sqrt((qx*qx)+(qy*qy)) >= qmin \
-                         and math.sqrt((qx*qx)+(qy*qy)) <= qmax:
-                       npts2fit += 1
+            npts2fit = len(self.data[self.mask])
         else:
             for qx in self.data.x:
@@ -966,7 +962,7 @@
         #Check if chi2 is finite
         if chisqr != None or numpy.isfinite(chisqr):
-        #format chi2
-            npt_fit = float(self.get_npts2fit())   
-            if self.engine_type == "park" and npt_fit > 0:   
+        #format chi2  
+            if self.engine_type == "park" and npt_fit > 0:  
+                npt_fit = float(self.get_npts2fit()) 
                 chisqr =chisqr/npt_fit    
             chi2 = format_number(chisqr)    
@@ -1057,5 +1053,5 @@
 
                                 has_error = True
-            	    i += 1         
+                    i += 1         
         #Show error title when any errors displayed
         if has_error: 
@@ -1086,4 +1082,7 @@
             return
         temp_smearer = None
+        # make sure once more if it is smearer
+        self.smearer = smear_selection(self.data)
+
         if self.enable_smearer.GetValue():
             temp_smearer= self.smearer
Index: sansview/perspectives/fitting/fitting.py
===================================================================
--- sansview/perspectives/fitting/fitting.py	(revision b324aa9324de278f19e7264b7f4942401a9f39f3)
+++ sansview/perspectives/fitting/fitting.py	(revision e575db9662930b83110efe94cb57f283c0833a4b)
@@ -965,46 +965,78 @@
         
         detector = Detector()
-        theory.detector.append(detector) 
-            
-        theory.detector[0].distance=1e+32
+        theory.detector.append(detector)         
         theory.source= Source()
-        theory.source.wavelength=2*math.pi/1e+32
-      
-        ## Create detector for Model 2D
-        xmax=2*theory.detector[0].distance*math.atan(\
-                            qmax/(4*math.pi/theory.source.wavelength))
-        
-        theory.detector[0].pixel_size.x= xmax/(qstep/2-0.5)
-        theory.detector[0].pixel_size.y= xmax/(qstep/2-0.5)
+        
+        ## Default values    
+        theory.detector[0].distance= 8000   # mm        
+        theory.source.wavelength= 6         # A      
+        theory.detector[0].pixel_size.x= 5  # mm
+        theory.detector[0].pixel_size.y= 5  # mm
+        
         theory.detector[0].beam_center.x= qmax
         theory.detector[0].beam_center.y= qmax
+        
+        
         ## create x_bins and y_bins of the model 2D
-        distance   = theory.detector[0].distance
-        pixel      = qstep/2-1
-        theta      = pixel / distance / qstep#100.0
-        wavelength = theory.source.wavelength
         pixel_width_x = theory.detector[0].pixel_size.x
         pixel_width_y = theory.detector[0].pixel_size.y
         center_x      = theory.detector[0].beam_center.x/pixel_width_x
         center_y      = theory.detector[0].beam_center.y/pixel_width_y
-        
-        
-        size_x, size_y= numpy.shape(theory.data)
-        for i_x in range(size_x):
-            theta = (i_x-center_x)*pixel_width_x / distance 
-            qx = 4.0*math.pi/wavelength * math.tan(theta/2.0)
-            theory.x_bins.append(qx)    
-        for i_y in range(size_y):
-            theta = (i_y-center_y)*pixel_width_y / distance 
-            qy =4.0*math.pi/wavelength * math.tan(theta/2.0)
-            theory.y_bins.append(qy)
-           
+
+        # theory default: assume the beam center is located at the center of sqr detector
+        xmax = qmax
+        xmin = -qmax
+        ymax = qmax
+        ymin = -qmax
+        
+        x=  numpy.linspace(start= -1*qmax,
+                               stop= qmax,
+                               num= qstep,
+                               endpoint=True )  
+        y = numpy.linspace(start= -1*qmax,
+                               stop= qmax,
+                               num= qstep,
+                               endpoint=True )
+         
+        ## use data info instead
+        new_x = numpy.tile(x, (len(y),1))
+        new_y = numpy.tile(y, (len(x),1))
+        new_y = new_y.swapaxes(0,1)
+        
+        # all data reuire now in 1d array
+        qx_data = new_x.flatten()
+        qy_data = new_y.flatten()
+        
+        q_data = numpy.sqrt(qx_data*qx_data+qy_data*qy_data)
+        # set all True (standing for unmasked) as default
+        mask    = numpy.ones(len(qx_data), dtype = bool)
+        
+        # calculate the range of qx and qy: this way, it is a little more independent
+        x_size = xmax- xmin
+        y_size = ymax -ymin
+        
+        # store x and y bin centers in q space
+        x_bins  = x
+        y_bins  = y 
+        # bin size: x- & y-directions
+        xstep = x_size/len(x_bins-1)
+        ystep = y_size/len(y_bins-1)
+        
+        #theory.data = numpy.zeros(len(mask))
+        theory.err_data = numpy.zeros(len(mask))
+        theory.qx_data = qx_data 
+        theory.qy_data = qy_data  
+        theory.q_data = q_data 
+        theory.mask = mask            
+        theory.x_bins = x_bins  
+        theory.y_bins = y_bins   
+        
+        # max and min taking account of the bin sizes
+        theory.xmin= xmin - xstep/2
+        theory.xmax= xmax + xstep/2
+        theory.ymin= ymin - ystep/2
+        theory.ymax= ymax + ystep/2
         theory.group_id ="Model"
         theory.id ="Model"
-        ## determine plot boundaries
-        theory.xmin= -qmax
-        theory.xmax= qmax
-        theory.ymin= -qmax
-        theory.ymax= qmax
         
         
@@ -1103,4 +1135,9 @@
             theory.source= data.source
             theory.is_data =False 
+            theory.qx_data = data.qx_data
+            theory.qy_data = data.qy_data
+            theory.q_data = data.q_data
+            theory.err_data = data.err_data
+            theory.mask = data.mask
             ## plot boundaries
             theory.ymin= data.ymin
@@ -1151,5 +1188,5 @@
                 x= data.x_bins
                 y= data.y_bins
-            
+                
         if not enable2D:
             return
Index: sansview/perspectives/fitting/model_thread.py
===================================================================
--- sansview/perspectives/fitting/model_thread.py	(revision e627f19c6e24db3d16d07d2479225f700cc16be5)
+++ sansview/perspectives/fitting/model_thread.py	(revision e575db9662930b83110efe94cb57f283c0833a4b)
@@ -25,12 +25,7 @@
         self.qmax= qmax
         self.qstep= qstep
-        # Reshape dimensions of x and y to call evalDistribution
-        #self.x_array = numpy.reshape(x,[len(x),1])
-        #self.y_array = numpy.reshape(y,[1,len(y)])
-        self.x_array = numpy.reshape(x,[1,len(x)])
-        self.y_array = numpy.reshape(y,[len(y),1])
-        # Numpy array of dimensions 1 used for model.run method
-        self.x= numpy.array(x)
-        self.y= numpy.array(y)
+
+        self.x = x
+        self.y = y
         self.data= data
         # the model on to calculate
@@ -51,22 +46,47 @@
                 newy= math.pow(max(math.fabs(self.data.ymax),math.fabs(self.data.ymin)),2)
                 self.qmax=math.sqrt( newx + newy )
-        # Define matrix where data will be plotted        
-        radius= numpy.sqrt( self.x_array**2 + self.y_array**2 )
-        index_data= (self.qmin<= radius)
-        index_model = (self.qmin <= radius)&(radius<= self.qmax)
-       
-        output = numpy.zeros((len(self.x),len(self.y)))
-     
-        ## receive only list of 2 numpy array 
-        ## One must reshape to vertical and the other to horizontal
-        value = self.model.evalDistribution([self.x_array,self.y_array] )
-        ## for data ignore the qmax 
-        if self.data == None:
+        
+        if self.data != None:
+            self.qx_data = self.data.qx_data
+            self.qy_data = self.data.qy_data
+            self.mask    = self.data.mask
+        else:          
+            xbin =  numpy.linspace(start= -1*self.qmax,
+                                   stop= self.qmax,
+                                   num= self.qstep,
+                                   endpoint=True )  
+            ybin = numpy.linspace(start= -1*self.qmax,
+                                   stop= self.qmax,
+                                   num= self.qstep,
+                                   endpoint=True )            
+            
+            new_xbin = numpy.tile(xbin, (len(ybin),1))
+            new_ybin = numpy.tile(ybin, (len(xbin),1))
+            new_ybin = new_ybin.swapaxes(0,1)
+            new_xbin = new_xbin.flatten()
+            new_ybin = new_ybin.flatten()
+            self.qy_data = new_ybin
+            self.qx_data = new_xbin
+           
+            self.mask = numpy.ones(len(self.qx_data),dtype=bool)
+            
+        # Define matrix where data will be plotted    
+        radius= numpy.sqrt( self.qx_data*self.qx_data + self.qy_data*self.qy_data )
+        index_data= (self.qmin<= radius)&(self.mask)
+        
+        # For theory, qmax is based on 1d qmax 
+        # so that must be mulitified by sqrt(2) to get actual max for 2d
+        index_model = ((self.qmin <= radius)&(radius<= self.qmax))
+        self.mask = (index_model)&(self.mask)
+        
+        if self.data ==None:
             # Only qmin value will be consider for the detector
-            output = value *index_data  
-        else:
-            # The user can define qmin and qmax for the detector
-            output = index_model*value
-      
+            self.mask = index_data  
+             
+        value = self.model.evalDistribution([self.qx_data[self.mask],self.qy_data[self.mask]] )
+
+        output = numpy.zeros(len(self.mask))
+        output[self.mask] = value 
+
         elapsed = time.time()-self.starttime
         self.complete( image = output,
@@ -75,5 +95,5 @@
                        elapsed = elapsed,
                        qmin = self.qmin,
-                       qmax =self.qmax,
+                       qmax = self.qmax,
                        qstep = self.qstep )
         
