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/fitting
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • 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/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 
Note: See TracChangeset for help on using the changeset viewer.