Index: sansrealspace/src/realspace/VolumeCanvas.py
===================================================================
--- sansrealspace/src/realspace/VolumeCanvas.py	(revision 3c7569637575e6744d9806b177d81106617f5924)
+++ sansrealspace/src/realspace/VolumeCanvas.py	(revision a2c1196ad8c06b1343cc4c9c510c9764628d9da2)
@@ -551,11 +551,11 @@
             raise ValueError, "runXY(q): bad type for q"
     
-        
-    def getIq2D(self, qx, qy):
+    def _create_modelObject(self):
         """
             Returns simulate I(q) for given q_x and q_y values.
+            Also returns model object
             @param qx: q_x [A-1]
             @param qy: q_y [A-1]
-            @return: I(q) [cm-1]
+            @return: I(q) [cm-1], model object
         """
         # To find a complete example of the correct call order:
@@ -581,7 +581,16 @@
         #pointsmodelpy.get_lorespoints(self.lores_model, self.points)
         self.npts = pointsmodelpy.get_complexpoints(self.complex_model, self.points)
+        
+        
+    def getIq2D(self, qx, qy):
+        """
+            Returns simulate I(q) for given q_x and q_y values.
+            @param qx: q_x [A-1]
+            @param qy: q_y [A-1]
+            @return: I(q) [cm-1]
+        """
+        self._create_modelObject()
                 
         norm =  1.0e8/self.params['lores_density']*self.params['scale']
-        #return norm*pointsmodelpy.get_lores_i(self.lores_model, q)
         return norm*pointsmodelpy.get_complex_iq_2D(self.complex_model, self.points, qx, qy)\
             + self.params['background']
@@ -624,5 +633,5 @@
             self.getPr()
 
-        # By dividing by the density instead of the actuall V/N, 
+        # By dividing by the density instead of the actual V/N, 
         # we have an uncertainty of +-1 on N because the number 
         # of points chosen for the simulation is int(density*volume).
@@ -653,3 +662,32 @@
         simerr = 2*val/self.npts
         return val, err+simerr
