Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/plottools/PlotPanel.py

    r9a5097c r463e7ffc  
    2929DEFAULT_CMAP = pylab.cm.jet 
    3030import copy 
    31 import numpy as np 
     31import numpy 
    3232 
    3333from sas.sasgui.guiframe.events import StatusEvent 
    3434from .toolbar import NavigationToolBar, PlotPrintout, bind 
     35 
     36logger = logging.getLogger(__name__) 
    3537 
    3638def show_tree(obj, d=0): 
     
    14521454                if  self.zmin_2D <= 0  and len(output[output > 0]) > 0: 
    14531455                    zmin_temp = self.zmin_2D 
    1454                     output[output > 0] = np.log10(output[output > 0]) 
     1456                    output[output > 0] = numpy.log10(output[output > 0]) 
    14551457                    #In log scale Negative values are not correct in general 
    1456                     #output[output<=0] = math.log(np.min(output[output>0])) 
     1458                    #output[output<=0] = math.log(numpy.min(output[output>0])) 
    14571459                elif self.zmin_2D <= 0: 
    14581460                    zmin_temp = self.zmin_2D 
    1459                     output[output > 0] = np.zeros(len(output)) 
     1461                    output[output > 0] = numpy.zeros(len(output)) 
    14601462                    output[output <= 0] = -32 
    14611463                else: 
    14621464                    zmin_temp = self.zmin_2D 
    1463                     output[output > 0] = np.log10(output[output > 0]) 
     1465                    output[output > 0] = numpy.log10(output[output > 0]) 
    14641466                    #In log scale Negative values are not correct in general 
    1465                     #output[output<=0] = math.log(np.min(output[output>0])) 
     1467                    #output[output<=0] = math.log(numpy.min(output[output>0])) 
    14661468            except: 
    14671469                #Too many problems in 2D plot with scale 
     
    14921494            X = self.x_bins[0:-1] 
    14931495            Y = self.y_bins[0:-1] 
    1494             X, Y = np.meshgrid(X, Y) 
     1496            X, Y = numpy.meshgrid(X, Y) 
    14951497 
    14961498            try: 
     
    15061508                    from mpl_toolkits.mplot3d import Axes3D 
    15071509                except: 
    1508                     logging.error("PlotPanel could not import Axes3D") 
     1510                    logger.error("PlotPanel could not import Axes3D") 
    15091511                self.subplot.figure.clear() 
    15101512                ax = Axes3D(self.subplot.figure) 
     
    15551557        # 1d array to use for weighting the data point averaging 
    15561558        #when they fall into a same bin. 
    1557         weights_data = np.ones([self.data.size]) 
     1559        weights_data = numpy.ones([self.data.size]) 
    15581560        # get histogram of ones w/len(data); this will provide 
    15591561        #the weights of data on each bins 
    1560         weights, xedges, yedges = np.histogram2d(x=self.qy_data, 
     1562        weights, xedges, yedges = numpy.histogram2d(x=self.qy_data, 
    15611563                                                    y=self.qx_data, 
    15621564                                                    bins=[self.y_bins, self.x_bins], 
    15631565                                                    weights=weights_data) 
    15641566        # get histogram of data, all points into a bin in a way of summing 
    1565         image, xedges, yedges = np.histogram2d(x=self.qy_data, 
     1567        image, xedges, yedges = numpy.histogram2d(x=self.qy_data, 
    15661568                                                  y=self.qx_data, 
    15671569                                                  bins=[self.y_bins, self.x_bins], 
     
    15811583        # do while loop until all vacant bins are filled up up 
    15821584        #to loop = max_loop 
    1583         while not(np.isfinite(image[weights == 0])).all(): 
     1585        while not(numpy.isfinite(image[weights == 0])).all(): 
    15841586            if loop >= max_loop:  # this protects never-ending loop 
    15851587                break 
     
    16301632 
    16311633        # store x and y bin centers in q space 
    1632         x_bins = np.linspace(xmin, xmax, npix_x) 
    1633         y_bins = np.linspace(ymin, ymax, npix_y) 
     1634        x_bins = numpy.linspace(xmin, xmax, npix_x) 
     1635        y_bins = numpy.linspace(ymin, ymax, npix_y) 
    16341636 
    16351637        #set x_bins and y_bins 
     
    16501652        """ 
    16511653        # No image matrix given 
    1652         if image == None or np.ndim(image) != 2 \ 
    1653                 or np.isfinite(image).all() \ 
     1654        if image == None or numpy.ndim(image) != 2 \ 
     1655                or numpy.isfinite(image).all() \ 
    16541656                or weights == None: 
    16551657            return image 
     
    16571659        len_y = len(image) 
    16581660        len_x = len(image[1]) 
    1659         temp_image = np.zeros([len_y, len_x]) 
    1660         weit = np.zeros([len_y, len_x]) 
     1661        temp_image = numpy.zeros([len_y, len_x]) 
     1662        weit = numpy.zeros([len_y, len_x]) 
    16611663        # do for-loop for all pixels 
    16621664        for n_y in range(len(image)): 
    16631665            for n_x in range(len(image[1])): 
    16641666                # find only null pixels 
    1665                 if weights[n_y][n_x] > 0 or np.isfinite(image[n_y][n_x]): 
     1667                if weights[n_y][n_x] > 0 or numpy.isfinite(image[n_y][n_x]): 
    16661668                    continue 
    16671669                else: 
    16681670                    # find 4 nearest neighbors 
    16691671                    # check where or not it is at the corner 
    1670                     if n_y != 0 and np.isfinite(image[n_y - 1][n_x]): 
     1672                    if n_y != 0 and numpy.isfinite(image[n_y - 1][n_x]): 
    16711673                        temp_image[n_y][n_x] += image[n_y - 1][n_x] 
    16721674                        weit[n_y][n_x] += 1 
    1673                     if n_x != 0 and np.isfinite(image[n_y][n_x - 1]): 
     1675                    if n_x != 0 and numpy.isfinite(image[n_y][n_x - 1]): 
    16741676                        temp_image[n_y][n_x] += image[n_y][n_x - 1] 
    16751677                        weit[n_y][n_x] += 1 
    1676                     if n_y != len_y - 1 and np.isfinite(image[n_y + 1][n_x]): 
     1678                    if n_y != len_y - 1 and numpy.isfinite(image[n_y + 1][n_x]): 
    16771679                        temp_image[n_y][n_x] += image[n_y + 1][n_x] 
    16781680                        weit[n_y][n_x] += 1 
    1679                     if n_x != len_x - 1 and np.isfinite(image[n_y][n_x + 1]): 
     1681                    if n_x != len_x - 1 and numpy.isfinite(image[n_y][n_x + 1]): 
    16801682                        temp_image[n_y][n_x] += image[n_y][n_x + 1] 
    16811683                        weit[n_y][n_x] += 1 
    16821684                    # go 4 next nearest neighbors when no non-zero 
    16831685                    # neighbor exists 
    1684                     if n_y != 0 and n_x != 0 and \ 
    1685                             np.isfinite(image[n_y - 1][n_x - 1]): 
     1686                    if n_y != 0 and n_x != 0 and\ 
     1687                         numpy.isfinite(image[n_y - 1][n_x - 1]): 
    16861688                        temp_image[n_y][n_x] += image[n_y - 1][n_x - 1] 
    16871689                        weit[n_y][n_x] += 1 
    16881690                    if n_y != len_y - 1 and n_x != 0 and \ 
    1689                             np.isfinite(image[n_y + 1][n_x - 1]): 
     1691                        numpy.isfinite(image[n_y + 1][n_x - 1]): 
    16901692                        temp_image[n_y][n_x] += image[n_y + 1][n_x - 1] 
    16911693                        weit[n_y][n_x] += 1 
    16921694                    if n_y != len_y and n_x != len_x - 1 and \ 
    1693                             np.isfinite(image[n_y - 1][n_x + 1]): 
     1695                        numpy.isfinite(image[n_y - 1][n_x + 1]): 
    16941696                        temp_image[n_y][n_x] += image[n_y - 1][n_x + 1] 
    16951697                        weit[n_y][n_x] += 1 
    16961698                    if n_y != len_y - 1 and n_x != len_x - 1 and \ 
    1697                             np.isfinite(image[n_y + 1][n_x + 1]): 
     1699                        numpy.isfinite(image[n_y + 1][n_x + 1]): 
    16981700                        temp_image[n_y][n_x] += image[n_y + 1][n_x + 1] 
    16991701                        weit[n_y][n_x] += 1 
Note: See TracChangeset for help on using the changeset viewer.