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


Ignore:
Timestamp:
Apr 4, 2017 12:50:04 PM (7 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/perspectives
Files:
24 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/perspectives/calculator/data_operator.py

    r61780e3 r9a5097c  
    55import sys 
    66import time 
    7 import numpy 
     7import numpy as np 
    88from sas.sascalc.dataloader.data_info import Data1D 
    99from sas.sasgui.plottools.PlotPanel import PlotPanel 
     
    541541                    theory, _ = theory_list.values()[0] 
    542542                    dnames.append(theory.name) 
    543         ind = numpy.argsort(dnames) 
     543        ind = np.argsort(dnames) 
    544544        if len(ind) > 0: 
    545             val_list = numpy.array(self._data.values())[ind] 
     545            val_list = np.array(self._data.values())[ind] 
    546546            for datastate in val_list: 
    547547                data = datastate.data 
  • src/sas/sasgui/perspectives/calculator/gen_scatter_panel.py

    r463e7ffc r9c0f3c17  
    77import sys 
    88import os 
    9 import numpy 
     9import numpy as np 
    1010#import math 
    1111import wx.aui as aui 
     
    743743            marker = 'o' 
    744744            m_size = 3.5 
    745         sld_tot = (numpy.fabs(sld_mx) + numpy.fabs(sld_my) + \ 
    746                    numpy.fabs(sld_mz) + numpy.fabs(output.sld_n)) 
     745        sld_tot = (np.fabs(sld_mx) + np.fabs(sld_my) + \ 
     746                   np.fabs(sld_mz) + np.fabs(output.sld_n)) 
    747747        is_nonzero = sld_tot > 0.0 
    748748        is_zero = sld_tot == 0.0 
     
    759759            pix_symbol = output.pix_symbol[is_nonzero] 
    760760        # II. Plot selective points in color 
    761         other_color = numpy.ones(len(pix_symbol), dtype='bool') 
     761        other_color = np.ones(len(pix_symbol), dtype='bool') 
    762762        for key in color_dic.keys(): 
    763763            chosen_color = pix_symbol == key 
    764             if numpy.any(chosen_color): 
     764            if np.any(chosen_color): 
    765765                other_color = other_color & (chosen_color != True) 
    766766                color = color_dic[key] 
     
    769769                        markeredgecolor=color, markersize=m_size, label=key) 
    770770        # III. Plot All others         
    771         if numpy.any(other_color): 
     771        if np.any(other_color): 
    772772            a_name = '' 
    773773            if output.pix_type == 'atom': 
     
    797797                draw magnetic vectors w/arrow 
    798798                """ 
    799                 max_mx = max(numpy.fabs(sld_mx)) 
    800                 max_my = max(numpy.fabs(sld_my)) 
    801                 max_mz = max(numpy.fabs(sld_mz)) 
     799                max_mx = max(np.fabs(sld_mx)) 
     800                max_my = max(np.fabs(sld_my)) 
     801                max_mz = max(np.fabs(sld_mz)) 
    802802                max_m = max(max_mx, max_my, max_mz) 
    803803                try: 
     
    814814                        unit_z2 = sld_mz / max_m 
    815815                        # 0.8 is for avoiding the color becomes white=(1,1,1)) 
    816                         color_x = numpy.fabs(unit_x2 * 0.8) 
    817                         color_y = numpy.fabs(unit_y2 * 0.8) 
    818                         color_z = numpy.fabs(unit_z2 * 0.8) 
     816                        color_x = np.fabs(unit_x2 * 0.8) 
     817                        color_y = np.fabs(unit_y2 * 0.8) 
     818                        color_z = np.fabs(unit_z2 * 0.8) 
    819819                        x2 = pos_x + unit_x2 * max_step 
    820820                        y2 = pos_y + unit_y2 * max_step 
    821821                        z2 = pos_z + unit_z2 * max_step 
    822                         x_arrow = numpy.column_stack((pos_x, x2)) 
    823                         y_arrow = numpy.column_stack((pos_y, y2)) 
    824                         z_arrow = numpy.column_stack((pos_z, z2)) 
    825                         colors = numpy.column_stack((color_x, color_y, color_z)) 
     822                        x_arrow = np.column_stack((pos_x, x2)) 
     823                        y_arrow = np.column_stack((pos_y, y2)) 
     824                        z_arrow = np.column_stack((pos_z, z2)) 
     825                        colors = np.column_stack((color_x, color_y, color_z)) 
    826826                        arrows = Arrow3D(panel, x_arrow, z_arrow, y_arrow, 
    827827                                        colors, mutation_scale=10, lw=1, 
     
    882882            if self.is_avg or self.is_avg == None: 
    883883                self._create_default_1d_data() 
    884                 i_out = numpy.zeros(len(self.data.y)) 
     884                i_out = np.zeros(len(self.data.y)) 
    885885                inputs = [self.data.x, [], i_out] 
    886886            else: 
    887887                self._create_default_2d_data() 
    888                 i_out = numpy.zeros(len(self.data.data)) 
     888                i_out = np.zeros(len(self.data.data)) 
    889889                inputs = [self.data.qx_data, self.data.qy_data, i_out] 
    890890 
     
    991991        :Param input: input list [qx_data, qy_data, i_out] 
    992992        """ 
    993         out = numpy.empty(0) 
     993        out = np.empty(0) 
    994994        #s = time.time() 
    995995        for ind in range(len(input[0])): 
     
    10001000                inputi = [input[0][ind:ind + 1], [], input[2][ind:ind + 1]] 
    10011001                outi = self.model.run(inputi) 
    1002                 out = numpy.append(out, outi) 
     1002                out = np.append(out, outi) 
    10031003            else: 
    10041004                if ind % 50 == 0  and update != None: 
     
    10081008                          input[2][ind:ind + 1]] 
    10091009                outi = self.model.runXY(inputi) 
    1010                 out = numpy.append(out, outi) 
     1010                out = np.append(out, outi) 
    10111011        #print time.time() - s 
    10121012        if self.is_avg or self.is_avg == None: 
     
    10291029        self.npts_x = int(float(self.npt_ctl.GetValue())) 
    10301030        self.data = Data2D() 
    1031         qmax = self.qmax_x #/ numpy.sqrt(2) 
     1031        qmax = self.qmax_x #/ np.sqrt(2) 
    10321032        self.data.xaxis('\\rm{Q_{x}}', '\AA^{-1}') 
    10331033        self.data.yaxis('\\rm{Q_{y}}', '\AA^{-1}') 
     
    10501050        qstep = self.npts_x 
    10511051 
    1052         x = numpy.linspace(start=xmin, stop=xmax, num=qstep, endpoint=True) 
    1053         y = numpy.linspace(start=ymin, stop=ymax, num=qstep, endpoint=True) 
     1052        x = np.linspace(start=xmin, stop=xmax, num=qstep, endpoint=True) 
     1053        y = np.linspace(start=ymin, stop=ymax, num=qstep, endpoint=True) 
    10541054        ## use data info instead 
    1055         new_x = numpy.tile(x, (len(y), 1)) 
    1056         new_y = numpy.tile(y, (len(x), 1)) 
     1055        new_x = np.tile(x, (len(y), 1)) 
     1056        new_y = np.tile(y, (len(x), 1)) 
    10571057        new_y = new_y.swapaxes(0, 1) 
    10581058        # all data reuire now in 1d array 
    10591059        qx_data = new_x.flatten() 
    10601060        qy_data = new_y.flatten() 
    1061         q_data = numpy.sqrt(qx_data * qx_data + qy_data * qy_data) 
     1061        q_data = np.sqrt(qx_data * qx_data + qy_data * qy_data) 
    10621062        # set all True (standing for unmasked) as default 
    1063         mask = numpy.ones(len(qx_data), dtype=bool) 
     1063        mask = np.ones(len(qx_data), dtype=bool) 
    10641064        # store x and y bin centers in q space 
    10651065        x_bins = x 
    10661066        y_bins = y 
    10671067        self.data.source = Source() 
    1068         self.data.data = numpy.ones(len(mask)) 
    1069         self.data.err_data = numpy.ones(len(mask)) 
     1068        self.data.data = np.ones(len(mask)) 
     1069        self.data.err_data = np.ones(len(mask)) 
    10701070        self.data.qx_data = qx_data 
    10711071        self.data.qy_data = qy_data 
     
    10861086        :warning: This data is never plotted. 
    10871087                    residuals.x = data_copy.x[index] 
    1088             residuals.dy = numpy.ones(len(residuals.y)) 
     1088            residuals.dy = np.ones(len(residuals.y)) 
    10891089            residuals.dx = None 
    10901090            residuals.dxl = None 
     
    10931093        self.qmax_x = float(self.qmax_ctl.GetValue()) 
    10941094        self.npts_x = int(float(self.npt_ctl.GetValue())) 
    1095         qmax = self.qmax_x #/ numpy.sqrt(2) 
     1095        qmax = self.qmax_x #/ np.sqrt(2) 
    10961096        ## Default values 
    10971097        xmax = qmax 
    10981098        xmin = qmax * _Q1D_MIN 
    10991099        qstep = self.npts_x 
    1100         x = numpy.linspace(start=xmin, stop=xmax, num=qstep, endpoint=True) 
     1100        x = np.linspace(start=xmin, stop=xmax, num=qstep, endpoint=True) 
    11011101        # store x and y bin centers in q space 
    11021102        #self.data.source = Source() 
    1103         y = numpy.ones(len(x)) 
    1104         dy = numpy.zeros(len(x)) 
    1105         dx = numpy.zeros(len(x)) 
     1103        y = np.ones(len(x)) 
     1104        dy = np.zeros(len(x)) 
     1105        dx = np.zeros(len(x)) 
    11061106        self.data = Data1D(x=x, y=y) 
    11071107        self.data.dx = dx 
     
    11731173        state = None 
    11741174 
    1175         numpy.nan_to_num(image) 
     1175        np.nan_to_num(image) 
    11761176        new_plot = Data2D(image=image, err_image=data.err_data) 
    11771177        new_plot.name = model.name + '2d' 
     
    16421642            for key in sld_list.keys(): 
    16431643                if ctr_list[0] == key: 
    1644                     min_val = numpy.min(sld_list[key]) 
    1645                     max_val = numpy.max(sld_list[key]) 
    1646                     mean_val = numpy.mean(sld_list[key]) 
     1644                    min_val = np.min(sld_list[key]) 
     1645                    max_val = np.max(sld_list[key]) 
     1646                    mean_val = np.mean(sld_list[key]) 
    16471647                    enable = (min_val == max_val) and \ 
    16481648                             sld_data.pix_type == 'pixel' 
     
    17351735                    npts = -1 
    17361736                    break 
    1737                 if numpy.isfinite(n_val): 
     1737                if np.isfinite(n_val): 
    17381738                    npts *= int(n_val) 
    17391739            if npts > 0: 
     
    17721772                        ctl.Refresh() 
    17731773                        return 
    1774                     if numpy.isfinite(s_val): 
     1774                    if np.isfinite(s_val): 
    17751775                        s_size *= s_val 
    17761776                self.sld_data.set_pixel_volumes(s_size) 
     
    17891789        try: 
    17901790            sld_data = self.parent.get_sld_from_omf() 
    1791             #nop = (nop * numpy.pi) / 6 
     1791            #nop = (nop * np.pi) / 6 
    17921792            nop = len(sld_data.sld_n) 
    17931793        except: 
  • src/sas/sasgui/perspectives/fitting/basepage.py

    r463e7ffc r9c0f3c17  
    55import os 
    66import wx 
    7 import numpy 
     7import numpy as np 
    88import time 
    99import copy 
     
    101101        self.graph_id = None 
    102102        # Q range for data set 
    103         self.qmin_data_set = numpy.inf 
     103        self.qmin_data_set = np.inf 
    104104        self.qmax_data_set = None 
    105105        self.npts_data_set = 0 
     
    279279 
    280280        """ 
    281         x = numpy.linspace(start=self.qmin_x, stop=self.qmax_x, 
     281        x = np.linspace(start=self.qmin_x, stop=self.qmax_x, 
    282282                           num=self.npts_x, endpoint=True) 
    283283        self.data = Data1D(x=x) 
     
    296296        """ 
    297297        if self.qmin_x >= 1.e-10: 
    298             qmin = numpy.log10(self.qmin_x) 
     298            qmin = np.log10(self.qmin_x) 
    299299        else: 
    300300            qmin = -10. 
    301301 
    302302        if self.qmax_x <= 1.e10: 
    303             qmax = numpy.log10(self.qmax_x) 
     303            qmax = np.log10(self.qmax_x) 
    304304        else: 
    305305            qmax = 10. 
    306306 
    307         x = numpy.logspace(start=qmin, stop=qmax, 
     307        x = np.logspace(start=qmin, stop=qmax, 
    308308                           num=self.npts_x, endpoint=True, base=10.0) 
    309309        self.data = Data1D(x=x) 
     
    342342        qstep = self.npts_x 
    343343 
    344         x = numpy.linspace(start=xmin, stop=xmax, num=qstep, endpoint=True) 
    345         y = numpy.linspace(start=ymin, stop=ymax, num=qstep, endpoint=True) 
     344        x = np.linspace(start=xmin, stop=xmax, num=qstep, endpoint=True) 
     345        y = np.linspace(start=ymin, stop=ymax, num=qstep, endpoint=True) 
    346346        # use data info instead 
    347         new_x = numpy.tile(x, (len(y), 1)) 
    348         new_y = numpy.tile(y, (len(x), 1)) 
     347        new_x = np.tile(x, (len(y), 1)) 
     348        new_y = np.tile(y, (len(x), 1)) 
    349349        new_y = new_y.swapaxes(0, 1) 
    350350        # all data reuire now in 1d array 
    351351        qx_data = new_x.flatten() 
    352352        qy_data = new_y.flatten() 
    353         q_data = numpy.sqrt(qx_data * qx_data + qy_data * qy_data) 
     353        q_data = np.sqrt(qx_data * qx_data + qy_data * qy_data) 
    354354        # set all True (standing for unmasked) as default 
    355         mask = numpy.ones(len(qx_data), dtype=bool) 
     355        mask = np.ones(len(qx_data), dtype=bool) 
    356356        # store x and y bin centers in q space 
    357357        x_bins = x 
     
    359359 
    360360        self.data.source = Source() 
    361         self.data.data = numpy.ones(len(mask)) 
    362         self.data.err_data = numpy.ones(len(mask)) 
     361        self.data.data = np.ones(len(mask)) 
     362        self.data.err_data = np.ones(len(mask)) 
    363363        self.data.qx_data = qx_data 
    364364        self.data.qy_data = qy_data 
     
    784784                    # Skip non-data lines 
    785785                    logger.error(traceback.format_exc()) 
    786             return numpy.array(angles), numpy.array(weights) 
     786            return np.array(angles), np.array(weights) 
    787787        except: 
    788788            raise 
     
    14501450                self.state_change = True 
    14511451                self._draw_model() 
    1452                 # Time delay has been introduced to prevent _handle error 
    1453                 # on Windows 
    1454                 # This part of code is executed when model is selected and 
    1455                 # it's parameters are changed (with respect to previously 
    1456                 # selected model). There are two Iq evaluations occuring one 
    1457                 # after another and therefore there may be compilation error 
    1458                 # if model is calculated for the first time. 
    1459                 # This seems to be Windows only issue - haven't tested on Linux 
    1460                 # though.The proper solution (other than time delay) requires 
    1461                 # more fundemental code refatoring 
    1462                 # Wojtek P. Nov 7, 2016 
    1463                 if not ON_MAC: 
    1464                     time.sleep(0.1) 
    14651452                self.Refresh() 
    14661453 
     
    21212108        for data in self.data_list: 
    21222109            # q value from qx and qy 
    2123             radius = numpy.sqrt(data.qx_data * data.qx_data + 
     2110            radius = np.sqrt(data.qx_data * data.qx_data + 
    21242111                                data.qy_data * data.qy_data) 
    21252112            # get unmasked index 
     
    21272114                         (radius <= float(self.qmax.GetValue())) 
    21282115            index_data = (index_data) & (data.mask) 
    2129             index_data = (index_data) & (numpy.isfinite(data.data)) 
     2116            index_data = (index_data) & (np.isfinite(data.data)) 
    21302117 
    21312118            if len(index_data[index_data]) < 10: 
     
    21622149            index_data = (float(self.qmin.GetValue()) <= radius) & \ 
    21632150                         (radius <= float(self.qmax.GetValue())) 
    2164             index_data = (index_data) & (numpy.isfinite(data.y)) 
     2151            index_data = (index_data) & (np.isfinite(data.y)) 
    21652152 
    21662153            if len(index_data[index_data]) < 5: 
     
    22342221 
    22352222                # Check that min is less than max 
    2236                 low = -numpy.inf if min_str == "" else float(min_str) 
    2237                 high = numpy.inf if max_str == "" else float(max_str) 
     2223                low = -np.inf if min_str == "" else float(min_str) 
     2224                high = np.inf if max_str == "" else float(max_str) 
    22382225                if high < low: 
    22392226                    min_ctrl.SetBackgroundColour("pink") 
     
    26102597            Layout is called after fitting. 
    26112598        """ 
    2612         self._sleep4sec() 
    26132599        self.Layout() 
    26142600        return 
    2615  
    2616     def _sleep4sec(self): 
    2617         """ 
    2618             sleep for 1 sec only applied on Mac 
    2619             Note: This 1sec helps for Mac not to crash on self. 
    2620             Layout after self._draw_model 
    2621         """ 
    2622         if ON_MAC: 
    2623             time.sleep(1) 
    26242601 
    26252602    def _find_polyfunc_selection(self, disp_func=None): 
     
    26552632            self.qmin_x = data_min 
    26562633            self.qmax_x = math.sqrt(x * x + y * y) 
    2657             # self.data.mask = numpy.ones(len(self.data.data),dtype=bool) 
     2634            # self.data.mask = np.ones(len(self.data.data),dtype=bool) 
    26582635            # check smearing 
    26592636            if not self.disable_smearer.GetValue(): 
     
    33673344 
    33683345            if value[1] == 'array': 
    3369                 pd_vals = numpy.array(value[2]) 
    3370                 pd_weights = numpy.array(value[3]) 
     3346                pd_vals = np.array(value[2]) 
     3347                pd_weights = np.array(value[3]) 
    33713348                if len(pd_vals) == 0 or len(pd_vals) != len(pd_weights): 
    33723349                    msg = ("bad array distribution parameters for %s" 
  • src/sas/sasgui/perspectives/fitting/fitpage.py

    rd85f1d8a red2276f  
    66import wx 
    77import wx.lib.newevent 
    8 import numpy 
     8import numpy as np 
    99import copy 
    1010import math 
     
    11151115            if item.GetValue(): 
    11161116                if button_list.index(item) == 0: 
    1117                     flag = 0  # dy = numpy.ones_like(dy_data) 
     1117                    flag = 0  # dy = np.ones_like(dy_data) 
    11181118                elif button_list.index(item) == 1: 
    11191119                    flag = 1  # dy = dy_data 
    11201120                elif button_list.index(item) == 2: 
    1121                     flag = 2  # dy = numpy.sqrt(numpy.abs(data)) 
     1121                    flag = 2  # dy = np.sqrt(np.abs(data)) 
    11221122                elif button_list.index(item) == 3: 
    1123                     flag = 3  # dy = numpy.abs(data) 
     1123                    flag = 3  # dy = np.abs(data) 
    11241124                break 
    11251125        return flag 
     
    14221422        key = event.GetKeyCode() 
    14231423        length = len(self.data.x) 
    1424         indx = (numpy.abs(self.data.x - x_data)).argmin() 
     1424        indx = (np.abs(self.data.x - x_data)).argmin() 
    14251425        # return array.flat[idx] 
    14261426        if key == wx.WXK_PAGEUP or key == wx.WXK_NUMPAD_PAGEUP: 
     
    14771477                    self.enable2D: 
    14781478                # set mask 
    1479                 radius = numpy.sqrt(self.data.qx_data * self.data.qx_data + 
     1479                radius = np.sqrt(self.data.qx_data * self.data.qx_data + 
    14801480                                    self.data.qy_data * self.data.qy_data) 
    14811481                index_data = ((self.qmin_x <= radius) & (radius <= self.qmax_x)) 
    14821482                index_data = (index_data) & (self.data.mask) 
    1483                 index_data = (index_data) & (numpy.isfinite(self.data.data)) 
     1483                index_data = (index_data) & (np.isfinite(self.data.data)) 
    14841484                if len(index_data[index_data]) < 10: 
    14851485                    msg = "Cannot Plot :No or too little npts in" 
     
    15981598                and data.dqx_data.any() != 0: 
    15991599                self.smear_type = "Pinhole2d" 
    1600                 self.dq_l = format_number(numpy.average(data.dqx_data)) 
    1601                 self.dq_r = format_number(numpy.average(data.dqy_data)) 
     1600                self.dq_l = format_number(np.average(data.dqx_data)) 
     1601                self.dq_r = format_number(np.average(data.dqy_data)) 
    16021602                return 
    16031603            else: 
    16041604                return 
    16051605        # check if it is pinhole smear and get min max if it is. 
    1606         if data.dx is not None and numpy.any(data.dx): 
     1606        if data.dx is not None and np.any(data.dx): 
    16071607            self.smear_type = "Pinhole" 
    16081608            self.dq_l = data.dx[0] 
     
    16121612        elif data.dxl is not None or data.dxw is not None: 
    16131613            self.smear_type = "Slit" 
    1614             if data.dxl is not None and numpy.all(data.dxl, 0): 
     1614            if data.dxl is not None and np.all(data.dxl, 0): 
    16151615                self.dq_l = data.dxl[0] 
    1616             if data.dxw is not None and numpy.all(data.dxw, 0): 
     1616            if data.dxw is not None and np.all(data.dxw, 0): 
    16171617                self.dq_r = data.dxw[0] 
    16181618        # return self.smear_type,self.dq_l,self.dq_r 
     
    18081808        if not flag: 
    18091809            self.onSmear(None) 
    1810  
    1811     def _mac_sleep(self, sec=0.2): 
    1812         """ 
    1813         Give sleep to MAC 
    1814         """ 
    1815         if self.is_mac: 
    1816             time.sleep(sec) 
    18171810 
    18181811    def get_view_mode(self): 
     
    19211914                self.default_mask = copy.deepcopy(self.data.mask) 
    19221915                if self.data.err_data is not None \ 
    1923                         and numpy.any(self.data.err_data): 
     1916                        and np.any(self.data.err_data): 
    19241917                    di_flag = True 
    19251918                if self.data.dqx_data is not None \ 
    1926                         and numpy.any(self.data.dqx_data): 
     1919                        and np.any(self.data.dqx_data): 
    19271920                    dq_flag = True 
    19281921            else: 
    19291922                self.slit_smearer.Enable(True) 
    19301923                self.pinhole_smearer.Enable(True) 
    1931                 if self.data.dy is not None and numpy.any(self.data.dy): 
     1924                if self.data.dy is not None and np.any(self.data.dy): 
    19321925                    di_flag = True 
    1933                 if self.data.dx is not None and numpy.any(self.data.dx): 
     1926                if self.data.dx is not None and np.any(self.data.dx): 
    19341927                    dq_flag = True 
    1935                 elif self.data.dxl is not None and numpy.any(self.data.dxl): 
     1928                elif self.data.dxl is not None and np.any(self.data.dxl): 
    19361929                    dq_flag = True 
    19371930 
     
    20672060        if self.data.__class__.__name__ == "Data2D" or \ 
    20682061                        self.enable2D: 
    2069             radius = numpy.sqrt(self.data.qx_data * self.data.qx_data + 
     2062            radius = np.sqrt(self.data.qx_data * self.data.qx_data + 
    20702063                                self.data.qy_data * self.data.qy_data) 
    20712064            index_data = (self.qmin_x <= radius) & (radius <= self.qmax_x) 
    20722065            index_data = (index_data) & (self.data.mask) 
    2073             index_data = (index_data) & (numpy.isfinite(self.data.data)) 
     2066            index_data = (index_data) & (np.isfinite(self.data.data)) 
    20742067            npts2fit = len(self.data.data[index_data]) 
    20752068        else: 
     
    21042097        # make sure stop button to fit button all the time 
    21052098        self._on_fit_complete() 
    2106         if out is None or not numpy.isfinite(chisqr): 
     2099        if out is None or not np.isfinite(chisqr): 
    21072100            raise ValueError, "Fit error occured..." 
    21082101 
     
    21152108 
    21162109        # Check if chi2 is finite 
    2117         if chisqr is not None and numpy.isfinite(chisqr): 
     2110        if chisqr is not None and np.isfinite(chisqr): 
    21182111            # format chi2 
    21192112            chi2 = format_number(chisqr, True) 
     
    21672160 
    21682161                        if cov[ind] is not None: 
    2169                             if numpy.isfinite(float(cov[ind])): 
     2162                            if np.isfinite(float(cov[ind])): 
    21702163                                val_err = format_number(cov[ind], True) 
    21712164                                item[4].SetForegroundColour(wx.BLACK) 
     
    21882181        self.save_current_state() 
    21892182 
    2190         if not self.is_mac: 
    2191             self.Layout() 
    2192             self.Refresh() 
    2193         self._mac_sleep(0.1) 
    21942183        # plot model ( when drawing, do not update chisqr value again) 
    21952184        self._draw_model(update_chisqr=False, source='fit') 
     
    22912280            self.smear_type = 'Pinhole2d' 
    22922281            len_data = len(data.data) 
    2293             data.dqx_data = numpy.zeros(len_data) 
    2294             data.dqy_data = numpy.zeros(len_data) 
     2282            data.dqx_data = np.zeros(len_data) 
     2283            data.dqy_data = np.zeros(len_data) 
    22952284        else: 
    22962285            self.smear_type = 'Pinhole' 
    22972286            len_data = len(data.x) 
    2298             data.dx = numpy.zeros(len_data) 
     2287            data.dx = np.zeros(len_data) 
    22992288            data.dxl = None 
    23002289            data.dxw = None 
     
    24692458        try: 
    24702459            self.dxl = float(self.smear_slit_height.GetValue()) 
    2471             data.dxl = self.dxl * numpy.ones(data_len) 
     2460            data.dxl = self.dxl * np.ones(data_len) 
    24722461            self.smear_slit_height.SetBackgroundColour(wx.WHITE) 
    24732462        except: 
    24742463            self.dxl = None 
    2475             data.dxl = numpy.zeros(data_len) 
     2464            data.dxl = np.zeros(data_len) 
    24762465            if self.smear_slit_height.GetValue().lstrip().rstrip() != "": 
    24772466                self.smear_slit_height.SetBackgroundColour("pink") 
     
    24822471            self.dxw = float(self.smear_slit_width.GetValue()) 
    24832472            self.smear_slit_width.SetBackgroundColour(wx.WHITE) 
    2484             data.dxw = self.dxw * numpy.ones(data_len) 
     2473            data.dxw = self.dxw * np.ones(data_len) 
    24852474        except: 
    24862475            self.dxw = None 
    2487             data.dxw = numpy.zeros(data_len) 
     2476            data.dxw = np.zeros(data_len) 
    24882477            if self.smear_slit_width.GetValue().lstrip().rstrip() != "": 
    24892478                self.smear_slit_width.SetBackgroundColour("pink") 
     
    26122601            if event is None: 
    26132602                output = "-" 
    2614             elif not numpy.isfinite(event.output): 
     2603            elif not np.isfinite(event.output): 
    26152604                output = "-" 
    26162605            else: 
  • src/sas/sasgui/perspectives/fitting/fitting.py

    r463e7ffc r9c0f3c17  
    1616import wx 
    1717import logging 
    18 import numpy 
     18import numpy as np 
    1919import time 
    2020from copy import deepcopy 
     
    878878                qmin=qmin, qmax=qmax, weight=weight) 
    879879 
    880     def _mac_sleep(self, sec=0.2): 
    881         """ 
    882         Give sleep to MAC 
    883         """ 
    884         if ON_MAC: 
    885             time.sleep(sec) 
    886  
    887880    def draw_model(self, model, page_id, data=None, smearer=None, 
    888881                   enable1D=True, enable2D=False, 
     
    10321025                                manager=self, 
    10331026                                improvement_delta=0.1) 
    1034         self._mac_sleep(0.2) 
    10351027 
    10361028        # batch fit 
     
    12721264        :param elapsed: time spent at the fitting level 
    12731265        """ 
    1274         self._mac_sleep(0.2) 
    12751266        uid = page_id[0] 
    12761267        if uid in self.fit_thread_list.keys(): 
     
    13341325                    new_theory = copy_data.data 
    13351326                    new_theory[res.index] = res.theory 
    1336                     new_theory[res.index == False] = numpy.nan 
     1327                    new_theory[res.index == False] = np.nan 
    13371328                    correct_result = True 
    13381329                #get all fittable parameters of the current model 
     
    13431334                        param_list.remove(param) 
    13441335                if not correct_result or res.fitness is None or \ 
    1345                     not numpy.isfinite(res.fitness) or \ 
    1346                     numpy.any(res.pvec == None) or not \ 
    1347                     numpy.all(numpy.isfinite(res.pvec)): 
     1336                    not np.isfinite(res.fitness) or \ 
     1337                        np.any(res.pvec == None) or not \ 
     1338                        np.all(np.isfinite(res.pvec)): 
    13481339                    data_name = str(None) 
    13491340                    if data is not None: 
     
    13541345                    msg += "Data %s and Model %s did not fit.\n" % (data_name, 
    13551346                                                                    model_name) 
    1356                     ERROR = numpy.NAN 
     1347                    ERROR = np.NAN 
    13571348                    cell = BatchCell() 
    13581349                    cell.label = res.fitness 
     
    13681359                            batch_inputs["error on %s" % str(param)].append(ERROR) 
    13691360                else: 
    1370                     # TODO: Why sometimes res.pvec comes with numpy.float64? 
     1361                    # TODO: Why sometimes res.pvec comes with np.float64? 
    13711362                    # probably from scipy lmfit 
    1372                     if res.pvec.__class__ == numpy.float64: 
     1363                    if res.pvec.__class__ == np.float64: 
    13731364                        res.pvec = [res.pvec] 
    13741365 
     
    15221513            page_id = [] 
    15231514        ## fit more than 1 model at the same time 
    1524         self._mac_sleep(0.2) 
    15251515        try: 
    15261516            index = 0 
     
    15351525                fit_msg = res.mesg 
    15361526                if res.fitness is None or \ 
    1537                     not numpy.isfinite(res.fitness) or \ 
    1538                     numpy.any(res.pvec == None) or \ 
    1539                     not numpy.all(numpy.isfinite(res.pvec)): 
     1527                    not np.isfinite(res.fitness) or \ 
     1528                        np.any(res.pvec == None) or \ 
     1529                    not np.all(np.isfinite(res.pvec)): 
    15401530                    fit_msg += "\nFitting did not converge!!!" 
    15411531                    wx.CallAfter(self._update_fit_button, page_id) 
    15421532                else: 
    15431533                    #set the panel when fit result are float not list 
    1544                     if res.pvec.__class__ == numpy.float64: 
     1534                    if res.pvec.__class__ == np.float64: 
    15451535                        pvec = [res.pvec] 
    15461536                    else: 
    15471537                        pvec = res.pvec 
    1548                     if res.stderr.__class__ == numpy.float64: 
     1538                    if res.stderr.__class__ == np.float64: 
    15491539                        stderr = [res.stderr] 
    15501540                    else: 
     
    16941684        if dy is None: 
    16951685            new_plot.is_data = False 
    1696             new_plot.dy = numpy.zeros(len(y)) 
     1686            new_plot.dy = np.zeros(len(y)) 
    16971687            # If this is a theory curve, pick the proper symbol to make it a curve 
    16981688            new_plot.symbol = GUIFRAME_ID.CURVE_SYMBOL_NUM 
     
    17431733        """ 
    17441734        try: 
    1745             numpy.nan_to_num(y) 
     1735            np.nan_to_num(y) 
    17461736            new_plot = self.create_theory_1D(x, y, page_id, model, data, state, 
    17471737                                             data_description=model.name, 
     
    18271817        that can be plot. 
    18281818        """ 
    1829         numpy.nan_to_num(image) 
     1819        np.nan_to_num(image) 
    18301820        new_plot = Data2D(image=image, err_image=data.err_data) 
    18311821        new_plot.name = model.name + '2d' 
     
    20192009        if data_copy.__class__.__name__ == "Data2D": 
    20202010            if index == None: 
    2021                 index = numpy.ones(len(data_copy.data), dtype=bool) 
     2011                index = np.ones(len(data_copy.data), dtype=bool) 
    20222012            if weight != None: 
    20232013                data_copy.err_data = weight 
    20242014            # get rid of zero error points 
    20252015            index = index & (data_copy.err_data != 0) 
    2026             index = index & (numpy.isfinite(data_copy.data)) 
     2016            index = index & (np.isfinite(data_copy.data)) 
    20272017            fn = data_copy.data[index] 
    20282018            theory_data = self.page_finder[page_id].get_theory_data(fid=data_copy.id) 
     
    20342024            # 1 d theory from model_thread is only in the range of index 
    20352025            if index == None: 
    2036                 index = numpy.ones(len(data_copy.y), dtype=bool) 
     2026                index = np.ones(len(data_copy.y), dtype=bool) 
    20372027            if weight != None: 
    20382028                data_copy.dy = weight 
    20392029            if data_copy.dy == None or data_copy.dy == []: 
    2040                 dy = numpy.ones(len(data_copy.y)) 
     2030                dy = np.ones(len(data_copy.y)) 
    20412031            else: 
    20422032                ## Set consistently w/AbstractFitengine: 
     
    20592049            return 
    20602050 
    2061         residuals = res[numpy.isfinite(res)] 
     2051        residuals = res[np.isfinite(res)] 
    20622052        # get chisqr only w/finite 
    2063         chisqr = numpy.average(residuals * residuals) 
     2053        chisqr = np.average(residuals * residuals) 
    20642054 
    20652055        self._plot_residuals(page_id=page_id, data=data_copy, 
     
    20982088            residuals.qy_data = data_copy.qy_data 
    20992089            residuals.q_data = data_copy.q_data 
    2100             residuals.err_data = numpy.ones(len(residuals.data)) 
     2090            residuals.err_data = np.ones(len(residuals.data)) 
    21012091            residuals.xmin = min(residuals.qx_data) 
    21022092            residuals.xmax = max(residuals.qx_data) 
     
    21122102            # 1 d theory from model_thread is only in the range of index 
    21132103            if data_copy.dy == None or data_copy.dy == []: 
    2114                 dy = numpy.ones(len(data_copy.y)) 
     2104                dy = np.ones(len(data_copy.y)) 
    21152105            else: 
    21162106                if weight == None: 
    2117                     dy = numpy.ones(len(data_copy.y)) 
     2107                    dy = np.ones(len(data_copy.y)) 
    21182108                ## Set consitently w/AbstractFitengine: 
    21192109                ## But this should be corrected later. 
     
    21342124                residuals.y = (fn - gn[index]) / en 
    21352125            residuals.x = data_copy.x[index] 
    2136             residuals.dy = numpy.ones(len(residuals.y)) 
     2126            residuals.dy = np.ones(len(residuals.y)) 
    21372127            residuals.dx = None 
    21382128            residuals.dxl = None 
  • src/sas/sasgui/perspectives/fitting/model_thread.py

    rc1c9929 r9a5097c  
    44 
    55import time 
    6 import numpy 
     6import numpy as np 
    77import math 
    88from sas.sascalc.data_util.calcthread import CalcThread 
     
    6868 
    6969        # Define matrix where data will be plotted 
    70         radius = numpy.sqrt((self.data.qx_data * self.data.qx_data) + \ 
     70        radius = np.sqrt((self.data.qx_data * self.data.qx_data) + \ 
    7171                    (self.data.qy_data * self.data.qy_data)) 
    7272 
     
    7575        index_model = (self.qmin <= radius) & (radius <= self.qmax) 
    7676        index_model = index_model & self.data.mask 
    77         index_model = index_model & numpy.isfinite(self.data.data) 
     77        index_model = index_model & np.isfinite(self.data.data) 
    7878 
    7979        if self.smearer is not None: 
     
    9191                self.data.qy_data[index_model] 
    9292            ]) 
    93         output = numpy.zeros(len(self.data.qx_data)) 
     93        output = np.zeros(len(self.data.qx_data)) 
    9494        # output default is None 
    9595        # This method is to distinguish between masked 
     
    163163        """ 
    164164        self.starttime = time.time() 
    165         output = numpy.zeros((len(self.data.x))) 
     165        output = np.zeros((len(self.data.x))) 
    166166        index = (self.qmin <= self.data.x) & (self.data.x <= self.qmax) 
    167167 
     
    175175                                                             self.qmax) 
    176176            mask = self.data.x[first_bin:last_bin+1] 
    177             unsmeared_output = numpy.zeros((len(self.data.x))) 
     177            unsmeared_output = np.zeros((len(self.data.x))) 
    178178            unsmeared_output[first_bin:last_bin+1] = self.model.evalDistribution(mask) 
    179179            self.smearer.model = self.model 
     
    183183            # Check that the arrays are compatible. If we only have a model but no data, 
    184184            # the length of data.y will be zero. 
    185             if isinstance(self.data.y, numpy.ndarray) and output.shape == self.data.y.shape: 
    186                 unsmeared_data = numpy.zeros((len(self.data.x))) 
    187                 unsmeared_error = numpy.zeros((len(self.data.x))) 
     185            if isinstance(self.data.y, np.ndarray) and output.shape == self.data.y.shape: 
     186                unsmeared_data = np.zeros((len(self.data.x))) 
     187                unsmeared_error = np.zeros((len(self.data.x))) 
    188188                unsmeared_data[first_bin:last_bin+1] = self.data.y[first_bin:last_bin+1]\ 
    189189                                                        * unsmeared_output[first_bin:last_bin+1]\ 
     
    209209 
    210210        if p_model is not None and s_model is not None: 
    211             sq_values = numpy.zeros((len(self.data.x))) 
    212             pq_values = numpy.zeros((len(self.data.x))) 
     211            sq_values = np.zeros((len(self.data.x))) 
     212            pq_values = np.zeros((len(self.data.x))) 
    213213            sq_values[index] = s_model.evalDistribution(self.data.x[index]) 
    214214            pq_values[index] = p_model.evalDistribution(self.data.x[index]) 
  • src/sas/sasgui/perspectives/fitting/pagestate.py

    r463e7ffc r9c0f3c17  
    1818import copy 
    1919import logging 
    20 import numpy 
     20import numpy as np 
    2121import traceback 
    2222 
     
    412412        for fittable, name, value, _, uncert, lower, upper, units in params: 
    413413            if not value: 
    414                 value = numpy.nan 
     414                value = np.nan 
    415415            if not uncert or uncert[1] == '' or uncert[1] == 'None': 
    416416                uncert[0] = False 
    417                 uncert[1] = numpy.nan 
     417                uncert[1] = np.nan 
    418418            if not upper or upper[1] == '' or upper[1] == 'None': 
    419419                upper[0] = False 
    420                 upper[1] = numpy.nan 
     420                upper[1] = np.nan 
    421421            if not lower or lower[1] == '' or lower[1] == 'None': 
    422422                lower[0] = False 
    423                 lower[1] = numpy.nan 
     423                lower[1] = np.nan 
    424424            if is_string: 
    425425                p[name] = str(value) 
     
    451451                lower = params.get(name + ".lower", '-inf') 
    452452                units = params.get(name + ".units") 
    453                 if std is not None and std is not numpy.nan: 
     453                if std is not None and std is not np.nan: 
    454454                    std = [True, str(std)] 
    455455                else: 
    456456                    std = [False, ''] 
    457                 if lower is not None and lower is not numpy.nan: 
     457                if lower is not None and lower is not np.nan: 
    458458                    lower = [True, str(lower)] 
    459459                else: 
    460460                    lower = [True, '-inf'] 
    461                 if upper is not None and upper is not numpy.nan: 
     461                if upper is not None and upper is not np.nan: 
    462462                    upper = [True, str(upper)] 
    463463                else: 
     
    11021102                                       % (line, tagname, name)) 
    11031103                                logger.error(msg + traceback.format_exc()) 
    1104                         dic[name] = numpy.array(value_list) 
     1104                        dic[name] = np.array(value_list) 
    11051105                    setattr(self, varname, dic) 
    11061106 
  • src/sas/sasgui/perspectives/fitting/utils.py

    rd85c194 r9a5097c  
    22Module contains functions frequently used in this package 
    33""" 
    4 import numpy 
     4import numpy as np 
    55 
    66 
     
    1919        data = data.y 
    2020    if flag == 0: 
    21         weight = numpy.ones_like(data) 
     21        weight = np.ones_like(data) 
    2222    elif flag == 1: 
    2323        weight = dy_data 
    2424    elif flag == 2: 
    25         weight = numpy.sqrt(numpy.abs(data)) 
     25        weight = np.sqrt(np.abs(data)) 
    2626    elif flag == 3: 
    27         weight = numpy.abs(data) 
     27        weight = np.abs(data) 
    2828    return weight 
  • src/sas/sasgui/perspectives/pr/explore_dialog.py

    r463e7ffc r9c0f3c17  
    1919 
    2020import wx 
    21 import numpy 
     21import numpy as np 
    2222import logging 
    2323import sys 
     
    6767 
    6868        step = (self.max - self.min) / (self.npts - 1) 
    69         self.x = numpy.arange(self.min, self.max + step * 0.01, step) 
    70         dx = numpy.zeros(len(self.x)) 
    71         y = numpy.ones(len(self.x)) 
    72         dy = numpy.zeros(len(self.x)) 
     69        self.x = np.arange(self.min, self.max + step * 0.01, step) 
     70        dx = np.zeros(len(self.x)) 
     71        y = np.ones(len(self.x)) 
     72        dy = np.zeros(len(self.x)) 
    7373 
    7474        # Plot area 
  • src/sas/sasgui/perspectives/pr/pr.py

    r463e7ffc r9c0f3c17  
    2121import time 
    2222import math 
    23 import numpy 
     23import numpy as np 
    2424import pylab 
    2525from sas.sasgui.guiframe.gui_manager import MDIFrame 
     
    209209        r = pylab.arange(0.01, d_max, d_max / 51.0) 
    210210        M = len(r) 
    211         y = numpy.zeros(M) 
    212         pr_err = numpy.zeros(M) 
     211        y = np.zeros(M) 
     212        pr_err = np.zeros(M) 
    213213 
    214214        total = 0.0 
     
    255255        """ 
    256256        # Show P(r) 
    257         y_true = numpy.zeros(len(x)) 
     257        y_true = np.zeros(len(x)) 
    258258 
    259259        sum_true = 0.0 
     
    309309 
    310310        x = pylab.arange(minq, maxq, maxq / 301.0) 
    311         y = numpy.zeros(len(x)) 
    312         err = numpy.zeros(len(x)) 
     311        y = np.zeros(len(x)) 
     312        err = np.zeros(len(x)) 
    313313        for i in range(len(x)): 
    314314            value = pr.iq(out, x[i]) 
     
    339339        if pr.slit_width > 0 or pr.slit_height > 0: 
    340340            x = pylab.arange(minq, maxq, maxq / 301.0) 
    341             y = numpy.zeros(len(x)) 
    342             err = numpy.zeros(len(x)) 
     341            y = np.zeros(len(x)) 
     342            err = np.zeros(len(x)) 
    343343            for i in range(len(x)): 
    344344                value = pr.iq_smeared(out, x[i]) 
     
    384384        x = pylab.arange(0.0, pr.d_max, pr.d_max / self._pr_npts) 
    385385 
    386         y = numpy.zeros(len(x)) 
    387         dy = numpy.zeros(len(x)) 
    388         y_true = numpy.zeros(len(x)) 
     386        y = np.zeros(len(x)) 
     387        dy = np.zeros(len(x)) 
     388        y_true = np.zeros(len(x)) 
    389389 
    390390        total = 0.0 
    391391        pmax = 0.0 
    392         cov2 = numpy.ascontiguousarray(cov) 
     392        cov2 = np.ascontiguousarray(cov) 
    393393 
    394394        for i in range(len(x)): 
     
    482482        """ 
    483483        # Read the data from the data file 
    484         data_x = numpy.zeros(0) 
    485         data_y = numpy.zeros(0) 
    486         data_err = numpy.zeros(0) 
     484        data_x = np.zeros(0) 
     485        data_y = np.zeros(0) 
     486        data_err = np.zeros(0) 
    487487        scale = None 
    488488        min_err = 0.0 
     
    506506                        #err = 0 
    507507 
    508                     data_x = numpy.append(data_x, x) 
    509                     data_y = numpy.append(data_y, y) 
    510                     data_err = numpy.append(data_err, err) 
     508                    data_x = np.append(data_x, x) 
     509                    data_y = np.append(data_y, y) 
     510                    data_err = np.append(data_err, err) 
    511511                except: 
    512512                    logger.error(sys.exc_value) 
     
    530530        """ 
    531531        # Read the data from the data file 
    532         data_x = numpy.zeros(0) 
    533         data_y = numpy.zeros(0) 
    534         data_err = numpy.zeros(0) 
     532        data_x = np.zeros(0) 
     533        data_y = np.zeros(0) 
     534        data_err = np.zeros(0) 
    535535        scale = None 
    536536        min_err = 0.0 
     
    557557                            #err = 0 
    558558 
    559                         data_x = numpy.append(data_x, x) 
    560                         data_y = numpy.append(data_y, y) 
    561                         data_err = numpy.append(data_err, err) 
     559                        data_x = np.append(data_x, x) 
     560                        data_y = np.append(data_y, y) 
     561                        data_err = np.append(data_err, err) 
    562562                    except: 
    563563                        logger.error(sys.exc_value) 
     
    642642        # Now replot the original added data 
    643643        for plot in self._added_plots: 
    644             self._added_plots[plot].y = numpy.copy(self._default_Iq[plot]) 
     644            self._added_plots[plot].y = np.copy(self._default_Iq[plot]) 
    645645            wx.PostEvent(self.parent, 
    646646                         NewPlotEvent(plot=self._added_plots[plot], 
     
    666666        # Now scale the added plots too 
    667667        for plot in self._added_plots: 
    668             total = numpy.sum(self._added_plots[plot].y) 
     668            total = np.sum(self._added_plots[plot].y) 
    669669            npts = len(self._added_plots[plot].x) 
    670670            total *= self._added_plots[plot].x[npts - 1] / npts 
     
    816816        # Save Pr invertor 
    817817        self.pr = pr 
    818         cov = numpy.ascontiguousarray(cov) 
     818        cov = np.ascontiguousarray(cov) 
    819819 
    820820        # Show result on control panel 
     
    984984        all_zeros = True 
    985985        if err == None: 
    986             err = numpy.zeros(len(pr.y)) 
     986            err = np.zeros(len(pr.y)) 
    987987        else: 
    988988            for i in range(len(err)): 
     
    10901090        # If we have not errors, add statistical errors 
    10911091        if y is not None: 
    1092             if err == None or numpy.all(err) == 0: 
    1093                 err = numpy.zeros(len(y)) 
     1092            if err == None or np.all(err) == 0: 
     1093                err = np.zeros(len(y)) 
    10941094                scale = None 
    10951095                min_err = 0.0 
  • src/sas/sasgui/perspectives/simulation/simulation.py

    r463e7ffc r9c0f3c17  
    1010import wx 
    1111import os 
    12 import numpy 
     12import numpy as np 
    1313import time 
    1414import logging 
     
    4848    def compute(self): 
    4949        x = self.x 
    50         output = numpy.zeros(len(x)) 
    51         error = numpy.zeros(len(x)) 
     50        output = np.zeros(len(x)) 
     51        error = np.zeros(len(x)) 
    5252         
    5353        self.starttime = time.time() 
     
    125125        # Q-values for plotting simulated I(Q) 
    126126        step = (self.q_max-self.q_min)/(self.q_npts-1) 
    127         self.x = numpy.arange(self.q_min, self.q_max+step*0.01, step)         
     127        self.x = np.arange(self.q_min, self.q_max+step*0.01, step) 
    128128         
    129129        # Set the list of panels that are part of the simulation perspective 
     
    189189        # Q-values for plotting simulated I(Q) 
    190190        step = (self.q_max-self.q_min)/(self.q_npts-1) 
    191         self.x = numpy.arange(self.q_min, self.q_max+step*0.01, step)     
     191        self.x = np.arange(self.q_min, self.q_max+step*0.01, step) 
    192192          
    193193        # Compute the simulated I(Q) 
  • src/sas/sasgui/perspectives/calculator/calculator.py

    ra0c1e1d r463e7ffc  
    2828import logging 
    2929 
     30logger = logging.getLogger(__name__) 
     31 
    3032class Plugin(PluginBase): 
    3133    """ 
     
    3638        PluginBase.__init__(self, name="Calculator") 
    3739        # Log startup 
    38         logging.info("Calculator plug-in started") 
     40        logger.info("Calculator plug-in started") 
    3941        self.sub_menu = "Tool" 
    4042        self.data_edit_frame = None 
  • src/sas/sasgui/perspectives/calculator/model_editor.py

    rddbac66 r463e7ffc  
    3232from sas.sasgui.guiframe.documentation_window import DocumentationWindow 
    3333from .pyconsole import show_model_output, check_model 
     34 
     35logger = logging.getLogger(__name__) 
    3436 
    3537 
     
    985987                exec "from %s import Model" % name 
    986988            except: 
    987                 logging.error(sys.exc_value) 
     989                logger.error(sys.exc_value) 
    988990 
    989991        # Prepare the messagebox 
  • src/sas/sasgui/perspectives/calculator/resolution_calculator_panel.py

    ra0c1e1d r463e7ffc  
    3434from sas.sasgui.perspectives.calculator import calculator_widgets as widget 
    3535from sas.sasgui.guiframe.documentation_window import DocumentationWindow 
     36 
     37logger = logging.getLogger(__name__) 
    3638 
    3739_BOX_WIDTH = 100 
     
    10981100                new_string.append(value) 
    10991101            except: 
    1100                 logging.error(sys.exc_value) 
     1102                logger.error(sys.exc_value) 
    11011103 
    11021104        return new_string 
     
    11401142                        return out 
    11411143                except: 
    1142                     logging.error(sys.exc_value) 
     1144                    logger.error(sys.exc_value) 
    11431145 
    11441146    def _on_xy_coordinate(self, event=None): 
     
    13181320                except: 
    13191321                    # Skip non-data lines 
    1320                     logging.error(sys.exc_value) 
     1322                    logger.error(sys.exc_value) 
    13211323 
    13221324            return [wavelength, intensity] 
  • src/sas/sasgui/perspectives/corfunc/corfunc.py

    r1dc8ec9 r463e7ffc  
    2020from plot_labels import * 
    2121 
     22logger = logging.getLogger(__name__) 
    2223 
    2324class Plugin(PluginBase): 
     
    2930    def __init__(self): 
    3031        PluginBase.__init__(self, name="Correlation Function") 
    31         logging.info("Correlation function plug-in started") 
     32        logger.info("Correlation function plug-in started") 
    3233        self._always_active = True 
    3334        self.state_reader = Reader(self.set_state) 
  • src/sas/sasgui/perspectives/corfunc/corfunc_state.py

    rae9b8bf r463e7ffc  
    1313from sas.sascalc.dataloader.loader import Loader 
    1414 
     15logger = logging.getLogger(__name__) 
     16 
    1517CORNODE_NAME = 'corfunc' 
    1618CANSAS_NS = 'cansas1d/1.0' 
     
    216218                    msg = ("CorfuncState.fromXML: Could not read timestamp", 
    217219                        "\n{}").format(sys.exc_value) 
    218                     logging.error(msg) 
     220                    logger.error(msg) 
    219221 
    220222            # Parse current state 
     
    360362            msg = "XML document does not contain CorfuncState information\n{}" 
    361363            msg.format(sys.exc_value) 
    362             logging.info(msg) 
     364            logger.info(msg) 
    363365        return state 
  • src/sas/sasgui/perspectives/file_converter/file_converter.py

    rba65aff r463e7ffc  
    66from sas.sasgui.guiframe.plugin_base import PluginBase 
    77from sas.sasgui.perspectives.file_converter.converter_panel import ConverterWindow 
     8 
     9logger = logging.getLogger(__name__) 
    810 
    911class Plugin(PluginBase): 
     
    1517    def __init__(self): 
    1618        PluginBase.__init__(self, name="File Converter") 
    17         logging.info("File Converter plug-in started") 
     19        logger.info("File Converter plug-in started") 
    1820        self._sub_menu = "Tool" 
    1921        self.converter_frame = None 
  • src/sas/sasgui/perspectives/fitting/models.py

    r11b094f r463e7ffc  
    1818from sas.sasgui.guiframe.CategoryInstaller import CategoryInstaller 
    1919from sasmodels.sasview_model import load_custom_model, load_standard_models 
     20 
     21logger = logging.getLogger(__name__) 
    2022 
    2123 
     
    168170    if not os.path.isdir(dir): 
    169171        msg = "SasView couldn't locate Model plugin folder %r." % dir 
    170         logging.warning(msg) 
     172        logger.warning(msg) 
    171173        return {} 
    172174 
    173175    plugin_log("looking for models in: %s" % str(dir)) 
    174176    #compile_file(dir)  #always recompile the folder plugin 
    175     logging.info("plugin model dir: %s" % str(dir)) 
     177    logger.info("plugin model dir: %s" % str(dir)) 
    176178 
    177179    plugins = {} 
     
    188190                msg += "\nwhile accessing model in %r" % path 
    189191                plugin_log(msg) 
    190                 logging.warning("Failed to load plugin %r. See %s for details" 
     192                logger.warning("Failed to load plugin %r. See %s for details" 
    191193                                % (path, PLUGIN_LOG)) 
    192194             
     
    261263        if self.is_changed(): 
    262264            return  _findModels(dir) 
    263         logging.info("plugin model : %s" % str(temp)) 
     265        logger.info("plugin model : %s" % str(temp)) 
    264266        return temp 
    265267 
  • src/sas/sasgui/perspectives/invariant/invariant.py

    rc10d9d6c r463e7ffc  
    2727from sas.sasgui.guiframe.plugin_base import PluginBase 
    2828 
     29logger = logging.getLogger(__name__) 
     30 
    2931class Plugin(PluginBase): 
    3032    """ 
     
    4648 
    4749        # Log startup 
    48         logging.info("Invariant plug-in started") 
     50        logger.info("Invariant plug-in started") 
    4951 
    5052    def get_data(self): 
     
    280282 
    281283        except: 
    282             logging.error("invariant.set_state: %s" % sys.exc_value) 
     284            logger.error("invariant.set_state: %s" % sys.exc_value) 
    283285 
    284286    def on_set_state_helper(self, event=None): 
  • src/sas/sasgui/perspectives/invariant/invariant_panel.py

    r18b7ecb9 r463e7ffc  
    2424from sas.sasgui.guiframe.panel_base import PanelBase 
    2525from sas.sasgui.guiframe.documentation_window import DocumentationWindow 
     26 
     27logger = logging.getLogger(__name__) 
    2628 
    2729# The minimum q-value to be used when extrapolating 
     
    460462                self._manager.plot_theory(name="Low-Q extrapolation") 
    461463            except: 
    462                 logging.error(sys.exc_value) 
     464                logger.error(sys.exc_value) 
    463465 
    464466    def get_high_qstar(self, inv, high_q=False): 
     
    494496                self._manager.plot_theory(name="High-Q extrapolation") 
    495497            except: 
    496                 logging.error(sys.exc_value) 
     498                logger.error(sys.exc_value) 
    497499 
    498500    def get_qstar(self, inv): 
     
    845847            attr.SetValue(value) 
    846848        except: 
    847             logging.error("Invariant state: %s", sys.exc_value) 
     849            logger.error("Invariant state: %s", sys.exc_value) 
    848850 
    849851    def get_bookmark_by_num(self, num=None): 
     
    862864            _, _, current_state, comp_state = self.state.bookmark_list[int(num)] 
    863865        except: 
    864             logging.error(sys.exc_value) 
     866            logger.error(sys.exc_value) 
    865867            raise ValueError, "No such bookmark exists" 
    866868 
     
    957959                    self.state.clone_state() 
    958960        except: 
    959             logging.error(sys.exc_value) 
     961            logger.error(sys.exc_value) 
    960962 
    961963        self._set_undo_flag(True) 
     
    10011003                del self.state.state_list[str(i)] 
    10021004            except: 
    1003                 logging.error(sys.exc_value) 
     1005                logger.error(sys.exc_value) 
    10041006        # Enable the undo button if it was not 
    10051007        self._set_undo_flag(True) 
     
    10661068                del self.state.state_list[str(i)] 
    10671069            except: 
    1068                 logging.error(sys.exc_value) 
     1070                logger.error(sys.exc_value) 
    10691071 
    10701072        # try to add new state of the text changes in the state_list 
     
    10811083            self.state.state_list[str(self.state.state_num)] = self.state.clone_state() 
    10821084        except: 
    1083             logging.error(sys.exc_value) 
     1085            logger.error(sys.exc_value) 
    10841086 
    10851087        self._set_undo_flag(True) 
     
    11031105            self.state.state_list[str(self.state.state_num)] = self.state.clone_state() 
    11041106        except: 
    1105             logging.error(sys.exc_value) 
     1107            logger.error(sys.exc_value) 
    11061108 
    11071109    def _get_input_list(self): 
  • src/sas/sasgui/perspectives/invariant/invariant_state.py

    rdb5294e r463e7ffc  
    1616from sas.sasgui.guiframe.gui_style import GUIFRAME_ID 
    1717from sas.sasgui.guiframe.dataFitting import Data1D 
     18 
     19logger = logging.getLogger(__name__) 
    1820 
    1921INVNODE_NAME = 'invariant' 
     
    381383                    msg = "InvariantSate.fromXML: Could not read" 
    382384                    msg += " timestamp\n %s" % sys.exc_value 
    383                     logging.error(msg) 
     385                    logger.error(msg) 
    384386 
    385387            # Parse bookmarks 
     
    694696            msg = "XML document does not contain invariant" 
    695697            msg += " information.\n %s" % sys.exc_value 
    696             logging.info(msg) 
     698            logger.info(msg) 
    697699        return state 
    698700 
  • src/sas/sasgui/perspectives/invariant/report_dialog.py

    rd85c194 r463e7ffc  
    2020 
    2121from sas.sasgui.guiframe.report_dialog import BaseReportDialog 
     22 
     23logger = logging.getLogger(__name__) 
    2224 
    2325class ReportDialog(BaseReportDialog): 
     
    9294                    except: 
    9395                        # DO not open 
    94                         logging.error("Could not open file: %s" % sys.exc_value) 
     96                        logger.error("Could not open file: %s" % sys.exc_value) 
    9597            # delete image file 
    9698            os.remove(pic_fname) 
  • src/sas/sasgui/perspectives/pr/inversion_panel.py

    r18b7ecb9 r463e7ffc  
    1717from pr_widgets import OutputTextCtrl 
    1818from sas.sasgui.guiframe.documentation_window import DocumentationWindow 
     19 
     20logger = logging.getLogger(__name__) 
    1921 
    2022if sys.platform.count("win32") > 0: 
     
    710712            self.alpha_ctl.SetValue(alpha) 
    711713        except ValueError: 
    712             logging.error("InversionControl._on_accept_alpha got a value that was not a number: %s" % alpha ) 
     714            logger.error("InversionControl._on_accept_alpha got a value that was not a number: %s" % alpha ) 
    713715        except: 
    714716            # No estimate or bad estimate, either do nothing 
    715             logging.error("InversionControl._on_accept_alpha: %s" % sys.exc_value) 
     717            logger.error("InversionControl._on_accept_alpha: %s" % sys.exc_value) 
    716718 
    717719    def _on_accept_nterms(self, evt): 
     
    726728            self.nfunc_ctl.SetValue(nterms) 
    727729        except ValueError: 
    728             logging.error("InversionControl._on_accept_nterms got a value that was not a number: %s" % nterms ) 
     730            logger.error("InversionControl._on_accept_nterms got a value that was not a number: %s" % nterms ) 
    729731        except: 
    730732            # No estimate or bad estimate, either do nothing 
    731             logging.error("InversionControl._on_accept_nterms: %s" % sys.exc_value) 
     733            logger.error("InversionControl._on_accept_nterms: %s" % sys.exc_value) 
    732734 
    733735    def clear_panel(self): 
     
    947949            except: 
    948950                msg = "InversionControl._change_file: %s" % sys.exc_value 
    949                 logging.error(msg) 
     951                logger.error(msg) 
    950952 
    951953    def on_help(self, event): 
  • src/sas/sasgui/perspectives/pr/inversion_state.py

    rd85c194 r463e7ffc  
    2222from sas.sascalc.dataloader.readers.cansas_reader import get_content 
    2323 
     24logger = logging.getLogger(__name__) 
     25 
    2426PRNODE_NAME = 'pr_inversion' 
    2527CANSAS_NS = "cansas1d/1.0" 
     
    250252                    msg = "InversionState.fromXML: Could not read " 
    251253                    msg += "timestamp\n %s" % sys.exc_value 
    252                     logging.error(msg) 
     254                    logger.error(msg) 
    253255 
    254256            # Parse inversion inputs 
     
    306308                        err_msg += "%d %d" % (len(self.coefficients), 
    307309                                              self.nfunc) 
    308                         logging.error(err_msg) 
     310                        logger.error(err_msg) 
    309311                        self.coefficients = None 
    310312 
     
    343345                        err_msg += " covariance matrix: " 
    344346                        err_msg += "%d %d" % (len(self.covariance), self.nfunc) 
    345                         logging.error(err_msg) 
     347                        logger.error(err_msg) 
    346348                        self.covariance = None 
    347349 
     
    430432            msg = "XML document does not contain P(r) " 
    431433            msg += "information.\n %s" % sys.exc_value 
    432             logging.info(msg) 
     434            logger.info(msg) 
    433435 
    434436        return state 
Note: See TracChangeset for help on using the changeset viewer.