-        
+
+    def getIq2DError(self, qx, qy):
+        """
+            Return the simulated value along with its estimated
+            error for a given q-value
+            
+            Propagation of errors is used to evaluate the
+            uncertainty.
+            
+            @param q: q-value [float]
+            @return: mean, error [float, float]
+        """
+        self._create_modelObject()
+                
+        norm =  1.0e8/self.params['lores_density']*self.params['scale']
+        val = norm*pointsmodelpy.get_complex_iq_2D(self.complex_model, self.points, qx, qy)\
+            + self.params['background']
+        
+        # Simulation error (statistical)
+        norm =  1.0e8/self.params['lores_density']*self.params['scale'] \
+                * math.pow(self.npts/self.params['lores_density'], 1.0/3.0)/self.npts
+        err = norm*pointsmodelpy.get_complex_iq_2D_err(self.complex_model, self.points, qx, qy)
+        # Error on V/N
+        simerr = 2*val/self.npts
+        
+        # The error used for the position is over-simplified.
+        # The actual error was empirically found to be about
+        # an order of magnitude larger.
+        return val, 10.0*err+simerr
+        
Index: sansrealspace/src/realspace/test/coreshell_d=0.01_Iq.txt
===================================================================
--- sansrealspace/src/realspace/test/coreshell_d=0.01_Iq.txt	(revision a2c1196ad8c06b1343cc4c9c510c9764628d9da2)
+++ sansrealspace/src/realspace/test/coreshell_d=0.01_Iq.txt	(revision a2c1196ad8c06b1343cc4c9c510c9764628d9da2)
@@ -0,0 +1,52 @@
+PARS: {'core_sld': 1.0, 'thickness': 5, 'solvent_sld': 0.0, 'scale': 1.0, 'radius': 15, 'background': 0.0, 'shell_sld': -0.7297297297297296}
+<q>  <ana>  <sim>  <err>
+0.001  546.461  9.78363e+006  1.51638e+009
+0.0213878  1.12037e+008  6.28976e+007  1.78903e+010
+0.0417755  1.5392e+009  1.69459e+009  4.9295e+010
+0.0621633  6.85689e+009  1.68046e+010  1.20691e+011
+0.082551  1.86312e+010  2.72164e+009  4.8322e+010
+0.102939  3.77797e+010  4.99703e+010  2.56606e+011
+0.123327  6.25086e+010  5.49159e+010  3.08699e+011
+0.143714  8.83525e+010  5.79293e+010  3.03282e+011
+0.164102  1.09375e+011  6.81951e+010  3.68556e+011
+0.18449  1.20102e+011  9.11503e+010  3.94774e+011
+0.204878  1.17429e+011  7.5517e+010  3.66396e+011
+0.225265  1.01772e+011  7.55982e+010  3.57809e+011
+0.245653  7.69907e+010  6.76884e+010  3.33057e+011
+0.266041  4.91381e+010  5.46391e+010  3.059e+011
+0.286429  2.4505e+010  2.91311e+010  2.09596e+011
+0.306816  7.70105e+009  1.50421e+010  1.55602e+011
+0.327204  4.46446e+008  7.73594e+009  1.16253e+011
+0.347592  1.44323e+009  6.61388e+009  1.09883e+011
+0.36798  7.26659e+009  2.67697e+010  2.10412e+011
+0.388367  1.38447e+010  6.69746e+009  1.06623e+011
+0.408755  1.79268e+010  3.57793e+010  2.45747e+011
+0.429143  1.80167e+010  1.74915e+010  1.64273e+011
+0.449531  1.45166e+010  4.17646e+010  2.77463e+011
+0.469918  9.15928e+009  1.74956e+010  1.65486e+011
+0.490306  4.06238e+009  1.68219e+010  1.68458e+011
+0.510694  8.28382e+008  1.17877e+010  1.43717e+011
+0.531082  2.58879e+007  1.31559e+010  1.47206e+011
+0.551469  1.17967e+009  3.78552e+010  2.485e+011
+0.571857  3.17457e+009  1.55803e+009  5.10627e+010
+0.592245  4.83142e+009  4.67277e+008  2.68516e+010
+0.612633  5.38985e+009  9.99761e+009  1.34718e+011
+0.63302  4.72163e+009  1.66971e+010  1.63231e+011
+0.653408  3.24255e+009  1.72664e+010  1.69255e+011
+0.673796  1.62119e+009  1.31521e+009  4.73275e+010
+0.694184  4.47037e+008  5.66857e+009  9.38055e+010
+0.714571  4.15178e+006  2.84074e+006  2.15692e+009
+0.734959  2.21749e+008  1.87719e+009  5.37223e+010
+0.755347  7.83703e+008  8.17585e+008  3.53672e+010
+0.775735  1.31559e+009  8.3075e+009  1.18316e+011
+0.796122  1.55288e+009  4.67401e+009  8.6085e+010
+0.81651  1.42344e+009  7.90246e+009  1.1491e+011
+0.836898  1.02948e+009  1.32814e+010  1.49737e+011
+0.857286  5.60678e+008  1.64135e+009  5.14098e+010
+0.877673  1.92343e+008  2.57106e+010  1.95691e+011
+0.898061  1.59082e+007  1.28795e+009  4.60586e+010
+0.918449  2.32131e+007  8.75344e+009  1.21031e+011
+0.938837  1.3713e+008  5.01801e+009  9.18403e+010
+0.959224  2.62821e+008  9.89061e+008  3.77781e+010
+0.979612  3.31767e+008  8.83918e+009  1.23905e+011
+1  3.21634e+008  1.11387e+010  1.3461e+011
Index: sansrealspace/src/realspace/test/coreshell_d=0.01_Iq2D.txt
===================================================================
--- sansrealspace/src/realspace/test/coreshell_d=0.01_Iq2D.txt	(revision a2c1196ad8c06b1343cc4c9c510c9764628d9da2)
+++ sansrealspace/src/realspace/test/coreshell_d=0.01_Iq2D.txt	(revision a2c1196ad8c06b1343cc4c9c510c9764628d9da2)
@@ -0,0 +1,52 @@
+PARS: {'core_sld': 1.0, 'thickness': 5, 'solvent_sld': 0.0, 'scale': 1.0, 'radius': 15, 'background': 0.0, 'shell_sld': -0.7297297297297296}
+<q>  <ana>  <sim>  <err>
+0.001  546.461  1.21638e+008  1.2016e+009
+0.0213878  1.12037e+008  1.2839e+009  1.59299e+010
+0.0417755  1.5392e+009  3.93595e+009  7.8457e+010
+0.0621633  6.85689e+009  5.88314e+009  5.73483e+010
+0.082551  1.86312e+010  1.98724e+010  1.35924e+011
+0.102939  3.77797e+010  3.44297e+010  2.06274e+011
+0.123327  6.25086e+010  6.59725e+010  3.26031e+011
+0.143714  8.83525e+010  8.7311e+010  4.15349e+011
+0.164102  1.09375e+011  1.09368e+011  4.35735e+011
+0.18449  1.20102e+011  1.19377e+011  4.69383e+011
+0.204878  1.17429e+011  1.53161e+011  4.83084e+011
+0.225265  1.01772e+011  1.46379e+011  4.89614e+011
+0.245653  7.69907e+010  9.38531e+010  3.94462e+011
+0.266041  4.91381e+010  4.74658e+010  2.91893e+011
+0.286429  2.4505e+010  3.21805e+010  2.38203e+011
+0.306816  7.70105e+009  2.36014e+010  1.97419e+011
+0.327204  4.46446e+008  1.07878e+009  4.06772e+010
+0.347592  1.44323e+009  6.93473e+009  1.02155e+011
+0.36798  7.26659e+009  3.49299e+009  7.28129e+010
+0.388367  1.38447e+010  3.30173e+009  7.40374e+010
+0.408755  1.79268e+010  1.39599e+009  4.57608e+010
+0.429143  1.80167e+010  4.60742e+010  2.8027e+011
+0.449531  1.45166e+010  1.72552e+010  1.69762e+011
+0.469918  9.15928e+009  3.05415e+009  6.99179e+010
+0.490306  4.06238e+009  5.27682e+009  9.70532e+010
+0.510694  8.28382e+008  2.06999e+010  1.83338e+011
+0.531082  2.58879e+007  3.40593e+009  7.47703e+010
+0.551469  1.17967e+009  3.18486e+008  2.27763e+010
+0.571857  3.17457e+009  1.49177e+010  1.60638e+011
+0.592245  4.83142e+009  6.36589e+008  3.27628e+010
+0.612633  5.38985e+009  1.05704e+010  1.30789e+011
+0.63302  4.72163e+009  3.47806e+009  7.35678e+010
+0.653408  3.24255e+009  1.51278e+010  1.5752e+011
+0.673796  1.62119e+009  1.49976e+009  4.91816e+010
+0.694184  4.47037e+008  5.02124e+009  9.0916e+010
+0.714571  4.15178e+006  7.49138e+008  3.53079e+010
+0.734959  2.21749e+008  9.49262e+008  4.19363e+010
+0.755347  7.83703e+008  2.54424e+008  2.09059e+010
+0.775735  1.31559e+009  1.64014e+010  1.63377e+011
+0.796122  1.55288e+009  2.75212e+009  6.93338e+010
+0.81651  1.42344e+009  1.74937e+010  1.58982e+011
+0.836898  1.02948e+009  6.4384e+009  1.00077e+011
+0.857286  5.60678e+008  2.88601e+009  6.78735e+010
+0.877673  1.92343e+008  1.37891e+010  1.48133e+011
+0.898061  1.59082e+007  2.32365e+009  6.28421e+010
+0.918449  2.32131e+007  3.88396e+009  7.84832e+010
+0.938837  1.3713e+008  2.61822e+008  1.96818e+010
+0.959224  2.62821e+008  5.22131e+009  9.49729e+010
+0.979612  3.31767e+008  7.55844e+009  1.10645e+011
+1  3.21634e+008  3.78722e+009  7.73818e+010
Index: sansrealspace/src/realspace/test/coreshell_d=0.1_Iq2D.txt
===================================================================
--- sansrealspace/src/realspace/test/coreshell_d=0.1_Iq2D.txt	(revision a2c1196ad8c06b1343cc4c9c510c9764628d9da2)
+++ sansrealspace/src/realspace/test/coreshell_d=0.1_Iq2D.txt	(revision a2c1196ad8c06b1343cc4c9c510c9764628d9da2)
@@ -0,0 +1,52 @@
+PARS: {'core_sld': 1.0, 'thickness': 5, 'solvent_sld': 0.0, 'scale': 1.0, 'radius': 15, 'background': 0.0, 'shell_sld': -0.7297297297297296}
+<q>  <ana>  <sim>  <err>
+0.001  546.461  6.9305e+006  6.35698e+006
+0.0213878  1.12037e+008  1.68978e+008  3.70253e+008
+0.0417755  1.5392e+009  1.07256e+009  2.0699e+009
+0.0621633  6.85689e+009  3.87464e+009  5.10377e+009
+0.082551  1.86312e+010  1.90073e+010  1.22829e+010
+0.102939  3.77797e+010  3.87483e+010  2.21376e+010
+0.123327  6.25086e+010  6.47701e+010  3.26543e+010
+0.143714  8.83525e+010  9.2365e+010  4.20165e+010
+0.164102  1.09375e+011  1.01115e+011  4.31731e+010
+0.18449  1.20102e+011  1.00671e+011  4.34356e+010
+0.204878  1.17429e+011  1.30585e+011  4.69878e+010
+0.225265  1.01772e+011  1.15828e+011  4.29907e+010
+0.245653  7.69907e+010  6.55518e+010  3.18003e+010
+0.266041  4.91381e+010  4.86895e+010  2.84409e+010
+0.286429  2.4505e+010  2.54433e+010  2.05071e+010
+0.306816  7.70105e+009  3.90553e+009  8.0109e+009
+0.327204  4.46446e+008  1.80111e+009  5.47593e+009
+0.347592  1.44323e+009  2.19471e+009  5.98723e+009
+0.36798  7.26659e+009  1.60673e+010  1.60877e+010
+0.388367  1.38447e+010  8.31296e+009  1.19335e+010
+0.408755  1.79268e+010  1.87001e+010  1.7552e+010
+0.429143  1.80167e+010  1.53246e+010  1.5979e+010
+0.449531  1.45166e+010  8.46704e+009  1.19446e+010
+0.469918  9.15928e+009  1.00565e+010  1.31606e+010
+0.490306  4.06238e+009  6.87222e+009  1.07643e+010
+0.510694  8.28382e+008  1.84683e+009  5.53302e+009
+0.531082  2.58879e+007  4.88396e+009  8.81205e+009
+0.551469  1.17967e+009  1.42076e+009  4.90195e+009
+0.571857  3.17457e+009  1.04674e+009  4.10931e+009
+0.592245  4.83142e+009  5.16756e+009  9.36037e+009
+0.612633  5.38985e+009  4.74891e+009  8.97335e+009
+0.63302  4.72163e+009  5.0429e+009  9.17435e+009
+0.653408  3.24255e+009  3.08742e+009  7.21224e+009
+0.673796  1.62119e+009  9.22474e+008  3.83059e+009
+0.694184  4.47037e+008  2.73855e+009  6.84996e+009
+0.714571  4.15178e+006  1.72505e+009  5.33631e+009
+0.734959  2.21749e+008  8.84279e+008  3.82889e+009
+0.755347  7.83703e+008  2.01607e+008  1.8597e+009
+0.775735  1.31559e+009  9.57234e+008  3.9553e+009
+0.796122  1.55288e+009  7.10999e+008  3.44087e+009
+0.81651  1.42344e+009  3.59538e+009  7.65374e+009
+0.836898  1.02948e+009  2.65828e+009  6.6712e+009
+0.857286  5.60678e+008  9.80808e+008  3.98234e+009
+0.877673  1.92343e+008  2.0201e+009  5.84993e+009
+0.898061  1.59082e+007  7.41857e+008  3.52562e+009
+0.918449  2.32131e+007  1.37519e+009  4.77188e+009
+0.938837  1.3713e+008  4.37348e+008  2.69662e+009
+0.959224  2.62821e+008  3.00008e+009  7.22066e+009
+0.979612  3.31767e+008  1.17961e+009  4.38027e+009
+1  3.21634e+008  1.71936e+007  5.35703e+008
Index: sansrealspace/src/realspace/test/coreshell_d=10_Iq2D.txt
===================================================================
--- sansrealspace/src/realspace/test/coreshell_d=10_Iq2D.txt	(revision a2c1196ad8c06b1343cc4c9c510c9764628d9da2)
+++ sansrealspace/src/realspace/test/coreshell_d=10_Iq2D.txt	(revision a2c1196ad8c06b1343cc4c9c510c9764628d9da2)
@@ -0,0 +1,52 @@
+PARS: {'core_sld': 1.0, 'thickness': 5, 'solvent_sld': 0.0, 'scale': 1.0, 'radius': 15, 'background': 0.0, 'shell_sld': -0.7297297297297296}
+<q>  <ana>  <sim>  <err>
+0.001  546.461  1.8291e+006  11016.1
+0.0213878  1.12037e+008  1.42867e+008  1.05964e+006
+0.0417755  1.5392e+009  1.56655e+009  1.14044e+007
+0.0621633  6.85689e+009  6.92762e+009  4.75868e+007
+0.082551  1.86312e+010  1.86485e+010  1.18483e+008
+0.102939  3.77797e+010  3.75096e+010  2.15985e+008
+0.123327  6.25086e+010  6.21069e+010  3.19636e+008
+0.143714  8.83525e+010  8.81222e+010  4.03087e+008
+0.164102  1.09375e+011  1.09753e+011  4.5117e+008
+0.18449  1.20102e+011  1.18811e+011  4.60297e+008
+0.204878  1.17429e+011  1.1731e+011  4.44316e+008
+0.225265  1.01772e+011  1.0078e+011  4.04571e+008
+0.245653  7.69907e+010  7.7844e+010  3.54115e+008
+0.266041  4.91381e+010  5.09974e+010  2.87986e+008
+0.286429  2.4505e+010  2.43381e+010  2.01105e+008
+0.306816  7.70105e+009  7.90615e+009  1.14903e+008
+0.327204  4.46446e+008  4.35924e+008  2.68936e+007
+0.347592  1.44323e+009  1.31768e+009  4.65984e+007
+0.36798  7.26659e+009  7.2098e+009  1.08625e+008
+0.388367  1.38447e+010  1.416e+010  1.52243e+008
+0.408755  1.79268e+010  1.80501e+010  1.72569e+008
+0.429143  1.80167e+010  1.82662e+010  1.7423e+008
+0.449531  1.45166e+010  1.42902e+010  1.54731e+008
+0.469918  9.15928e+009  9.60124e+009  1.26591e+008
+0.490306  4.06238e+009  3.93192e+009  8.05645e+007
+0.510694  8.28382e+008  7.73975e+008  3.56698e+007
+0.531082  2.58879e+007  1.53155e+007  4.99069e+006
+0.551469  1.17967e+009  1.38782e+009  4.75815e+007
+0.571857  3.17457e+009  3.39492e+009  7.46843e+007
+0.592245  4.83142e+009  4.93922e+009  9.03765e+007
+0.612633  5.38985e+009  5.62586e+009  9.68723e+007
+0.63302  4.72163e+009  4.21189e+009  8.39065e+007
+0.653408  3.24255e+009  2.83436e+009  6.86054e+007
+0.673796  1.62119e+009  1.70737e+009  5.32202e+007
+0.694184  4.47037e+008  4.48008e+008  2.71052e+007
+0.714571  4.15178e+006  2.87201e+007  6.87056e+006
+0.734959  2.21749e+008  2.18013e+008  1.89799e+007
+0.755347  7.83703e+008  6.38498e+008  3.24592e+007
+0.775735  1.31559e+009  1.36715e+009  4.76742e+007
+0.796122  1.55288e+009  1.55422e+009  5.0809e+007
+0.81651  1.42344e+009  1.17056e+009  4.40303e+007
+0.836898  1.02948e+009  1.30272e+009  4.64514e+007
+0.857286  5.60678e+008  5.85392e+008  3.10908e+007
+0.877673  1.92343e+008  2.47972e+008  2.01745e+007
+0.898061  1.59082e+007  1.01612e+007  4.0982e+006
+0.918449  2.32131e+007  5.18427e+007  9.24602e+006
+0.938837  1.3713e+008  1.54162e+008  1.59867e+007
+0.959224  2.62821e+008  3.74191e+008  2.48221e+007
+0.979612  3.31767e+008  2.79885e+008  2.15031e+007
+1  3.21634e+008  2.75996e+008  2.13277e+007
Index: sansrealspace/src/realspace/test/coreshell_d=20_Iq2D.txt
===================================================================
--- sansrealspace/src/realspace/test/coreshell_d=20_Iq2D.txt	(revision a2c1196ad8c06b1343cc4c9c510c9764628d9da2)
+++ sansrealspace/src/realspace/test/coreshell_d=20_Iq2D.txt	(revision a2c1196ad8c06b1343cc4c9c510c9764628d9da2)
@@ -0,0 +1,52 @@
+PARS: {'core_sld': 1.0, 'thickness': 5, 'solvent_sld': 0.0, 'scale': 1.0, 'radius': 15, 'background': 0.0, 'shell_sld': -0.7297297297297296}
+<q>  <ana>  <sim>  <err>
+0.001  546.461  1.15222e+006  5725.74
+0.0213878  1.12037e+008  1.22579e+008  972912
+0.0417755  1.5392e+009  1.65915e+009  5.90146e+006
+0.0621633  6.85689e+009  7.03626e+009  2.4005e+007
+0.082551  1.86312e+010  1.88339e+010  5.95793e+007
+0.102939  3.77797e+010  3.80021e+010  1.08655e+008
+0.123327  6.25086e+010  6.26906e+010  1.60378e+008
+0.143714  8.83525e+010  8.87598e+010  2.02532e+008
+0.164102  1.09375e+011  1.08325e+011  2.244e+008
+0.18449  1.20102e+011  1.20458e+011  2.31223e+008
+0.204878  1.17429e+011  1.17239e+011  2.22381e+008
+0.225265  1.01772e+011  1.03154e+011  2.04254e+008
+0.245653  7.69907e+010  7.80216e+010  1.77101e+008
+0.266041  4.91381e+010  4.94439e+010  1.41966e+008
+0.286429  2.4505e+010  2.50411e+010  1.01809e+008
+0.306816  7.70105e+009  7.51734e+009  5.59675e+007
+0.327204  4.46446e+008  4.36517e+008  1.3483e+007
+0.347592  1.44323e+009  1.47752e+009  2.46922e+007
+0.36798  7.26659e+009  7.39652e+009  5.49751e+007
+0.388367  1.38447e+010  1.41522e+010  7.6106e+007
+0.408755  1.79268e+010  1.7874e+010  8.58976e+007
+0.429143  1.80167e+010  1.80037e+010  8.65589e+007
+0.449531  1.45166e+010  1.42603e+010  7.717e+007
+0.469918  9.15928e+009  8.78846e+009  6.0712e+007
+0.490306  4.06238e+009  4.2486e+009  4.19399e+007
+0.510694  8.28382e+008  8.00143e+008  1.81116e+007
+0.531082  2.58879e+007  6.73064e+006  1.65766e+006
+0.551469  1.17967e+009  1.14883e+009  2.16792e+007
+0.571857  3.17457e+009  3.11495e+009  3.57412e+007
+0.592245  4.83142e+009  5.07361e+009  4.59031e+007
+0.612633  5.38985e+009  5.46415e+009  4.77128e+007
+0.63302  4.72163e+009  4.77654e+009  4.46111e+007
+0.653408  3.24255e+009  3.19319e+009  3.64724e+007
+0.673796  1.62119e+009  1.48657e+009  2.47478e+007
+0.694184  4.47037e+008  4.63526e+008  1.37879e+007
+0.714571  4.15178e+006  1.3219e+006  742295
+0.734959  2.21749e+008  2.16977e+008  9.44449e+006
+0.755347  7.83703e+008  8.60571e+008  1.88503e+007
+0.775735  1.31559e+009  1.42564e+009  2.42762e+007
+0.796122  1.55288e+009  1.52242e+009  2.51306e+007
+0.81651  1.42344e+009  1.25803e+009  2.28049e+007
+0.836898  1.02948e+009  1.23565e+009  2.26009e+007
+0.857286  5.60678e+008  5.01314e+008  1.43695e+007
+0.877673  1.92343e+008  1.57459e+008  8.05352e+006
+0.898061  1.59082e+007  2.31014e+007  3.09074e+006
+0.918449  2.32131e+007  4.63237e+006  1.3823e+006
+0.938837  1.3713e+008  1.50965e+008  7.91162e+006
+0.959224  2.62821e+008  3.0305e+008  1.11885e+007
+0.979612  3.31767e+008  3.22573e+008  1.15534e+007
+1  3.21634e+008  2.61916e+008  1.03893e+007
Index: sansrealspace/src/realspace/test/coreshell_d=5_Iq2D.txt
===================================================================
--- sansrealspace/src/realspace/test/coreshell_d=5_Iq2D.txt	(revision a2c1196ad8c06b1343cc4c9c510c9764628d9da2)
+++ sansrealspace/src/realspace/test/coreshell_d=5_Iq2D.txt	(revision a2c1196ad8c06b1343cc4c9c510c9764628d9da2)
@@ -0,0 +1,52 @@
+PARS: {'core_sld': 1.0, 'thickness': 5, 'solvent_sld': 0.0, 'scale': 1.0, 'radius': 15, 'background': 0.0, 'shell_sld': -0.7297297297297296}
+<q>  <ana>  <sim>  <err>
+0.001  546.461  47787.2  18653.3
+0.0213878  1.12037e+008  6.52179e+007  1.3764e+006
+0.0417755  1.5392e+009  1.44223e+009  2.21783e+007
+0.0621633  6.85689e+009  7.20904e+009  9.76105e+007
+0.082551  1.86312e+010  1.91008e+010  2.40753e+008
+0.102939  3.77797e+010  3.81118e+010  4.35188e+008
+0.123327  6.25086e+010  6.27312e+010  6.40772e+008
+0.143714  8.83525e+010  8.96516e+010  8.15055e+008
+0.164102  1.09375e+011  1.09255e+011  9.06679e+008
+0.18449  1.20102e+011  1.20694e+011  9.26622e+008
+0.204878  1.17429e+011  1.19804e+011  8.97211e+008
+0.225265  1.01772e+011  1.00669e+011  8.11389e+008
+0.245653  7.69907e+010  7.93911e+010  7.15105e+008
+0.266041  4.91381e+010  4.72989e+010  5.5592e+008
+0.286429  2.4505e+010  2.33427e+010  3.92859e+008
+0.306816  7.70105e+009  7.12407e+009  2.181e+008
+0.327204  4.46446e+008  6.25023e+008  6.43552e+007
+0.347592  1.44323e+009  1.33499e+009  9.376e+007
+0.36798  7.26659e+009  7.32794e+009  2.18939e+008
+0.388367  1.38447e+010  1.45087e+010  3.07687e+008
+0.408755  1.79268e+010  1.75176e+010  3.39799e+008
+0.429143  1.80167e+010  1.7349e+010  3.40499e+008
+0.449531  1.45166e+010  1.54066e+010  3.21199e+008
+0.469918  9.15928e+009  8.6321e+009  2.40258e+008
+0.490306  4.06238e+009  4.39657e+009  1.70859e+008
+0.510694  8.28382e+008  7.63671e+008  7.07651e+007
+0.531082  2.58879e+007  3.75936e+007  1.56903e+007
+0.551469  1.17967e+009  8.05605e+008  7.25129e+007
+0.571857  3.17457e+009  2.57005e+009  1.30117e+008
+0.592245  4.83142e+009  5.23706e+009  1.86784e+008
+0.612633  5.38985e+009  4.35429e+009  1.70916e+008
+0.63302  4.72163e+009  5.08359e+009  1.84484e+008
+0.653408  3.24255e+009  3.00826e+009  1.41533e+008
+0.673796  1.62119e+009  2.1508e+009  1.19144e+008
+0.694184  4.47037e+008  3.05289e+008  4.47605e+007
+0.714571  4.15178e+006  1.87591e+007  1.11599e+007
+0.734959  2.21749e+008  1.76982e+008  3.42118e+007
+0.755347  7.83703e+008  6.74246e+008  6.66859e+007
+0.775735  1.31559e+009  1.33327e+009  9.38255e+007
+0.796122  1.55288e+009  1.47054e+009  9.89272e+007
+0.81651  1.42344e+009  1.39127e+009  9.63056e+007
+0.836898  1.02948e+009  1.30233e+009  9.27107e+007
+0.857286  5.60678e+008  5.9545e+008  6.2795e+007
+0.877673  1.92343e+008  1.3826e+008  3.03185e+007
+0.898061  1.59082e+007  4.82192e+006  5.64448e+006
+0.918449  2.32131e+007  4.26263e+007  1.67843e+007
+0.938837  1.3713e+008  1.94705e+008  3.589e+007
+0.959224  2.62821e+008  2.70976e+008  4.2308e+007
+0.979612  3.31767e+008  3.48754e+008  4.80756e+007
+1  3.21634e+008  4.25282e+008  5.32365e+007
Index: sansrealspace/src/realspace/test/cylinder_d=0.5_Iq2D.txt
===================================================================
--- sansrealspace/src/realspace/test/cylinder_d=0.5_Iq2D.txt	(revision a2c1196ad8c06b1343cc4c9c510c9764628d9da2)
+++ sansrealspace/src/realspace/test/cylinder_d=0.5_Iq2D.txt	(revision a2c1196ad8c06b1343cc4c9c510c9764628d9da2)
@@ -0,0 +1,27 @@
+PARS: {'scale': 1.0, 'length': 100, 'radius': 20, 'background': 0.0, 'cyl_theta': 1.0, 'contrast': 1.0, 'cyl_phi': 1.0}
+<q>  <ana>  <sim>  <err>
+0.001  1.25586e+013  1.25584e+013  5.26233e+008
+0.00929167  1.1909e+013  1.19068e+013  1.04923e+010
+0.0175833  1.0341e+013  1.03408e+013  3.11388e+010
+0.025875  8.16205e+012  8.15049e+012  5.18067e+010
+0.0341667  5.77306e+012  5.75279e+012  6.23249e+010
+0.0424583  3.56425e+012  3.55305e+012  5.89665e+010
+0.05075  1.82415e+012  1.84081e+012  4.53723e+010
+0.0590417  6.86403e+011  6.74985e+011  2.6955e+010
+0.0673333  1.26379e+011  1.248e+011  1.07889e+010
+0.075625  1.69416e+009  2.89547e+009  1.50778e+009
+0.0839167  1.17674e+011  1.07376e+011  8.66466e+009
+0.0922083  2.93262e+011  2.90816e+011  1.4123e+010
+0.1005  4.06932e+011  3.98585e+011  1.69585e+010
+0.108792  4.1248e+011  4.30879e+011  1.82588e+010
+0.117083  3.26735e+011  3.32331e+011  1.66224e+010
+0.125375  2.00372e+011  1.9155e+011  1.2709e+010
+0.133667  8.63351e+010  9.06573e+010  8.67162e+009
+0.141958  1.76833e+010  1.4993e+010  3.5005e+009
+0.15025  2.29778e+008  2.08421e+008  4.0582e+008
+0.158542  1.83678e+010  1.58227e+010  3.54108e+009
+0.166833  4.78555e+010  4.61547e+010  6.02634e+009
+0.175125  6.83196e+010  6.41105e+010  7.15624e+009
+0.183417  7.03999e+010  7.16712e+010  7.5763e+009
+0.191708  5.61199e+010  5.95249e+010  6.90467e+009
+0.2  3.43293e+010  4.68345e+010  6.07661e+009
Index: sansrealspace/src/realspace/test/cylinder_d=1_Iq2D.txt
===================================================================
--- sansrealspace/src/realspace/test/cylinder_d=1_Iq2D.txt	(revision a2c1196ad8c06b1343cc4c9c510c9764628d9da2)
+++ sansrealspace/src/realspace/test/cylinder_d=1_Iq2D.txt	(revision a2c1196ad8c06b1343cc4c9c510c9764628d9da2)
@@ -0,0 +1,27 @@
+PARS: {'scale': 1.0, 'length': 100, 'radius': 20, 'background': 0.0, 'cyl_theta': 1.0, 'contrast': 1.0, 'cyl_phi': 1.0}
+<q>  <ana>  <sim>  <err>
+0.001  1.25586e+013  1.25585e+013  2.62063e+008
+0.00929167  1.1909e+013  1.19112e+013  5.21255e+009
+0.0175833  1.0341e+013  1.03476e+013  1.55295e+010
+0.025875  8.16205e+012  8.14775e+012  2.58886e+010
+0.0341667  5.77306e+012  5.76393e+012  3.11733e+010
+0.0424583  3.56425e+012  3.5892e+012  2.95574e+010
+0.05075  1.82415e+012  1.84182e+012  2.26526e+010
+0.0590417  6.86403e+011  6.78248e+011  1.34722e+010
+0.0673333  1.26379e+011  1.24533e+011  5.37752e+009
+0.075625  1.69416e+009  2.00737e+009  6.27927e+008
+0.0839167  1.17674e+011  1.17611e+011  4.55543e+009
+0.0922083  2.93262e+011  2.99299e+011  7.16101e+009
+0.1005  4.06932e+011  4.18146e+011  8.68167e+009
+0.108792  4.1248e+011  4.01046e+011  8.84498e+009
+0.117083  3.26735e+011  3.16525e+011  8.09549e+009
+0.125375  2.00372e+011  2.01046e+011  6.51183e+009
+0.133667  8.63351e+010  8.55105e+010  4.22216e+009
+0.141958  1.76833e+010  2.01817e+010  2.02658e+009
+0.15025  2.29778e+008  2.30259e+008  2.14584e+008
+0.158542  1.83678e+010  2.06003e+010  2.01657e+009
+0.166833  4.78555e+010  4.6418e+010  3.03196e+009
+0.175125  6.83196e+010  6.62813e+010  3.62839e+009
+0.183417  7.03999e+010  7.04295e+010  3.76065e+009
+0.191708  5.61199e+010  5.71321e+010  3.38173e+009
+0.2  3.43293e+010  3.37377e+010  2.57894e+009
Index: sansrealspace/src/realspace/test/early_test.py
===================================================================
--- sansrealspace/src/realspace/test/early_test.py	(revision 1b0707e1e5fe6a8a9dfd13c74040c3fdefbdf53c)
+++ sansrealspace/src/realspace/test/early_test.py	(revision a2c1196ad8c06b1343cc4c9c510c9764628d9da2)
@@ -237,6 +237,54 @@
     print ana, sim, sim/ana, ana/sim
     
