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

File:
1 edited

Legend:

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