Index: src/sas/calculator/resolution_calculator.py
===================================================================
--- src/sas/calculator/resolution_calculator.py	(revision 794922220f2fb3b23dd08c648aabf87b4850596c)
+++ src/sas/calculator/resolution_calculator.py	(revision 6bd3a8d1ff8ae5d31daee4cf6f10dfaeb0d72131)
@@ -25,5 +25,5 @@
     """
     def __init__(self):
-        
+
         # wavelength
         self.wave = Neutron()
@@ -85,5 +85,5 @@
         self.qxrange = []
         self.qyrange = []
-        
+
     def compute_and_plot(self, qx_value, qy_value, qx_min, qx_max,
                           qy_min, qy_max, coord='cartesian'):
@@ -122,9 +122,4 @@
                             sigma_r, qx_min, qx_max, qy_min, qy_max,
                             coord, False)
-            
-            # Non tof mode to be speed up
-            #if num_lamda < 2:
-            #    return self.plot_image(image)
-            
             if qx_min > self.qx_min:
                 qx_min = self.qx_min
@@ -135,5 +130,5 @@
             if qy_max < self.qy_max:
                 qy_max = self.qy_max
-                
+
             # set max qranges
             self.qxrange = [qx_min, qx_max]
@@ -167,5 +162,5 @@
             sigma1d += sigma1d_list[ind] * sigma1d_list[ind] * self.intensity
             total_intensity += self.intensity
-        
+
         if total_intensity != 0:
             # average variance
@@ -195,12 +190,12 @@
         else:
             self.image = image_out
-        
+
         # plot image
         return self.plot_image(self.image)
-    
+
     def setup_tof(self, wavelength, wavelength_spread):
         """
         Setup all parameters in instrument
-        
+
         : param ind: index of lambda, etc
         """
@@ -210,10 +205,10 @@
         self.set_wavelength_spread(wavelength_spread)
         self.intensity = self.wave.get_intensity()
-        
+
         if wavelength == 0:
             msg = "Can't compute the resolution: the wavelength is zero..."
             raise RuntimeError, msg
         return self.intensity
-        
+
     def compute(self, wavelength, wavelength_spread, qx_value, qy_value,
                 coord='cartesian', tof=False):
@@ -260,5 +255,5 @@
         # sample to detector distance
         l_two = l_sad - l_sas
-        
+
         # Sample offset correction for l_one and Lp on variance calculation
         l1_cor = (l_ssa * l_two) / (l_sas + l_two)
@@ -297,5 +292,5 @@
         # normalize
         variance_1d_1 = knot * knot * variance_1d_1 / 12
-        
+
         # for 2d
         #sigma_1 += sigma_wave_1
@@ -328,5 +323,5 @@
         # normalize
         variance_1d_2 = knot * knot * variance_1d_2 / 12
-        
+
         # for 2d
         #sigma_2 =  knot*sqrt(sigma_2/12)
@@ -341,5 +336,5 @@
         self.sigma_1d = sigma1d
         return qr_value, phi, sigma_1, sigma_2, sigma_r, sigma1d
-    
+
     def _within_detector_range(self, qx_value, qy_value):
         """
@@ -364,5 +359,5 @@
             return False
         return True