-
+def test_7():
+    from sans.models.CoreShellModel import CoreShellModel
+    print "Testing core-shell"
+    radius = 15
+    thickness = 5
+    density = 5
+    
+    core_vol = 4.0/3.0*math.pi*radius*radius*radius
+    outer_radius = radius+thickness
+    shell_vol = 4.0/3.0*math.pi*outer_radius*outer_radius*outer_radius - core_vol
+    shell_sld = -1.0*core_vol/shell_vol
+
+    # Core-shell
+    sphere = CoreShellModel()
+    # Core radius
+    sphere.setParam('radius', radius)
+    # Shell thickness
+    sphere.setParam('thickness', thickness)
+    sphere.setParam('core_sld', 1.0)
+    sphere.setParam('shell_sld', shell_sld)
+    sphere.setParam('solvent_sld', 0.0)
+    sphere.setParam('background', 0.0)
+    sphere.setParam('scale', 1.0)
+    ana = sphere
+   
+    canvas = VolumeCanvas.VolumeCanvas()        
+    canvas.setParam('lores_density', density)
+    
+    handle = canvas.add('sphere')
+    canvas.setParam('%s.radius' % handle, outer_radius)
+    canvas.setParam('%s.contrast' % handle, shell_sld)
+   
+    handle2 = canvas.add('sphere')
+    canvas.setParam('%s.radius' % handle2, radius)
+    canvas.setParam('%s.contrast' % handle2, 1.0)
+           
+    canvas.setParam('scale' , 1.0)
+    canvas.setParam('background' , 0.0)
+    
+               
+    """ Testing default core-shell orientation """
+    qlist = [.0001, 0.002, .01, .1, 1.0, 5.]
+    for q in qlist:
+        ana_val = ana.runXY([q, 0.2])
+        sim_val, err = canvas.getIq2DError(q, 0.2)
+        print ana_val, sim_val, sim_val/ana_val, err, (sim_val-ana_val)/err
+    
+
+    
     
 if __name__ == "__main__":
