Changeset 9c0f3c17 in sasview for src/sas/sasgui/plottools


Ignore:
Timestamp:
Apr 4, 2017 12:50:04 PM (8 years ago)
Author:
Ricardo Ferraz Leal <ricleal@…>
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
f2940c4
Parents:
463e7ffc (diff), 1779e72 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

After merge conflict

Location:
src/sas/sasgui/plottools
Files:
6 edited

Legend:

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

    r463e7ffc r9c0f3c17  
    2929DEFAULT_CMAP = pylab.cm.jet 
    3030import copy 
    31 import numpy 
     31import numpy as np 
    3232 
    3333from sas.sasgui.guiframe.events import StatusEvent 
     
    14541454                if  self.zmin_2D <= 0  and len(output[output > 0]) > 0: 
    14551455                    zmin_temp = self.zmin_2D 
    1456                     output[output > 0] = numpy.log10(output[output > 0]) 
     1456                    output[output > 0] = np.log10(output[output > 0]) 
    14571457                    #In log scale Negative values are not correct in general 
    1458                     #output[output<=0] = math.log(numpy.min(output[output>0])) 
     1458                    #output[output<=0] = math.log(np.min(output[output>0])) 
    14591459                elif self.zmin_2D <= 0: 
    14601460                    zmin_temp = self.zmin_2D 
    1461                     output[output > 0] = numpy.zeros(len(output)) 
     1461                    output[output > 0] = np.zeros(len(output)) 
    14621462                    output[output <= 0] = -32 
    14631463                else: 
    14641464                    zmin_temp = self.zmin_2D 
    1465                     output[output > 0] = numpy.log10(output[output > 0]) 
     1465                    output[output > 0] = np.log10(output[output > 0]) 
    14661466                    #In log scale Negative values are not correct in general 
    1467                     #output[output<=0] = math.log(numpy.min(output[output>0])) 
     1467                    #output[output<=0] = math.log(np.min(output[output>0])) 
    14681468            except: 
    14691469                #Too many problems in 2D plot with scale 
     
    14941494            X = self.x_bins[0:-1] 
    14951495            Y = self.y_bins[0:-1] 
    1496             X, Y = numpy.meshgrid(X, Y) 
     1496            X, Y = np.meshgrid(X, Y) 
    14971497 
    14981498            try: 
     
    15571557        # 1d array to use for weighting the data point averaging 
    15581558        #when they fall into a same bin. 
    1559         weights_data = numpy.ones([self.data.size]) 
     1559        weights_data = np.ones([self.data.size]) 
    15601560        # get histogram of ones w/len(data); this will provide 
    15611561        #the weights of data on each bins 
    1562         weights, xedges, yedges = numpy.histogram2d(x=self.qy_data, 
     1562        weights, xedges, yedges = np.histogram2d(x=self.qy_data, 
    15631563                                                    y=self.qx_data, 
    15641564                                                    bins=[self.y_bins, self.x_bins], 
    15651565                                                    weights=weights_data) 
    15661566        # get histogram of data, all points into a bin in a way of summing 
    1567         image, xedges, yedges = numpy.histogram2d(x=self.qy_data, 
     1567        image, xedges, yedges = np.histogram2d(x=self.qy_data, 
    15681568                                                  y=self.qx_data, 
    15691569                                                  bins=[self.y_bins, self.x_bins], 
     
    15831583        # do while loop until all vacant bins are filled up up 
    15841584        #to loop = max_loop 
    1585         while not(numpy.isfinite(image[weights == 0])).all(): 
     1585        while not(np.isfinite(image[weights == 0])).all(): 
    15861586            if loop >= max_loop:  # this protects never-ending loop 
    15871587                break 
     
    16321632 
    16331633        # store x and y bin centers in q space 
    1634         x_bins = numpy.linspace(xmin, xmax, npix_x) 
    1635         y_bins = numpy.linspace(ymin, ymax, npix_y) 
     1634        x_bins = np.linspace(xmin, xmax, npix_x) 
     1635        y_bins = np.linspace(ymin, ymax, npix_y) 
    16361636 
    16371637        #set x_bins and y_bins 
     
    16521652        """ 
    16531653        # No image matrix given 
    1654         if image == None or numpy.ndim(image) != 2 \ 
    1655                 or numpy.isfinite(image).all() \ 
     1654        if image == None or np.ndim(image) != 2 \ 
     1655                or np.isfinite(image).all() \ 
    16561656                or weights == None: 
    16571657            return image 
     
    16591659        len_y = len(image) 
    16601660        len_x = len(image[1]) 
    1661         temp_image = numpy.zeros([len_y, len_x]) 
    1662         weit = numpy.zeros([len_y, len_x]) 
     1661        temp_image = np.zeros([len_y, len_x]) 
     1662        weit = np.zeros([len_y, len_x]) 
    16631663        # do for-loop for all pixels 
    16641664        for n_y in range(len(image)): 
    16651665            for n_x in range(len(image[1])): 
    16661666                # find only null pixels 
    1667                 if weights[n_y][n_x] > 0 or numpy.isfinite(image[n_y][n_x]): 
     1667                if weights[n_y][n_x] > 0 or np.isfinite(image[n_y][n_x]): 
    16681668                    continue 
    16691669                else: 
    16701670                    # find 4 nearest neighbors 
    16711671                    # check where or not it is at the corner 
    1672                     if n_y != 0 and numpy.isfinite(image[n_y - 1][n_x]): 
     1672                    if n_y != 0 and np.isfinite(image[n_y - 1][n_x]): 
    16731673                        temp_image[n_y][n_x] += image[n_y - 1][n_x] 
    16741674                        weit[n_y][n_x] += 1 
    1675                     if n_x != 0 and numpy.isfinite(image[n_y][n_x - 1]): 
     1675                    if n_x != 0 and np.isfinite(image[n_y][n_x - 1]): 
    16761676                        temp_image[n_y][n_x] += image[n_y][n_x - 1] 
    16771677                        weit[n_y][n_x] += 1 
    1678                     if n_y != len_y - 1 and numpy.isfinite(image[n_y + 1][n_x]): 
     1678                    if n_y != len_y - 1 and np.isfinite(image[n_y + 1][n_x]): 
    16791679                        temp_image[n_y][n_x] += image[n_y + 1][n_x] 
    16801680                        weit[n_y][n_x] += 1 
    1681                     if n_x != len_x - 1 and numpy.isfinite(image[n_y][n_x + 1]): 
     1681                    if n_x != len_x - 1 and np.isfinite(image[n_y][n_x + 1]): 
    16821682                        temp_image[n_y][n_x] += image[n_y][n_x + 1] 
    16831683                        weit[n_y][n_x] += 1 
    16841684                    # go 4 next nearest neighbors when no non-zero 
    16851685                    # neighbor exists 
    1686                     if n_y != 0 and n_x != 0 and\ 
    1687                          numpy.isfinite(image[n_y - 1][n_x - 1]): 
     1686                    if n_y != 0 and n_x != 0 and \ 
     1687                            np.isfinite(image[n_y - 1][n_x - 1]): 
    16881688                        temp_image[n_y][n_x] += image[n_y - 1][n_x - 1] 
    16891689                        weit[n_y][n_x] += 1 
    16901690                    if n_y != len_y - 1 and n_x != 0 and \ 
    1691                         numpy.isfinite(image[n_y + 1][n_x - 1]): 
     1691                            np.isfinite(image[n_y + 1][n_x - 1]): 
    16921692                        temp_image[n_y][n_x] += image[n_y + 1][n_x - 1] 
    16931693                        weit[n_y][n_x] += 1 
    16941694                    if n_y != len_y and n_x != len_x - 1 and \ 
    1695                         numpy.isfinite(image[n_y - 1][n_x + 1]): 
     1695                            np.isfinite(image[n_y - 1][n_x + 1]): 
    16961696                        temp_image[n_y][n_x] += image[n_y - 1][n_x + 1] 
    16971697                        weit[n_y][n_x] += 1 
    16981698                    if n_y != len_y - 1 and n_x != len_x - 1 and \ 
    1699                         numpy.isfinite(image[n_y + 1][n_x + 1]): 
     1699                            np.isfinite(image[n_y + 1][n_x + 1]): 
    17001700                        temp_image[n_y][n_x] += image[n_y + 1][n_x + 1] 
    17011701                        weit[n_y][n_x] += 1 
  • src/sas/sasgui/plottools/fitDialog.py

    rdd5bf63 r9a5097c  
    22from plottables import Theory1D 
    33import math 
    4 import numpy 
     4import numpy as np 
    55import fittings 
    66import transform 
     
    482482 
    483483                if self.xLabel.lower() == "log10(x)": 
    484                     tempdy = numpy.asarray(tempdy) 
     484                    tempdy = np.asarray(tempdy) 
    485485                    tempdy[tempdy == 0] = 1 
    486486                    chisqr, out, cov = fittings.sasfit(self.model, 
     
    491491                                                       math.log10(xmax)) 
    492492                else: 
    493                     tempdy = numpy.asarray(tempdy) 
     493                    tempdy = np.asarray(tempdy) 
    494494                    tempdy[tempdy == 0] = 1 
    495495                    chisqr, out, cov = fittings.sasfit(self.model, 
     
    572572        if self.rg_on: 
    573573            if self.Rg_tctr.IsShown(): 
    574                 rg = numpy.sqrt(-3 * float(cstA)) 
     574                rg = np.sqrt(-3 * float(cstA)) 
    575575                value = format_number(rg) 
    576576                self.Rg_tctr.SetValue(value) 
    577577                if self.I0_tctr.IsShown(): 
    578                     val = numpy.exp(cstB) 
     578                    val = np.exp(cstB) 
    579579                    self.I0_tctr.SetValue(format_number(val)) 
    580580            if self.Rgerr_tctr.IsShown(): 
     
    585585                self.Rgerr_tctr.SetValue(value) 
    586586                if self.I0err_tctr.IsShown(): 
    587                     val = numpy.abs(numpy.exp(cstB) * errB) 
     587                    val = np.abs(np.exp(cstB) * errB) 
    588588                    self.I0err_tctr.SetValue(format_number(val)) 
    589589            if self.Diameter_tctr.IsShown(): 
    590                 rg = numpy.sqrt(-2 * float(cstA)) 
    591                 _diam = 4 * numpy.sqrt(-float(cstA)) 
     590                rg = np.sqrt(-2 * float(cstA)) 
     591                _diam = 4 * np.sqrt(-float(cstA)) 
    592592                value = format_number(_diam) 
    593593                self.Diameter_tctr.SetValue(value) 
  • src/sas/sasgui/plottools/plottables.py

    r463e7ffc r9c0f3c17  
    4343# Support for ancient python versions 
    4444import copy 
    45 import numpy 
     45import numpy as np 
    4646import sys 
    4747import logging 
     
    708708                self.dy = None 
    709709            if not has_err_x: 
    710                 dx = numpy.zeros(len(x)) 
     710                dx = np.zeros(len(x)) 
    711711            if not has_err_y: 
    712                 dy = numpy.zeros(len(y)) 
     712                dy = np.zeros(len(y)) 
    713713            for i in range(len(x)): 
    714714                try: 
     
    798798        tempdy = [] 
    799799        if self.dx == None: 
    800             self.dx = numpy.zeros(len(self.x)) 
     800            self.dx = np.zeros(len(self.x)) 
    801801        if self.dy == None: 
    802             self.dy = numpy.zeros(len(self.y)) 
     802            self.dy = np.zeros(len(self.y)) 
    803803        if self.xLabel == "log10(x)": 
    804804            for i in range(len(self.x)): 
     
    828828        tempdy = [] 
    829829        if self.dx == None: 
    830             self.dx = numpy.zeros(len(self.x)) 
     830            self.dx = np.zeros(len(self.x)) 
    831831        if self.dy == None: 
    832             self.dy = numpy.zeros(len(self.y)) 
     832            self.dy = np.zeros(len(self.y)) 
    833833        if self.yLabel == "log10(y)": 
    834834            for i in range(len(self.x)): 
     
    861861        tempdy = [] 
    862862        if self.dx == None: 
    863             self.dx = numpy.zeros(len(self.x)) 
     863            self.dx = np.zeros(len(self.x)) 
    864864        if self.dy == None: 
    865             self.dy = numpy.zeros(len(self.y)) 
     865            self.dy = np.zeros(len(self.y)) 
    866866        if xmin != None and xmax != None: 
    867867            for i in range(len(self.x)): 
     
    12301230 
    12311231def sample_graph(): 
    1232     import numpy as nx 
     1232    import numpy as np 
    12331233 
    12341234    # Construct a simple graph 
    12351235    if False: 
    1236         x = nx.array([1, 2, 3, 4, 5, 6], 'd') 
    1237         y = nx.array([4, 5, 6, 5, 4, 5], 'd') 
    1238         dy = nx.array([0.2, 0.3, 0.1, 0.2, 0.9, 0.3]) 
     1236        x = np.array([1, 2, 3, 4, 5, 6], 'd') 
     1237        y = np.array([4, 5, 6, 5, 4, 5], 'd') 
     1238        dy = np.array([0.2, 0.3, 0.1, 0.2, 0.9, 0.3]) 
    12391239    else: 
    1240         x = nx.linspace(0, 1., 10000) 
    1241         y = nx.sin(2 * nx.pi * x * 2.8) 
    1242         dy = nx.sqrt(100 * nx.abs(y)) / 100 
     1240        x = np.linspace(0, 1., 10000) 
     1241        y = np.sin(2 * np.pi * x * 2.8) 
     1242        dy = np.sqrt(100 * np.abs(y)) / 100 
    12431243    data = Data1D(x, y, dy=dy) 
    12441244    data.xaxis('distance', 'm') 
  • src/sas/sasgui/plottools/binder.py

    rd7bb526 r463e7ffc  
    44import sys 
    55import logging 
     6 
     7logger = logging.getLogger(__name__) 
    68 
    79class Selection(object): 
     
    121123            for cid in self._connections: self.canvas.mpl_disconnect(cid) 
    122124        except: 
    123             logging.error("Error disconnection canvas: %s" % sys.exc_value) 
     125            logger.error("Error disconnection canvas: %s" % sys.exc_value) 
    124126        self._connections = [] 
    125127 
  • src/sas/sasgui/plottools/canvas.py

    rd7bb526 r463e7ffc  
    1111from matplotlib.backends.backend_wx import RendererWx 
    1212 
     13logger = logging.getLogger(__name__) 
     14 
    1315 
    1416def draw_image(self, x, y, im, bbox, clippath=None, clippath_trans=None): 
     
    9698            dc.DrawBitmap(self.canvas.bitmap, (0, 0)) 
    9799        except: 
    98             logging.error(sys.exc_value) 
     100            logger.error(sys.exc_value) 
    99101 
    100102    # restore original figure  resolution 
     
    207209                fig.draw(self) 
    208210            except ValueError: 
    209                 logging.error(sys.exc_value) 
     211                logger.error(sys.exc_value) 
    210212        else: 
    211213            self._isRendered = False 
  • src/sas/sasgui/plottools/toolbar.py

    rd7bb526 r463e7ffc  
    66from matplotlib.backends.backend_wx import _load_bitmap 
    77import logging 
     8 
     9logger = logging.getLogger(__name__) 
    810 
    911# Event binding code changed after version 2.5 
     
    9496            self._parent.onToolContextMenu(event=event) 
    9597        except: 
    96             logging.error("Plot toolbar could not show menu") 
     98            logger.error("Plot toolbar could not show menu") 
    9799 
    98100    def context_menu(self, event): 
     
    122124        except: 
    123125            import traceback 
    124             logging.error(traceback.format_exc()) 
     126            logger.error(traceback.format_exc()) 
    125127 
    126128    def copy_figure(self, event): 
Note: See TracChangeset for help on using the changeset viewer.