-    
+
     def get_image(self, qx_value, qy_value, sigma_1, sigma_2, sigma_r,
                   qx_min, qx_max, qy_min, qy_max,
@@ -378,5 +373,5 @@
         # Get  qx_max and qy_max...
         self._get_detector_qxqy_pixels()
-       
+
         qr_value, phi = self._get_polar_value(qx_value, qy_value)
 
@@ -397,5 +392,5 @@
         if not full_cal:
             return None
- 
+
         # Make an empty graph in the detector scale
         dx_size = (self.qx_max - self.qx_min) / (1000 - 1)
@@ -421,5 +416,5 @@
             # qy_center
             qc_2 = qy_value
-            
+
             # Calculate the 2D Gaussian distribution image
             image = self._gaussian2d(q_1, q_2, qc_1, qc_2,
@@ -436,12 +431,12 @@
         else:
             self.image_lam = image * self.intensity
-        
+
         return self.image_lam
-    
+
     def plot_image(self, image):
         """
         Plot image using pyplot
         : image: 2d resolution image
-        
+
         : return plt: pylab object
         """
@@ -463,5 +458,5 @@
 
         return plt
-    
+
     def reset_image(self):
         """
@@ -469,5 +464,5 @@
         """
         self.image = []
-        
+
     def get_variance(self, size=[], distance=0, phi=0, comp='radial'):
         """
@@ -476,10 +471,10 @@
         : distance: [z, x] where z along the incident beam, x // qx_value
         : comp: direction of the sigma; can be 'phi', 'y', 'x', and 'radial'
-        
+
         : return variance: sigma^2
         """
         # check the length of size (list)
         len_size = len(size)
-        
+
         # define sigma component direction
         if comp == 'radial':
@@ -522,10 +517,10 @@
         """
         Get the variance when the wavelength spread is given
-        
+
         : radius: the radial distance from the beam center to the pix of q
         : distance: sample to detector distance
         : spread: wavelength spread (ratio)
         : comp: direction of the sigma; can be 'phi', 'y', 'x', and 'radial'
-        
+
         : return variance: sigma^2 for 2d, sigma^2 for 1d [tuple]
         """
@@ -560,5 +555,5 @@
             else:
                 sigma *= 1
-                
+
             return sigma, sigma1d
 
@@ -567,5 +562,5 @@
         """
         Get the variance from gravity when the wavelength spread is given
-        
+
         : s_distance: source to sample distance
         : d_distance: sample to detector distance
@@ -573,5 +568,5 @@
         : spread: wavelength spread (ratio)
         : comp: direction of the sigma; can be 'phi', 'y', 'x', and 'radial'
-        
+
         : return variance: sigma^2
         """
@@ -590,17 +585,10 @@
             sigma *= math.pow(spread, 2)
             sigma *= 8
-            
-            # only for the polar coordinate
-            #if comp == 'radial':
-            #    sigma *= (math.sin(phi) * math.sin(phi))
-            #elif comp == 'phi':
-            #    sigma *= (math.cos(phi) * math.cos(phi))
-            
             return sigma
-    
+
     def _cal_A_value(self, lamda, s_distance, d_distance):
         """
         Calculate A value for gravity
-        
+
         : s_distance: source to sample distance
         : d_distance: sample to detector distance
@@ -624,5 +612,5 @@
             a_value *= (4 * lamda * lamda)
         return a_value
-    
+
     def get_intensity(self):
         """
@@ -636,12 +624,5 @@
         """
         return self.wave.wavelength
-    
-    #TODO: why was this method duplicated?
-    #def get_spectrum(self):
-    #    """
-    #    Get spectrum
-    #    """
-    #    return self.wave.spectrum
-    
+
     def get_default_spectrum(self):
         """
@@ -649,5 +630,5 @@
         """
         return self.wave.get_default_spectrum()
-    
+
     def get_spectrum(self):
         """
@@ -655,5 +636,5 @@
         """
         return self.wave.get_spectrum()
-         
+
     def get_wavelength_spread(self):
         """
@@ -661,5 +642,5 @@
         """
         return self.wave.wavelength_spread
-    
+
     def get_neutron_mass(self):
         """
@@ -667,5 +648,5 @@
         """
         return self.wave.mass
-    
+
     def get_source_aperture_size(self):
         """
@@ -673,5 +654,5 @@
         """
         return self.aperture.source_size
-    
+
     def get_sample_aperture_size(self):
         """
@@ -679,5 +660,5 @@
         """
         return self.aperture.sample_size
-    
+
     def get_detector_pix_size(self):
         """
@@ -685,5 +666,5 @@
         """
         return self.detector.pix_size
-       
+
     def get_detector_size(self):
         """
@@ -691,5 +672,5 @@
         """
         return self.detector.size
-     
+
     def get_source2sample_distance(self):
         """
@@ -697,5 +678,5 @@
         """
         return self.aperture.sample_distance
-    
+
     def get_sample2sample_distance(self):
         """
@@ -703,5 +684,5 @@
         """
         return self.sample.distance
-    
+
     def get_sample2detector_distance(self):
         """
@@ -709,5 +690,5 @@
         """
         return self.detector.distance
-    
+
     def set_intensity(self, intensity):
         """
@@ -715,5 +696,5 @@
         """
         self.wave.set_intensity(intensity)
-        
+
     def set_wave(self, wavelength):
         """
@@ -727,5 +708,5 @@
         else:
             raise
-    
+
     def set_wave_spread(self, wavelength_spread):
         """
@@ -736,8 +717,7 @@
         elif wavelength_spread.__class__.__name__ == 'float':
             self.wave.set_wave_spread_list([wavelength_spread])
-            #self.set_wavelength_spread(wavelength_spread)
         else:
             raise
-        
+
     def set_wavelength(self, wavelength):
         """
@@ -746,5 +726,5 @@
         self.wavelength = wavelength
         self.wave.set_wavelength(wavelength)
-        
+
     def set_spectrum(self, spectrum):
         """
@@ -753,5 +733,5 @@
         self.spectrum = spectrum
         self.wave.set_spectrum(spectrum)
-          
+
     def set_wavelength_spread(self, wavelength_spread):
         """
@@ -760,5 +740,5 @@
         self.wavelength_spread = wavelength_spread
         self.wave.set_wavelength_spread(wavelength_spread)
-        
+
     def set_wave_list(self, wavelength_list, wavelengthspread_list):
         """
@@ -767,5 +747,5 @@
         self.wave.set_wave_list(wavelength_list)
         self.wave.set_wave_spread_list(wavelengthspread_list)
-    
+
     def get_wave_list(self):
         """
@@ -773,5 +753,5 @@
         """
         return self.wave.get_wave_list()
-    
+
     def get_intensity_list(self):
         """
@@ -779,9 +759,9 @@
         """
         return self.wave.get_intensity_list()
-           
+
     def set_source_aperture_size(self, size):
         """
         Set source aperture size
-        
+
         : param size: [dia_value] or [x_value, y_value]
         """
@@ -789,5 +769,5 @@
             raise RuntimeError, "The length of the size must be one or two."
         self.aperture.set_source_size(size)
-        
+
     def set_neutron_mass(self, mass):
         """
@@ -796,9 +776,9 @@
         self.wave.set_mass(mass)
         self.mass = mass
-        
+
     def set_sample_aperture_size(self, size):
         """
         Set sample aperture size
-        
+
         : param size: [dia_value] or [xheight_value, yheight_value]
         """
@@ -806,5 +786,5 @@
             raise RuntimeError, "The length of the size must be one or two."
         self.aperture.set_sample_size(size)
-    
+
     def set_detector_pix_size(self, size):
         """
@@ -812,5 +792,5 @@
         """
         self.detector.set_pix_size(size)
-        
+
     def set_detector_size(self, size):
         """
@@ -819,9 +799,9 @@
         """
         self.detector.set_size(size)
-        
+
     def set_source2sample_distance(self, distance):
         """
         Set detector source2sample_distance
-        
+
         : param distance: [distance, x_offset]
         """
@@ -833,5 +813,5 @@
         """
         Set detector sample_slit2sample_distance
-        
+
         : param distance: [distance, x_offset]
         """
@@ -839,9 +819,9 @@
             raise RuntimeError, "The length of the size must be one or two."
         self.sample.set_distance(distance)
-   
+
     def set_sample2detector_distance(self, distance):
         """
         Set detector sample2detector_distance
-        
+
         : param distance: [distance, x_offset]
         """
@@ -849,12 +829,9 @@
             raise RuntimeError, "The length of the size must be one or two."
         self.detector.set_distance(distance)
-        
+
     def get_all_instrument_params(self):
         """
         Get all instrumental parameters
         """
-        #self.intensity = self.get_intensity()
-        #self.wavelength = self.get_wavelength()
-        #self.wavelength_spread = self.get_wavelength_spread()
         self.mass = self.get_neutron_mass()
         self.spectrum = self.get_spectrum()
@@ -866,9 +843,9 @@
         self.sample2sample_distance = self.get_sample2sample_distance()
         self.sample2detector_distance = self.get_sample2detector_distance()
-    
+
     def get_detector_qrange(self):
         """
         get max detector q ranges
-        
+
         : return: qx_min, qx_max, qy_min, qy_max tuple
         """
@@ -879,7 +856,7 @@
         qy_min = self.qyrange[0]
         qy_max = self.qyrange[1]
-        
+
         return qx_min, qx_max, qy_min, qy_max
-    
+
     def _rotate_z(self, x_value, y_value, theta=0.0):
         """
@@ -888,13 +865,13 @@
         : y_value: numpy array of y values
         : theta: angle to rotate by in rad
-        
+
         :return: x_prime, y-prime
-        """        
+        """
         # rotate by theta
         x_prime = x_value * math.cos(theta) + y_value * math.sin(theta)
         y_prime = -x_value * math.sin(theta) + y_value * math.cos(theta)
-    
+
         return x_prime, y_prime
-    
+
     def _gaussian2d(self, x_val, y_val, x0_val, y0_val,
                     sigma_x, sigma_y, sigma_r):
@@ -907,5 +884,5 @@
         : sigma_x: variance in x-direction
         : sigma_y: variance in y-direction
-        
+
         : return: gaussian (value)
         """
@@ -914,5 +891,5 @@
         y_value = y_val - y0_val
         phi_i = numpy.arctan2(y_val, x_val)
-        
+
         # phi correction due to the gravity shift (in phi)
         phi_0 = math.atan2(y0_val, x0_val)
@@ -921,8 +898,8 @@
         sin_phi = numpy.sin(self.gravity_phi)
         cos_phi = numpy.cos(self.gravity_phi)
-        
+
         x_p = x_value * cos_phi + y_value * sin_phi
         y_p = -x_value * sin_phi + y_value * cos_phi
-        
+
         new_sig_x = sqrt(sigma_r * sigma_r / (sigma_x * sigma_x) + 1)
         new_sig_y = sqrt(sigma_r * sigma_r / (sigma_y * sigma_y) + 1)
@@ -951,5 +928,5 @@
         : sigma_y: variance in phi-direction
         : sigma_r: wavelength variance in r-direction
-        
+
         : return: gaussian (value)
         """
@@ -958,10 +935,10 @@
         gaussian  = self._gaussian1d(x_val, x0_val, sigma_x)
         gaussian *= self._gaussian1d(y_val, y0_val, sigma_y)
- 
+
         # normalizing factor correction
         if sigma_x != 0 and sigma_y != 0:
             gaussian *= sqrt(2 * pi)
         return gaussian
-    
+
     def _gaussian1d(self, value, mean, sigma):
         """
@@ -970,5 +947,5 @@
         : mean: mean value
         : sigma: variance
-        
+
         : return: gaussian (value)
         """
@@ -984,7 +961,7 @@
             # normalize
             gaussian /= sqrt(2 * pi)
-            
+
         return gaussian
-    
+
     def _atan_phi(self, qy_value, qx_value):
         """
@@ -992,5 +969,5 @@
         : qx_value: x component of q
         : qy_value: y component of q
-        
+
         : return phi: the azimuthal angle of q on x-y plane
         """
@@ -1019,13 +996,13 @@
         Get the pixel positions of the detector in the qx_value-qy_value space
         """
-        
+
         # update all param values
         self.get_all_instrument_params()
-        
+
         # wavelength
         wavelength = self.wave.wavelength
         # Gavity correction
         delta_y = self._get_beamcenter_drop()  # in cm
-        
+
         # detector_pix size
         detector_pix_size = self.detector_pix_size
@@ -1050,8 +1027,8 @@
         except:
             pass
-        
+
         # detector size in [no of pix_x,no of pix_y]
         detector_pix_nums_x = self.detector_size[0]
-        
+
         # get pix_y if it exists, otherwse take it from [0]
         try:
@@ -1059,9 +1036,9 @@
         except:
             detector_pix_nums_y = self.detector_size[0]
-        
+
         # detector offset in pix number
         offset_x = detector_offset / pix_x_size
         offset_y = delta_y / pix_y_size
-        
+
         # beam center position in pix number (start from 0)
         center_x, center_y = self._get_beamcenter_position(detector_pix_nums_x,
@@ -1078,9 +1055,9 @@
         detector_ind_x = detector_ind_x - center_x
         detector_ind_y = detector_ind_y - center_y
-        
+
         # unit correction in cm
         detector_ind_x = detector_ind_x * pix_x_size
         detector_ind_y = detector_ind_y * pix_y_size
-        
+
         qx_value = numpy.zeros(len(detector_ind_x))
         qy_value = numpy.zeros(len(detector_ind_y))
@@ -1094,5 +1071,5 @@
             qy_value[i] = self._get_qx(indy, sample2detector_distance, wavelength)
             i += 1
-            
+
         # qx_value and qy_value values in array
         qx_value = qx_value.repeat(detector_pix_nums_y)
@@ -1107,5 +1084,5 @@
         self.qy_min = numpy.min(qy_value)
         self.qy_max = numpy.max(qy_value)
-                
+
         # Appr. min and max values of the detector display limits
         # i.e., edges of the last pixels.
@@ -1119,5 +1096,5 @@
         self.qx_max += self._get_qx(0.5 * pix_x_size,
                                     sample2detector_distance, wavelength)
-        
+
         # min and max values of detecter
         self.detector_qx_min = self.qx_min
@@ -1125,5 +1102,5 @@
         self.detector_qy_min = self.qy_min
         self.detector_qy_max = self.qy_max
-        
+
         # try to set it as a Data2D otherwise pass (not required for now)
         try:
@@ -1136,12 +1113,12 @@
         except:
             pass
-        
+
         return output
-        
+
     def _get_qx(self, dx_size, det_dist, wavelength):
         """
         :param dx_size: x-distance from beam center [cm]
         :param det_dist: sample to detector distance [cm]
-        
+
         :return: q-value at the given position
         """
@@ -1152,9 +1129,9 @@
         qx_value = (2.0 * pi / wavelength) * numpy.sin(theta)
         return qx_value
-    
+
     def _get_polar_value(self, qx_value, qy_value):
         """
         Find qr_value and phi from qx_value and qy_value values
-        
+
         : return qr_value, phi
         """
@@ -1163,7 +1140,7 @@
         # find angle phi
         phi = self._atan_phi(qy_value, qx_value)
-        
+
         return qr_value, phi
-    
+
     def _get_beamcenter_position(self, num_x, num_y, offset_x, offset_y):
         """
@@ -1171,5 +1148,5 @@
         :param num_y: number of pixel in y-direction
         :param offset: detector offset in x-direction in pix number
-        
+
         :return: pix number; pos_x, pos_y in pix index
         """
@@ -1188,5 +1165,5 @@
         """
         Get the beam center drop (delta y) in y diection due to gravity
-        
+
         :return delta y: the beam center drop in cm
         """