-    test_6()
+    test_7()
Index: sansrealspace/src/realspace/test/ellipsoid_d=0.5_Iq2D.txt
===================================================================
--- sansrealspace/src/realspace/test/ellipsoid_d=0.5_Iq2D.txt	(revision a2c1196ad8c06b1343cc4c9c510c9764628d9da2)
+++ sansrealspace/src/realspace/test/ellipsoid_d=0.5_Iq2D.txt	(revision a2c1196ad8c06b1343cc4c9c510c9764628d9da2)
@@ -0,0 +1,27 @@
+PARS: {'scale': 1.0, 'axis_theta': 1.5700000000000001, 'radius_b': 15, 'radius_a': 20, 'axis_phi': 0.0, 'background': 0.0, 'contrast': 1.0}
+<q>  <ana>  <sim>  <err>
+0.001  1.88485e+012  1.8847e+012  4.10542e+008
+0.0217917  1.83608e+012  1.83655e+012  3.06675e+009
+0.0425833  1.70412e+012  1.7055e+012  9.72073e+009
+0.063375  1.50455e+012  1.50079e+012  1.85184e+010
+0.0841667  1.26003e+012  1.25632e+012  2.61434e+010
+0.104958  9.96513e+011  9.90983e+011  3.1059e+010
+0.12575  7.39268e+011  7.36377e+011  3.15408e+010
+0.146542  5.09224e+011  5.10729e+011  2.90619e+010
+0.167333  3.2051e+011  3.07972e+011  2.32998e+010
+0.188125  1.7944e+011  1.84463e+011  1.76986e+010
+0.208917  8.49775e+010  8.71545e+010  1.18554e+010
+0.229708  3.04121e+010  2.86599e+010  6.56268e+009
+0.2505  5.71493e+009  6.81516e+009  3.12076e+009
+0.271292  8.04693e+006  9.03155e+007  3.61655e+008
+0.292083  3.62647e+009  3.03417e+009  2.08145e+009
+0.312875  9.43653e+009  1.08412e+010  3.95509e+009
+0.333667  1.32991e+010  1.67259e+010  5.05345e+009
+0.354458  1.37812e+010  1.21334e+010  4.3185e+009
+0.37525  1.13721e+010  1.17844e+010  4.23494e+009
+0.396042  7.51749e+009  7.34231e+009  3.35522e+009
+0.416833  3.75654e+009  6.72932e+009  3.19781e+009
+0.437625  1.14945e+009  2.84868e+008  6.53813e+008
+0.458417  5.78751e+007  9.3358e+007  3.75074e+008
+0.479208  2.29357e+008  1.40995e+009  1.44511e+009
+0.5  1.0643e+009  7.04596e+008  1.02303e+009
Index: sansrealspace/src/realspace/test/sim_validation.py
===================================================================
--- sansrealspace/src/realspace/test/sim_validation.py	(revision ba1d1e9d2a812317a3694cc34f831cb9178b9f54)
+++ sansrealspace/src/realspace/test/sim_validation.py	(revision a2c1196ad8c06b1343cc4c9c510c9764628d9da2)
@@ -18,4 +18,6 @@
     def __init__(self):
         self.density = 0.1
+        self.canvas  = None
+        self.ana     = None
         self.create()
         
@@ -23,5 +25,5 @@
         pass
          
-    def run_sim(self, q, density=None):
+    def run_sim2D(self, qx, qy, density=None):
         """
             Calculate the mean and error of the simulation
@@ -34,5 +36,26 @@
             self.create()
         
+        return self.canvas.getIq2DError(qx, qy)
+    
+    def run_sim(self, q, density=None):
+        """
+            Calculate the mean and error of the simulation
+            @param q: q-value to calculate at
+            @param density: point density of simulation
+            #return: mean, error
+        """
+        if not density == None:
+            self.density = density
+            self.create()
+        
         return self.canvas.getIqError(q)
+         
+    def run_ana2D(self, qx, qy):
+        """
+            Return analytical value
+            @param q: q-value to evaluate at [float]
+            @return: analytical output [float]
+        """
+        return self.ana.runXY([qx, qy]) 
          
     def run_ana(self, q):
@@ -227,4 +250,33 @@
     output.close()
        
+def validate_model_2D(validator, q_min, q_max, phi, n_q):
+    """
+         Validate a model
+         An output file containing a comparison between
+         simulation and the analytical solution will be
+         produced.
+         
+         @param validator: validator object
+         @param q_min: minimum q
+         @param q_max: maximum q
+         @param n_q: number of q points
+         @param N: number of times to evaluate each simulation point
+    """
+    
+    q_list = pylab.arange(q_min, q_max*1.0001, (q_max-q_min)/(n_q-1))
+    
+    output = open('%s_d=%g_Iq2D.txt' % (validator.name, validator.density), 'w')
+    output.write("PARS: %s\n" % validator.ana.params)
+    output.write("<q>  <ana>  <sim>  <err>\n")
+    t_0 = time.time()
+    for q in q_list:
+        ana = validator.run_ana2D(q*math.cos(phi), q*math.sin(phi))
+        sim, err = validator.run_sim2D(q*math.cos(phi), q*math.sin(phi))
+        print "q=%-g  ana=%-g  sim=%-g  err=%-g  diff=%-g (%-g) %s" % (q, ana, sim, err, 
+                        (sim-ana), sim/ana, str(math.fabs(sim-ana)>err))
+        output.write("%g  %g  %g  %g\n" % (q, ana, sim, err))
+    print "Time elapsed: ", time.time()-t_0
+    output.close()
+       
 def check_density(validator, q, d_min, d_max, n_d): 
     """
@@ -257,15 +309,28 @@
     
 if __name__ == '__main__':
-    #vali = CoreShellValidator(radius = 15, thickness=5, density = 0.01)
-    #validate_model(vali, q_min=0.001, q_max=1, n_q=50, N=40)
-
+    
+    # 2D: Density=5, 71.2 secs for 50 points
+    vali = CoreShellValidator(radius = 15, thickness=5, density = 5.0)
+    #validate_model(vali, q_min=0.001, q_max=1, n_q=50)
+    validate_model_2D(vali, q_min=0.001, q_max=1, phi=1.0, n_q=50)
+
+    # 2D: Density=2, 11.1 secs for 25 points
     #vali = SphereValidator(radius = 20, density = 0.02)
-    #validate_model(vali, q_min=0.001, q_max=0.5, n_q=25, N=20)
-    
-    vali = CylinderValidator(radius = 20, length=100, density = 0.1)
-    validate_model(vali, q_min=0.001, q_max=0.5, n_q=25)
-    
+    #validate_model(vali, q_min=0.001, q_max=0.5, n_q=25)
+    #vali = SphereValidator(radius = 20, density = 2.0)
+    #validate_model_2D(vali, q_min=0.001, q_max=0.5, phi=1.0, n_q=25)
+    
+    # 2D: Density=1, 19.4 secs for 25 points
+    # 2D: Density=0.5, 9.8 secs for 25 points
+    #vali = CylinderValidator(radius = 20, length=100, density = 0.1)
+    #validate_model(vali, q_min=0.001, q_max=0.5, n_q=25)
+    #vali = CylinderValidator(radius = 20, length=100, density = 0.5)
+    #validate_model_2D(vali, q_min=0.001, q_max=0.2, phi=1.0, n_q=25)
+    
+    # 2D: Density=0.5, 2.26 secs for 25 points
     #vali = EllipsoidValidator(radius_a = 20, radius_b=15, density = 0.05)
     #validate_model(vali, q_min=0.001, q_max=0.5, n_q=25)
+    #vali = EllipsoidValidator(radius_a = 20, radius_b=15, density = 0.5)
+    #validate_model_2D(vali, q_min=0.001, q_max=0.5, phi=1.0, n_q=25)
     
     #vali = HelixValidator(density = 0.05)
Index: sansrealspace/src/realspace/test/sphere_d=2_Iq2D.txt
===================================================================
--- sansrealspace/src/realspace/test/sphere_d=2_Iq2D.txt	(revision a2c1196ad8c06b1343cc4c9c510c9764628d9da2)
+++ sansrealspace/src/realspace/test/sphere_d=2_Iq2D.txt	(revision a2c1196ad8c06b1343cc4c9c510c9764628d9da2)
@@ -0,0 +1,27 @@
+PARS: {'scale': 1.0, 'radius': 20, 'contrast': 1.0, 'background': 0.0}
+<q>  <ana>  <sim>  <err>
+0.001  3.35076e+012  3.35073e+012  1.02559e+008
+0.0217917  3.22578e+012  3.22556e+012  1.26748e+009
+0.0425833  2.89407e+012  2.89631e+012  3.98876e+009
+0.063375  2.41141e+012  2.4136e+012  7.05401e+009
+0.0841667  1.85421e+012  1.85598e+012  9.16184e+009
+0.104958  1.30194e+012  1.29271e+012  9.61462e+009
+0.12575  8.20339e+011  8.18218e+011  8.47219e+009
+0.146542  4.50004e+011  4.53479e+011  6.46034e+009
+0.167333  2.02695e+011  2.05057e+011  4.21957e+009
+0.188125  6.53019e+010  7.08642e+010  2.37486e+009
+0.208917  9.08587e+009  8.04306e+009  7.69335e+008
+0.229708  6.52867e+008  4.6001e+008  1.82649e+008
+0.2505  1.12169e+010  1.27539e+010  9.69079e+008
+0.271292  2.19267e+010  2.07541e+010  1.26591e+009
+0.292083  2.47336e+010  2.40875e+010  1.38764e+009
+0.312875  1.98194e+010  1.53331e+010  1.11323e+009
+0.333667  1.14538e+010  1.06653e+010  9.16921e+008
+0.354458  4.1655e+009  4.50656e+009  5.89412e+008
+0.37525  4.46529e+008  2.35626e+008  1.34098e+008
+0.396042  2.84717e+008  5.60381e+008  2.06561e+008
+0.416833  2.03152e+009  1.86189e+009  3.77226e+008
+0.437625  3.7442e+009  3.55198e+009  5.28877e+008
+0.458417  4.22545e+009  3.88908e+009  5.5361e+008
+0.479208  3.36846e+009  3.81988e+009  5.4743e+008
+0.5  1.85693e+009  1.91111e+009  3.83604e+008
Index: sansrealspace/src/realspace/test/utest_oriented.py
===================================================================
--- sansrealspace/src/realspace/test/utest_oriented.py	(revision 3c7569637575e6744d9806b177d81106617f5924)
+++ sansrealspace/src/realspace/test/utest_oriented.py	(revision a2c1196ad8c06b1343cc4c9c510c9764628d9da2)
@@ -240,5 +240,5 @@
             self.assert_( math.fabs(sim_val/ana_val-1.0)<0.05 )
         except:
-            print ana_val, sim_val, sim_val/ana_val
+            print "Error", ana_val, sim_val, sim_val/ana_val
             raise sys.exc_type, sys.exc_value
 
@@ -288,12 +288,64 @@
         canvas.setParam('background' , 0.0)
         self.canvas = canvas 
+           
+    def testdefault(self):
+        """ Testing default core-shell orientation """
+        ana_val = self.ana.runXY([0.1, 0.2])
+        sim_val, err = self.canvas.getIq2DError(0.1, 0.2)
+        
+        self.assert_( math.fabs(sim_val/ana_val-1.0)<0.05 )
+                   
+class TestCoreShellError(unittest.TestCase):
+    """ Tests for oriented (2D) systems """
+        
+    def setUp(self):
+        """ Set up zero-SLD-average core-shell model """
+        from sans.models.CoreShellModel import CoreShellModel
+        
+        radius = 15
+        thickness = 5
+        density = 5
+        
+        core_vol = 4.0/3.0*math.pi*radius*radius*radius
+        self.outer_radius = radius+thickness
+        shell_vol = 4.0/3.0*math.pi*self.outer_radius*self.outer_radius*self.outer_radius - core_vol
+        self.shell_sld = -1.0*core_vol/shell_vol
+
+        self.density = density
+           
+        # Core-shell
+        sphere = CoreShellModel()
+        # Core radius
+        sphere.setParam('radius', radius)
+        # Shell thickness
+        sphere.setParam('thickness', thickness)
+        sphere.setParam('core_sld', 1.0)
+        sphere.setParam('shell_sld', self.shell_sld)
+        sphere.setParam('solvent_sld', 0.0)
+        sphere.setParam('background', 0.0)
+        sphere.setParam('scale', 1.0)
+        self.ana = sphere
+       
+        canvas = VolumeCanvas.VolumeCanvas()        
+        canvas.setParam('lores_density', self.density)
+        
+        handle = canvas.add('sphere')
+        canvas.setParam('%s.radius' % handle, self.outer_radius)
+        canvas.setParam('%s.contrast' % handle, self.shell_sld)
+       
+        handle2 = canvas.add('sphere')
+        canvas.setParam('%s.radius' % handle2, radius)
+        canvas.setParam('%s.contrast' % handle2, 1.0)
+               
+        canvas.setParam('scale' , 1.0)
+        canvas.setParam('background' , 0.0)
+        self.canvas = canvas 
                    
     def testdefault(self):
         """ Testing default core-shell orientation """
         ana_val = self.ana.runXY([0.1, 0.2])
-        sim_val = self.canvas.getIq2D(0.1, 0.2)
-        #print ana_val, sim_val, sim_val/ana_val
-        
-        self.assert_( math.fabs(sim_val/ana_val-1.0)<0.05 )
+        sim_val, err = self.canvas.getIq2DError(0.1, 0.2)
+        
+        self.assert_( math.fabs(sim_val-ana_val) < 3.0 * err )
 
 class TestRunMethods(unittest.TestCase):
@@ -306,5 +358,5 @@
         radius_a = 10
         radius_b = 15
-        density = 1
+        density = 5
         
         self.ana = EllipsoidModel()
@@ -339,5 +391,9 @@
         #print ana_val, sim_val, sim_val/ana_val
         
-        self.assert_( math.fabs(sim_val/ana_val-1.0)<0.05 )
+        try:
+            self.assert_( math.fabs(sim_val/ana_val-1.0)<0.05 )
+        except:
+            print "Error", ana_val, sim_val, sim_val/ana_val
+            raise sys.exc_type, sys.exc_value
 
     def testRunXY_float(self):
@@ -347,5 +403,9 @@
         #print ana_val, sim_val, sim_val/ana_val
         
-        self.assert_( math.fabs(sim_val/ana_val-1.0)<0.05 )
+        try:
+            self.assert_( math.fabs(sim_val/ana_val-1.0)<0.05 )
+        except:
+            print "Error", ana_val, sim_val, sim_val/ana_val
+            raise sys.exc_type, sys.exc_value
 
     def testRun_float(self):
@@ -355,5 +415,9 @@
         #print ana_val, sim_val, sim_val/ana_val
         
-        self.assert_( math.fabs(sim_val/ana_val-1.0)<0.05 )
+        try:
+            self.assert_( math.fabs(sim_val/ana_val-1.0)<0.05 )
+        except:
+            print "Error", ana_val, sim_val, sim_val/ana_val
+            raise sys.exc_type, sys.exc_value
 
     def testRun_list(self):
@@ -363,5 +427,9 @@
         #print ana_val, sim_val, sim_val/ana_val
         
-        self.assert_( math.fabs(sim_val/ana_val-1.0)<0.05 )
+        try:
+            self.assert_( math.fabs(sim_val/ana_val-1.0)<0.05 )
+        except:
+            print "Error", ana_val, sim_val, sim_val/ana_val
+            raise sys.exc_type, sys.exc_value
 
           
